From 380a07155136e583cd3ee530cdd0a09fefa28231 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 13 Jun 2022 14:54:38 +0800 Subject: [PATCH] fix: handle the memory leak of parser --- docs-en/14-reference/03-connector/rust.mdx | 6 +- include/common/tcommon.h | 9 +- include/common/tmsg.h | 70 +- include/common/tmsgdef.h | 2 +- include/common/ttokendef.h | 141 +- include/libs/nodes/cmdnodes.h | 1 + include/libs/nodes/nodes.h | 28 +- include/libs/parser/parser.h | 2 +- include/libs/sync/sync.h | 4 + include/libs/sync/syncTools.h | 32 + include/util/taoserror.h | 16 +- include/util/tlrucache.h | 71 + source/client/src/clientEnv.c | 2 +- source/client/src/clientHb.c | 2 +- source/client/src/clientImpl.c | 3 +- source/client/src/clientSml.c | 182 +- source/client/src/tmq.c | 8 +- source/client/test/CMakeLists.txt | 8 +- source/client/test/clientTests.cpp | 4 +- source/client/test/smlTest.cpp | 356 +- source/common/src/systable.c | 4 +- source/common/src/tdatablock.c | 45 +- source/common/src/tmsg.c | 99 +- source/common/src/ttime.c | 46 +- source/dnode/mgmt/mgmt_dnode/src/dmHandle.c | 12 +- source/dnode/mgmt/node_util/src/dmEps.c | 31 +- source/dnode/mnode/impl/inc/mndDef.h | 51 +- source/dnode/mnode/impl/inc/mndGrant.h | 2 + source/dnode/mnode/impl/inc/mndScheduler.h | 6 +- source/dnode/mnode/impl/inc/mndTrans.h | 1 + source/dnode/mnode/impl/inc/mndVgroup.h | 1 + source/dnode/mnode/impl/src/mndConsumer.c | 7 + source/dnode/mnode/impl/src/mndDb.c | 4 +- source/dnode/mnode/impl/src/mndDnode.c | 4 +- source/dnode/mnode/impl/src/mndGrant.c | 108 +- source/dnode/mnode/impl/src/mndMnode.c | 15 +- source/dnode/mnode/impl/src/mndOffset.c | 5 +- source/dnode/mnode/impl/src/mndScheduler.c | 321 +- source/dnode/mnode/impl/src/mndSma.c | 96 +- source/dnode/mnode/impl/src/mndStb.c | 4 +- source/dnode/mnode/impl/src/mndStream.c | 10 +- source/dnode/mnode/impl/src/mndSync.c | 10 +- source/dnode/mnode/impl/src/mndTopic.c | 2 +- source/dnode/mnode/impl/src/mndTrans.c | 29 +- source/dnode/mnode/impl/src/mndVgroup.c | 184 +- source/dnode/mnode/sdb/src/sdb.c | 7 +- source/dnode/mnode/sdb/src/sdbFile.c | 6 +- source/dnode/vnode/CMakeLists.txt | 1 - source/dnode/vnode/src/inc/sma.h | 63 +- source/dnode/vnode/src/inc/vnodeInt.h | 3 +- source/dnode/vnode/src/meta/metaQuery.c | 4 + source/dnode/vnode/src/meta/metaSma.c | 6 +- source/dnode/vnode/src/sma/sma.c | 18 +- source/dnode/vnode/src/sma/smaEnv.c | 88 +- source/dnode/vnode/src/sma/smaRollup.c | 10 +- source/dnode/vnode/src/sma/smaTDBImpl.c | 130 - source/dnode/vnode/src/sma/smaTimeRange.c | 1037 ---- source/dnode/vnode/src/sma/smaTimeRange2.c | 958 +--- source/dnode/vnode/src/tq/tq.c | 13 +- source/dnode/vnode/src/tq/tqPush.c | 3 - source/dnode/vnode/src/tsdb/tsdbCommit.c | 2 +- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 4 +- source/dnode/vnode/src/vnd/vnodeSvr.c | 8 +- source/dnode/vnode/test/tsdbSmaTest.cpp | 2 +- source/libs/command/src/explain.c | 6 +- source/libs/executor/inc/executorimpl.h | 5 +- source/libs/executor/src/executorimpl.c | 87 +- source/libs/executor/src/groupoperator.c | 2 +- source/libs/executor/src/scanoperator.c | 10 +- source/libs/executor/src/sortoperator.c | 9 +- source/libs/executor/src/timewindowoperator.c | 167 +- source/libs/executor/src/tsort.c | 14 +- source/libs/function/inc/builtinsimpl.h | 4 + source/libs/function/src/builtins.c | 55 +- source/libs/function/src/builtinsimpl.c | 61 +- source/libs/function/src/functionMgt.c | 12 +- source/libs/nodes/src/nodesCloneFuncs.c | 39 +- source/libs/nodes/src/nodesCodeFuncs.c | 2 +- source/libs/nodes/src/nodesEqualFuncs.c | 2 +- source/libs/nodes/src/nodesTraverseFuncs.c | 4 +- source/libs/nodes/src/nodesUtilFuncs.c | 220 +- source/libs/parser/inc/sql.y | 1 + source/libs/parser/src/parAstCreater.c | 112 +- source/libs/parser/src/parAstParser.c | 2 +- source/libs/parser/src/parCalcConst.c | 2 +- source/libs/parser/src/parInsert.c | 20 +- source/libs/parser/src/parTokenizer.c | 1 + source/libs/parser/src/parTranslater.c | 164 +- source/libs/parser/src/parUtil.c | 34 +- source/libs/parser/src/parser.c | 7 +- source/libs/parser/src/sql.c | 4465 +++++++++-------- source/libs/parser/test/parInitialATest.cpp | 36 +- source/libs/parser/test/parInitialCTest.cpp | 78 +- source/libs/parser/test/parInsertTest.cpp | 18 +- source/libs/parser/test/parTestUtil.cpp | 234 +- source/libs/parser/test/parTestUtil.h | 2 +- source/libs/planner/src/planLogicCreater.c | 80 +- source/libs/planner/src/planOptimizer.c | 42 +- source/libs/planner/src/planPhysiCreater.c | 90 +- source/libs/planner/src/planScaleOut.c | 16 +- source/libs/planner/src/planSpliter.c | 88 +- source/libs/planner/src/planUtil.c | 5 +- source/libs/planner/src/planner.c | 14 +- source/libs/qworker/src/qwUtil.c | 2 +- source/libs/stream/src/stream.c | 4 +- source/libs/stream/src/streamDispatch.c | 7 +- source/libs/sync/inc/syncInt.h | 4 +- source/libs/sync/inc/syncRaftCfg.h | 6 +- source/libs/sync/inc/syncSnapshot.h | 1 + source/libs/sync/src/syncAppendEntries.c | 246 +- source/libs/sync/src/syncAppendEntriesReply.c | 17 +- source/libs/sync/src/syncCommit.c | 2 +- source/libs/sync/src/syncMain.c | 255 +- source/libs/sync/src/syncMessage.c | 172 + source/libs/sync/src/syncRaftCfg.c | 8 + source/libs/sync/src/syncRaftLog.c | 20 +- source/libs/sync/src/syncSnapshot.c | 190 +- source/libs/sync/src/syncUtil.c | 8 +- source/libs/sync/test/CMakeLists.txt | 14 + .../libs/sync/test/syncLeaderTransferTest.cpp | 101 + source/libs/sync/test/syncRaftCfgTest.cpp | 2 + .../libs/sync/test/syncSnapshotSendTest.cpp | 12 + source/os/src/osSemaphore.c | 32 +- source/util/src/terror.c | 46 +- source/util/src/thash.c | 6 +- source/util/src/tlrucache.c | 794 +++ tests/pytest/util/dnodes.py | 10 +- tests/script/jenkins/basic.txt | 6 +- tests/script/tsim/dnode/create_dnode.sim | 11 - .../tsim/dnode/drop_dnode_has_mnode.sim | 98 + tests/script/tsim/dnode/drop_dnode_mnode.sim | 52 - ...edistribute_vgroup_replica3_v1_leader.sim} | 39 +- tests/script/tsim/mnode/basic2.sim | 4 + tests/script/tsim/mnode/basic3.sim | 82 +- tests/script/tsim/mnode/basic4.sim | 2 +- tests/script/tsim/mnode/basic5.sim | 349 ++ .../tsim/stream/distributeInterval0.sim | 176 + tests/script/tsim/stream/session0.sim | 18 +- tests/system-test/1-insert/alter_stable.py | 6 +- tests/system-test/1-insert/alter_table.py | 109 +- .../1-insert/influxdb_line_taosc_insert.py | 4 + .../opentsdb_telnet_line_taosc_insert.py | 4 + tests/system-test/2-query/To_iso8601.py | 162 +- tests/system-test/2-query/abs.py | 104 + tests/system-test/2-query/csum.py | 4 + tests/system-test/2-query/function_diff.py | 4 + tests/system-test/2-query/mavg.py | 4 + tests/system-test/7-tmq/basic5.py | 21 +- tests/system-test/7-tmq/db.py | 12 +- tests/system-test/7-tmq/subscribeDb.py | 12 +- tests/system-test/7-tmq/subscribeDb0.py | 12 +- tests/system-test/7-tmq/subscribeDb1.py | 30 +- tests/system-test/7-tmq/subscribeStb.py | 12 +- tests/system-test/7-tmq/subscribeStb0.py | 12 +- tests/system-test/7-tmq/subscribeStb1.py | 12 +- tests/system-test/7-tmq/subscribeStb2.py | 12 +- tests/system-test/7-tmq/subscribeStb3.py | 12 +- tests/system-test/7-tmq/subscribeStb4.py | 12 +- tests/system-test/fulltest.bat | 169 +- tests/system-test/fulltest.sh | 2 +- tests/system-test/simpletest.bat | 103 + tests/system-test/test-all.bat | 50 +- tests/test/c/tmqSim.c | 19 +- 163 files changed, 7579 insertions(+), 6737 deletions(-) create mode 100644 include/util/tlrucache.h delete mode 100644 source/dnode/vnode/src/sma/smaTDBImpl.c delete mode 100644 source/dnode/vnode/src/sma/smaTimeRange.c create mode 100644 source/libs/sync/test/syncLeaderTransferTest.cpp create mode 100644 source/util/src/tlrucache.c create mode 100644 tests/script/tsim/dnode/drop_dnode_has_mnode.sim delete mode 100644 tests/script/tsim/dnode/drop_dnode_mnode.sim rename tests/script/tsim/dnode/{redistribute_vgroup_replica3_move_1_vnode.sim => redistribute_vgroup_replica3_v1_leader.sim} (90%) create mode 100644 tests/script/tsim/mnode/basic5.sim create mode 100644 tests/script/tsim/stream/distributeInterval0.sim create mode 100644 tests/system-test/simpletest.bat diff --git a/docs-en/14-reference/03-connector/rust.mdx b/docs-en/14-reference/03-connector/rust.mdx index cd54f35982..a5cbaeac80 100644 --- a/docs-en/14-reference/03-connector/rust.mdx +++ b/docs-en/14-reference/03-connector/rust.mdx @@ -45,15 +45,15 @@ Add the [libtaos][libtaos] dependency to the [Rust](https://rust-lang.org) proje -Add [libtaos][libtaos] to the ``Cargo.toml`'' file. +Add [libtaos][libtaos] to the `Cargo.toml` file. -``toml +```toml [dependencies] # use default feature libtaos = "*" ``` - Add [libtaos][libtaos] to the `Cargo.toml` file and enable the `rest` feature. diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 362f56c865..2e646f4769 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -37,19 +37,12 @@ enum { TMQ_MSG_TYPE__EP_RSP, }; -enum { - STREAM_TRIGGER__AT_ONCE = 1, - STREAM_TRIGGER__WINDOW_CLOSE, - STREAM_TRIGGER__BY_COUNT, - STREAM_TRIGGER__BY_BATCH_COUNT, - STREAM_TRIGGER__BY_EVENT_TIME, -}; - typedef enum EStreamType { STREAM_NORMAL = 1, STREAM_INVERT, STREAM_REPROCESS, STREAM_INVALID, + STREAM_GET_ALL, } EStreamType; typedef struct { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 7d8cee379e..820f0fbe8d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1494,10 +1494,9 @@ typedef struct { int32_t code; } STaskDropRsp; -#define STREAM_TRIGGER_AT_ONCE_SMA 0 -#define STREAM_TRIGGER_AT_ONCE 1 -#define STREAM_TRIGGER_WINDOW_CLOSE 2 -#define STREAM_TRIGGER_WINDOW_CLOSE_SMA 3 +#define STREAM_TRIGGER_AT_ONCE 1 +#define STREAM_TRIGGER_WINDOW_CLOSE 2 +#define STREAM_TRIGGER_MAX_DELAY 3 typedef struct { char name[TSDB_TABLE_FNAME_LEN]; @@ -1507,6 +1506,7 @@ typedef struct { char* sql; char* ast; int8_t triggerType; + int64_t maxDelay; int64_t watermark; } SCMCreateStreamReq; @@ -2337,24 +2337,26 @@ typedef struct { } SVgEpSet; typedef struct { - int8_t version; // for compatibility(default 0) - int8_t intervalUnit; // MACRO: TIME_UNIT_XXX - int8_t slidingUnit; // MACRO: TIME_UNIT_XXX - int8_t timezoneInt; // sma data expired if timezone changes. - int32_t dstVgId; - char indexName[TSDB_INDEX_NAME_LEN]; - int32_t exprLen; - int32_t tagsFilterLen; - int32_t numOfVgroups; - int64_t indexUid; - tb_uid_t tableUid; // super/child/common table uid - int64_t interval; - int64_t offset; // use unit by precision of DB - int64_t sliding; - char* expr; // sma expression - char* tagsFilter; - SVgEpSet* pVgEpSet; -} STSma; // Time-range-wise SMA + int8_t version; // for compatibility(default 0) + int8_t intervalUnit; // MACRO: TIME_UNIT_XXX + int8_t slidingUnit; // MACRO: TIME_UNIT_XXX + int8_t timezoneInt; // sma data expired if timezone changes. + int32_t dstVgId; + char indexName[TSDB_INDEX_NAME_LEN]; + int32_t exprLen; + int32_t tagsFilterLen; + int64_t indexUid; + tb_uid_t tableUid; // super/child/common table uid + tb_uid_t dstTbUid; // for dstVgroup + int64_t interval; + int64_t offset; // use unit by precision of DB + int64_t sliding; + char* dstTbName; // for dstVgroup + char* expr; // sma expression + char* tagsFilter; + SSchemaWrapper schemaRow; // for dstVgroup + SSchemaWrapper schemaTag; // for dstVgroup +} STSma; // Time-range-wise SMA typedef STSma SVCreateTSmaReq; @@ -2438,27 +2440,6 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) { return 0; } -typedef struct { - int64_t indexUid; - STimeWindow queryWindow; -} SVGetTsmaExpWndsReq; - -#define SMA_WNDS_EXPIRE_FLAG (0x1) -#define SMA_WNDS_IS_EXPIRE(flag) (((flag)&SMA_WNDS_EXPIRE_FLAG) != 0) -#define SMA_WNDS_SET_EXPIRE(flag) ((flag) |= SMA_WNDS_EXPIRE_FLAG) - -typedef struct { - int64_t indexUid; - int8_t flags; // 0x1 all window expired - int32_t numExpWnds; - TSKEY wndSKeys[]; -} SVGetTsmaExpWndsRsp; - -int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder* pCoder, const SVGetTsmaExpWndsReq* pReq); -int32_t tDecodeSVGetTsmaExpWndsReq(SDecoder* pCoder, SVGetTsmaExpWndsReq* pReq); -int32_t tEncodeSVGetTSmaExpWndsRsp(SEncoder* pCoder, const SVGetTsmaExpWndsRsp* pReq); -int32_t tDecodeSVGetTsmaExpWndsRsp(SDecoder* pCoder, SVGetTsmaExpWndsRsp* pReq); - typedef struct { int idx; } SMCreateFullTextReq; @@ -2518,7 +2499,8 @@ typedef struct { int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp); int32_t tDeserializeSTableIndexRsp(void* buf, int32_t bufLen, STableIndexRsp* pRsp); -void tFreeSTableIndexInfo(void* pInfo); + +void tFreeSTableIndexInfo(void* pInfo); typedef struct { int8_t mqMsgType; diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 3b38362647..743f10bd55 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -190,7 +190,6 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp) - TD_DEF_MSG_TYPE(TDMT_VND_GET_TSMA_EXP_WNDS, "vnode-get-tsma-expired-windows", SVGetTsmaExpWndsReq, SVGetTsmaExpWndsRsp) TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL) @@ -237,6 +236,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_SYNC_CONFIG_CHANGE, "sync-config-change", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 84e0527587..f5495db5ae 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -184,76 +184,77 @@ #define TK_TRIGGER 166 #define TK_AT_ONCE 167 #define TK_WINDOW_CLOSE 168 -#define TK_WATERMARK 169 -#define TK_KILL 170 -#define TK_CONNECTION 171 -#define TK_TRANSACTION 172 -#define TK_BALANCE 173 -#define TK_VGROUP 174 -#define TK_MERGE 175 -#define TK_REDISTRIBUTE 176 -#define TK_SPLIT 177 -#define TK_SYNCDB 178 -#define TK_DELETE 179 -#define TK_NULL 180 -#define TK_NK_QUESTION 181 -#define TK_NK_ARROW 182 -#define TK_ROWTS 183 -#define TK_TBNAME 184 -#define TK_QSTARTTS 185 -#define TK_QENDTS 186 -#define TK_WSTARTTS 187 -#define TK_WENDTS 188 -#define TK_WDURATION 189 -#define TK_CAST 190 -#define TK_NOW 191 -#define TK_TODAY 192 -#define TK_TIMEZONE 193 -#define TK_COUNT 194 -#define TK_FIRST 195 -#define TK_LAST 196 -#define TK_LAST_ROW 197 -#define TK_BETWEEN 198 -#define TK_IS 199 -#define TK_NK_LT 200 -#define TK_NK_GT 201 -#define TK_NK_LE 202 -#define TK_NK_GE 203 -#define TK_NK_NE 204 -#define TK_MATCH 205 -#define TK_NMATCH 206 -#define TK_CONTAINS 207 -#define TK_JOIN 208 -#define TK_INNER 209 -#define TK_SELECT 210 -#define TK_DISTINCT 211 -#define TK_WHERE 212 -#define TK_PARTITION 213 -#define TK_BY 214 -#define TK_SESSION 215 -#define TK_STATE_WINDOW 216 -#define TK_SLIDING 217 -#define TK_FILL 218 -#define TK_VALUE 219 -#define TK_NONE 220 -#define TK_PREV 221 -#define TK_LINEAR 222 -#define TK_NEXT 223 -#define TK_HAVING 224 -#define TK_ORDER 225 -#define TK_SLIMIT 226 -#define TK_SOFFSET 227 -#define TK_LIMIT 228 -#define TK_OFFSET 229 -#define TK_ASC 230 -#define TK_NULLS 231 -#define TK_ID 232 -#define TK_NK_BITNOT 233 -#define TK_INSERT 234 -#define TK_VALUES 235 -#define TK_IMPORT 236 -#define TK_NK_SEMI 237 -#define TK_FILE 238 +#define TK_MAX_DELAY 169 +#define TK_WATERMARK 170 +#define TK_KILL 171 +#define TK_CONNECTION 172 +#define TK_TRANSACTION 173 +#define TK_BALANCE 174 +#define TK_VGROUP 175 +#define TK_MERGE 176 +#define TK_REDISTRIBUTE 177 +#define TK_SPLIT 178 +#define TK_SYNCDB 179 +#define TK_DELETE 180 +#define TK_NULL 181 +#define TK_NK_QUESTION 182 +#define TK_NK_ARROW 183 +#define TK_ROWTS 184 +#define TK_TBNAME 185 +#define TK_QSTARTTS 186 +#define TK_QENDTS 187 +#define TK_WSTARTTS 188 +#define TK_WENDTS 189 +#define TK_WDURATION 190 +#define TK_CAST 191 +#define TK_NOW 192 +#define TK_TODAY 193 +#define TK_TIMEZONE 194 +#define TK_COUNT 195 +#define TK_FIRST 196 +#define TK_LAST 197 +#define TK_LAST_ROW 198 +#define TK_BETWEEN 199 +#define TK_IS 200 +#define TK_NK_LT 201 +#define TK_NK_GT 202 +#define TK_NK_LE 203 +#define TK_NK_GE 204 +#define TK_NK_NE 205 +#define TK_MATCH 206 +#define TK_NMATCH 207 +#define TK_CONTAINS 208 +#define TK_JOIN 209 +#define TK_INNER 210 +#define TK_SELECT 211 +#define TK_DISTINCT 212 +#define TK_WHERE 213 +#define TK_PARTITION 214 +#define TK_BY 215 +#define TK_SESSION 216 +#define TK_STATE_WINDOW 217 +#define TK_SLIDING 218 +#define TK_FILL 219 +#define TK_VALUE 220 +#define TK_NONE 221 +#define TK_PREV 222 +#define TK_LINEAR 223 +#define TK_NEXT 224 +#define TK_HAVING 225 +#define TK_ORDER 226 +#define TK_SLIMIT 227 +#define TK_SOFFSET 228 +#define TK_LIMIT 229 +#define TK_OFFSET 230 +#define TK_ASC 231 +#define TK_NULLS 232 +#define TK_ID 233 +#define TK_NK_BITNOT 234 +#define TK_INSERT 235 +#define TK_VALUES 236 +#define TK_IMPORT 237 +#define TK_NK_SEMI 238 +#define TK_FILE 239 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 25369f2342..8d4e94663f 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -289,6 +289,7 @@ typedef struct SKillStmt { typedef struct SStreamOptions { ENodeType type; int8_t triggerType; + SNode* pDelay; SNode* pWatermark; } SStreamOptions; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 7df731b95c..3937fc13f4 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -252,22 +252,20 @@ typedef struct SNodeList { SListCell* pTail; } SNodeList; -#define SNodeptr void* - -SNodeptr nodesMakeNode(ENodeType type); -void nodesDestroyNode(SNodeptr pNode); +SNode* nodesMakeNode(ENodeType type); +void nodesDestroyNode(SNode* pNode); SNodeList* nodesMakeList(); -int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode); -int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode); -int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode); -int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode); +int32_t nodesListAppend(SNodeList* pList, SNode* pNode); +int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode); +int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode); +int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode); int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc); -int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode); +int32_t nodesListPushFront(SNodeList* pList, SNode* pNode); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); -SNodeptr nodesListGetNode(SNodeList* pList, int32_t index); +SNode* nodesListGetNode(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); // Only clear the linked list structure, without releasing the elements inside void nodesClearList(SNodeList* pList); @@ -275,9 +273,9 @@ void nodesClearList(SNodeList* pList); typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes; typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext); -void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext); +void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext); void nodesWalkExprs(SNodeList* pList, FNodeWalker walker, void* pContext); -void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext); +void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext); void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext); typedef EDealRes (*FNodeRewriter)(SNode** pNode, void* pContext); @@ -286,13 +284,13 @@ void nodesRewriteExprs(SNodeList* pList, FNodeRewriter rewriter, void* pContext) void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext); void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext); -bool nodesEqualNode(const SNodeptr a, const SNodeptr b); +bool nodesEqualNode(const SNode* a, const SNode* b); -SNodeptr nodesCloneNode(const SNodeptr pNode); +SNode* nodesCloneNode(const SNode* pNode); SNodeList* nodesCloneList(const SNodeList* pList); const char* nodesNodeName(ENodeType type); -int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen); +int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen); int32_t nodesStringToNode(const char* pStr, SNode** pNode); int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen); diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 6abd1ffa6d..ef28b832a0 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -63,7 +63,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata void qDestroyQuery(SQuery* pQueryNode); int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema); -int32_t qSetSTableIdForRSma(SNode* pStmt, int64_t uid); +int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid); int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash); int32_t qResetStmtDataBlock(void* block, bool keepBuf); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 9d1385bff2..3a77cc1e19 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -48,6 +48,7 @@ typedef enum { TAOS_SYNC_PROPOSE_SUCCESS = 0, TAOS_SYNC_PROPOSE_NOT_LEADER = 1, TAOS_SYNC_PROPOSE_OTHER_ERROR = 2, + TAOS_SYNC_ONLY_ONE_REPLICA = 3, } ESyncProposeCode; typedef enum { @@ -200,6 +201,9 @@ int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta); int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg); int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg); +int32_t syncLeaderTransfer(int64_t rid); +int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader); + // to be moved to static void syncStartNormal(int64_t rid); void syncStartStandBy(int64_t rid); diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index bb50fc141c..68a33d48cb 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -398,6 +398,8 @@ typedef struct SyncSnapshotSend { SyncTerm term; SyncIndex lastIndex; // lastIndex of snapshot SyncTerm lastTerm; // lastTerm of snapshot + SyncIndex lastConfigIndex; + SSyncCfg lastConfig; SyncTerm privateTerm; int32_t seq; uint32_t dataLen; @@ -456,6 +458,36 @@ void syncSnapshotRspPrint2(char* s, const SyncSnapshotRsp* pMsg); void syncSnapshotRspLog(const SyncSnapshotRsp* pMsg); void syncSnapshotRspLog2(char* s, const SyncSnapshotRsp* pMsg); +// --------------------------------------------- +typedef struct SyncLeaderTransfer { + uint32_t bytes; + int32_t vgId; + uint32_t msgType; + /* + SRaftId srcId; + SRaftId destId; + */ + SRaftId newLeaderId; +} SyncLeaderTransfer; + +SyncLeaderTransfer* syncLeaderTransferBuild(int32_t vgId); +void syncLeaderTransferDestroy(SyncLeaderTransfer* pMsg); +void syncLeaderTransferSerialize(const SyncLeaderTransfer* pMsg, char* buf, uint32_t bufLen); +void syncLeaderTransferDeserialize(const char* buf, uint32_t len, SyncLeaderTransfer* pMsg); +char* syncLeaderTransferSerialize2(const SyncLeaderTransfer* pMsg, uint32_t* len); +SyncLeaderTransfer* syncLeaderTransferDeserialize2(const char* buf, uint32_t len); +void syncLeaderTransfer2RpcMsg(const SyncLeaderTransfer* pMsg, SRpcMsg* pRpcMsg); +void syncLeaderTransferFromRpcMsg(const SRpcMsg* pRpcMsg, SyncLeaderTransfer* pMsg); +SyncLeaderTransfer* syncLeaderTransferFromRpcMsg2(const SRpcMsg* pRpcMsg); +cJSON* syncLeaderTransfer2Json(const SyncLeaderTransfer* pMsg); +char* syncLeaderTransfer2Str(const SyncLeaderTransfer* pMsg); + +// for debug ---------------------- +void syncLeaderTransferPrint(const SyncLeaderTransfer* pMsg); +void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg); +void syncLeaderTransferLog(const SyncLeaderTransfer* pMsg); +void syncLeaderTransferLog2(char* s, const SyncLeaderTransfer* pMsg); + // on message ---------------------- int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index ecddd0e0c5..03308e395f 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -352,9 +352,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0619) #define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061A) #define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061B) -#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x061C) -#define TSDB_CODE_TDB_INVALID_SMA_STAT TAOS_DEF_ERROR_CODE(0, 0x061D) -#define TSDB_CODE_TDB_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x061E) // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) @@ -686,6 +683,19 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002) #define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003) +//tsma +#define TSDB_CODE_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x3100) +#define TSDB_CODE_TSMA_NO_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x3101) +#define TSDB_CODE_TSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3102) +#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3103) +#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3104) +#define TSDB_CODE_TSMA_RM_SKEY_IN_HASH TAOS_DEF_ERROR_CODE(0, 0x3105) + +//rsma +#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150) +#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151) + + #ifdef __cplusplus } #endif diff --git a/include/util/tlrucache.h b/include/util/tlrucache.h new file mode 100644 index 0000000000..5aee50c42a --- /dev/null +++ b/include/util/tlrucache.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_UTIL_LRUCACHE_H_ +#define _TD_UTIL_LRUCACHE_H_ + +#include "thash.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SLRUCache SLRUCache; + +typedef void (*_taos_lru_deleter_t)(const void *key, size_t keyLen, void *value); + +typedef struct LRUHandle LRUHandle; + +typedef enum { + TAOS_LRU_PRIORITY_HIGH, + TAOS_LRU_PRIORITY_LOW +} LRUPriority; + +typedef enum { + TAOS_LRU_STATUS_OK, + TAOS_LRU_STATUS_FAIL, + TAOS_LRU_STATUS_INCOMPLETE, + TAOS_LRU_STATUS_OK_OVERWRITTEN +} LRUStatus; + +SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoolRatio); +void taosLRUCacheCleanup(SLRUCache *cache); + +LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, + _taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority); +LRUHandle *taosLRUCacheLookup(SLRUCache * cache, const void *key, size_t keyLen); +void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen); + +void taosLRUCacheEraseUnrefEntries(SLRUCache *cache); + +bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle); +bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef); + +void* taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle); + +size_t taosLRUCacheGetUsage(SLRUCache *cache); +size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache); + +void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity); +size_t taosLRUCacheGetCapacity(SLRUCache *cache); + +void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict); +bool taosLRUCacheIsStrictCapacity(SLRUCache *cache); + +#ifdef __cplusplus +} +#endif + +#endif // _TD_UTIL_LRUCACHE_H_ diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 171f06c257..bb60624145 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -167,7 +167,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, int32_t c taosThreadMutexInit(&pObj->mutex, NULL); pObj->id = taosAddRef(clientConnRefPool, pObj); - pObj->schemalessType = 0; + pObj->schemalessType = 1; tscDebug("connObj created, 0x%" PRIx64, pObj->id); return pObj; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index a4c109ee17..ad8a16b460 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -691,7 +691,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { return NULL; } - taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq); + // taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq); taosThreadMutexLock(&clientHbMgr.lock); taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 65a91fe426..dc83f7bc43 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -689,16 +689,15 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) { .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE}; SAppInstInfo* pAppInfo = getAppInfo(pRequest); - if (TSDB_CODE_SUCCESS == code) { code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pNodeList); - tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); } if (TSDB_CODE_SUCCESS == code) { schedulerAsyncExecJob(pAppInfo->pTransporter, pNodeList, pRequest->body.pDag, &pRequest->body.queryJob, pRequest->sqlstr, pRequest->metric.start, schedulerExecCb, pRequest); } else { + tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); pRequest->body.queryFp(pRequest->body.param, pRequest, code); } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index bf60d25976..bbf9eba363 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -72,7 +72,7 @@ for (int i = 1; i < keyLen; ++i) { \ #define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" " #define MAX_RETRY_TIMES 5 -#define LINE_BATCH 20 +#define LINE_BATCH 20000 //================================================================================================= typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; @@ -161,7 +161,6 @@ typedef struct { typedef struct{ SRequestObj* request; - SCatalog* catalog; tsem_t sem; TdThreadSpinlock lock; } Params; @@ -307,19 +306,10 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { const char* errStr = taos_errstr(res); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%"PRIx64" apply schema action. error: %s", info->id, errStr); + taosMsleep(100); } taos_free_result(res); -// if (code == TSDB_CODE_MND_FIELD_ALREADY_EXIST || code == TSDB_CODE_MND_TAG_ALREADY_EXIST || tscDupColNames) { - if (code == TSDB_CODE_MND_TAG_ALREADY_EXIST) { - TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE"); - code = taos_errno(res2); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); - } - taos_free_result(res2); - taosMsleep(500); - } break; } case SCHEMA_ACTION_ADD_TAG: { @@ -331,19 +321,10 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { const char* errStr = taos_errstr(res); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + taosMsleep(100); } taos_free_result(res); -// if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST || code == TSDB_CODE_MND_FIELD_ALREAY_EXIST || tscDupColNames) { - if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST) { - TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE"); - code = taos_errno(res2); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); - } - taos_free_result(res2); - taosMsleep(500); - } break; } case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { @@ -354,19 +335,10 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + taosMsleep(100); } taos_free_result(res); -// if (code == TSDB_CODE_MND_INVALID_COLUMN_LENGTH || code == TSDB_CODE_TSC_INVALID_COLUMN_LENGTH) { - if (code == TSDB_CODE_TSC_INVALID_COLUMN_LENGTH) { - TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE"); - code = taos_errno(res2); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); - } - taos_free_result(res2); - taosMsleep(500); - } break; } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { @@ -377,19 +349,10 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + taosMsleep(100); } taos_free_result(res); -// if (code == TSDB_CODE_MND_INVALID_TAG_LENGTH || code == TSDB_CODE_TSC_INVALID_TAG_LENGTH) { - if (code == TSDB_CODE_TSC_INVALID_TAG_LENGTH) { - TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE"); - code = taos_errno(res2); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); - } - taos_free_result(res2); - taosMsleep(500); - } break; } case SCHEMA_ACTION_CREATE_STABLE: { @@ -429,18 +392,10 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + taosMsleep(100); } taos_free_result(res); - if (code == TSDB_CODE_MND_STB_ALREADY_EXIST) { - TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE"); - code = taos_errno(res2); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); - } - taos_free_result(res2); - taosMsleep(500); - } break; } @@ -474,6 +429,21 @@ static int32_t smlProcessSchemaAction(SSmlHandle* info, SSchema* schemaField, SH return TSDB_CODE_SUCCESS; } +static int32_t smlCheckMeta(SSchema* schema, int32_t length, SArray* cols){ + SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + for(uint16_t i = 0; i < length; i++){ + taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &i, SHORT_BYTES); + } + + for(int32_t i = 0; i < taosArrayGetSize(cols); i++){ + SSmlKv* kv = (SSmlKv*)taosArrayGetP(cols, i); + if(taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL){ + return -1; + } + } + return 0; +} + static int32_t smlModifyDBSchemas(SSmlHandle* info) { int32_t code = 0; SEpSet ep = getEpSet_s(&info->taos->pAppInfo->mgmtEp); @@ -484,6 +454,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { while (tableMetaSml) { SSmlSTableMeta* sTableData = *tableMetaSml; STableMeta *pTableMeta = NULL; + bool needCheckMeta = false; // for multi thread size_t superTableLen = 0; void *superTable = taosHashGetKey(tableMetaSml, &superTableLen); @@ -534,6 +505,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { if (code != TSDB_CODE_SUCCESS) { goto end; } + needCheckMeta = true; } else { uError("SML:0x%"PRIx64" load table meta error: %s", info->id, tstrerror(code)); goto end; @@ -545,6 +517,20 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { uError("SML:0x%"PRIx64" catalogGetSTableMeta failed. super table name %s", info->id, (char*)superTable); goto end; } + + if(needCheckMeta){ + code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%"PRIx64" check tag failed. super table name %s", info->id, (char*)superTable); + goto end; + } + code = smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%"PRIx64" check cols failed. super table name %s", info->id, (char*)superTable); + goto end; + } + } + sTableData->tableMeta = pTableMeta; tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, tableMetaSml); @@ -1292,9 +1278,46 @@ static void smlDestroyTableInfo(SSmlHandle* info, SSmlTableInfo *tag){ taosMemoryFree(tag); } +static int32_t smlKvTimeArrayCompare(const void* key1, const void* key2) { + SArray *s1 = *(SArray **)key1; + SArray *s2 = *(SArray **)key2; + SSmlKv *kv1 = (SSmlKv *)taosArrayGetP(s1, 0); + SSmlKv *kv2 = (SSmlKv *)taosArrayGetP(s2, 0); + ASSERT(kv1->type == TSDB_DATA_TYPE_TIMESTAMP); + ASSERT(kv2->type == TSDB_DATA_TYPE_TIMESTAMP); + if (kv1->i < kv2->i) { + return -1; + } else if (kv1->i > kv2->i) { + return 1; + } else { + return 0; + } +} + +static int32_t smlKvTimeHashCompare(const void* key1, const void* key2) { + SHashObj *s1 = *(SHashObj **)key1; + SHashObj *s2 = *(SHashObj **)key2; + SSmlKv *kv1 = (SSmlKv *)taosHashGet(s1, TS, TS_LEN); + SSmlKv *kv2 = (SSmlKv *)taosHashGet(s2, TS, TS_LEN); + ASSERT(kv1->type == TSDB_DATA_TYPE_TIMESTAMP); + ASSERT(kv2->type == TSDB_DATA_TYPE_TIMESTAMP); + if (kv1->i < kv2->i) { + return -1; + } else if (kv1->i > kv2->i) { + return 1; + } else { + return 0; + } +} + static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *cols){ if(dataFormat){ - taosArrayPush(oneTable->cols, &cols); + void *p = taosArraySearch(oneTable->cols, &cols, smlKvTimeArrayCompare, TD_GE); + if(p == NULL){ + taosArrayPush(oneTable->cols, &cols); + }else{ + taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &cols); + } return TSDB_CODE_SUCCESS; } @@ -1307,8 +1330,13 @@ static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *col SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); } - taosArrayPush(oneTable->cols, &kvHash); + void *p = taosArraySearch(oneTable->cols, &kvHash, smlKvTimeHashCompare, TD_GE); + if(p == NULL){ + taosArrayPush(oneTable->cols, &kvHash); + }else{ + taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &kvHash); + } return TSDB_CODE_SUCCESS; } @@ -1419,6 +1447,11 @@ static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocol ((SVnodeModifOpStmt*)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV; info->taos = (STscObj *)taos; + code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog); + if(code != TSDB_CODE_SUCCESS){ + uError("SML:0x%"PRIx64" get catalog error %d", info->id, code); + goto cleanup; + } info->precision = precision; info->protocol = protocol; @@ -2196,6 +2229,7 @@ static int32_t smlInsertData(SSmlHandle* info) { code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat, (*pMeta)->tableMeta, tableData->childTableName, info->msgBuf.buf, info->msgBuf.len); if(code != TSDB_CODE_SUCCESS){ + uError("SML:0x%"PRIx64" smlBindData failed", info->id); return code; } oneTable = (SSmlTableInfo**)taosHashIterate(info->childTables, oneTable); @@ -2261,7 +2295,7 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { code = smlParseLine(info, lines, numLines); if (code != 0) { uError("SML:0x%"PRIx64" smlParseLine error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } info->cost.lineNum = numLines; @@ -2277,24 +2311,27 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { if (code != 0) { uError("SML:0x%"PRIx64" smlModifyDBSchemas error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } info->cost.insertBindTime = taosGetTimestampUs(); code = smlInsertData(info); if (code != 0) { uError("SML:0x%"PRIx64" smlInsertData error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } - info->cost.endTime = taosGetTimestampUs(); -cleanup: - info->cost.code = code; - smlPrintStatisticInfo(info); return code; } -static int32_t isSchemalessDb(STscObj *taos, SCatalog *catalog){ +static int32_t isSchemalessDb(STscObj *taos){ + SCatalog* catalog = NULL; + int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, &catalog); + if(code != TSDB_CODE_SUCCESS){ + uError("SML get catalog error %d", code); + return code; + } + SName name; tNameSetDbName(&name, taos->acctId, taos->db, strlen(taos->db)); char dbFname[TSDB_DB_FNAME_LEN] = {0}; @@ -2302,7 +2339,7 @@ static int32_t isSchemalessDb(STscObj *taos, SCatalog *catalog){ SDbCfgInfo pInfo = {0}; SEpSet ep = getEpSet_s(&taos->pAppInfo->mgmtEp); - int32_t code = catalogGetDBCfg(catalog, taos->pAppInfo->pTransporter, &ep, dbFname, &pInfo); + code = catalogGetDBCfg(catalog, taos->pAppInfo->pTransporter, &ep, dbFname, &pInfo); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2318,6 +2355,7 @@ static void smlInsertCallback(void* param, void* res, int32_t code) { SRequestObj *pRequest = (SRequestObj *)res; SSmlHandle* info = (SSmlHandle *)param; + uDebug("SML:0x%"PRIx64" result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); // lock if(code != TSDB_CODE_SUCCESS){ taosThreadSpinLock(&info->params->lock); @@ -2329,6 +2367,9 @@ static void smlInsertCallback(void* param, void* res, int32_t code) { printf("SML:0x%" PRIx64 " insert finished, code: %d, total: %d\n", info->id, code, info->affectedRows); Params *pParam = info->params; bool isLast = info->isLast; + info->cost.endTime = taosGetTimestampUs(); + info->cost.code = code; + smlPrintStatisticInfo(info); smlDestroyInfo(info); if(isLast){ @@ -2373,20 +2414,13 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr tsem_init(¶ms.sem, 0, 0); taosThreadSpinInit(&(params.lock), 0); - int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, ¶ms.catalog); - if(code != TSDB_CODE_SUCCESS){ - uError("SML get catalog error %d", code); - request->code = code; - goto end; - } - if(request->pDb == NULL){ request->code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; smlBuildInvalidDataMsg(&msg, "Database not specified", NULL); goto end; } - if(isSchemalessDb(((STscObj *)taos), params.catalog) != TSDB_CODE_SUCCESS){ + if(isSchemalessDb(((STscObj *)taos)) != TSDB_CODE_SUCCESS){ request->code = TSDB_CODE_SML_INVALID_DB_CONF; smlBuildInvalidDataMsg(&msg, "Cannot write data to a non schemaless database", NULL); goto end; @@ -2436,11 +2470,10 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr } info->params = ¶ms; - info->pCatalog = params.catalog; info->affectedRows = perBatch; info->pRequest->body.queryFp = smlInsertCallback; info->pRequest->body.param = info; - code = smlProcess(info, lines, perBatch); + int32_t code = smlProcess(info, lines, perBatch); lines += perBatch; if (code != TSDB_CODE_SUCCESS){ info->pRequest->body.queryFp(info, req, code); @@ -2451,8 +2484,9 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr end: taosThreadSpinDestroy(¶ms.lock); tsem_destroy(¶ms.sem); - ((STscObj *)taos)->schemalessType = 0; - uDebug("result:%s", request->msgBuf); +// ((STscObj *)taos)->schemalessType = 0; + ((STscObj *)taos)->schemalessType = 1; + uDebug("resultend:%s", request->msgBuf); return (TAOS_RES*)request; } diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 58905cac19..7d49c4206f 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -408,7 +408,7 @@ int32_t tmqCommitInner(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_ pParam->userParam = userParam; if (!async) tsem_init(&pParam->rspSem, 0, 0); - sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo)); + sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (sendInfo == NULL) goto END; sendInfo->msgInfo = (SDataBuf){ .pData = buf, @@ -704,7 +704,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { void* abuf = buf; tSerializeSCMSubscribeReq(&abuf, &req); - SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo)); + SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (sendInfo == NULL) goto FAIL; SMqSubscribeCbParam param = { @@ -1008,7 +1008,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) { pParam->async = async; tsem_init(&pParam->rspSem, 0, 0); - SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo)); + SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (sendInfo == NULL) { tsem_destroy(&pParam->rspSem); taosMemoryFree(pParam); @@ -1162,7 +1162,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { pParam->vgId = pVg->vgId; pParam->epoch = tmq->epoch; - SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo)); + SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (sendInfo == NULL) { taosMemoryFree(pReq); taosMemoryFree(pParam); diff --git a/source/client/test/CMakeLists.txt b/source/client/test/CMakeLists.txt index bb9f0ed23e..03d2b48134 100644 --- a/source/client/test/CMakeLists.txt +++ b/source/client/test/CMakeLists.txt @@ -41,7 +41,7 @@ TARGET_INCLUDE_DIRECTORIES( PRIVATE "${TD_SOURCE_DIR}/source/client/inc" ) -#add_test( -# NAME smlTest -# COMMAND smlTest -#) +add_test( + NAME smlTest + COMMAND smlTest +) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index f9825c50ff..dc15c0b13d 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -778,9 +778,9 @@ TEST(testCase, async_api_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - taos_query(pConn, "use test"); + taos_query(pConn, "use nest"); - TAOS_RES* pRes = taos_query(pConn, "desc abc1.tu"); + TAOS_RES* pRes = taos_query(pConn, "select NOW() from (select * from regular_table_2 where tbname in ('regular_table_2_1') and q_bigint <= 9223372036854775807 and q_tinyint <= 127 and q_bool in ( true , false) ) order by ts;"); if (taos_errno(pRes) != 0) { printf("failed, reason:%s\n", taos_errstr(pRes)); } diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index 25bf13a113..4ad73a6424 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -476,22 +476,40 @@ TEST(testCase, smlParseCols_Test) { taosMemoryFree(sql); } +TEST(testCase, smlGetTimestampLen_Test) { + uint8_t len = smlGetTimestampLen(0); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(1); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(10); + ASSERT_EQ(len, 2); + + len = smlGetTimestampLen(390); + ASSERT_EQ(len, 3); + + len = smlGetTimestampLen(-1); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(-10); + ASSERT_EQ(len, 2); + + len = smlGetTimestampLen(-390); + ASSERT_EQ(len, 3); +} + +/* TEST(testCase, smlProcess_influx_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists inflx_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists inflx_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use inflx_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[] = { "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 1451606401000000000", "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 1451607402000000000", @@ -505,19 +523,20 @@ TEST(testCase, smlProcess_influx_Test) { "stable,t1=t1,t2=t2,t3=t3 c1=1,c2=2,c3=\"kk\",c4=4 1451629501000000000", "stable,t2=t2,t1=t1,t3=t3 c1=1,c3=\"\",c4=4 1451629602000000000", }; - int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_EQ(ret, 0); + pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); // case 1 - TAOS_RES *res = taos_query(taos, "select * from t_91e0b182be80332b5c530cbf872f760e"); - ASSERT_NE(res, nullptr); - int fieldNum = taos_field_count(res); + pRes = taos_query(taos, "select * from t_91e0b182be80332b5c530cbf872f760e"); + ASSERT_NE(pRes, nullptr); + int fieldNum = taos_field_count(pRes); ASSERT_EQ(fieldNum, 11); printf("fieldNum:%d\n", fieldNum); TAOS_ROW row = NULL; int32_t rowIndex = 0; - while((row = taos_fetch_row(res)) != NULL) { + while((row = taos_fetch_row(pRes)) != NULL) { int64_t ts = *(int64_t*)row[0]; double load_capacity = *(double*)row[1]; double fuel_capacity = *(double*)row[2]; @@ -546,18 +565,18 @@ TEST(testCase, smlProcess_influx_Test) { } rowIndex++; } - taos_free_result(res); + taos_free_result(pRes); // case 2 - res = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d"); - ASSERT_NE(res, nullptr); - fieldNum = taos_field_count(res); + pRes = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d"); + ASSERT_NE(pRes, nullptr); + fieldNum = taos_field_count(pRes); ASSERT_EQ(fieldNum, 5); printf("fieldNum:%d\n", fieldNum); rowIndex = 0; - while((row = taos_fetch_row(res)) != NULL) { - int *length = taos_fetch_lengths(res); + while((row = taos_fetch_row(pRes)) != NULL) { + int *length = taos_fetch_lengths(pRes); int64_t ts = *(int64_t*)row[0]; double c1 = *(double*)row[1]; @@ -580,20 +599,16 @@ TEST(testCase, smlProcess_influx_Test) { } rowIndex++; } - taos_free_result(res); + taos_free_result(pRes); // case 2 - res = taos_query(taos, "show tables"); - ASSERT_NE(res, nullptr); + pRes = taos_query(taos, "show tables"); + ASSERT_NE(pRes, nullptr); - row = taos_fetch_row(res); - int rowNum = taos_affected_rows(res); + row = taos_fetch_row(pRes); + int rowNum = taos_affected_rows(pRes); ASSERT_EQ(rowNum, 5); - taos_free_result(res); - - - destroyRequest(request); - smlDestroyInfo(info); + taos_free_result(pRes); } // different types @@ -601,122 +616,79 @@ TEST(testCase, smlParseLine_error_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[] = { "measure,t1=3 c1=8", "measure,t2=3 c1=8u8" }; - int ret = smlProcess(info, (char **)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_NE(ret, 0); - destroyRequest(request); - smlDestroyInfo(info); -} - -TEST(testCase, smlGetTimestampLen_Test) { - uint8_t len = smlGetTimestampLen(0); - ASSERT_EQ(len, 1); - - len = smlGetTimestampLen(1); - ASSERT_EQ(len, 1); - - len = smlGetTimestampLen(10); - ASSERT_EQ(len, 2); - - len = smlGetTimestampLen(390); - ASSERT_EQ(len, 3); - - len = smlGetTimestampLen(-1); - ASSERT_EQ(len, 1); - - len = smlGetTimestampLen(-10); - ASSERT_EQ(len, 2); - - len = smlGetTimestampLen(-390); - ASSERT_EQ(len, 3); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, smlProcess_telnet_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists telnet_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists telnet_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use telnet_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[] = { "sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0", "sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01 ", "sys.if.bytes.out 1479496102 1.3E3 network=tcp", " sys.procs.running 1479496100 42 host=web01 " }; - int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_EQ(ret, 0); + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); // case 1 - TAOS_RES *res = taos_query(taos, "select * from t_8c30283b3c4131a071d1e16cf6d7094a"); - ASSERT_NE(res, nullptr); - int fieldNum = taos_field_count(res); + pRes = taos_query(taos, "select * from t_8c30283b3c4131a071d1e16cf6d7094a"); + ASSERT_NE(pRes, nullptr); + int fieldNum = taos_field_count(pRes); ASSERT_EQ(fieldNum, 2); - TAOS_ROW row = taos_fetch_row(res); + TAOS_ROW row = taos_fetch_row(pRes); int64_t ts = *(int64_t*)row[0]; double c1 = *(double*)row[1]; ASSERT_EQ(ts, 1479496100000); ASSERT_EQ(c1, 42); - int rowNum = taos_affected_rows(res); + int rowNum = taos_affected_rows(pRes); ASSERT_EQ(rowNum, 1); - taos_free_result(res); + taos_free_result(pRes); // case 2 - res = taos_query(taos, "show tables"); - ASSERT_NE(res, nullptr); + pRes = taos_query(taos, "show tables"); + ASSERT_NE(pRes, nullptr); - row = taos_fetch_row(res); - rowNum = taos_affected_rows(res); + row = taos_fetch_row(pRes); + rowNum = taos_affected_rows(pRes); ASSERT_EQ(rowNum, 3); - taos_free_result(res); - - destroyRequest(request); - smlDestroyInfo(info); + taos_free_result(pRes); } TEST(testCase, smlProcess_json1_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES *pRes = taos_query(taos, "create database if not exists json_db"); + TAOS_RES *pRes = taos_query(taos, "create database if not exists json_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use json_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - - const char *sql = + const char *sql[] = { "[\n" " {\n" " \"metric\": \"sys.cpu.nice\",\n" @@ -724,6 +696,7 @@ TEST(testCase, smlProcess_json1_Test) { " \"value\": 18,\n" " \"tags\": {\n" " \"host\": \"web01\",\n" + " \"id\": \"t1\",\n" " \"dc\": \"lga\"\n" " }\n" " },\n" @@ -736,55 +709,48 @@ TEST(testCase, smlProcess_json1_Test) { " \"dc\": \"lga\"\n" " }\n" " }\n" - "]"; - int ret = smlProcess(info, (char **)(&sql), 1); - ASSERT_EQ(ret, 0); + "]"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); // case 1 - TAOS_RES *res = taos_query(taos, "select * from t_cb27a7198d637b4f1c6464bd73f756a7"); - ASSERT_NE(res, nullptr); - int fieldNum = taos_field_count(res); + pRes = taos_query(taos, "select * from t1"); + ASSERT_NE(pRes, nullptr); + int fieldNum = taos_field_count(pRes); ASSERT_EQ(fieldNum, 2); - TAOS_ROW row = taos_fetch_row(res); + TAOS_ROW row = taos_fetch_row(pRes); int64_t ts = *(int64_t*)row[0]; double c1 = *(double*)row[1]; ASSERT_EQ(ts, 1346846400000); ASSERT_EQ(c1, 18); - int rowNum = taos_affected_rows(res); + int rowNum = taos_affected_rows(pRes); ASSERT_EQ(rowNum, 1); - taos_free_result(res); + taos_free_result(pRes); // case 2 - res = taos_query(taos, "show tables"); - ASSERT_NE(res, nullptr); + pRes = taos_query(taos, "show tables"); + ASSERT_NE(pRes, nullptr); - row = taos_fetch_row(res); - rowNum = taos_affected_rows(res); + row = taos_fetch_row(pRes); + rowNum = taos_affected_rows(pRes); ASSERT_EQ(rowNum, 2); - taos_free_result(res); - - destroyRequest(request); - smlDestroyInfo(info); + taos_free_result(pRes); } TEST(testCase, smlProcess_json2_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql = + const char *sql[] = { "{\n" " \"metric\": \"meter_current0\",\n" " \"timestamp\": {\n" @@ -806,29 +772,23 @@ TEST(testCase, smlProcess_json2_Test) { " },\n" " \"id\": \"d1001\"\n" " }\n" - "}"; - int32_t ret = smlProcess(info, (char **)(&sql), -1); - ASSERT_EQ(ret, 0); - destroyRequest(request); - smlDestroyInfo(info); + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, smlProcess_json3_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql = + const char *sql[] ={ "{\n" " \"metric\": \"meter_current1\",\n" " \"timestamp\": {\n" @@ -878,29 +838,23 @@ TEST(testCase, smlProcess_json3_Test) { " },\n" " \"id\": \"d1001\"\n" " }\n" - "}"; - int32_t ret = smlProcess(info, (char **)(&sql), -1); - ASSERT_EQ(ret, 0); - destroyRequest(request); - smlDestroyInfo(info); + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, smlProcess_json4_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql = "{\n" + const char *sql[] = {"{\n" " \"metric\": \"meter_current2\",\n" " \"timestamp\": {\n" " \"value\" : 1346846500000,\n" @@ -940,18 +894,17 @@ TEST(testCase, smlProcess_json4_Test) { " \"t9\": false,\n" " \"id\": \"d1001\"\n" " }\n" - "}"; - int32_t ret = smlProcess(info, (char**)(&sql), -1); - ASSERT_EQ(ret, 0); - destroyRequest(request); - smlDestroyInfo(info); + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, smlParseTelnetLine_error_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); @@ -1000,34 +953,27 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[2] = { "sys.procs.running 1479496104000 42 host=web01", "sys.procs.running 1479496104000 42u8 host=web01" }; - int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_NE(ret, 0); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(taos_errno(pRes), 0); + taos_free_result(pRes); - destroyRequest(request); - smlDestroyInfo(info); } TEST(testCase, smlParseTelnetLine_json_error_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); @@ -1095,19 +1041,13 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - - const char *sql[2] = { + const char *sql[] = { "[\n" " {\n" " \"metric\": \"sys.cpu.nice\",\n" @@ -1129,30 +1069,22 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { " },\n" "]", }; - int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_NE(ret, 0); - - destroyRequest(request); - smlDestroyInfo(info); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - - const char *sql[2] = { + const char *sql[] = { "[\n" " {\n" " \"metric\": \"sys.cpu.nice\",\n" @@ -1174,90 +1106,64 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { " },\n" "]", }; - int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_NE(ret, 0); - - destroyRequest(request); - smlDestroyInfo(info); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, sml_TD15662_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES *pRes = taos_query(taos, "create database if not exists db_15662 precision 'ns'"); + TAOS_RES *pRes = taos_query(taos, "create database if not exists db_15662 precision 'ns' schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use db_15662"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[] = { "hetrey c0=f,c1=127i8 1626006833639", "hetrey,t1=r c0=f,c1=127i8 1626006833640", }; - int ret = smlProcess(info, (char **)sql, sizeof(sql) / sizeof(sql[0])); - ASSERT_EQ(ret, 0); - - destroyRequest(request); - smlDestroyInfo(info); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, sml_TD15735_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[1] = { "{'metric': 'pekoiw', 'timestamp': {'value': 1626006833639000000, 'type': 'ns'}, 'value': {'value': False, 'type': 'bool'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {'value': 9223372036854775807, 'type': 'bigint'}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'binaryTagValue', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}}}", }; - int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_NE(ret, 0); - - destroyRequest(request); - smlDestroyInfo(info); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); + ASSERT_NE(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, sml_TD15742_Test) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(taos, nullptr); - TAOS_RES* pRes = taos_query(taos, "create database if not exists TD15742"); + TAOS_RES* pRes = taos_query(taos, "create database if not exists TD15742 schemaless 1"); taos_free_result(pRes); pRes = taos_query(taos, "use TD15742"); taos_free_result(pRes); - SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_NE(info, nullptr); - const char *sql[] = { "test_ms,t0=t c0=f 1626006833641", }; - int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0])); - ASSERT_EQ(ret, 0); - - destroyRequest(request); - smlDestroyInfo(info); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); } TEST(testCase, sml_params_Test) { @@ -1325,8 +1231,8 @@ TEST(testCase, sml_oom_Test) { pRes = taos_query(taos, "use oom"); taos_free_result(pRes); - TAOS_RES* res = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(res), 0); + pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + ASSERT_EQ(taos_errno(pRes), 0); taos_free_result(pRes); } @@ -1354,4 +1260,4 @@ TEST(testCase, sml_16368_Test) { pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS); ASSERT_EQ(taos_errno(pRes), 0); taos_free_result(pRes); -} +}*/ diff --git a/source/common/src/systable.c b/source/common/src/systable.c index cb38a3cf70..08977abd61 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -91,7 +91,7 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, - {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, +// {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "retension", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update @@ -175,7 +175,7 @@ static const SSysDbTableSchema userUsersSchema[] = { }; static const SSysDbTableSchema grantsSchema[] = { - {.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f8ce86a30c..b7a9ef88b6 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -294,7 +294,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, in int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows) { ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type); - if (numOfRows == 0) { + if (numOfRows <= 0) { return numOfRows; } @@ -1239,6 +1239,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) { return NULL; } + if (pSrc->pData == NULL) { + continue; + } colDataAssign(pDst, pSrc, pDataBlock->info.rows); } @@ -1631,25 +1634,31 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks break; default: if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) { - char tv[8] = {0}; - if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = 0; - GET_TYPED_DATA(v, float, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) { - double v = 0; - GET_TYPED_DATA(v, double, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) { - int64_t v = 0; - GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); + if (pCol->type == pColInfoData->info.type) { + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset, + k); } else { - uint64_t v = 0; - GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); + char tv[8] = {0}; + if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else { + uint64_t v = 0; + GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset, + k); } - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset, k); } else { uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); TASSERT(0); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index a7d4903696..40c801c1a1 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -692,6 +692,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq void tFreeSMAltertbReq(SMAlterStbReq *pReq) { taosArrayDestroy(pReq->pFields); pReq->pFields = NULL; + taosMemoryFreeClear(pReq->comment); } int32_t tSerializeSEpSet(void *buf, int32_t bufLen, const SEpSet *pEpset) { @@ -3877,9 +3878,10 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) { if (tEncodeCStr(pCoder, pSma->indexName) < 0) return -1; if (tEncodeI32(pCoder, pSma->exprLen) < 0) return -1; if (tEncodeI32(pCoder, pSma->tagsFilterLen) < 0) return -1; - if (tEncodeI32(pCoder, pSma->numOfVgroups) < 0) return -1; if (tEncodeI64(pCoder, pSma->indexUid) < 0) return -1; if (tEncodeI64(pCoder, pSma->tableUid) < 0) return -1; + if (tEncodeI64(pCoder, pSma->dstTbUid) < 0) return -1; + if (tEncodeCStr(pCoder, pSma->dstTbName) < 0) return -1; if (tEncodeI64(pCoder, pSma->interval) < 0) return -1; if (tEncodeI64(pCoder, pSma->offset) < 0) return -1; if (tEncodeI64(pCoder, pSma->sliding) < 0) return -1; @@ -3889,17 +3891,10 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) { if (pSma->tagsFilterLen > 0) { if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1; } - for (int32_t v = 0; v < pSma->numOfVgroups; ++v) { - if (tEncodeI32(pCoder, pSma->pVgEpSet[v].vgId) < 0) return -1; - if (tEncodeI8(pCoder, pSma->pVgEpSet[v].epSet.inUse) < 0) return -1; - int8_t numOfEps = pSma->pVgEpSet[v].epSet.numOfEps; - if (tEncodeI8(pCoder, numOfEps) < 0) return -1; - for (int32_t n = 0; n < numOfEps; ++n) { - const SEp *pEp = &pSma->pVgEpSet[v].epSet.eps[n]; - if (tEncodeCStr(pCoder, pEp->fqdn) < 0) return -1; - if (tEncodeU16(pCoder, pEp->port) < 0) return -1; - } - } + + tEncodeSSchemaWrapper(pCoder, &pSma->schemaRow); + tEncodeSSchemaWrapper(pCoder, &pSma->schemaTag); + return 0; } @@ -3907,14 +3902,15 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) { if (tDecodeI8(pCoder, &pSma->version) < 0) return -1; if (tDecodeI8(pCoder, &pSma->intervalUnit) < 0) return -1; if (tDecodeI8(pCoder, &pSma->slidingUnit) < 0) return -1; - if (tDecodeI32(pCoder, &pSma->dstVgId) < 0) return -1; if (tDecodeI8(pCoder, &pSma->timezoneInt) < 0) return -1; + if (tDecodeI32(pCoder, &pSma->dstVgId) < 0) return -1; if (tDecodeCStrTo(pCoder, pSma->indexName) < 0) return -1; if (tDecodeI32(pCoder, &pSma->exprLen) < 0) return -1; if (tDecodeI32(pCoder, &pSma->tagsFilterLen) < 0) return -1; - if (tDecodeI32(pCoder, &pSma->numOfVgroups) < 0) return -1; if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1; if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1; + if (tDecodeI64(pCoder, &pSma->dstTbUid) < 0) return -1; + if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1; if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1; if (tDecodeI64(pCoder, &pSma->offset) < 0) return -1; if (tDecodeI64(pCoder, &pSma->sliding) < 0) return -1; @@ -3928,27 +3924,9 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) { } else { pSma->tagsFilter = NULL; } - if (pSma->numOfVgroups > 0) { - pSma->pVgEpSet = (SVgEpSet *)tDecoderMalloc(pCoder, pSma->numOfVgroups * sizeof(SVgEpSet)); - if (!pSma->pVgEpSet) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - memset(pSma->pVgEpSet, 0, pSma->numOfVgroups * sizeof(SVgEpSet)); - - for (int32_t v = 0; v < pSma->numOfVgroups; ++v) { - if (tDecodeI32(pCoder, &pSma->pVgEpSet[v].vgId) < 0) return -1; - if (tDecodeI8(pCoder, &pSma->pVgEpSet[v].epSet.inUse) < 0) return -1; - if (tDecodeI8(pCoder, &pSma->pVgEpSet[v].epSet.numOfEps) < 0) return -1; - int8_t numOfEps = pSma->pVgEpSet[v].epSet.numOfEps; - for (int32_t n = 0; n < numOfEps; ++n) { - SEp *pEp = &pSma->pVgEpSet[v].epSet.eps[n]; - if (tDecodeCStrTo(pCoder, pEp->fqdn) < 0) return -1; - if (tDecodeU16(pCoder, &pEp->port) < 0) return -1; - } - } - } + // only needed in dstVgroup + tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaRow); + tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaTag); return 0; } @@ -3991,55 +3969,6 @@ int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) { return 0; } -int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder *pCoder, const SVGetTsmaExpWndsReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI64(pCoder, pReq->indexUid) < 0) return -1; - if (tEncodeI64(pCoder, pReq->queryWindow.skey) < 0) return -1; - if (tEncodeI64(pCoder, pReq->queryWindow.ekey) < 0) return -1; - - tEndEncode(pCoder); - return 0; -} - -int32_t tDecodeSVGetTsmaExpWndsReq(SDecoder *pCoder, SVGetTsmaExpWndsReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI64(pCoder, &pReq->indexUid) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->queryWindow.skey) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->queryWindow.ekey) < 0) return -1; - - tEndDecode(pCoder); - return 0; -} - -int32_t tEncodeSVGetTSmaExpWndsRsp(SEncoder *pCoder, const SVGetTsmaExpWndsRsp *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI64(pCoder, pReq->indexUid) < 0) return -1; - if (tEncodeI8(pCoder, pReq->flags) < 0) return -1; - if (tEncodeI32(pCoder, pReq->numExpWnds) < 0) return -1; - for (int32_t i = 0; i < pReq->numExpWnds; ++i) { - if (tEncodeI64(pCoder, pReq->wndSKeys[i]) < 0) return -1; - } - tEndEncode(pCoder); - return 0; -} - -int32_t tDecodeSVGetTsmaExpWndsRsp(SDecoder *pCoder, SVGetTsmaExpWndsRsp *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI64(pCoder, &pReq->indexUid) < 0) return -1; - if (tDecodeI8(pCoder, &pReq->flags) < 0) return -1; - if (tDecodeI32(pCoder, &pReq->numExpWnds) < 0) return -1; - for (int32_t i = 0; i < pReq->numExpWnds; ++i) { - if (tDecodeI64(pCoder, &pReq->wndSKeys[i]) < 0) return -1; - } - - tEndDecode(pCoder); - return 0; -} - int32_t tSerializeSVDeleteReq(void *buf, int32_t bufLen, SVDeleteReq *pReq) { int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { @@ -4136,6 +4065,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeI32(&encoder, sqlLen) < 0) return -1; if (tEncodeI32(&encoder, astLen) < 0) return -1; if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1; + if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1; if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1; if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; @@ -4162,6 +4092,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; if (tDecodeI32(&decoder, &astLen) < 0) return -1; if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1; if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1; if (sqlLen > 0) { diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 10ba58af29..0b59e9b6cc 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -76,22 +76,22 @@ void deltaToUtcInitOnce() { static int64_t parseFraction(char* str, char** end, int32_t timePrec); static int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim); -static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec); -static int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec); +static int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec); +static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec); static char* forwardToTimeStringEnd(char* str); static bool checkTzPresent(const char* str, int32_t len); -static int32_t (*parseLocaltimeFp[])(char* timestr, int64_t* time, int32_t timePrec) = {parseLocaltime, +static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec) = {parseLocaltime, parseLocaltimeDst}; -int32_t taosParseTime(const char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) { +int32_t taosParseTime(const char* timestr, int64_t* utime, int32_t len, int32_t timePrec, int8_t day_light) { /* parse datatime string in with tz */ if (strnchr(timestr, 'T', len, false) != NULL) { - return parseTimeWithTz(timestr, time, timePrec, 'T'); + return parseTimeWithTz(timestr, utime, timePrec, 'T'); } else if (checkTzPresent(timestr, len)) { - return parseTimeWithTz(timestr, time, timePrec, 0); + return parseTimeWithTz(timestr, utime, timePrec, 0); } else { - return (*parseLocaltimeFp[day_light])((char*)timestr, time, timePrec); + return (*parseLocaltimeFp[day_light])((char*)timestr, len, utime, timePrec); } } @@ -309,12 +309,36 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch return 0; } -int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) { +static FORCE_INLINE bool validateTm(struct tm* pTm) { + if (pTm == NULL) { + return false; + } + + int32_t dayOfMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + int32_t leapYearMonthDay = 29; + int32_t year = pTm->tm_year + 1900; + bool isLeapYear = ((year % 100) == 0)? ((year % 400) == 0):((year % 4) == 0); + + if (isLeapYear && (pTm->tm_mon == 1)) { + if (pTm->tm_mday > leapYearMonthDay) { + return false; + } + } else { + if (pTm->tm_mday > dayOfMonth[pTm->tm_mon]) { + return false; + } + } + + return true; +} + +int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePrec) { *time = 0; struct tm tm = {0}; char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm); - if (str == NULL) { + if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; } @@ -343,13 +367,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) { return 0; } -int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) { +int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t timePrec) { *time = 0; struct tm tm = {0}; tm.tm_isdst = -1; char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm); - if (str == NULL) { + if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; } diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index fbd46db183..3e55469a4a 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -38,9 +38,13 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { SStatusRsp statusRsp = {0}; if (pRsp->pCont != NULL && pRsp->contLen > 0 && tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) { - pMgmt->pData->dnodeVer = statusRsp.dnodeVer; - dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg); - dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps); + dTrace("status msg received from mnode, dnodeVer:%" PRId64 " saved:%" PRId64, statusRsp.dnodeVer, + pMgmt->pData->dnodeVer); + if (pMgmt->pData->dnodeVer != statusRsp.dnodeVer) { + pMgmt->pData->dnodeVer = statusRsp.dnodeVer; + dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg); + dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps); + } } rpcFreeCont(pRsp->pCont); tFreeSStatusRsp(&statusRsp); @@ -89,7 +93,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527}; SRpcMsg rpcRsp = {0}; - dTrace("send status msg to mnode"); + dTrace("send status msg to mnode, dnodeVer:%" PRId64, req.dnodeVer); SEpSet epSet = {0}; dmGetMnodeEpSet(pMgmt->pData, &epSet); diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 6f6896ff9f..096fc753b2 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -81,6 +81,13 @@ int32_t dmReadEps(SDnodeData *pData) { } pData->dnodeId = dnodeId->valueint; + cJSON *dnodeVer = cJSON_GetObjectItem(root, "dnodeVer"); + if (!dnodeVer || dnodeVer->type != cJSON_String) { + dError("failed to read %s since dnodeVer not found", file); + goto _OVER; + } + pData->dnodeVer = atoll(dnodeVer->valuestring); + cJSON *clusterId = cJSON_GetObjectItem(root, "clusterId"); if (!clusterId || clusterId->type != cJSON_String) { dError("failed to read %s since clusterId not found", file); @@ -193,6 +200,7 @@ int32_t dmWriteEps(SDnodeData *pData) { len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pData->dnodeId); + len += snprintf(content + len, maxLen - len, " \"dnodeVer\": \"%" PRId64 "\",\n", pData->dnodeVer); len += snprintf(content + len, maxLen - len, " \"clusterId\": \"%" PRId64 "\",\n", pData->clusterId); len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pData->dropped); len += snprintf(content + len, maxLen - len, " \"dnodes\": [{\n"); @@ -224,30 +232,15 @@ int32_t dmWriteEps(SDnodeData *pData) { } pData->updateTime = taosGetTimestampMs(); - dDebug("successed to write %s", realfile); + dDebug("successed to write %s, dnodeVer:%" PRId64, realfile, pData->dnodeVer); return 0; } void dmUpdateEps(SDnodeData *pData, SArray *eps) { - int32_t numOfEps = taosArrayGetSize(eps); - if (numOfEps <= 0) return; - taosThreadRwlockWrlock(&pData->lock); - - int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pData->dnodeEps); - if (numOfEps != numOfEpsOld) { - dDebug("new dnode list get from mnode"); - dmResetEps(pData, eps); - dmWriteEps(pData); - } else { - int32_t size = numOfEps * sizeof(SDnodeEp); - if (memcmp(pData->dnodeEps->pData, eps->pData, size) != 0) { - dDebug("new dnode list get from mnode"); - dmResetEps(pData, eps); - dmWriteEps(pData); - } - } - + dDebug("new dnode list get from mnode, dnodeVer:%" PRId64, pData->dnodeVer); + dmResetEps(pData, eps); + dmWriteEps(pData); taosThreadRwlockUnlock(&pData->lock); } diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 238ac967a2..4ea92a2538 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -298,31 +298,32 @@ typedef struct { } SVgObj; typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; - char stb[TSDB_TABLE_FNAME_LEN]; - char db[TSDB_DB_FNAME_LEN]; - int64_t createdTime; - int64_t uid; - int64_t stbUid; - int64_t dbUid; - int8_t intervalUnit; - int8_t slidingUnit; - int8_t timezone; - int32_t dstVgId; // for stream - int64_t dstTbUid; - int64_t interval; - int64_t offset; - int64_t sliding; - int32_t exprLen; // strlen + 1 - int32_t tagsFilterLen; - int32_t sqlLen; - int32_t astLen; - int32_t numOfVgroups; - char* expr; - char* tagsFilter; - char* sql; - char* ast; - SVgEpSet* pVgEpSet; + char name[TSDB_TABLE_FNAME_LEN]; + char stb[TSDB_TABLE_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + char dstTbName[TSDB_TABLE_FNAME_LEN]; + int64_t createdTime; + int64_t uid; + int64_t stbUid; + int64_t dbUid; + int64_t dstTbUid; + int8_t intervalUnit; + int8_t slidingUnit; + int8_t timezone; + int32_t dstVgId; // for stream + int64_t interval; + int64_t offset; + int64_t sliding; + int32_t exprLen; // strlen + 1 + int32_t tagsFilterLen; + int32_t sqlLen; + int32_t astLen; + char* expr; + char* tagsFilter; + char* sql; + char* ast; + SSchemaWrapper schemaRow; // for dstVgroup + SSchemaWrapper schemaTag; // for dstVgroup } SSmaObj; typedef struct { diff --git a/source/dnode/mnode/impl/inc/mndGrant.h b/source/dnode/mnode/impl/inc/mndGrant.h index ad3dc7f79d..525dd2c2e5 100644 --- a/source/dnode/mnode/impl/inc/mndGrant.h +++ b/source/dnode/mnode/impl/inc/mndGrant.h @@ -20,6 +20,8 @@ "C" { #endif +#include "mndInt.h" + typedef enum { TSDB_GRANT_ALL, TSDB_GRANT_TIME, diff --git a/source/dnode/mnode/impl/inc/mndScheduler.h b/source/dnode/mnode/impl/inc/mndScheduler.h index fa5e20ab6f..80fe472c56 100644 --- a/source/dnode/mnode/impl/inc/mndScheduler.h +++ b/source/dnode/mnode/impl/inc/mndScheduler.h @@ -27,10 +27,10 @@ void mndCleanupScheduler(SMnode* pMnode); int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub); -int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); -int32_t mndConvertRSmaTask(const char* ast, int64_t uid, int8_t triggerType, int64_t watermark, char** pStr, - int32_t* pLen, double filesFactor); +int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType, + int64_t watermark, double filesFactor); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index 5ac9d2233f..0175e29a77 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -75,6 +75,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans); int32_t mndTransProcessRsp(SRpcMsg *pRsp); void mndTransPullup(SMnode *pMnode); int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans); +void mndTransExecute(SMnode *pMnode, STrans *pTrans); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index c50279889e..e0ff7a70d7 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -29,6 +29,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup); SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup); SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup); int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId); +void mndSortVnodeGid(SVgObj *pVgroup); SArray *mndBuildDnodesArray(SMnode *, int32_t exceptDnodeId); int32_t mndAllocSmaVgroup(SMnode *, SDbObj *pDb, SVgObj *pVgroup); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 7aabbf1e4f..4da3c906d7 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -447,6 +447,8 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { pConsumerOld = mndAcquireConsumer(pMnode, consumerId); if (pConsumerOld == NULL) { + mInfo("receive subscribe request from new consumer: %ld", consumerId); + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); tstrncpy(pConsumerNew->clientId, subscribe.clientId, 256); pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY; @@ -463,7 +465,12 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { } else { /*taosRLockLatch(&pConsumerOld->lock);*/ + int32_t status = atomic_load_32(&pConsumerOld->status); + + mInfo("receive subscribe request from old consumer: %ld, current status: %s", consumerId, + mndConsumerStatusName(status)); + if (status != MQ_CONSUMER_STATUS__READY) { terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; goto SUBSCRIBE_OVER; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index c20459829e..b4237466d4 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1503,8 +1503,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)statusB, false); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false); +// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); +// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false); char *p = buildRetension(pDb->cfg.pRetensions); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 3fab870277..73eea70195 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -385,7 +385,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE); int64_t curMs = taosGetTimestampMs(); bool online = mndIsDnodeOnline(pDnode, curMs); - bool dnodeChanged = (statusReq.dnodeVer != dnodeVer); + bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer); bool reboot = (pDnode->rebootTime != statusReq.rebootTime); bool needCheck = !online || dnodeChanged || reboot; @@ -427,7 +427,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { if (!online) { mInfo("dnode:%d, from offline to online", pDnode->id); } else { - mDebug("dnode:%d, send dnode epset, online:%d dnode_ver:%" PRId64 ":%" PRId64 " reboot:%d", pDnode->id, online, + mDebug("dnode:%d, send dnode epset, online:%d dnodeVer:%" PRId64 ":%" PRId64 " reboot:%d", pDnode->id, online, statusReq.dnodeVer, dnodeVer, reboot); } diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c index 94acca5f61..d1d43c841c 100644 --- a/source/dnode/mnode/impl/src/mndGrant.c +++ b/source/dnode/mnode/impl/src/mndGrant.c @@ -14,19 +14,115 @@ */ #define _DEFAULT_SOURCE -#include "os.h" -#include "taoserror.h" #include "mndGrant.h" -#include "mndInt.h" #include "mndShow.h" #ifndef _GRANT -static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { return TSDB_CODE_OPS_NOT_SUPPORT; } + +static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { + int32_t numOfRows = 0; + char *pWrite; + int32_t cols = 0; + char tmp[32]; + char tmp1[32]; + + if (pShow->numOfRows < 1) { + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + const char *src = "community"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "false"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + src = "unlimited"; + STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + colDataAppend(pColInfo, numOfRows, tmp, false); + + numOfRows++; + } + + pShow->numOfRows += numOfRows; + return numOfRows; +} int32_t mndInitGrant(SMnode *pMnode) { - mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant); - return TSDB_CODE_SUCCESS; + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant); + return 0; } + void mndCleanupGrant() {} void grantParseParameter() { mError("can't parsed parameter k"); } int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 027de66b42..c5a4282b3b 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -397,17 +397,17 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (sdbGetSize(pMnode->pSdb, SDB_MNODE) >= 3) { - terrno = TSDB_CODE_MND_TOO_MANY_MNODES; - goto _OVER; - } - pDnode = mndAcquireDnode(pMnode, createReq.dnodeId); if (pDnode == NULL) { terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; goto _OVER; } + if (sdbGetSize(pMnode->pSdb, SDB_MNODE) >= 3) { + terrno = TSDB_CODE_MND_TOO_MANY_MNODES; + goto _OVER; + } + if (!mndIsDnodeOnline(pDnode, taosGetTimestampMs())) { terrno = TSDB_CODE_NODE_OFFLINE; goto _OVER; @@ -597,6 +597,11 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { goto _OVER; } + if (!mndIsDnodeOnline(pObj->pDnode, taosGetTimestampMs())) { + terrno = TSDB_CODE_NODE_OFFLINE; + goto _OVER; + } + pUser = mndAcquireUser(pMnode, pReq->conn.user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index 00c8bb30d0..18f2e993b2 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -183,7 +183,10 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) { for (int32_t i = 0; i < commitOffsetReq.num; i++) { SMqOffset *pOffset = &commitOffsetReq.offsets[i]; + mInfo("commit offset %ld to vg %d of consumer group %s on topic %s", pOffset->offset, pOffset->vgId, + pOffset->cgroup, pOffset->topicName); if (mndMakePartitionKey(key, pOffset->cgroup, pOffset->topicName, pOffset->vgId) < 0) { + mError("submit offset to topic %s failed", pOffset->topicName); return -1; } bool create = false; @@ -192,7 +195,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) { SMqTopicObj *pTopic = mndAcquireTopic(pMnode, pOffset->topicName); if (pTopic == NULL) { terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST; - mError("submit offset to topic %s failed since %s", pOffset->topicName, terrstr()); + mError("submit offset to topic %s failed since %s", pOffset->topicName, terrstr()); continue; } pOffsetObj = taosMemoryMalloc(sizeof(SMqOffsetObj)); diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index deb7382183..a3b7754a4e 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -42,8 +42,8 @@ static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) { return 0; } -int32_t mndConvertRSmaTask(const char* ast, int64_t uid, int8_t triggerType, int64_t watermark, char** pStr, - int32_t* pLen, double filesFactor) { +int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType, + int64_t watermark, double filesFactor) { SNode* pAst = NULL; SQueryPlan* pPlan = NULL; terrno = TSDB_CODE_SUCCESS; @@ -53,7 +53,7 @@ int32_t mndConvertRSmaTask(const char* ast, int64_t uid, int8_t triggerType, int goto END; } - if (qSetSTableIdForRSma(pAst, uid) < 0) { + if (qSetSTableIdForRsma(pAst, uid) < 0) { terrno = TSDB_CODE_QRY_INVALID_INPUT; goto END; } @@ -77,7 +77,7 @@ int32_t mndConvertRSmaTask(const char* ast, int64_t uid, int8_t triggerType, int terrno = TSDB_CODE_QRY_INVALID_INPUT; goto END; } - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); int32_t opNum = LIST_LENGTH(inner->pNodeList); if (opNum != 1) { @@ -85,15 +85,15 @@ int32_t mndConvertRSmaTask(const char* ast, int64_t uid, int8_t triggerType, int goto END; } - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); - if (qSubPlanToString(plan, pStr, pLen) < 0) { + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); + if (qSubPlanToString(plan, pDst, pDstLen) < 0) { terrno = TSDB_CODE_QRY_INVALID_INPUT; goto END; } END: if (pAst) nodesDestroyNode(pAst); - if (pPlan) nodesDestroyNode(pPlan); + if (pPlan) nodesDestroyNode((SNode*)pPlan); return terrno; } @@ -151,33 +151,36 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj* ASSERT(pDb); if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) { - sdbRelease(pMnode->pSdb, pDb); + ASSERT(0); + return -1; + } + sdbRelease(pMnode->pSdb, pDb); - SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; - int32_t sz = taosArrayGetSize(pVgs); - SArray* sinkLv = taosArrayGetP(pStream->tasks, 0); - int32_t sinkLvSize = taosArrayGetSize(sinkLv); - for (int32_t i = 0; i < sz; i++) { - SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i); - for (int32_t j = 0; j < sinkLvSize; j++) { - SStreamTask* pLastLevelTask = taosArrayGetP(sinkLv, j); - if (pLastLevelTask->nodeId == pVgInfo->vgId) { - pVgInfo->taskId = pLastLevelTask->taskId; - break; - } + SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; + int32_t sz = taosArrayGetSize(pVgs); + SArray* sinkLv = taosArrayGetP(pStream->tasks, 0); + int32_t sinkLvSize = taosArrayGetSize(sinkLv); + for (int32_t i = 0; i < sz; i++) { + SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i); + for (int32_t j = 0; j < sinkLvSize; j++) { + SStreamTask* pLastLevelTask = taosArrayGetP(sinkLv, j); + if (pLastLevelTask->nodeId == pVgInfo->vgId) { + pVgInfo->taskId = pLastLevelTask->taskId; + ASSERT(pVgInfo->taskId != 0); + break; } } - } else { - pTask->dispatchType = TASK_DISPATCH__FIXED; - pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; - SArray* pArray = taosArrayGetP(pStream->tasks, 0); - // one sink only - ASSERT(taosArrayGetSize(pArray) == 1); - SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0); - pTask->fixedEpDispatcher.taskId = lastLevelTask->taskId; - pTask->fixedEpDispatcher.nodeId = lastLevelTask->nodeId; - pTask->fixedEpDispatcher.epSet = lastLevelTask->epSet; } + } else { + pTask->dispatchType = TASK_DISPATCH__FIXED; + pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; + SArray* pArray = taosArrayGetP(pStream->tasks, 0); + // one sink only + ASSERT(taosArrayGetSize(pArray) == 1); + SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0); + pTask->fixedEpDispatcher.taskId = lastLevelTask->taskId; + pTask->fixedEpDispatcher.nodeId = lastLevelTask->nodeId; + pTask->fixedEpDispatcher.epSet = lastLevelTask->epSet; } return 0; } @@ -335,7 +338,7 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* return 0; } -int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); if (pPlan == NULL) { @@ -348,9 +351,15 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) ASSERT(totLevel <= 2); pStream->tasks = taosArrayInit(totLevel, sizeof(void*)); - bool hasExtraSink = false; - bool externalTargetDB = strcmp(pStream->sourceDb, pStream->targetDb) != 0; - if (totLevel == 2 || externalTargetDB) { + bool hasExtraSink = false; + bool externalTargetDB = strcmp(pStream->sourceDb, pStream->targetDb) != 0; + SDbObj* pDbObj = mndAcquireDb(pMnode, pStream->targetDb); + ASSERT(pDbObj != NULL); + sdbRelease(pSdb, pDbObj); + + bool multiTarget = pDbObj->cfg.numOfVgroups > 1; + + if (totLevel == 2 || externalTargetDB || multiTarget) { SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskOneLevel); // add extra sink @@ -361,6 +370,7 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) mndAddFixedSinkTaskToStream(pMnode, pTrans, pStream); } } + if (totLevel > 1) { SStreamTask* pFinalTask; // inner plan @@ -368,8 +378,8 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) SArray* taskInnerLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskInnerLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE); pFinalTask = tNewSStreamTask(pStream->uid); @@ -378,7 +388,10 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) pFinalTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; // dispatch - mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pFinalTask); + if (mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pFinalTask) < 0) { + qDestroyQueryPlan(pPlan); + return -1; + } // exec pFinalTask->execType = TASK_EXEC__PIPE; @@ -394,8 +407,8 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) SArray* taskSourceLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskSourceLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 1); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN); void* pIter = NULL; @@ -436,9 +449,9 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskOneLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); ASSERT(LIST_LENGTH(inner->pNodeList) == 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN); void* pIter = NULL; @@ -472,229 +485,7 @@ int32_t mndScheduleStream1(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) } } } - return 0; -} - -int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { - SSdb* pSdb = pMnode->pSdb; - SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); - if (pPlan == NULL) { - terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; - } - ASSERT(pStream->vgNum == 0); - - int32_t totLevel = LIST_LENGTH(pPlan->pSubplans); - ASSERT(totLevel <= 2); - pStream->tasks = taosArrayInit(totLevel, sizeof(void*)); - - bool hasExtraSink = false; - bool externalTargetDB = strcmp(pStream->sourceDb, pStream->targetDb) != 0; - if (totLevel == 2 || externalTargetDB) { - SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); - taosArrayPush(pStream->tasks, &taskOneLevel); - // add extra sink - hasExtraSink = true; - if (pStream->fixedSinkVgId == 0) { - mndAddShuffleSinkTasksToStream(pMnode, pTrans, pStream); - } else { - mndAddFixedSinkTaskToStream(pMnode, pTrans, pStream); - } - } - - for (int32_t level = 0; level < totLevel; level++) { - SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); - taosArrayPush(pStream->tasks, &taskOneLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level); - ASSERT(LIST_LENGTH(inner->pNodeList) == 1); - - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); - - // if (level == totLevel - 1 /* or no snode */) { - if (level == totLevel - 1) { - // last level, source, must assign to vnode - // must be scan type - ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN); - - // replicate task to each vnode - void* pIter = NULL; - while (1) { - SVgObj* pVgroup; - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); - if (pIter == NULL) break; - if (pVgroup->dbUid != pStream->dbUid) { - sdbRelease(pSdb, pVgroup); - continue; - } - SStreamTask* pTask = tNewSStreamTask(pStream->uid); - mndAddTaskToTaskSet(taskOneLevel, pTask); - // source part - pTask->sourceType = TASK_SOURCE__SCAN; - pTask->inputType = TASK_INPUT_TYPE__SUMBIT_BLOCK; - - // sink part - if (level == 0) { - // only for inplace - pTask->sinkType = TASK_SINK__NONE; - if (!hasExtraSink) { -#if 1 - if (pStream->createdBy == STREAM_CREATED_BY__SMA) { - pTask->sinkType = TASK_SINK__SMA; - pTask->smaSink.smaId = pStream->smaId; - } else { - pTask->sinkType = TASK_SINK__TABLE; - pTask->tbSink.stbUid = pStream->targetStbUid; - memcpy(pTask->tbSink.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); - pTask->tbSink.pSchemaWrapper = tCloneSSchemaWrapper(&pStream->outputSchema); - } -#endif - } - } else { - pTask->sinkType = TASK_SINK__NONE; - } - - // dispatch part - if (level == 0 && !hasExtraSink) { - pTask->dispatchType = TASK_DISPATCH__NONE; - } else { - // add fixed ep dispatcher - int32_t lastLevel = level - 1; - if (hasExtraSink) lastLevel++; - ASSERT(lastLevel == 0); - SArray* pArray = taosArrayGetP(pStream->tasks, lastLevel); - // one merge only - ASSERT(taosArrayGetSize(pArray) == 1); - SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0); - pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; - pTask->dispatchType = TASK_DISPATCH__FIXED; - - pTask->fixedEpDispatcher.taskId = lastLevelTask->taskId; - pTask->fixedEpDispatcher.nodeId = lastLevelTask->nodeId; - pTask->fixedEpDispatcher.epSet = lastLevelTask->epSet; - } - - // exec part - pTask->execType = TASK_EXEC__PIPE; - if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) { - sdbRelease(pSdb, pVgroup); - qDestroyQueryPlan(pPlan); - return -1; - } - sdbRelease(pSdb, pVgroup); - } - } else { - // merge plan - - // TODO if has snode, assign to snode - - // else, assign to vnode - ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE); - SStreamTask* pTask = tNewSStreamTask(pStream->uid); - mndAddTaskToTaskSet(taskOneLevel, pTask); - - // source part, currently only support multi source - pTask->sourceType = TASK_SOURCE__PIPE; - pTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; - - // sink part - pTask->sinkType = TASK_SINK__NONE; - - // dispatch part - ASSERT(hasExtraSink); - /*pTask->dispatchType = TASK_DISPATCH__NONE;*/ -#if 1 - - if (hasExtraSink) { - // add dispatcher - if (pStream->fixedSinkVgId == 0) { - pTask->dispatchType = TASK_DISPATCH__SHUFFLE; - - pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; - SDbObj* pDb = mndAcquireDb(pMnode, pStream->targetDb); - ASSERT(pDb); - if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) { - sdbRelease(pSdb, pDb); - qDestroyQueryPlan(pPlan); - return -1; - } - sdbRelease(pSdb, pDb); - - // put taskId to useDbRsp - // TODO: optimize - SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; - int32_t sz = taosArrayGetSize(pVgs); - SArray* sinkLv = taosArrayGetP(pStream->tasks, 0); - int32_t sinkLvSize = taosArrayGetSize(sinkLv); - for (int32_t i = 0; i < sz; i++) { - SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i); - for (int32_t j = 0; j < sinkLvSize; j++) { - SStreamTask* pLastLevelTask = taosArrayGetP(sinkLv, j); - if (pLastLevelTask->nodeId == pVgInfo->vgId) { - pVgInfo->taskId = pLastLevelTask->taskId; - break; - } - } - } - } else { - pTask->dispatchType = TASK_DISPATCH__FIXED; - /*pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC;*/ - pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; - SArray* pArray = taosArrayGetP(pStream->tasks, 0); - // one sink only - ASSERT(taosArrayGetSize(pArray) == 1); - SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0); - pTask->fixedEpDispatcher.taskId = lastLevelTask->taskId; - pTask->fixedEpDispatcher.nodeId = lastLevelTask->nodeId; - pTask->fixedEpDispatcher.epSet = lastLevelTask->epSet; - } - } -#endif - - // exec part - pTask->execType = TASK_EXEC__MERGE; - SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->dbUid); - ASSERT(pVgroup); - if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) { - sdbRelease(pSdb, pVgroup); - qDestroyQueryPlan(pPlan); - return -1; - } - sdbRelease(pSdb, pVgroup); - } - } - -#if 0 - if (totLevel == 2) { - void* pIter = NULL; - while (1) { - SVgObj* pVgroup; - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); - if (pIter == NULL) break; - if (pVgroup->dbUid != pStream->dbUid) { - sdbRelease(pSdb, pVgroup); - continue; - } - SStreamTask* pTask = tNewSStreamTask(pStream->uid); - - // source part - pTask->sourceType = TASK_SOURCE__MERGE; - pTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; - - // sink part - pTask->sinkType = TASK_SINK__NONE; - - // dispatch part - pTask->dispatchType = TASK_DISPATCH__NONE; - - // exec part - pTask->execType = TASK_EXEC__NONE; - } - } -#endif - - // free memory qDestroyQueryPlan(pPlan); - return 0; } @@ -718,7 +509,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib return -1; } - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); int32_t opNum = LIST_LENGTH(inner->pNodeList); if (opNum != 1) { @@ -726,7 +517,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib terrno = TSDB_CODE_MND_INVALID_TOPIC_QUERY; return -1; } - plan = nodesListGetNode(inner->pNodeList, 0); + plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); } ASSERT(pSub->unassignedVgs); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index cde36eac58..c19b558f19 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -26,6 +26,7 @@ #include "mndTrans.h" #include "mndUser.h" #include "mndVgroup.h" +#include "parser.h" #include "tname.h" #define TSDB_SMA_VER_NUMBER 1 @@ -82,10 +83,12 @@ 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_INT64(pRaw, dataPos, pSma->createdTime, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->uid, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->stbUid, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->dbUid, _OVER) + SDB_SET_INT64(pRaw, dataPos, pSma->dstTbUid, _OVER) SDB_SET_INT8(pRaw, dataPos, pSma->intervalUnit, _OVER) SDB_SET_INT8(pRaw, dataPos, pSma->slidingUnit, _OVER) SDB_SET_INT8(pRaw, dataPos, pSma->timezone, _OVER) @@ -147,10 +150,12 @@ 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_INT64(pRaw, dataPos, &pSma->createdTime, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->uid, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->stbUid, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->dbUid, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pSma->dstTbUid, _OVER) SDB_GET_INT8(pRaw, dataPos, &pSma->intervalUnit, _OVER) SDB_GET_INT8(pRaw, dataPos, &pSma->slidingUnit, _OVER) SDB_GET_INT8(pRaw, dataPos, &pSma->timezone, _OVER) @@ -260,14 +265,17 @@ static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSm req.tagsFilterLen = pSma->tagsFilterLen; req.indexUid = pSma->uid; req.tableUid = pSma->stbUid; + req.dstVgId = pSma->dstVgId; + req.dstTbUid = pSma->dstTbUid; req.interval = pSma->interval; req.offset = pSma->offset; req.sliding = pSma->sliding; req.expr = pSma->expr; req.tagsFilter = pSma->tagsFilter; - req.numOfVgroups = pSma->numOfVgroups; - req.pVgEpSet = pSma->pVgEpSet; - + req.schemaRow = pSma->schemaRow; + req.schemaTag = pSma->schemaTag; + req.dstTbName = pSma->dstTbName; + // get length int32_t ret = 0; tEncodeSize(tEncodeSVCreateTSmaReq, &req, contLen, ret); @@ -425,14 +433,30 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, mndReleaseDnode(pMnode, pDnode); // todo add sma info here - SVgEpSet *pVgEpSet = NULL; - int32_t numOfVgroups = 0; - if (mndSmaGetVgEpSet(pMnode, pDb, &pVgEpSet, &numOfVgroups) != 0) { + SNode *pAst = NULL; + if (nodesStringToNode(pSma->ast, &pAst) < 0) { return -1; } + if (qExtractResultSchema(pAst, &pSma->schemaRow.nCols, &pSma->schemaRow.pSchema) != 0) { + nodesDestroyNode(pAst); + return -1; + } + nodesDestroyNode(pAst); + pSma->schemaRow.version = 1; + + // TODO: the schemaTag generated by qExtractResultXXX later. + pSma->schemaTag.nCols = 1; + pSma->schemaTag.version = 1; + pSma->schemaTag.pSchema = taosMemoryCalloc(1, sizeof(SSchema)); + if (!pSma->schemaTag.pSchema) { + return -1; + } + pSma->schemaTag.pSchema[0].type = TSDB_DATA_TYPE_BIGINT; + pSma->schemaTag.pSchema[0].bytes = TYPE_BYTES[TSDB_DATA_TYPE_BIGINT]; + pSma->schemaTag.pSchema[0].colId = pSma->schemaRow.nCols + PRIMARYKEY_TIMESTAMP_COL_ID; + pSma->schemaTag.pSchema[0].flags = 0; + snprintf(pSma->schemaTag.pSchema[0].name, TSDB_COL_NAME_LEN, "groupId"); - pSma->pVgEpSet = pVgEpSet; - pSma->numOfVgroups = numOfVgroups; int32_t smaContLen = 0; void *pSmaReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &smaContLen); @@ -464,12 +488,15 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea memcpy(smaObj.db, pDb->name, TSDB_DB_FNAME_LEN); smaObj.createdTime = taosGetTimestampMs(); smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); + char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0}; + snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "td.tsma.rst.tb.%s", pCreate->name); + memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN); + smaObj.dstTbUid = mndGenerateUid(smaObj.dstTbName, TSDB_TABLE_FNAME_LEN); smaObj.stbUid = pStb->uid; smaObj.dbUid = pStb->dbUid; smaObj.intervalUnit = pCreate->intervalUnit; smaObj.slidingUnit = pCreate->slidingUnit; smaObj.timezone = pCreate->timezone; - smaObj.dstVgId = pCreate->dstVgId; smaObj.interval = pCreate->interval; smaObj.offset = pCreate->offset; smaObj.sliding = pCreate->sliding; @@ -1087,53 +1114,4 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc static void mndCancelGetNextSma(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); -} - -static int32_t mndSmaGetVgEpSet(SMnode *pMnode, SDbObj *pDb, SVgEpSet **ppVgEpSet, int32_t *numOfVgroups) { - SSdb *pSdb = pMnode->pSdb; - SVgObj *pVgroup = NULL; - void *pIter = NULL; - SVgEpSet *pVgEpSet = NULL; - int32_t nAllocVgs = 16; - int32_t nVgs = 0; - - pVgEpSet = taosMemoryCalloc(nAllocVgs, sizeof(SVgEpSet)); - if (!pVgEpSet) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - while (1) { - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { - sdbRelease(pSdb, pVgroup); - continue; - } - - if (nVgs >= nAllocVgs) { - void *p = taosMemoryRealloc(pVgEpSet, nAllocVgs * 2 * sizeof(SVgEpSet)); - if (!p) { - taosMemoryFree(pVgEpSet); - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - pVgEpSet = (SVgEpSet *)p; - nAllocVgs *= 2; - } - - (pVgEpSet + nVgs)->vgId = pVgroup->vgId; - (pVgEpSet + nVgs)->epSet = mndGetVgroupEpset(pMnode, pVgroup); - - ++nVgs; - - sdbRelease(pSdb, pVgroup); - } - - *ppVgEpSet = pVgEpSet; - *numOfVgroups = nVgs; - - return 0; -} +} \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 9981dc8530..ad0c913fb8 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -395,13 +395,13 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.pRSmaParam.xFilesFactor = pStb->xFilesFactor; req.pRSmaParam.delay = pStb->delay; if (pStb->ast1Len > 0) { - if (mndConvertRSmaTask(pStb->pAst1, pStb->uid, 0, 0, &req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, + if (mndConvertRsmaTask(&req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, pStb->pAst1, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { return NULL; } } if (pStb->ast2Len > 0) { - if (mndConvertRSmaTask(pStb->pAst2, pStb->uid, 0, 0, &req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, + if (mndConvertRsmaTask(&req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, pStb->pAst2, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { return NULL; } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 4a2c0a59a1..96d199fcb6 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -235,10 +235,10 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64 } if (TSDB_CODE_SUCCESS == code) { - code = nodesNodeToString(pPlan, false, pStr, NULL); + code = nodesNodeToString((SNode*)pPlan, false, pStr, NULL); } nodesDestroyNode(pAst); - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); terrno = code; return code; } @@ -252,8 +252,12 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast } if (qExtractResultSchema(pAst, (int32_t *)&pStream->outputSchema.nCols, &pStream->outputSchema.pSchema) != 0) { + nodesDestroyNode(pAst); return -1; } + // free + nodesDestroyNode(pAst); + #if 0 printf("|"); @@ -269,7 +273,7 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast return -1; } - if (mndScheduleStream1(pMnode, pTrans, pStream) < 0) { + if (mndScheduleStream(pMnode, pTrans, pStream) < 0) { mError("stream:%ld, schedule stream since %s", pStream->uid, terrstr()); return -1; } diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index a0f722b3d2..e0b4cc6a57 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -61,6 +61,12 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM } tsem_post(&pMgmt->syncSem); } else { + STrans *pTrans = mndAcquireTrans(pMnode, transId); + if (pTrans != NULL) { + mndTransExecute(pMnode, pTrans); + mndReleaseTrans(pMnode, pTrans); + } + if (cbMeta.index - sdbGetApplyIndex(pMnode->pSdb) > 100) { SSnapshotMeta sMeta = {0}; if (syncGetSnapshotMeta(pMnode->syncMgmt.sync, &sMeta) == 0) { @@ -200,14 +206,14 @@ int32_t mndInitSync(SMnode *pMnode) { return -1; } - mDebug("mnode sync is opened, id:%" PRId64, pMgmt->sync); + mDebug("mnode-sync is opened, id:%" PRId64, pMgmt->sync); return 0; } void mndCleanupSync(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; syncStop(pMgmt->sync); - mDebug("mnode sync is stopped, id:%" PRId64, pMgmt->sync); + mDebug("mnode-sync is stopped, id:%" PRId64, pMgmt->sync); tsem_destroy(&pMgmt->syncSem); memset(pMgmt, 0, sizeof(SSyncMgmt)); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index c8333c32f0..3247008d58 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * return -1; } - if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) { + if (nodesNodeToString((SNode*)pPlan, false, &topicObj.physicalPlan, NULL) != 0) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); taosMemoryFree(topicObj.ast); taosMemoryFree(topicObj.sql); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index a689c89037..033687db3e 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -52,8 +52,8 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans); static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans); static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans); static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans); +static bool mndCantExecuteTransAction(SMnode *pMnode) { return !pMnode->deploy && !mndIsMaster(pMnode); } -static void mndTransExecute(SMnode *pMnode, STrans *pTrans); static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); static int32_t mndProcessTransReq(SRpcMsg *pReq); static int32_t mndProcessKillTransReq(SRpcMsg *pReq); @@ -297,7 +297,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) action.pRaw = taosMemoryMalloc(dataLen); if (action.pRaw == NULL) goto _OVER; - mTrace("raw:%p, is created", pData); + // mTrace("raw:%p, is created", pData); SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER); if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER; action.pRaw = NULL; @@ -330,7 +330,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) action.pRaw = taosMemoryMalloc(dataLen); if (action.pRaw == NULL) goto _OVER; - mTrace("raw:%p, is created", pData); + // mTrace("raw:%p, is created", action.pRaw); SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER); if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER; action.pRaw = NULL; @@ -363,7 +363,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) action.pRaw = taosMemoryMalloc(dataLen); if (action.pRaw == NULL) goto _OVER; - mTrace("raw:%p, is created", action.pRaw); + // mTrace("raw:%p, is created", action.pRaw); SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER); if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER; action.pRaw = NULL; @@ -517,12 +517,12 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { if (pOld->stage == TRN_STAGE_COMMIT) { pOld->stage = TRN_STAGE_COMMIT_ACTION; - mTrace("trans:%d, stage from commit to commitAction", pNew->id); + mTrace("trans:%d, stage from commit to commitAction since perform update action", pNew->id); } if (pOld->stage == TRN_STAGE_ROLLBACK) { pOld->stage = TRN_STAGE_FINISHED; - mTrace("trans:%d, stage from rollback to finished", pNew->id); + mTrace("trans:%d, stage from rollback to finished since perform update action", pNew->id); } return 0; } @@ -914,7 +914,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransAction *pAction) { if (pAction->msgSent) return 0; - if (!pMnode->deploy && !mndIsMaster(pMnode)) return -1; + if (mndCantExecuteTransAction(pMnode)) return -1; int64_t signature = pTrans->id; signature = (signature << 32); @@ -1114,9 +1114,9 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) pTrans->lastEpset = pAction->epSet; } - if (code == 0) { - if (!pMnode->deploy && !mndIsMaster(pMnode)) break; + if (mndCantExecuteTransAction(pMnode)) break; + if (code == 0) { pTrans->code = 0; pTrans->redoActionPos++; mDebug("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage), @@ -1160,6 +1160,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) { code = mndTransExecuteRedoActions(pMnode, pTrans); } + if (mndCantExecuteTransAction(pMnode)) return false; + if (code == 0) { pTrans->code = 0; pTrans->stage = TRN_STAGE_COMMIT; @@ -1185,6 +1187,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) { } static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans) { + if (mndCantExecuteTransAction(pMnode)) return false; + bool continueExec = true; int32_t code = mndTransCommit(pMnode, pTrans); @@ -1233,6 +1237,8 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) { bool continueExec = true; int32_t code = mndTransExecuteUndoActions(pMnode, pTrans); + if (mndCantExecuteTransAction(pMnode)) return false; + if (code == 0) { pTrans->stage = TRN_STAGE_ROLLBACK; mDebug("trans:%d, stage from undoAction to rollback", pTrans->id); @@ -1250,6 +1256,8 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) { } static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans) { + if (mndCantExecuteTransAction(pMnode)) return false; + bool continueExec = true; int32_t code = mndTransRollback(pMnode, pTrans); @@ -1284,10 +1292,11 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) { return continueExec; } -static void mndTransExecute(SMnode *pMnode, STrans *pTrans) { +void mndTransExecute(SMnode *pMnode, STrans *pTrans) { bool continueExec = true; while (continueExec) { + mDebug("trans:%d, continue to execute, stage:%s", pTrans->id, mndTransStr(pTrans->stage)); pTrans->lastExecTime = taosGetTimestampMs(); switch (pTrans->stage) { case TRN_STAGE_PREPARE: diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 1c395fa767..8410ec3757 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -394,12 +394,24 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) { return pArray; } +static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; } + static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) { float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes; float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes; return d1Score >= d2Score ? 1 : 0; } +void mndSortVnodeGid(SVgObj *pVgroup) { + for (int32_t i = 0; i < pVgroup->replica; ++i) { + for (int32_t j = 0; j < pVgroup->replica - 1 - i; ++j) { + if (pVgroup->vnodeGid[j].dnodeId > pVgroup->vnodeGid[j + 1].dnodeId) { + TSWAP(pVgroup->vnodeGid[j], pVgroup->vnodeGid[j + 1]); + } + } + } +} + static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) { SSdb *pSdb = pMnode->pSdb; int32_t allocedVnodes = 0; @@ -434,6 +446,7 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pAr pDnode->numOfVnodes++; } + mndSortVnodeGid(pVgroup); return 0; } @@ -1035,7 +1048,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); - mDebug("trans:%d, used to drop redistribute vgId:%d", pTrans->id, pVgroup->vgId); + mDebug("trans:%d, used to redistribute vgroup, vgId:%d", pTrans->id, pVgroup->vgId); SVgObj newVg = {0}; memcpy(&newVg, pVgroup, sizeof(SVgObj)); @@ -1044,7 +1057,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, mInfo("vgId:%d, vnode:%d dnode:%d", newVg.vgId, i, newVg.vnodeGid[i].dnodeId); } - if (pNew1 != pOld1) { + if (pNew1 != NULL && pOld1 != NULL) { int32_t numOfVnodes = mndGetVnodesNum(pMnode, pNew1->id); if (numOfVnodes >= pNew1->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew1->id, numOfVnodes, @@ -1055,7 +1068,8 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (mndAddIncVgroupReplicaToTrans(pMnode, pTrans, pDb, &newVg, pNew1->id) != 0) goto _OVER; if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pOld1->id) != 0) goto _OVER; } - if (pNew2 != pOld2) { + + if (pNew2 != NULL && pOld2 != NULL) { int32_t numOfVnodes = mndGetVnodesNum(pMnode, pNew2->id); if (numOfVnodes >= pNew2->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew2->id, numOfVnodes, @@ -1066,7 +1080,8 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (mndAddIncVgroupReplicaToTrans(pMnode, pTrans, pDb, &newVg, pNew2->id) != 0) goto _OVER; if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pOld2->id) != 0) goto _OVER; } - if (pNew3 != pOld3) { + + if (pNew3 != NULL && pOld3 != NULL) { int32_t numOfVnodes = mndGetVnodesNum(pMnode, pNew3->id); if (numOfVnodes >= pNew3->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew3->id, numOfVnodes, @@ -1111,15 +1126,18 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { SDbObj *pDb = NULL; int32_t code = -1; int64_t curMs = taosGetTimestampMs(); + int32_t newDnodeId[3] = {0}; + int32_t oldDnodeId[3] = {0}; + int32_t newIndex = -1; + int32_t oldIndex = -1; - SRedistributeVgroupReq redReq = {0}; - if (tDeserializeSRedistributeVgroupReq(pReq->pCont, pReq->contLen, &redReq) != 0) { + SRedistributeVgroupReq req = {0}; + if (tDeserializeSRedistributeVgroupReq(pReq->pCont, pReq->contLen, &req) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto _OVER; } - mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", redReq.vgId, redReq.dnodeId1, redReq.dnodeId2, - redReq.dnodeId3); + mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3); pUser = mndAcquireUser(pMnode, pReq->conn.user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; @@ -1128,65 +1146,147 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { if (mndCheckNodeAuth(pUser) != 0) goto _OVER; - pVgroup = mndAcquireVgroup(pMnode, redReq.vgId); + pVgroup = mndAcquireVgroup(pMnode, req.vgId); if (pVgroup == NULL) goto _OVER; pDb = mndAcquireDb(pMnode, pVgroup->dbName); if (pDb == NULL) goto _OVER; if (pVgroup->replica == 1) { - if (redReq.dnodeId2 != -1 || redReq.dnodeId3 != -1) { + if (req.dnodeId1 <= 0 || req.dnodeId2 > 0 || req.dnodeId3 > 0) { terrno = TSDB_CODE_MND_INVALID_REPLICA; goto _OVER; } - pNew1 = mndAcquireDnode(pMnode, redReq.dnodeId1); - pOld1 = mndAcquireDnode(pMnode, pVgroup->vnodeGid[0].dnodeId); - if (pNew1 == NULL || pOld1 == NULL) { - terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; - goto _OVER; - } - if (pNew1 == pOld1) { + + if (req.dnodeId1 == pVgroup->vnodeGid[0].dnodeId) { terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; goto _OVER; } - if (!mndIsDnodeOnline(pNew1, curMs) || !mndIsDnodeOnline(pOld1, curMs)) { + + pNew1 = mndAcquireDnode(pMnode, req.dnodeId1); + if (pNew1 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pNew1, curMs)) { terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; goto _OVER; } + + pOld1 = mndAcquireDnode(pMnode, pVgroup->vnodeGid[0].dnodeId); + if (pOld1 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pOld1, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + code = mndRedistributeVgroup(pMnode, pReq, pDb, pVgroup, pNew1, pOld1, NULL, NULL, NULL, NULL); + } else if (pVgroup->replica == 3) { - if (redReq.dnodeId2 == -1 || redReq.dnodeId3 == -1) { + if (req.dnodeId1 <= 0 || req.dnodeId2 <= 0 || req.dnodeId3 <= 0) { terrno = TSDB_CODE_MND_INVALID_REPLICA; goto _OVER; } - pNew1 = mndAcquireDnode(pMnode, redReq.dnodeId1); - pNew2 = mndAcquireDnode(pMnode, redReq.dnodeId2); - pNew3 = mndAcquireDnode(pMnode, redReq.dnodeId3); - pOld1 = mndAcquireDnode(pMnode, pVgroup->vnodeGid[0].dnodeId); - pOld2 = mndAcquireDnode(pMnode, pVgroup->vnodeGid[1].dnodeId); - pOld3 = mndAcquireDnode(pMnode, pVgroup->vnodeGid[2].dnodeId); - if (pNew1 == NULL || pOld1 == NULL || pNew2 == NULL || pOld2 == NULL || pNew3 == NULL || pOld3 == NULL) { - terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; - goto _OVER; - } - if (pNew1 == pNew2 || pNew1 == pNew3 || pNew2 == pNew3) { + + if (req.dnodeId1 == req.dnodeId2 || req.dnodeId1 == req.dnodeId3 || req.dnodeId2 == req.dnodeId3) { terrno = TSDB_CODE_MND_INVALID_REPLICA; goto _OVER; } - bool changed = false; - if (pNew1 != pOld1 && pNew1 != pOld2 && pNew1 != pOld3) changed = true; - if (pNew2 != pOld1 && pNew2 != pOld2 && pNew2 != pOld3) changed = true; - if (pNew3 != pOld1 && pNew3 != pOld2 && pNew3 != pOld3) changed = true; - if (!changed) { + + if (req.dnodeId1 != pVgroup->vnodeGid[0].dnodeId && req.dnodeId1 != pVgroup->vnodeGid[1].dnodeId && + req.dnodeId1 != pVgroup->vnodeGid[2].dnodeId) { + newDnodeId[++newIndex] = req.dnodeId1; + mInfo("vgId:2, dnode:%d will be added", newDnodeId[newIndex]); + } + + if (req.dnodeId2 != pVgroup->vnodeGid[0].dnodeId && req.dnodeId2 != pVgroup->vnodeGid[1].dnodeId && + req.dnodeId2 != pVgroup->vnodeGid[2].dnodeId) { + newDnodeId[++newIndex] = req.dnodeId2; + mInfo("vgId:2, dnode:%d will be added", newDnodeId[newIndex]); + } + + if (req.dnodeId3 != pVgroup->vnodeGid[0].dnodeId && req.dnodeId3 != pVgroup->vnodeGid[1].dnodeId && + req.dnodeId3 != pVgroup->vnodeGid[2].dnodeId) { + newDnodeId[++newIndex] = req.dnodeId3; + mInfo("vgId:2, dnode:%d will be added", newDnodeId[newIndex]); + } + + if (req.dnodeId1 != pVgroup->vnodeGid[0].dnodeId && req.dnodeId2 != pVgroup->vnodeGid[0].dnodeId && + req.dnodeId3 != pVgroup->vnodeGid[0].dnodeId) { + oldDnodeId[++oldIndex] = pVgroup->vnodeGid[0].dnodeId; + mInfo("vgId:2, dnode:%d will be removed", oldDnodeId[oldIndex]); + } + + if (req.dnodeId1 != pVgroup->vnodeGid[1].dnodeId && req.dnodeId2 != pVgroup->vnodeGid[1].dnodeId && + req.dnodeId3 != pVgroup->vnodeGid[1].dnodeId) { + oldDnodeId[++oldIndex] = pVgroup->vnodeGid[1].dnodeId; + mInfo("vgId:2, dnode:%d will be removed", oldDnodeId[oldIndex]); + } + + if (req.dnodeId1 != pVgroup->vnodeGid[2].dnodeId && req.dnodeId2 != pVgroup->vnodeGid[2].dnodeId && + req.dnodeId3 != pVgroup->vnodeGid[2].dnodeId) { + oldDnodeId[++oldIndex] = pVgroup->vnodeGid[2].dnodeId; + mInfo("vgId:2, dnode:%d will be removed", oldDnodeId[oldIndex]); + } + + if (newDnodeId[0] != 0) { + pNew1 = mndAcquireDnode(pMnode, newDnodeId[0]); + if (pNew1 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pNew1, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (newDnodeId[1] != 0) { + pNew2 = mndAcquireDnode(pMnode, newDnodeId[1]); + if (pNew2 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pNew2, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (newDnodeId[2] != 0) { + pNew3 = mndAcquireDnode(pMnode, newDnodeId[2]); + if (pNew3 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pNew3, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (oldDnodeId[0] != 0) { + pOld1 = mndAcquireDnode(pMnode, oldDnodeId[0]); + if (pOld1 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pOld1, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (oldDnodeId[1] != 0) { + pOld2 = mndAcquireDnode(pMnode, oldDnodeId[1]); + if (pOld2 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pOld2, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (oldDnodeId[2] != 0) { + pOld3 = mndAcquireDnode(pMnode, oldDnodeId[2]); + if (pOld3 == NULL) goto _OVER; + if (!mndIsDnodeOnline(pOld3, curMs)) { + terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; + goto _OVER; + } + } + + if (pNew1 == NULL && pOld1 == NULL && pNew2 == NULL && pOld2 == NULL && pNew3 == NULL && pOld3 == NULL) { terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; goto _OVER; } - if (!mndIsDnodeOnline(pNew1, curMs) || !mndIsDnodeOnline(pOld1, curMs) || !mndIsDnodeOnline(pNew2, curMs) || - !mndIsDnodeOnline(pOld2, curMs) || !mndIsDnodeOnline(pNew3, curMs) || !mndIsDnodeOnline(pOld3, curMs)) { - terrno = TSDB_CODE_MND_HAS_OFFLINE_DNODE; - goto _OVER; - } + code = mndRedistributeVgroup(pMnode, pReq, pDb, pVgroup, pNew1, pOld1, pNew2, pOld2, pNew3, pOld3); + } else { terrno = TSDB_CODE_MND_INVALID_REPLICA; goto _OVER; @@ -1196,8 +1296,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { - mError("vgId:%d, failed to redistribute to dnode %d %d %d since %s", redReq.vgId, redReq.dnodeId1, redReq.dnodeId2, - redReq.dnodeId3, terrstr()); + mError("vgId:%d, failed to redistribute to dnode %d:%d:%d since %s", req.vgId, req.dnodeId1, req.dnodeId2, + req.dnodeId3, terrstr()); } mndReleaseDnode(pMnode, pNew1); diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index c11aaaaa8a..39e9c75888 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -163,7 +163,12 @@ void sdbSetApplyIndex(SSdb *pSdb, int64_t index) { pSdb->curVer = index; } void sdbSetApplyTerm(SSdb *pSdb, int64_t term) { pSdb->curTerm = term; } -void sdbSetCurConfig(SSdb *pSdb, int64_t config) { pSdb->curConfig = config; } +void sdbSetCurConfig(SSdb *pSdb, int64_t config) { + if (pSdb->curConfig != config) { + mDebug("mnode sync config set from %" PRId64 " to %" PRId64, pSdb->curConfig, config); + pSdb->curConfig = config; + } +} int64_t sdbGetApplyIndex(SSdb *pSdb) { return pSdb->curVer; } diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index b32abc3eaa..34f5d6f23d 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -240,7 +240,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { if (pFile == NULL) { taosMemoryFree(pRaw); terrno = TAOS_SYSTEM_ERROR(errno); - mError("failed to read sdb file:%s since %s", file, terrstr()); + mDebug("failed to read sdb file:%s since %s", file, terrstr()); return 0; } @@ -432,8 +432,8 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { } else { pSdb->lastCommitVer = pSdb->curVer; pSdb->lastCommitTerm = pSdb->curTerm; - mDebug("write sdb file successfully, ver:%" PRId64 " term:%" PRId64 " file:%s", pSdb->lastCommitVer, - pSdb->lastCommitTerm, curfile); + mDebug("write sdb file successfully, index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s", + pSdb->lastCommitVer, pSdb->lastCommitTerm, pSdb->curConfig, curfile); } terrno = code; diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 978fd9013a..8dca589320 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -28,7 +28,6 @@ target_sources( # sma "src/sma/sma.c" - "src/sma/smaTDBImpl.c" "src/sma/smaEnv.c" "src/sma/smaOpen.c" "src/sma/smaRollup.c" diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 4ca62f1de9..e9da125841 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -43,35 +43,17 @@ typedef struct SRSmaInfo SRSmaInfo; struct SSmaEnv { TdThreadRwlock lock; int8_t type; - TXN txn; - void *pPool; // SPoolMem - SDiskID did; - TDB *dbEnv; // TODO: If it's better to put it in smaIndex level? - char *path; // relative path SSmaStat *pStat; }; #define SMA_ENV_LOCK(env) ((env)->lock) #define SMA_ENV_TYPE(env) ((env)->type) -#define SMA_ENV_DID(env) ((env)->did) -#define SMA_ENV_ENV(env) ((env)->dbEnv) -#define SMA_ENV_PATH(env) ((env)->path) #define SMA_ENV_STAT(env) ((env)->pStat) #define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems) struct SSmaStatItem { - /** - * @brief The field 'state' is here to demonstrate if one smaIndex is ready to provide service. - * - TSDB_SMA_STAT_OK: 1) The sma calculation of history data is finished; 2) Or recevied information from - * Streaming Module or TSDB local persistence. - * - TSDB_SMA_STAT_EXPIRED: 1) If sma calculation of history TS data is not finished; 2) Or if the TSDB is open, - * without information about its previous state. - * - TSDB_SMA_STAT_DROPPED: 1)sma dropped - * N.B. only applicable to tsma - */ - int8_t state; // ETsdbSmaStat - SHashObj *expiredWindows; // key: skey of time window, value: version - STSma *pTSma; // cache schema + int8_t state; // ETsdbSmaStat + STSma *pTSma; // cache schema }; struct SSmaStat { @@ -84,29 +66,6 @@ struct SSmaStat { #define SMA_STAT_ITEMS(s) ((s)->smaStatItems) #define SMA_STAT_INFO_HASH(s) ((s)->rsmaInfoHash) -struct SSmaKey { - TSKEY skey; - int64_t groupId; -}; - -typedef struct SDBFile SDBFile; - -struct SDBFile { - int32_t fid; - TTB *pDB; - char *path; -}; - -int32_t tdSmaBeginCommit(SSmaEnv *pEnv); -int32_t tdSmaEndCommit(SSmaEnv *pEnv); - -int32_t smaOpenDBEnv(TDB **ppEnv, const char *path); -int32_t smaCloseDBEnv(TDB *pEnv); -int32_t smaOpenDBF(TDB *pEnv, SDBFile *pDBF); -int32_t smaCloseDBF(SDBFile *pDBF); -int32_t smaSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn); -void *smaGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen); - void tdDestroySmaEnv(SSmaEnv *pSmaEnv); void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); #if 0 @@ -114,13 +73,6 @@ int32_t tbGetTSmaStatus(SSma *pSma, STSma *param, void *result); int32_t tbRemoveTSmaData(SSma *pSma, STSma *param, STimeWindow *pWin); #endif -static FORCE_INLINE int32_t tdEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void **pData) { - int32_t len = 0; - len += taosEncodeFixedI64(pData, tsKey); - len += taosEncodeFixedI64(pData, groupId); - return len; -} - int32_t tdInitSma(SSma *pSma); int32_t tdDropTSma(SSma *pSma, char *pMsg); int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid); @@ -128,13 +80,11 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg); int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat); int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat); -int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType); +int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck); int32_t tdLockSma(SSma *pSma); int32_t tdUnLockSma(SSma *pSma); -int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); - static FORCE_INLINE int16_t tdTSmaAdd(SSma *pSma, int16_t n) { return atomic_add_fetch_16(&SMA_TSMA_NUM(pSma), n); } static FORCE_INLINE int16_t tdTSmaSub(SSma *pSma, int16_t n) { return atomic_sub_fetch_16(&SMA_TSMA_NUM(pSma), n); } @@ -219,11 +169,8 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDisk void *tdFreeRSmaInfo(SRSmaInfo *pInfo); int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); -int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t version); -// TODO: This is the basic params, and should wrap the params to a queryHandle. -int32_t tdGetTSmaDataImpl(SSma *pSma, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult); - -int32_t tdGetTSmaDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); +int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); +int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 9b277ede06..0c2b09a493 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -150,7 +150,6 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg); int32_t smaOpen(SVnode* pVnode); int32_t smaClose(SSma* pSma); -int32_t tdUpdateExpireWindow(SSma* pSma, const SSubmitReq* pMsg, int64_t version); int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg); int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg); @@ -227,7 +226,7 @@ struct SVnode { SQHandle* pQuery; }; -#define TD_VID(PVNODE) (PVNODE)->config.vgId +#define TD_VID(PVNODE) ((PVNODE)->config.vgId) #define VND_TSDB(vnd) ((vnd)->pTsdb) #define VND_RSMA0(vnd) ((vnd)->pTsdb) diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 063a78b0c6..ebf5098a05 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -86,11 +86,15 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { int nData = 0; tb_uid_t uid = 0; + metaRLock(pMeta); + if (tdbTbGet(pMeta->pNameIdx, name, strlen(name) + 1, &pData, &nData) == 0) { uid = *(tb_uid_t *)pData; tdbFree(pData); } + metaULock(pMeta); + return 0; } diff --git a/source/dnode/vnode/src/meta/metaSma.c b/source/dnode/vnode/src/meta/metaSma.c index 689cd511c4..0b6a526d8c 100644 --- a/source/dnode/vnode/src/meta/metaSma.c +++ b/source/dnode/vnode/src/meta/metaSma.c @@ -34,13 +34,13 @@ int32_t metaCreateTSma(SMeta *pMeta, int64_t version, SSmaCfg *pCfg) { SMetaReader mr = {0}; // validate req + // save smaIndex metaReaderInit(&mr, pMeta, 0); if (metaGetTableEntryByUid(&mr, pCfg->indexUid) == 0) { -// TODO: just for pass case #if 1 - terrno = TSDB_CODE_TDB_TSMA_ALREADY_EXIST; + terrno = TSDB_CODE_TSMA_ALREADY_EXIST; metaReaderClear(&mr); - return -1; + return -1; // don't goto _err; #else metaReaderClear(&mr); return 0; diff --git a/source/dnode/vnode/src/sma/sma.c b/source/dnode/vnode/src/sma/sma.c index fd5dd080ca..98e5d7c66d 100644 --- a/source/dnode/vnode/src/sma/sma.c +++ b/source/dnode/vnode/src/sma/sma.c @@ -36,25 +36,9 @@ int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg) { return code; } -int32_t tdUpdateExpireWindow(SSma* pSma, const SSubmitReq* pMsg, int64_t version) { - int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdUpdateExpiredWindowImpl(pSma, pMsg, version)) < 0) { - smaWarn("vgId:%d, update expired sma window failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - return code; -} - -int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) { - int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdGetTSmaDataImpl(pSma, pData, indexUid, querySKey, nMaxResult)) < 0) { - smaWarn("vgId:%d, get tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - return code; -} - int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t* days) { int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdGetTSmaDaysImpl(pCfg, pCont, contLen, days)) < 0) { + if ((code = tdProcessTSmaGetDaysImpl(pCfg, pCont, contLen, days)) < 0) { smaWarn("vgId:%d, get tsma days failed since %s", pCfg->vgId, tstrerror(terrno)); } smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days); diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 179f573e8d..5eec5076e8 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -151,31 +151,11 @@ static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, return NULL; } - ASSERT(path && (strlen(path) > 0)); - SMA_ENV_PATH(pEnv) = strdup(path); - if (!SMA_ENV_PATH(pEnv)) { - tdFreeSmaEnv(pEnv); - return NULL; - } - - SMA_ENV_DID(pEnv) = did; - if (tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType) != TSDB_CODE_SUCCESS) { tdFreeSmaEnv(pEnv); return NULL; } - char aname[TSDB_FILENAME_LEN] = {0}; - tfsAbsoluteName(SMA_TFS(pSma), did, path, aname); - if (smaOpenDBEnv(&pEnv->dbEnv, aname) != TSDB_CODE_SUCCESS) { - tdFreeSmaEnv(pEnv); - return NULL; - } - - if (!(pEnv->pPool = openPool())) { - tdFreeSmaEnv(pEnv); - return NULL; - } return pEnv; } @@ -205,10 +185,7 @@ void tdDestroySmaEnv(SSmaEnv *pSmaEnv) { if (pSmaEnv) { tdDestroySmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv)); taosMemoryFreeClear(pSmaEnv->pStat); - taosMemoryFreeClear(pSmaEnv->path); taosThreadRwlockDestroy(&(pSmaEnv->lock)); - smaCloseDBEnv(pSmaEnv->dbEnv); - closePool(pSmaEnv->pPool); } } @@ -242,7 +219,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) { } /** - * 1. Lazy mode utilized when init SSmaStat to update expired window(or hungry mode when tdNew). + * 1. Lazy mode utilized when init SSmaStat to update expire window(or hungry mode when tdNew). * 2. Currently, there is mutex lock when init SSmaEnv, thus no need add lock on SSmaStat, and please add lock if * tdInitSmaStat invoked in other multithread environment later. */ @@ -280,7 +257,6 @@ void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem) { if (pSmaStatItem) { tDestroyTSma(pSmaStatItem->pTSma); taosMemoryFreeClear(pSmaStatItem->pTSma); - taosHashCleanup(pSmaStatItem->expiredWindows); taosMemoryFreeClear(pSmaStatItem); } return NULL; @@ -341,7 +317,7 @@ int32_t tdUnLockSma(SSma *pSma) { return 0; } -int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { +int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck) { SSmaEnv *pEnv = NULL; // return if already init @@ -399,63 +375,3 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { return TSDB_CODE_SUCCESS; }; - -int32_t tdSmaBeginCommit(SSmaEnv *pEnv) { - TXN *pTxn = &pEnv->txn; - // start a new txn - tdbTxnOpen(pTxn, 0, poolMalloc, poolFree, pEnv->pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - if (tdbBegin(pEnv->dbEnv, pTxn) != 0) { - smaWarn("tdSma tdb begin commit fail"); - return -1; - } - return 0; -} - -int32_t tdSmaEndCommit(SSmaEnv *pEnv) { - TXN *pTxn = &pEnv->txn; - - // Commit current txn - if (tdbCommit(pEnv->dbEnv, pTxn) != 0) { - smaWarn("tdSma tdb end commit fail"); - return -1; - } - tdbTxnClose(pTxn); - clearPool(pEnv->pPool); - return 0; -} - -#if 0 -/** - * @brief Get the start TS key of the last data block of one interval/sliding. - * - * @param pSma - * @param param - * @param result - * @return int32_t - * 1) Return 0 and fill the result if the check procedure is normal; - * 2) Return -1 if error occurs during the check procedure. - */ -int32_t tdGetTSmaStatus(SSma *pSma, void *smaIndex, void *result) { - const char *procedure = ""; - if (strncmp(procedure, "get the start TS key of the last data block", 100) != 0) { - return -1; - } - // fill the result - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Remove the tSma data files related to param between pWin. - * - * @param pSma - * @param param - * @param pWin - * @return int32_t - */ -int32_t tdRemoveTSmaData(SSma *pSma, void *smaIndex, STimeWindow *pWin) { - // for ("tSmaFiles of param-interval-sliding between pWin") { - // // remove the tSmaFile - // } - return TSDB_CODE_SUCCESS; -} -#endif diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index e738d3a408..1b34529506 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -65,7 +65,7 @@ static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SA pRSmaInfo = taosHashGet(SMA_STAT_INFO_HASH(pStat), suid, sizeof(tb_uid_t)); if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64, SMA_VID(pSma), *suid); - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; + terrno = TSDB_CODE_RSMA_INVALID_STAT; return TSDB_CODE_FAILED; } @@ -132,7 +132,7 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui SSmaStat *pStat = SMA_ENV_STAT(pEnv); SHashObj *infoHash = NULL; if (!pStat || !(infoHash = SMA_STAT_INFO_HASH(pStat))) { - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; + terrno = TSDB_CODE_RSMA_INVALID_STAT; return TSDB_CODE_FAILED; } @@ -167,13 +167,13 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui */ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { SSma *pSma = pVnode->pSma; - SMeta *pMeta = pVnode->pMeta; - SMsgCb *pMsgCb = &pVnode->msgCb; if (!pReq->rollup) { smaTrace("vgId:%d, return directly since no rollup for stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); return TSDB_CODE_SUCCESS; } + SMeta *pMeta = pVnode->pMeta; + SMsgCb *pMsgCb = &pVnode->msgCb; SRSmaParam *param = &pReq->pRSmaParam; if ((param->qmsg1Len == 0) && (param->qmsg2Len == 0)) { @@ -181,7 +181,7 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { return TSDB_CODE_SUCCESS; } - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP) != TSDB_CODE_SUCCESS) { + if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP, false) != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaTDBImpl.c b/source/dnode/vnode/src/sma/smaTDBImpl.c deleted file mode 100644 index cac986d053..0000000000 --- a/source/dnode/vnode/src/sma/smaTDBImpl.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define ALLOW_FORBID_FUNC - -#include "sma.h" - -int32_t smaOpenDBEnv(TDB **ppEnv, const char *path) { - int ret = 0; - - if (path == NULL) return -1; - - ret = tdbOpen(path, 4096, 256, ppEnv); // use as param - - if (ret != 0) { - smaError("failed to create tsdb db env, ret = %d", ret); - return -1; - } - - return 0; -} - -int32_t smaCloseDBEnv(TDB *pEnv) { return tdbClose(pEnv); } - -static inline int tdSmaKeyCmpr(const void *arg1, int len1, const void *arg2, int len2) { - const SSmaKey *pKey1 = (const SSmaKey *)arg1; - const SSmaKey *pKey2 = (const SSmaKey *)arg2; - - ASSERT(len1 == len2 && len1 == sizeof(SSmaKey)); - - if (pKey1->skey < pKey2->skey) { - return -1; - } else if (pKey1->skey > pKey2->skey) { - return 1; - } - if (pKey1->groupId < pKey2->groupId) { - return -1; - } else if (pKey1->groupId > pKey2->groupId) { - return 1; - } - - return 0; -} - -static int32_t smaOpenDBDb(TTB **ppDB, TDB *pEnv, const char *pFName) { - tdb_cmpr_fn_t compFunc; - - // Create a database - compFunc = tdSmaKeyCmpr; - if (tdbTbOpen(pFName, -1, -1, compFunc, pEnv, ppDB) < 0) { - return -1; - } - - return 0; -} - -static int32_t smaCloseDBDb(TTB *pDB) { return tdbTbClose(pDB); } - -int32_t smaOpenDBF(TDB *pEnv, SDBFile *pDBF) { - // TEnv is shared by a group of SDBFile - if (!pEnv || !pDBF) { - terrno = TSDB_CODE_INVALID_PTR; - return -1; - } - - // Open DBF - if (smaOpenDBDb(&(pDBF->pDB), pEnv, pDBF->path) < 0) { - smaError("failed to open DBF: %s", pDBF->path); - smaCloseDBDb(pDBF->pDB); - return -1; - } - - return 0; -} - -int32_t smaCloseDBF(SDBFile *pDBF) { - int32_t ret = 0; - if (pDBF->pDB) { - ret = smaCloseDBDb(pDBF->pDB); - pDBF->pDB = NULL; - } - taosMemoryFreeClear(pDBF->path); - return ret; -} - -int32_t smaSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn) { - int32_t ret; - - printf("save tsma data into %s, keyLen:%d valLen:%d txn:%p\n", pDBF->path, keyLen, valLen, txn); - ret = tdbTbUpsert(pDBF->pDB, pKey, keyLen, pVal, valLen, txn); - if (ret < 0) { - smaError("failed to upsert tsma data into db, ret = %d", ret); - return -1; - } - - return 0; -} - -void *smaGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen) { - void *pVal = NULL; - int ret; - - ret = tdbTbGet(pDBF->pDB, pKey, keyLen, &pVal, valLen); - - if (ret < 0) { - smaError("failed to get tsma data from db, ret = %d", ret); - return NULL; - } - - ASSERT(*valLen >= 0); - - // TODO: lock? - // TODO: Would the key/value be destoryed during return the data? - // TODO: How about the key is updated while value length is changed? The original value buffer would be freed - // automatically? - - return pVal; -} \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c deleted file mode 100644 index b72be06455..0000000000 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "sma.h" -#include "tsdb.h" - -typedef STsdbCfg STSmaKeepCfg; - -#undef _TEST_SMA_PRINT_DEBUG_LOG_ -#define SMA_STORAGE_TSDB_MINUTES 86400 -#define SMA_STORAGE_TSDB_TIMES 10 -#define SMA_STORAGE_SPLIT_FACTOR 144 // least records in tsma file -#define SMA_KEY_LEN 16 // TSKEY+groupId 8+8 -#define SMA_DROP_EXPIRED_TIME 10 // default is 10 seconds - -#define SMA_STATE_ITEM_HASH_SLOT 32 - -typedef struct { - SSma *pSma; - SDBFile dFile; - const SArray *pDataBlocks; // sma data - int64_t interval; // interval with the precision of DB -} STSmaWriteH; - -typedef struct { - int32_t iter; - int32_t fid; -} SmaFsIter; - -typedef struct { - STsdb *pTsdb; - SSma *pSma; - SDBFile dFile; - int64_t interval; // interval with the precision of DB - int32_t blockSize; // size of SMA block item - int32_t days; - int8_t storageLevel; - SmaFsIter smaFsIter; -} STSmaReadH; - -typedef enum { - SMA_STORAGE_LEVEL_TSDB = 0, // use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f200.tsma - SMA_STORAGE_LEVEL_DFILESET = 1 // use days of TS data e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f1906.tsma -} ESmaStorageLevel; - -// static func - -static int64_t tdGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted); -static int32_t tdGetSmaStorageLevel(STSmaKeepCfg *pCfg, int64_t interval); -static int32_t tdInitTSmaWriteH(STSmaWriteH *pSmaH, SSma *pSma, const SArray *pDataBlocks, int64_t interval, - int8_t intervalUnit); -static int32_t tdInitTSmaReadH(STSmaReadH *pSmaH, SSma *pSma, int64_t interval, int8_t intervalUnit); -static void tdDestroyTSmaWriteH(STSmaWriteH *pSmaH); -static int32_t tdGetTSmaDays(SSma *pSma, int64_t interval, int32_t storageLevel); -static int32_t tdSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid); -static int32_t tdInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey); -static bool tdSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); -static int32_t tdInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, int32_t keyLen, void *pData, int32_t dataLen, - TXN *txn); -// expired window - -static int32_t tdSetExpiredWindow(SSma *pSma, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version); -static int32_t tdResetExpiredWindow(SSma *pSma, SSmaStat *pStat, int64_t indexUid, TSKEY skey); -static int32_t tdDropTSmaDataImpl(SSma *pSma, int64_t indexUid); - -// read data - -// implementation - -/** - * @brief - * - * @param pSmaH - * @param pSma - * @param interval - * @param intervalUnit - * @return int32_t - */ -static int32_t tdInitTSmaReadH(STSmaReadH *pSmaH, SSma *pSma, int64_t interval, int8_t intervalUnit) { - STSmaKeepCfg *pCfg = SMA_TSDB_CFG(pSma); - pSmaH->pSma = pSma; - pSmaH->interval = tdGetIntervalByPrecision(interval, intervalUnit, SMA_TSDB_CFG(pSma)->precision, true); - pSmaH->storageLevel = tdGetSmaStorageLevel(pCfg, interval); - pSmaH->days = tdGetTSmaDays(pSma, pSmaH->interval, pSmaH->storageLevel); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Init of tSma FS - * - * @param pReadH - * @param indexUid - * @param skey - * @return int32_t - */ -static int32_t tdInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey) { - SSma *pSma = pSmaH->pSma; - - int32_t fid = (int32_t)(TSDB_KEY_FID(skey, pSmaH->days, SMA_TSDB_CFG(pSma)->precision)); - char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, SMA_VID(pSma), fid); - pSmaH->dFile.path = strdup(tSmaFile); - pSmaH->smaFsIter.iter = 0; - pSmaH->smaFsIter.fid = fid; - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Set and open tSma file if it has key locates in queryWin. - * - * @param pReadH - * @param param - * @param queryWin - * @return true - * @return false - */ -static bool tdSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { - // SArray *smaFs = pReadH->pTsdb->fs->cstatus->sf; - // int32_t nSmaFs = taosArrayGetSize(smaFs); - - smaCloseDBF(&pReadH->dFile); - -#if 0 - while (pReadH->smaFsIter.iter < nSmaFs) { - void *pSmaFile = taosArrayGet(smaFs, pReadH->smaFsIter.iter); - if (pSmaFile) { // match(indexName, queryWindow) - // TODO: select the file by index_name ... - pReadH->dFile = pSmaFile; - ++pReadH->smaFsIter.iter; - break; - } - ++pReadH->smaFsIter.iter; - } - - if (pReadH->pDFile) { - tdDebug("vg%d: smaFile %s matched", REPO_ID(pReadH->pTsdb), "[pSmaFile dir]"); - return true; - } -#endif - - return false; -} - -/** - * @brief Approximate value for week/month/year. - * - * @param interval - * @param intervalUnit - * @param precision - * @param adjusted Interval already adjusted according to DB precision - * @return int64_t - */ -static int64_t tdGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted) { - if (adjusted) { - return interval; - } - - switch (intervalUnit) { - case TIME_UNIT_YEAR: // approximate value - interval *= 365 * 86400 * 1e3; - break; - case TIME_UNIT_MONTH: // approximate value - interval *= 30 * 86400 * 1e3; - break; - case TIME_UNIT_WEEK: // approximate value - interval *= 7 * 86400 * 1e3; - break; - case TIME_UNIT_DAY: // the interval for tSma calculation must <= day - interval *= 86400 * 1e3; - break; - case TIME_UNIT_HOUR: - interval *= 3600 * 1e3; - break; - case TIME_UNIT_MINUTE: - interval *= 60 * 1e3; - break; - case TIME_UNIT_SECOND: - interval *= 1e3; - break; - default: - break; - } - - switch (precision) { - case TSDB_TIME_PRECISION_MILLI: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval / 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second - return interval / 1e6; - } else { // ms - return interval; - } - break; - case TSDB_TIME_PRECISION_MICRO: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval / 1e3; - } else { // ms - return interval * 1e3; - } - break; - case TSDB_TIME_PRECISION_NANO: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval * 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval; - } else { // ms - return interval * 1e6; - } - break; - default: // ms - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval / 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval / 1e6; - } else { // ms - return interval; - } - break; - } - return interval; -} - -static int32_t tdInitTSmaWriteH(STSmaWriteH *pSmaH, SSma *pSma, const SArray *pDataBlocks, int64_t interval, - int8_t intervalUnit) { - pSmaH->pSma = pSma; - pSmaH->interval = tdGetIntervalByPrecision(interval, intervalUnit, SMA_TSDB_CFG(pSma)->precision, true); - pSmaH->pDataBlocks = pDataBlocks; - pSmaH->dFile.fid = SMA_IVLD_FID; - return TSDB_CODE_SUCCESS; -} - -static void tdDestroyTSmaWriteH(STSmaWriteH *pSmaH) { - if (pSmaH) { - smaCloseDBF(&pSmaH->dFile); - } -} - -static int32_t tdSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid) { - SSma *pSma = pSmaH->pSma; - ASSERT(!pSmaH->dFile.path && !pSmaH->dFile.pDB); - - pSmaH->dFile.fid = fid; - char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, SMA_VID(pSma), fid); - pSmaH->dFile.path = strdup(tSmaFile); - - return TSDB_CODE_SUCCESS; -} - -/** - * @brief - * - * @param pSma - * @param interval Interval calculated by DB's precision - * @param storageLevel - * @return int32_t - */ -static int32_t tdGetTSmaDays(SSma *pSma, int64_t interval, int32_t storageLevel) { - STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); - int32_t daysPerFile = pCfg->days; // unit is minute - - if (storageLevel == SMA_STORAGE_LEVEL_TSDB) { - int32_t minutes = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerMin[pCfg->precision]); - if (minutes > SMA_STORAGE_TSDB_MINUTES) { - daysPerFile = SMA_STORAGE_TSDB_MINUTES; - } - } - - return daysPerFile; -} - -/** - * @brief Judge the tSma storage level - * - * @param pCfg - * @param interval - * @return int32_t - */ -static int32_t tdGetSmaStorageLevel(STSmaKeepCfg *pCfg, int64_t interval) { - int64_t mInterval = convertTimeFromPrecisionToUnit(interval, pCfg->precision, TIME_UNIT_MINUTE); - if (pCfg->days / mInterval >= SMA_STORAGE_SPLIT_FACTOR) { - return SMA_STORAGE_LEVEL_DFILESET; - } - return SMA_STORAGE_LEVEL_TSDB; -} - -/** - * @brief Insert/Update Time-range-wise SMA data. - * - If interval < SMA_STORAGE_SPLIT_HOURS(e.g. 24), save the SMA data as a part of DFileSet to e.g. - * v3f1900.tsma.${sma_index_name}. The days is the same with that for TS data files. - * - If interval >= SMA_STORAGE_SPLIT_HOURS, save the SMA data to e.g. vnode3/tsma/v3f632.tsma.${sma_index_name}. The - * days is 30 times of the interval, and the minimum days is SMA_STORAGE_TSDB_DAYS(30d). - * - The destination file of one data block for some interval is determined by its start TS key. - * - * @param pSma - * @param msg - * @return int32_t - */ -int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { - STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); - const SArray *pDataBlocks = (const SArray *)msg; - int64_t testSkey = TSKEY_INITIAL_VAL; - - // TODO: destroy SSDataBlocks(msg) - - // For super table aggregation, the sma data is stored in vgroup calculated from the hash value of stable name. Thus - // the sma data would arrive ahead of the update-expired-window msg. - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) != TSDB_CODE_SUCCESS) { - terrno = TSDB_CODE_TDB_INIT_FAILED; - return TSDB_CODE_FAILED; - } - - if (!pDataBlocks) { - terrno = TSDB_CODE_INVALID_PTR; - smaWarn("vgId:%d, insert tSma data failed since pDataBlocks is NULL", SMA_VID(pSma)); - return terrno; - } - - if (taosArrayGetSize(pDataBlocks) <= 0) { - terrno = TSDB_CODE_INVALID_PARA; - smaWarn("vgId:%d, insert tSma data failed since pDataBlocks is empty", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); - SSmaStatItem *pItem = NULL; - - tdRefSmaStat(pSma, pStat); - - if (pStat && SMA_STAT_ITEMS(pStat)) { - pItem = taosHashGet(SMA_STAT_ITEMS(pStat), &indexUid, sizeof(indexUid)); - } - - if (!pItem || !(pItem = *(SSmaStatItem **)pItem) || tdSmaStatIsDropped(pItem)) { - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - - STSma *pTSma = pItem->pTSma; - STSmaWriteH tSmaH = {0}; - - if (tdInitTSmaWriteH(&tSmaH, pSma, pDataBlocks, pTSma->interval, pTSma->intervalUnit) != 0) { - return TSDB_CODE_FAILED; - } - - char rPath[TSDB_FILENAME_LEN] = {0}; - char aPath[TSDB_FILENAME_LEN] = {0}; - snprintf(rPath, TSDB_FILENAME_LEN, "%s%s%" PRIi64, SMA_ENV_PATH(pEnv), TD_DIRSEP, indexUid); - tfsAbsoluteName(SMA_TFS(pSma), SMA_ENV_DID(pEnv), rPath, aPath); - if (!taosCheckExistFile(aPath)) { - if (tfsMkdirRecurAt(SMA_TFS(pSma), rPath, SMA_ENV_DID(pEnv)) != TSDB_CODE_SUCCESS) { - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - } - - // Step 1: Judge the storage level and days - int32_t storageLevel = tdGetSmaStorageLevel(pCfg, tSmaH.interval); - int32_t minutePerFile = tdGetTSmaDays(pSma, tSmaH.interval, storageLevel); - - char smaKey[SMA_KEY_LEN] = {0}; // key: skey + groupId - char dataBuf[512] = {0}; // val: aggr data // TODO: handle 512 buffer? - void *pDataBuf = NULL; - int32_t sz = taosArrayGetSize(pDataBlocks); - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock *pDataBlock = taosArrayGet(pDataBlocks, i); - int32_t colNum = pDataBlock->info.numOfCols; - int32_t rows = pDataBlock->info.rows; - int32_t rowSize = pDataBlock->info.rowSize; - int64_t groupId = pDataBlock->info.groupId; - for (int32_t j = 0; j < rows; ++j) { - printf("|"); - TSKEY skey = TSKEY_INITIAL_VAL; // the start key of TS window by interval - void *pSmaKey = &smaKey; - bool isStartKey = false; - - int32_t tlen = 0; // reset the len - pDataBuf = &dataBuf; // reset the buf - for (int32_t k = 0; k < colNum; ++k) { - SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); - void *var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); - switch (pColInfoData->info.type) { - case TSDB_DATA_TYPE_TIMESTAMP: - if (!isStartKey) { - isStartKey = true; - skey = *(TSKEY *)var; - testSkey = skey; - printf("= skey %" PRIi64 " groupId = %" PRIi64 "|", skey, groupId); - tdEncodeTSmaKey(groupId, skey, &pSmaKey); - } else { - printf(" %" PRIi64 " |", *(int64_t *)var); - tlen += taosEncodeFixedI64(&pDataBuf, *(int64_t *)var); - break; - } - break; - case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_UTINYINT: - printf(" %15d |", *(uint8_t *)var); - tlen += taosEncodeFixedU8(&pDataBuf, *(uint8_t *)var); - break; - case TSDB_DATA_TYPE_TINYINT: - printf(" %15d |", *(int8_t *)var); - tlen += taosEncodeFixedI8(&pDataBuf, *(int8_t *)var); - break; - case TSDB_DATA_TYPE_SMALLINT: - printf(" %15d |", *(int16_t *)var); - tlen += taosEncodeFixedI16(&pDataBuf, *(int16_t *)var); - break; - case TSDB_DATA_TYPE_USMALLINT: - printf(" %15d |", *(uint16_t *)var); - tlen += taosEncodeFixedU16(&pDataBuf, *(uint16_t *)var); - break; - case TSDB_DATA_TYPE_INT: - printf(" %15d |", *(int32_t *)var); - tlen += taosEncodeFixedI32(&pDataBuf, *(int32_t *)var); - break; - case TSDB_DATA_TYPE_FLOAT: - printf(" %15f |", *(float *)var); - tlen += taosEncodeBinary(&pDataBuf, var, sizeof(float)); - break; - case TSDB_DATA_TYPE_UINT: - printf(" %15u |", *(uint32_t *)var); - tlen += taosEncodeFixedU32(&pDataBuf, *(uint32_t *)var); - break; - case TSDB_DATA_TYPE_BIGINT: - printf(" %15ld |", *(int64_t *)var); - tlen += taosEncodeFixedI64(&pDataBuf, *(int64_t *)var); - break; - case TSDB_DATA_TYPE_DOUBLE: - printf(" %15lf |", *(double *)var); - tlen += taosEncodeBinary(&pDataBuf, var, sizeof(double)); - case TSDB_DATA_TYPE_UBIGINT: - printf(" %15lu |", *(uint64_t *)var); - tlen += taosEncodeFixedU64(&pDataBuf, *(uint64_t *)var); - break; - case TSDB_DATA_TYPE_NCHAR: { - char tmpChar[100] = {0}; - strncpy(tmpChar, varDataVal(var), varDataLen(var)); - printf(" %s |", tmpChar); - tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var)); - break; - } - case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY - char tmpChar[100] = {0}; - strncpy(tmpChar, varDataVal(var), varDataLen(var)); - printf(" %s |", tmpChar); - tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var)); - break; - } - case TSDB_DATA_TYPE_VARBINARY: - // TODO: add binary/varbinary - TASSERT(0); - default: - printf("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); - TASSERT(0); - break; - } - } - printf("\n"); - // if ((tlen > 0) && (skey != TSKEY_INITIAL_VAL)) { - if (tlen > 0) { - int32_t fid = (int32_t)(TSDB_KEY_FID(skey, minutePerFile, pCfg->precision)); - - // Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index - // file - // - Set and open the DFile or the B+Tree file - // TODO: tsdbStartTSmaCommit(); - if (fid != tSmaH.dFile.fid) { - if (tSmaH.dFile.fid != SMA_IVLD_FID) { - tdSmaEndCommit(pEnv); - smaCloseDBF(&tSmaH.dFile); - } - tdSetTSmaDataFile(&tSmaH, indexUid, fid); - smaDebug("vgId:%d, write to DBF %s, days:%d, interval:%" PRIi64 ", storageLevel:%" PRIi32 - " queryKey:%" PRIi64, - SMA_VID(pSma), tSmaH.dFile.path, minutePerFile, tSmaH.interval, storageLevel, testSkey); - if (smaOpenDBF(pEnv->dbEnv, &tSmaH.dFile) != 0) { - smaWarn("vgId:%d, open DB file %s failed since %s", SMA_VID(pSma), - tSmaH.dFile.path ? tSmaH.dFile.path : "path is NULL", tstrerror(terrno)); - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - tdSmaBeginCommit(pEnv); - } - - if (tdInsertTSmaBlocks(&tSmaH, &smaKey, SMA_KEY_LEN, dataBuf, tlen, &pEnv->txn) != 0) { - smaWarn("vgId:%d, insert tsma data blocks fail for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64 - " since %s", - SMA_VID(pSma), indexUid, skey, groupId, tstrerror(terrno)); - tdSmaEndCommit(pEnv); - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - - smaDebug("vgId:%d, insert tsma data blocks success for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64, - SMA_VID(pSma), indexUid, skey, groupId); - // TODO:tsdbEndTSmaCommit(); - - // Step 3: reset the SSmaStat - tdResetExpiredWindow(pSma, pStat, indexUid, skey); - } else { - smaWarn("vgId:%d, invalid data skey:%" PRIi64 ", tlen %" PRIi32 " during insert tSma data for %" PRIi64, - SMA_VID(pSma), skey, tlen, indexUid); - } - } - } - tdSmaEndCommit(pEnv); // TODO: not commit for every insert - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - - return TSDB_CODE_SUCCESS; -} - -int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid) { - int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdDropTSmaDataImpl(pSma, indexUid)) < 0) { - smaWarn("vgId:%d, drop tSma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - return code; -} - -/** - * @brief Insert TSma data blocks to DB File build by B+Tree - * - * @param pSmaH - * @param smaKey tableUid-colId-skeyOfWindow(8-2-8) - * @param keyLen - * @param pData - * @param dataLen - * @return int32_t - */ -static int32_t tdInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, int32_t keyLen, void *pData, int32_t dataLen, - TXN *txn) { - SDBFile *pDBFile = &pSmaH->dFile; - - // TODO: insert tsma data blocks into B+Tree(TTB) - if (smaSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen, txn) != 0) { - smaWarn("vgId:%d, insert tsma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 " fail", - SMA_VID(pSmaH->pSma), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen); - return TSDB_CODE_FAILED; - } - smaDebug("vgId:%d, insert tsma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 " succeed", - SMA_VID(pSmaH->pSma), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen); - -#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ - uint32_t valueSize = 0; - void *data = tdGetSmaDataByKey(pDBFile, smaKey, keyLen, &valueSize); - ASSERT(data != NULL); - for (uint32_t v = 0; v < valueSize; v += 8) { - smaWarn("vgId:%d, insert sma data val[%d] %" PRIi64, REPO_ID(pSmaH->pTsdb), v, *(int64_t *)POINTER_SHIFT(data, v)); - } -#endif - return TSDB_CODE_SUCCESS; -} - -/** - * @brief When sma data received from stream computing, make the relative expired window valid. - * - * @param pSma - * @param pStat - * @param indexUid - * @param skey - * @return int32_t - */ -static int32_t tdResetExpiredWindow(SSma *pSma, SSmaStat *pStat, int64_t indexUid, TSKEY skey) { - SSmaStatItem *pItem = NULL; - - tdRefSmaStat(pSma, pStat); - - if (pStat && SMA_STAT_ITEMS(pStat)) { - pItem = taosHashGet(SMA_STAT_ITEMS(pStat), &indexUid, sizeof(indexUid)); - } - if ((pItem) && ((pItem = *(SSmaStatItem **)pItem))) { - // pItem resides in hash buffer all the time unless drop sma index - // TODO: multithread protect - if (taosHashRemove(pItem->expiredWindows, &skey, sizeof(TSKEY)) != 0) { - // error handling - tdUnRefSmaStat(pSma, pStat); - smaWarn("vgId:%d, remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " fail", SMA_VID(pSma), skey, - indexUid); - return TSDB_CODE_FAILED; - } - smaDebug("vgId:%d, remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " succeed", SMA_VID(pSma), - skey, indexUid); - // TODO: use a standalone interface to received state upate notification from stream computing module. - /** - * @brief state - * - When SMA env init in TSDB, its status is TSDB_SMA_STAT_OK. - * - In startup phase of stream computing module, it should notify the SMA env in TSDB to expired if needed(e.g. - * when batch data caculation not finised) - * - When TSDB_SMA_STAT_OK, the stream computing module should also notify that to the SMA env in TSDB. - */ - pItem->state = TSDB_SMA_STAT_OK; - } else { - // error handling - tdUnRefSmaStat(pSma, pStat); - smaWarn("vgId:%d, expired window %" PRIi64 " not exists for sma index %" PRIi64, SMA_VID(pSma), skey, indexUid); - return TSDB_CODE_FAILED; - } - - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Drop tSma data and local cache - * - insert/query reference - * @param pSma - * @param msg - * @return int32_t - */ -static int32_t tdDropTSmaDataImpl(SSma *pSma, int64_t indexUid) { - SSmaEnv *pEnv = atomic_load_ptr(&SMA_TSMA_ENV(pSma)); - - // clear local cache - if (pEnv) { - smaDebug("vgId:%d, drop tSma local cache for %" PRIi64, SMA_VID(pSma), indexUid); - - SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pEnv), &indexUid, sizeof(indexUid)); - if ((pItem) || ((pItem = *(SSmaStatItem **)pItem))) { - if (tdSmaStatIsDropped(pItem)) { - smaDebug("vgId:%d, tSma stat is already dropped for %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_TDB_INVALID_ACTION; // TODO: duplicate drop msg would be intercepted by mnode - } - - tdWLockSmaEnv(pEnv); - if (tdSmaStatIsDropped(pItem)) { - tdUnLockSmaEnv(pEnv); - smaDebug("vgId:%d, tSma stat is already dropped for %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_TDB_INVALID_ACTION; // TODO: duplicate drop msg would be intercepted by mnode - } - tdSmaStatSetDropped(pItem); - tdUnLockSmaEnv(pEnv); - - int32_t nSleep = 0; - int32_t refVal = INT32_MAX; - while (true) { - if ((refVal = T_REF_VAL_GET(SMA_ENV_STAT(pEnv))) <= 0) { - smaDebug("vgId:%d, drop index %" PRIi64 " since refVal=%d", SMA_VID(pSma), indexUid, refVal); - break; - } - smaDebug("vgId:%d, wait 1s to drop index %" PRIi64 " since refVal=%d", SMA_VID(pSma), indexUid, refVal); - taosSsleep(1); - if (++nSleep > SMA_DROP_EXPIRED_TIME) { - smaDebug("vgId:%d, drop index %" PRIi64 " after wait %d (refVal=%d)", SMA_VID(pSma), indexUid, nSleep, refVal); - break; - }; - } - - tdFreeSmaStatItem(pItem); - smaDebug("vgId:%d, getTSmaDataImpl failed since no index %" PRIi64 " in local cache", SMA_VID(pSma), indexUid); - } - } - // clear sma data files - // TODO: - return TSDB_CODE_SUCCESS; -} - -/** - * @brief - * - * @param pSma Return the data between queryWin and fill the pData. - * @param pData - * @param indexUid - * @param pQuerySKey - * @param nMaxResult The query invoker should control the nMaxResult need to return to avoid OOM. - * @return int32_t - */ -int32_t tdGetTSmaDataImpl(SSma *pSma, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) { - SSmaEnv *pEnv = atomic_load_ptr(&SMA_TSMA_ENV(pSma)); - SSmaStat *pStat = NULL; - - if (!pEnv) { - terrno = TSDB_CODE_INVALID_PTR; - smaWarn("vgId:%d, getTSmaDataImpl failed since pTSmaEnv is NULL", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - pStat = SMA_ENV_STAT(pEnv); - - tdRefSmaStat(pSma, pStat); - SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pEnv), &indexUid, sizeof(indexUid)); - if (!pItem || !(pItem = *(SSmaStatItem **)pItem)) { - // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if - // it's NULL. - tdUnRefSmaStat(pSma, pStat); - terrno = TSDB_CODE_TDB_INVALID_ACTION; - smaDebug("vgId:%d, getTSmaDataImpl failed since no index %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_FAILED; - } - -#if 0 - int32_t nQueryWin = taosArrayGetSize(pQuerySKey); - for (int32_t n = 0; n < nQueryWin; ++n) { - TSKEY skey = taosArrayGet(pQuerySKey, n); - if (taosHashGet(pItem->expiredWindows, &skey, sizeof(TSKEY))) { - // TODO: mark this window as expired. - } - } -#endif - -#if 1 - int8_t smaStat = 0; - if (!tdSmaStatIsOK(pItem, &smaStat)) { // TODO: multiple check for large scale sma query - tdUnRefSmaStat(pSma, pStat); - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; - smaWarn("vgId:%d, getTSmaDataImpl failed from index %" PRIi64 " since %s %" PRIi8, SMA_VID(pSma), indexUid, - tstrerror(terrno), smaStat); - return TSDB_CODE_FAILED; - } - - if (taosHashGet(pItem->expiredWindows, &querySKey, sizeof(TSKEY))) { - // TODO: mark this window as expired. - smaDebug("vgId:%d, skey %" PRIi64 " of window exists in expired window for index %" PRIi64, SMA_VID(pSma), querySKey, - indexUid); - } else { - smaDebug("vgId:%d, skey %" PRIi64 " of window not in expired window for index %" PRIi64, SMA_VID(pSma), querySKey, - indexUid); - } - - STSma *pTSma = pItem->pTSma; -#endif - -#if 1 - STSmaReadH tReadH = {0}; - tdInitTSmaReadH(&tReadH, pSma, pTSma->interval, pTSma->intervalUnit); - smaCloseDBF(&tReadH.dFile); - - tdUnRefSmaStat(pSma, pStat); - - tdInitTSmaFile(&tReadH, indexUid, querySKey); - smaDebug("### vgId:%d read from DBF %s days:%d, interval:%" PRIi64 ", storageLevel:%" PRIi8 " queryKey:%" PRIi64, - SMA_VID(pSma), tReadH.dFile.path, tReadH.days, tReadH.interval, tReadH.storageLevel, querySKey); - if (smaOpenDBF(pEnv->dbEnv, &tReadH.dFile) != 0) { - smaWarn("vgId:%d, open DBF %s failed since %s", SMA_VID(pSma), tReadH.dFile.path, tstrerror(terrno)); - return TSDB_CODE_FAILED; - } - - char smaKey[SMA_KEY_LEN] = {0}; - void *pSmaKey = &smaKey; - int64_t queryGroupId = 0; - tdEncodeTSmaKey(queryGroupId, querySKey, (void **)&pSmaKey); - - smaDebug("vgId:%d, get sma data from %s: smaKey %" PRIx64 "-%" PRIx64 ", keyLen %d", SMA_VID(pSma), tReadH.dFile.path, - *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), SMA_KEY_LEN); - - void *result = NULL; - int32_t valueSize = 0; - if (!(result = smaGetSmaDataByKey(&tReadH.dFile, smaKey, SMA_KEY_LEN, &valueSize))) { - smaWarn("vgId:%d, get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIx64 " since %s", - SMA_VID(pSma), indexUid, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), tstrerror(terrno)); - smaCloseDBF(&tReadH.dFile); - return TSDB_CODE_FAILED; - } -#endif - -#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ - for (uint32_t v = 0; v < valueSize; v += 8) { - smaWarn("vgId:%d, get sma data v[%d]=%" PRIi64, SMA_VID(pSma), v, *(int64_t *)POINTER_SHIFT(result, v)); - } -#endif - taosMemoryFreeClear(result); // TODO: fill the result to output - -#if 0 - int32_t nResult = 0; - int64_t lastKey = 0; - - while (true) { - if (nResult >= nMaxResult) { - break; - } - - // set and open the file according to the STSma param - if (tdSetAndOpenTSmaFile(&tReadH, queryWin)) { - char bTree[100] = "\0"; - while (strncmp(bTree, "has more nodes", 100) == 0) { - if (nResult >= nMaxResult) { - break; - } - // tdGetDataFromBTree(bTree, queryWin, lastKey) - // fill the pData - ++nResult; - } - } - } -#endif - // read data from file and fill the result - smaCloseDBF(&tReadH.dFile); - return TSDB_CODE_SUCCESS; -} - -int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { - SSmaCfg *pCfg = (SSmaCfg *)pMsg; - - if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) { - return -1; - } - - tdTSmaAdd(pSma, 1); - return 0; -} - -int32_t tdDropTSma(SSma *pSma, char *pMsg) { -#if 0 - SVDropTSmaReq vDropSmaReq = {0}; - if (!tDeserializeSVDropTSmaReq(pMsg, &vDropSmaReq)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - // TODO: send msg to stream computing to drop tSma - // if ((send msg to stream computing) < 0) { - // tDestroyTSma(&vCreateSmaReq); - // return -1; - // } - // - - if (metaDropTSma(SMA_META(pSma), vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - if (tdDropTSmaData(pSma, vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - tdTSmaSub(pSma, 1); -#endif - - // TODO: return directly or go on follow steps? - return TSDB_CODE_SUCCESS; -} - -static SSmaStatItem *tdNewSmaStatItem(int8_t state) { - SSmaStatItem *pItem = NULL; - - pItem = (SSmaStatItem *)taosMemoryCalloc(1, sizeof(SSmaStatItem)); - if (!pItem) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - pItem->state = state; - pItem->expiredWindows = taosHashInit(SMA_STATE_ITEM_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP), - true, HASH_ENTRY_LOCK); - if (!pItem->expiredWindows) { - taosMemoryFreeClear(pItem); - return NULL; - } - - return pItem; -} - -static int32_t tdSetExpiredWindow(SSma *pSma, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, - int64_t version) { - SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - if (!pItem) { - // TODO: use TSDB_SMA_STAT_EXPIRED and update by stream computing later - pItem = tdNewSmaStatItem(TSDB_SMA_STAT_OK); // TODO use the real state - if (!pItem) { - // Response to stream computing: OOM - // For query, if the indexUid not found, the TSDB should tell query module to query raw TS data. - return TSDB_CODE_FAILED; - } - - // cache smaMeta - STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid); - if (!pTSma) { - terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META; - taosHashCleanup(pItem->expiredWindows); - taosMemoryFree(pItem); - smaWarn("vgId:%d, set expire window, get tsma meta failed for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - return TSDB_CODE_FAILED; - } - pItem->pTSma = pTSma; - - if (taosHashPut(pItemsHash, &indexUid, sizeof(indexUid), &pItem, sizeof(pItem)) != 0) { - // If error occurs during put smaStatItem, free the resources of pItem - taosHashCleanup(pItem->expiredWindows); - taosMemoryFree(pItem); - return TSDB_CODE_FAILED; - } - } else if (!(pItem = *(SSmaStatItem **)pItem)) { - terrno = TSDB_CODE_INVALID_PTR; - return TSDB_CODE_FAILED; - } - - if (taosHashPut(pItem->expiredWindows, &winSKey, sizeof(TSKEY), &version, sizeof(version)) != 0) { - // If error occurs during taosHashPut expired windows, remove the smaIndex from pSma->pSmaStat, thus TSDB would - // tell query module to query raw TS data. - // N.B. - // 1) It is assumed to be extemely little probability event of fail to taosHashPut. - // 2) This would solve the inconsistency to some extent, but not completely, unless we record all expired - // windows failed to put into hash table. - taosHashCleanup(pItem->expiredWindows); - taosMemoryFreeClear(pItem->pTSma); - taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid)); - smaWarn("vgId:%d, smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window fail", SMA_VID(pSma), indexUid, - winSKey); - return TSDB_CODE_FAILED; - } - - smaDebug("vgId:%d, smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window succeed", SMA_VID(pSma), indexUid, - winSKey); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Update expired window according to msg from stream computing module. - * - * @param pSma - * @param msg SSubmitReq - * @return int32_t - */ -int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t version) { - // no time-range-sma, just return success - if (atomic_load_16(&SMA_TSMA_NUM(pSma)) <= 0) { - smaTrace("vgId:%d, not update expire window since no tSma", SMA_VID(pSma)); - return TSDB_CODE_SUCCESS; - } - - if (!SMA_META(pSma)) { - terrno = TSDB_CODE_INVALID_PTR; - smaError("vgId:%d, update expire window failed since no meta ptr", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) < 0) { - smaError("vgId:%d, init sma env failed since %s", SMA_VID(pSma), terrstr(terrno)); - terrno = TSDB_CODE_TDB_INIT_FAILED; - return TSDB_CODE_FAILED; - } - - // Firstly, assume that tSma can only be created on super table/normal table. - // getActiveTimeWindow - - SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); - SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); - - TASSERT(pEnv && pStat && pItemsHash); - - // basic procedure - // TODO: optimization - tdRefSmaStat(pSma, pStat); - - SSubmitMsgIter msgIter = {0}; - SSubmitBlk *pBlock = NULL; - SInterval interval = {0}; - TSKEY lastWinSKey = INT64_MIN; - - if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) { - return TSDB_CODE_FAILED; - } - - while (true) { - tGetSubmitMsgNext(&msgIter, &pBlock); - if (!pBlock) break; - - STSmaWrapper *pSW = NULL; - STSma *pTSma = NULL; - - SSubmitBlkIter blkIter = {0}; - if (tInitSubmitBlkIter(&msgIter, pBlock, &blkIter) < 0) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - - while (true) { - STSRow *row = tGetSubmitBlkNext(&blkIter); - if (!row) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - if (!pSW || (pTSma && (pTSma->tableUid != msgIter.suid))) { - if (pSW) { - pSW = tFreeTSmaWrapper(pSW, false); - } - if (!(pSW = metaGetSmaInfoByTable(SMA_META(pSma), msgIter.suid, false))) { - break; - } - if ((pSW->number) <= 0 || !pSW->tSma) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - - pTSma = pSW->tSma; - - interval.interval = pTSma->interval; - interval.intervalUnit = pTSma->intervalUnit; - interval.offset = pTSma->offset; - interval.precision = SMA_TSDB_CFG(pSma)->precision; - interval.sliding = pTSma->sliding; - interval.slidingUnit = pTSma->slidingUnit; - } - - // TODO: process multiple tsma for one table uid - TSKEY winSKey = taosTimeTruncate(TD_ROW_KEY(row), &interval, interval.precision); - - if (lastWinSKey != winSKey) { - lastWinSKey = winSKey; - if (tdSetExpiredWindow(pSma, pItemsHash, pTSma->indexUid, winSKey, version) < 0) { - pSW = tFreeTSmaWrapper(pSW, false); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - } else { - smaDebug("vgId:%d, smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window ignore as duplicated", - SMA_VID(pSma), pTSma->indexUid, winSKey); - } - } - } - - tdUnRefSmaStat(pSma, pStat); - - return TSDB_CODE_SUCCESS; -} diff --git a/source/dnode/vnode/src/sma/smaTimeRange2.c b/source/dnode/vnode/src/sma/smaTimeRange2.c index 09adc1a6a2..9c613873ab 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange2.c +++ b/source/dnode/vnode/src/sma/smaTimeRange2.c @@ -30,54 +30,8 @@ typedef STsdbCfg STSmaKeepCfg; #define SMA_STATE_ITEM_HASH_SLOT 32 -typedef struct { - SSma *pSma; - SDBFile dFile; - const SArray *pDataBlocks; // sma data - int64_t interval; // interval with the precision of DB -} STSmaWriteH; - -typedef struct { - int32_t iter; - int32_t fid; -} SmaFsIter; - -typedef struct { - STsdb *pTsdb; - SSma *pSma; - SDBFile dFile; - int64_t interval; // interval with the precision of DB - int32_t blockSize; // size of SMA block item - int32_t days; - int8_t storageLevel; - SmaFsIter smaFsIter; -} STSmaReadH; - -typedef enum { - SMA_STORAGE_LEVEL_TSDB = 0, // use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f200.tsma - SMA_STORAGE_LEVEL_DFILESET = 1 // use days of TS data e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f1906.tsma -} ESmaStorageLevel; - // static func -static int64_t tdGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted); -static int32_t tdGetSmaStorageLevel(STSmaKeepCfg *pCfg, int64_t interval); -static int32_t tdInitTSmaWriteH(STSmaWriteH *pSmaH, SSma *pSma, const SArray *pDataBlocks, int64_t interval, - int8_t intervalUnit); -static int32_t tdInitTSmaReadH(STSmaReadH *pSmaH, SSma *pSma, int64_t interval, int8_t intervalUnit); -static void tdDestroyTSmaWriteH(STSmaWriteH *pSmaH); -static int32_t tdGetTSmaDays(SSma *pSma, int64_t interval, int32_t storageLevel); -static int32_t tdSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid); -static int32_t tdInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey); -static bool tdSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); -static int32_t tdInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, int32_t keyLen, void *pData, int32_t dataLen, - TXN *txn); -// expired window - -static int32_t tdSetExpiredWindow(SSma *pSma, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version); -static int32_t tdResetExpiredWindow(SSma *pSma, SSmaStat *pStat, int64_t indexUid, TSKEY skey); -static int32_t tdDropTSmaDataImpl(SSma *pSma, int64_t indexUid); - /** * @brief Judge the tsma file split days * @@ -87,7 +41,7 @@ static int32_t tdDropTSmaDataImpl(SSma *pSma, int64_t indexUid); * @param days unit is minute * @return int32_t */ -int32_t tdGetTSmaDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) { +int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) { SDecoder coder = {0}; tDecoderInit(&coder, pCont, contLen); @@ -130,225 +84,6 @@ _err: // implementation -/** - * @brief - * - * @param pSmaH - * @param pSma - * @param interval - * @param intervalUnit - * @return int32_t - */ -static int32_t tdInitTSmaReadH(STSmaReadH *pSmaH, SSma *pSma, int64_t interval, int8_t intervalUnit) { - STSmaKeepCfg *pCfg = SMA_TSDB_CFG(pSma); - pSmaH->pSma = pSma; - pSmaH->interval = tdGetIntervalByPrecision(interval, intervalUnit, SMA_TSDB_CFG(pSma)->precision, true); - pSmaH->storageLevel = tdGetSmaStorageLevel(pCfg, interval); - pSmaH->days = tdGetTSmaDays(pSma, pSmaH->interval, pSmaH->storageLevel); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Init of tSma FS - * - * @param pReadH - * @param indexUid - * @param skey - * @return int32_t - */ -static int32_t tdInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey) { - SSma *pSma = pSmaH->pSma; - - int32_t fid = (int32_t)(TSDB_KEY_FID(skey, pSmaH->days, SMA_TSDB_CFG(pSma)->precision)); - char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, SMA_VID(pSma), fid); - pSmaH->dFile.path = strdup(tSmaFile); - pSmaH->smaFsIter.iter = 0; - pSmaH->smaFsIter.fid = fid; - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Set and open tSma file if it has key locates in queryWin. - * - * @param pReadH - * @param param - * @param queryWin - * @return true - * @return false - */ -static bool tdSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { - // SArray *smaFs = pReadH->pTsdb->fs->cstatus->sf; - // int32_t nSmaFs = taosArrayGetSize(smaFs); - - smaCloseDBF(&pReadH->dFile); - -#if 0 - while (pReadH->smaFsIter.iter < nSmaFs) { - void *pSmaFile = taosArrayGet(smaFs, pReadH->smaFsIter.iter); - if (pSmaFile) { // match(indexName, queryWindow) - // TODO: select the file by index_name ... - pReadH->dFile = pSmaFile; - ++pReadH->smaFsIter.iter; - break; - } - ++pReadH->smaFsIter.iter; - } - - if (pReadH->pDFile) { - tdDebug("vg%d: smaFile %s matched", REPO_ID(pReadH->pTsdb), "[pSmaFile dir]"); - return true; - } -#endif - - return false; -} - -/** - * @brief Approximate value for week/month/year. - * - * @param interval - * @param intervalUnit - * @param precision - * @param adjusted Interval already adjusted according to DB precision - * @return int64_t - */ -static int64_t tdGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted) { - if (adjusted) { - return interval; - } - - switch (intervalUnit) { - case TIME_UNIT_YEAR: // approximate value - interval *= 365 * 86400 * 1e3; - break; - case TIME_UNIT_MONTH: // approximate value - interval *= 30 * 86400 * 1e3; - break; - case TIME_UNIT_WEEK: // approximate value - interval *= 7 * 86400 * 1e3; - break; - case TIME_UNIT_DAY: // the interval for tSma calculation must <= day - interval *= 86400 * 1e3; - break; - case TIME_UNIT_HOUR: - interval *= 3600 * 1e3; - break; - case TIME_UNIT_MINUTE: - interval *= 60 * 1e3; - break; - case TIME_UNIT_SECOND: - interval *= 1e3; - break; - default: - break; - } - - switch (precision) { - case TSDB_TIME_PRECISION_MILLI: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval / 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second - return interval / 1e6; - } else { // ms - return interval; - } - break; - case TSDB_TIME_PRECISION_MICRO: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval / 1e3; - } else { // ms - return interval * 1e3; - } - break; - case TSDB_TIME_PRECISION_NANO: - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval * 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval; - } else { // ms - return interval * 1e6; - } - break; - default: // ms - if (TIME_UNIT_MICROSECOND == intervalUnit) { // us - return interval / 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns - return interval / 1e6; - } else { // ms - return interval; - } - break; - } - return interval; -} - -static int32_t tdInitTSmaWriteH(STSmaWriteH *pSmaH, SSma *pSma, const SArray *pDataBlocks, int64_t interval, - int8_t intervalUnit) { - pSmaH->pSma = pSma; - pSmaH->interval = tdGetIntervalByPrecision(interval, intervalUnit, SMA_TSDB_CFG(pSma)->precision, true); - pSmaH->pDataBlocks = pDataBlocks; - pSmaH->dFile.fid = SMA_IVLD_FID; - return TSDB_CODE_SUCCESS; -} - -static void tdDestroyTSmaWriteH(STSmaWriteH *pSmaH) { - if (pSmaH) { - smaCloseDBF(&pSmaH->dFile); - } -} - -static int32_t tdSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid) { - SSma *pSma = pSmaH->pSma; - ASSERT(!pSmaH->dFile.path && !pSmaH->dFile.pDB); - - pSmaH->dFile.fid = fid; - char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, SMA_VID(pSma), fid); - pSmaH->dFile.path = strdup(tSmaFile); - - return TSDB_CODE_SUCCESS; -} - -/** - * @brief - * - * @param pSma - * @param interval Interval calculated by DB's precision - * @param storageLevel - * @return int32_t - */ -static int32_t tdGetTSmaDays(SSma *pSma, int64_t interval, int32_t storageLevel) { - STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); - int32_t daysPerFile = pCfg->days; // unit is minute - - if (storageLevel == SMA_STORAGE_LEVEL_TSDB) { - int32_t minutes = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerMin[pCfg->precision]); - if (minutes > SMA_STORAGE_TSDB_MINUTES) { - daysPerFile = SMA_STORAGE_TSDB_MINUTES; - } - } - - return daysPerFile; -} - -/** - * @brief Judge the tSma storage level - * - * @param pCfg - * @param interval - * @return int32_t - */ -static int32_t tdGetSmaStorageLevel(STSmaKeepCfg *pCfg, int64_t interval) { - int64_t mInterval = convertTimeFromPrecisionToUnit(interval, pCfg->precision, TIME_UNIT_MINUTE); - if (pCfg->days / mInterval >= SMA_STORAGE_SPLIT_FACTOR) { - return SMA_STORAGE_LEVEL_DFILESET; - } - return SMA_STORAGE_LEVEL_TSDB; -} - /** * @brief Insert/Update Time-range-wise SMA data. * - If interval < SMA_STORAGE_SPLIT_HOURS(e.g. 24), save the SMA data as a part of DFileSet to e.g. @@ -362,28 +97,28 @@ static int32_t tdGetSmaStorageLevel(STSmaKeepCfg *pCfg, int64_t interval) { * @return int32_t */ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { - STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); + STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); + const SArray *pDataBlocks = (const SArray *)msg; - int64_t testSkey = TSKEY_INITIAL_VAL; // TODO: destroy SSDataBlocks(msg) // For super table aggregation, the sma data is stored in vgroup calculated from the hash value of stable name. Thus // the sma data would arrive ahead of the update-expired-window msg. - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) != TSDB_CODE_SUCCESS) { + if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE, false) != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } if (!pDataBlocks) { terrno = TSDB_CODE_INVALID_PTR; - smaWarn("vgId:%d insert tSma data failed since pDataBlocks is NULL", SMA_VID(pSma)); + smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); return terrno; } if (taosArrayGetSize(pDataBlocks) <= 0) { terrno = TSDB_CODE_INVALID_PARA; - smaWarn("vgId:%d insert tSma data failed since pDataBlocks is empty", SMA_VID(pSma)); + smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma)); return TSDB_CODE_FAILED; } @@ -398,463 +133,15 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { } if (!pItem || !(pItem = *(SSmaStatItem **)pItem) || tdSmaStatIsDropped(pItem)) { - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; + terrno = TSDB_CODE_TSMA_INVALID_STAT; tdUnRefSmaStat(pSma, pStat); return TSDB_CODE_FAILED; } - STSma *pTSma = pItem->pTSma; - STSmaWriteH tSmaH = {0}; - - if (tdInitTSmaWriteH(&tSmaH, pSma, pDataBlocks, pTSma->interval, pTSma->intervalUnit) != 0) { - return TSDB_CODE_FAILED; - } - - char rPath[TSDB_FILENAME_LEN] = {0}; - char aPath[TSDB_FILENAME_LEN] = {0}; - snprintf(rPath, TSDB_FILENAME_LEN, "%s%s%" PRIi64, SMA_ENV_PATH(pEnv), TD_DIRSEP, indexUid); - tfsAbsoluteName(SMA_TFS(pSma), SMA_ENV_DID(pEnv), rPath, aPath); - if (!taosCheckExistFile(aPath)) { - if (tfsMkdirRecurAt(SMA_TFS(pSma), rPath, SMA_ENV_DID(pEnv)) != TSDB_CODE_SUCCESS) { - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - } - - // Step 1: Judge the storage level and days - int32_t storageLevel = tdGetSmaStorageLevel(pCfg, tSmaH.interval); - int32_t minutePerFile = tdGetTSmaDays(pSma, tSmaH.interval, storageLevel); - - char smaKey[SMA_KEY_LEN] = {0}; // key: skey + groupId - char dataBuf[512] = {0}; // val: aggr data // TODO: handle 512 buffer? - void *pDataBuf = NULL; - int32_t sz = taosArrayGetSize(pDataBlocks); - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock *pDataBlock = taosArrayGet(pDataBlocks, i); - int32_t colNum = pDataBlock->info.numOfCols; - int32_t rows = pDataBlock->info.rows; - int32_t rowSize = pDataBlock->info.rowSize; - int64_t groupId = pDataBlock->info.groupId; - for (int32_t j = 0; j < rows; ++j) { - printf("|"); - TSKEY skey = TSKEY_INITIAL_VAL; // the start key of TS window by interval - void *pSmaKey = &smaKey; - bool isStartKey = false; - - int32_t tlen = 0; // reset the len - pDataBuf = &dataBuf; // reset the buf - for (int32_t k = 0; k < colNum; ++k) { - SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); - void *var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); - switch (pColInfoData->info.type) { - case TSDB_DATA_TYPE_TIMESTAMP: - if (!isStartKey) { - isStartKey = true; - skey = *(TSKEY *)var; - testSkey = skey; - printf("= skey %" PRIi64 " groupId = %" PRIi64 "|", skey, groupId); - tdEncodeTSmaKey(groupId, skey, &pSmaKey); - } else { - printf(" %" PRIi64 " |", *(int64_t *)var); - tlen += taosEncodeFixedI64(&pDataBuf, *(int64_t *)var); - break; - } - break; - case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_UTINYINT: - printf(" %15d |", *(uint8_t *)var); - tlen += taosEncodeFixedU8(&pDataBuf, *(uint8_t *)var); - break; - case TSDB_DATA_TYPE_TINYINT: - printf(" %15d |", *(int8_t *)var); - tlen += taosEncodeFixedI8(&pDataBuf, *(int8_t *)var); - break; - case TSDB_DATA_TYPE_SMALLINT: - printf(" %15d |", *(int16_t *)var); - tlen += taosEncodeFixedI16(&pDataBuf, *(int16_t *)var); - break; - case TSDB_DATA_TYPE_USMALLINT: - printf(" %15d |", *(uint16_t *)var); - tlen += taosEncodeFixedU16(&pDataBuf, *(uint16_t *)var); - break; - case TSDB_DATA_TYPE_INT: - printf(" %15d |", *(int32_t *)var); - tlen += taosEncodeFixedI32(&pDataBuf, *(int32_t *)var); - break; - case TSDB_DATA_TYPE_FLOAT: - printf(" %15f |", *(float *)var); - tlen += taosEncodeBinary(&pDataBuf, var, sizeof(float)); - break; - case TSDB_DATA_TYPE_UINT: - printf(" %15u |", *(uint32_t *)var); - tlen += taosEncodeFixedU32(&pDataBuf, *(uint32_t *)var); - break; - case TSDB_DATA_TYPE_BIGINT: - printf(" %15ld |", *(int64_t *)var); - tlen += taosEncodeFixedI64(&pDataBuf, *(int64_t *)var); - break; - case TSDB_DATA_TYPE_DOUBLE: - printf(" %15lf |", *(double *)var); - tlen += taosEncodeBinary(&pDataBuf, var, sizeof(double)); - case TSDB_DATA_TYPE_UBIGINT: - printf(" %15lu |", *(uint64_t *)var); - tlen += taosEncodeFixedU64(&pDataBuf, *(uint64_t *)var); - break; - case TSDB_DATA_TYPE_NCHAR: { - char tmpChar[100] = {0}; - strncpy(tmpChar, varDataVal(var), varDataLen(var)); - printf(" %s |", tmpChar); - tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var)); - break; - } - case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY - char tmpChar[100] = {0}; - strncpy(tmpChar, varDataVal(var), varDataLen(var)); - printf(" %s |", tmpChar); - tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var)); - break; - } - case TSDB_DATA_TYPE_VARBINARY: - // TODO: add binary/varbinary - TASSERT(0); - default: - printf("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); - TASSERT(0); - break; - } - } - printf("\n"); - // if ((tlen > 0) && (skey != TSKEY_INITIAL_VAL)) { - if (tlen > 0) { - int32_t fid = (int32_t)(TSDB_KEY_FID(skey, minutePerFile, pCfg->precision)); - - // Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index - // file - // - Set and open the DFile or the B+Tree file - // TODO: tsdbStartTSmaCommit(); - if (fid != tSmaH.dFile.fid) { - if (tSmaH.dFile.fid != SMA_IVLD_FID) { - tdSmaEndCommit(pEnv); - smaCloseDBF(&tSmaH.dFile); - } - tdSetTSmaDataFile(&tSmaH, indexUid, fid); - smaDebug("@@@ vgId:%d write to DBF %s, days:%d, interval:%" PRIi64 ", storageLevel:%" PRIi32 - " queryKey:%" PRIi64, - SMA_VID(pSma), tSmaH.dFile.path, minutePerFile, tSmaH.interval, storageLevel, testSkey); - if (smaOpenDBF(pEnv->dbEnv, &tSmaH.dFile) != 0) { - smaWarn("vgId:%d open DB file %s failed since %s", SMA_VID(pSma), - tSmaH.dFile.path ? tSmaH.dFile.path : "path is NULL", tstrerror(terrno)); - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - tdSmaBeginCommit(pEnv); - } - - if (tdInsertTSmaBlocks(&tSmaH, &smaKey, SMA_KEY_LEN, dataBuf, tlen, &pEnv->txn) != 0) { - smaWarn("vgId:%d insert tsma data blocks fail for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64 - " since %s", - SMA_VID(pSma), indexUid, skey, groupId, tstrerror(terrno)); - tdSmaEndCommit(pEnv); - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - - smaDebug("vgId:%d insert tsma data blocks success for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64, - SMA_VID(pSma), indexUid, skey, groupId); - // TODO:tsdbEndTSmaCommit(); - - // Step 3: reset the SSmaStat - tdResetExpiredWindow(pSma, pStat, indexUid, skey); - } else { - smaWarn("vgId:%d invalid data skey:%" PRIi64 ", tlen %" PRIi32 " during insert tSma data for %" PRIi64, - SMA_VID(pSma), skey, tlen, indexUid); - } - } - } - tdSmaEndCommit(pEnv); // TODO: not commit for every insert - tdDestroyTSmaWriteH(&tSmaH); - tdUnRefSmaStat(pSma, pStat); - - return TSDB_CODE_SUCCESS; -} - -int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid) { - int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdDropTSmaDataImpl(pSma, indexUid)) < 0) { - smaWarn("vgId:%d drop tSma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - return code; -} - -/** - * @brief Insert TSma data blocks to DB File build by B+Tree - * - * @param pSmaH - * @param smaKey tableUid-colId-skeyOfWindow(8-2-8) - * @param keyLen - * @param pData - * @param dataLen - * @return int32_t - */ -static int32_t tdInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, int32_t keyLen, void *pData, int32_t dataLen, - TXN *txn) { - SDBFile *pDBFile = &pSmaH->dFile; - - // TODO: insert tsma data blocks into B+Tree(TTB) - if (smaSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen, txn) != 0) { - smaWarn("vgId:%d insert tsma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 " fail", - SMA_VID(pSmaH->pSma), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen); - return TSDB_CODE_FAILED; - } - smaDebug("vgId:%d insert tsma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 " succeed", - SMA_VID(pSmaH->pSma), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen); - -#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ - uint32_t valueSize = 0; - void *data = tdGetSmaDataByKey(pDBFile, smaKey, keyLen, &valueSize); - ASSERT(data != NULL); - for (uint32_t v = 0; v < valueSize; v += 8) { - smaWarn("vgId:%d insert sma data val[%d] %" PRIi64, REPO_ID(pSmaH->pTsdb), v, *(int64_t *)POINTER_SHIFT(data, v)); - } -#endif - return TSDB_CODE_SUCCESS; -} - -/** - * @brief When sma data received from stream computing, make the relative expired window valid. - * - * @param pSma - * @param pStat - * @param indexUid - * @param skey - * @return int32_t - */ -static int32_t tdResetExpiredWindow(SSma *pSma, SSmaStat *pStat, int64_t indexUid, TSKEY skey) { - SSmaStatItem *pItem = NULL; - - tdRefSmaStat(pSma, pStat); - - if (pStat && SMA_STAT_ITEMS(pStat)) { - pItem = taosHashGet(SMA_STAT_ITEMS(pStat), &indexUid, sizeof(indexUid)); - } - if ((pItem) && ((pItem = *(SSmaStatItem **)pItem))) { - // pItem resides in hash buffer all the time unless drop sma index - // TODO: multithread protect - if (taosHashRemove(pItem->expiredWindows, &skey, sizeof(TSKEY)) != 0) { - // error handling - tdUnRefSmaStat(pSma, pStat); - smaWarn("vgId:%d remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " fail", SMA_VID(pSma), skey, - indexUid); - return TSDB_CODE_FAILED; - } - smaDebug("vgId:%d remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " succeed", SMA_VID(pSma), - skey, indexUid); - // TODO: use a standalone interface to received state upate notification from stream computing module. - /** - * @brief state - * - When SMA env init in TSDB, its status is TSDB_SMA_STAT_OK. - * - In startup phase of stream computing module, it should notify the SMA env in TSDB to expired if needed(e.g. - * when batch data caculation not finised) - * - When TSDB_SMA_STAT_OK, the stream computing module should also notify that to the SMA env in TSDB. - */ - pItem->state = TSDB_SMA_STAT_OK; - } else { - // error handling - tdUnRefSmaStat(pSma, pStat); - smaWarn("vgId:%d expired window %" PRIi64 " not exists for sma index %" PRIi64, SMA_VID(pSma), skey, indexUid); - return TSDB_CODE_FAILED; - } - - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Drop tSma data and local cache - * - insert/query reference - * @param pSma - * @param msg - * @return int32_t - */ -static int32_t tdDropTSmaDataImpl(SSma *pSma, int64_t indexUid) { - SSmaEnv *pEnv = atomic_load_ptr(&SMA_TSMA_ENV(pSma)); - - // clear local cache - if (pEnv) { - smaDebug("vgId:%d drop tSma local cache for %" PRIi64, SMA_VID(pSma), indexUid); - - SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pEnv), &indexUid, sizeof(indexUid)); - if ((pItem) || ((pItem = *(SSmaStatItem **)pItem))) { - if (tdSmaStatIsDropped(pItem)) { - smaDebug("vgId:%d tSma stat is already dropped for %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_TDB_INVALID_ACTION; // TODO: duplicate drop msg would be intercepted by mnode - } - - tdWLockSmaEnv(pEnv); - if (tdSmaStatIsDropped(pItem)) { - tdUnLockSmaEnv(pEnv); - smaDebug("vgId:%d tSma stat is already dropped for %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_TDB_INVALID_ACTION; // TODO: duplicate drop msg would be intercepted by mnode - } - tdSmaStatSetDropped(pItem); - tdUnLockSmaEnv(pEnv); - - int32_t nSleep = 0; - int32_t refVal = INT32_MAX; - while (true) { - if ((refVal = T_REF_VAL_GET(SMA_ENV_STAT(pEnv))) <= 0) { - smaDebug("vgId:%d drop index %" PRIi64 " since refVal=%d", SMA_VID(pSma), indexUid, refVal); - break; - } - smaDebug("vgId:%d wait 1s to drop index %" PRIi64 " since refVal=%d", SMA_VID(pSma), indexUid, refVal); - taosSsleep(1); - if (++nSleep > SMA_DROP_EXPIRED_TIME) { - smaDebug("vgId:%d drop index %" PRIi64 " after wait %d (refVal=%d)", SMA_VID(pSma), indexUid, nSleep, refVal); - break; - }; - } - - tdFreeSmaStatItem(pItem); - smaDebug("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", SMA_VID(pSma), indexUid); - } - } - // clear sma data files - // TODO: - return TSDB_CODE_SUCCESS; -} - -/** - * @brief - * - * @param pSma Return the data between queryWin and fill the pData. - * @param pData - * @param indexUid - * @param pQuerySKey - * @param nMaxResult The query invoker should control the nMaxResult need to return to avoid OOM. - * @return int32_t - */ -int32_t tdGetTSmaDataImpl(SSma *pSma, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) { - SSmaEnv *pEnv = atomic_load_ptr(&SMA_TSMA_ENV(pSma)); - SSmaStat *pStat = NULL; - - if (!pEnv) { - terrno = TSDB_CODE_INVALID_PTR; - smaWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - pStat = SMA_ENV_STAT(pEnv); - - tdRefSmaStat(pSma, pStat); - SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pEnv), &indexUid, sizeof(indexUid)); - if (!pItem || !(pItem = *(SSmaStatItem **)pItem)) { - // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if - // it's NULL. - tdUnRefSmaStat(pSma, pStat); - terrno = TSDB_CODE_TDB_INVALID_ACTION; - smaDebug("vgId:%d getTSmaDataImpl failed since no index %" PRIi64, SMA_VID(pSma), indexUid); - return TSDB_CODE_FAILED; - } - -#if 0 - int32_t nQueryWin = taosArrayGetSize(pQuerySKey); - for (int32_t n = 0; n < nQueryWin; ++n) { - TSKEY skey = taosArrayGet(pQuerySKey, n); - if (taosHashGet(pItem->expiredWindows, &skey, sizeof(TSKEY))) { - // TODO: mark this window as expired. - } - } -#endif - -#if 1 - int8_t smaStat = 0; - if (!tdSmaStatIsOK(pItem, &smaStat)) { // TODO: multiple check for large scale sma query - tdUnRefSmaStat(pSma, pStat); - terrno = TSDB_CODE_TDB_INVALID_SMA_STAT; - smaWarn("vgId:%d getTSmaDataImpl failed from index %" PRIi64 " since %s %" PRIi8, SMA_VID(pSma), indexUid, - tstrerror(terrno), smaStat); - return TSDB_CODE_FAILED; - } - - if (taosHashGet(pItem->expiredWindows, &querySKey, sizeof(TSKEY))) { - // TODO: mark this window as expired. - smaDebug("vgId:%d skey %" PRIi64 " of window exists in expired window for index %" PRIi64, SMA_VID(pSma), querySKey, - indexUid); - } else { - smaDebug("vgId:%d skey %" PRIi64 " of window not in expired window for index %" PRIi64, SMA_VID(pSma), querySKey, - indexUid); - } - STSma *pTSma = pItem->pTSma; -#endif - -#if 1 - STSmaReadH tReadH = {0}; - tdInitTSmaReadH(&tReadH, pSma, pTSma->interval, pTSma->intervalUnit); - smaCloseDBF(&tReadH.dFile); tdUnRefSmaStat(pSma, pStat); - tdInitTSmaFile(&tReadH, indexUid, querySKey); - smaDebug("### vgId:%d read from DBF %s days:%d, interval:%" PRIi64 ", storageLevel:%" PRIi8 " queryKey:%" PRIi64, - SMA_VID(pSma), tReadH.dFile.path, tReadH.days, tReadH.interval, tReadH.storageLevel, querySKey); - if (smaOpenDBF(pEnv->dbEnv, &tReadH.dFile) != 0) { - smaWarn("vgId:%d open DBF %s failed since %s", SMA_VID(pSma), tReadH.dFile.path, tstrerror(terrno)); - return TSDB_CODE_FAILED; - } - - char smaKey[SMA_KEY_LEN] = {0}; - void *pSmaKey = &smaKey; - int64_t queryGroupId = 0; - tdEncodeTSmaKey(queryGroupId, querySKey, (void **)&pSmaKey); - - smaDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIx64 ", keyLen %d", SMA_VID(pSma), tReadH.dFile.path, - *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), SMA_KEY_LEN); - - void *result = NULL; - int32_t valueSize = 0; - if (!(result = smaGetSmaDataByKey(&tReadH.dFile, smaKey, SMA_KEY_LEN, &valueSize))) { - smaWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIx64 " since %s", - SMA_VID(pSma), indexUid, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), tstrerror(terrno)); - smaCloseDBF(&tReadH.dFile); - return TSDB_CODE_FAILED; - } -#endif - -#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ - for (uint32_t v = 0; v < valueSize; v += 8) { - smaWarn("vgId:%d get sma data v[%d]=%" PRIi64, SMA_VID(pSma), v, *(int64_t *)POINTER_SHIFT(result, v)); - } -#endif - taosMemoryFreeClear(result); // TODO: fill the result to output - -#if 0 - int32_t nResult = 0; - int64_t lastKey = 0; - - while (true) { - if (nResult >= nMaxResult) { - break; - } - - // set and open the file according to the STSma param - if (tdSetAndOpenTSmaFile(&tReadH, queryWin)) { - char bTree[100] = "\0"; - while (strncmp(bTree, "has more nodes", 100) == 0) { - if (nResult >= nMaxResult) { - break; - } - // tdGetDataFromBTree(bTree, queryWin, lastKey) - // fill the pData - ++nResult; - } - } - } -#endif - // read data from file and fill the result - smaCloseDBF(&tReadH.dFile); return TSDB_CODE_SUCCESS; } @@ -865,224 +152,19 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { return -1; } + if (TD_VID(pSma->pVnode) == pCfg->dstVgId) { + // create stable to save tsma result in dstVgId + SVCreateStbReq pReq = {0}; + pReq.name = pCfg->dstTbName; + pReq.suid = pCfg->dstTbUid; + pReq.schemaRow = pCfg->schemaRow; + pReq.schemaTag = pCfg->schemaTag; + + if (metaCreateSTable(SMA_META(pSma), version, &pReq) < 0) { + return -1; + } + } + tdTSmaAdd(pSma, 1); return 0; -} - -int32_t tdDropTSma(SSma *pSma, char *pMsg) { -#if 0 - SVDropTSmaReq vDropSmaReq = {0}; - if (!tDeserializeSVDropTSmaReq(pMsg, &vDropSmaReq)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - // TODO: send msg to stream computing to drop tSma - // if ((send msg to stream computing) < 0) { - // tDestroyTSma(&vCreateSmaReq); - // return -1; - // } - // - - if (metaDropTSma(SMA_META(pSma), vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - if (tdDropTSmaData(pSma, vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - tdTSmaSub(pSma, 1); -#endif - - // TODO: return directly or go on follow steps? - return TSDB_CODE_SUCCESS; -} - -static SSmaStatItem *tdNewSmaStatItem(int8_t state) { - SSmaStatItem *pItem = NULL; - - pItem = (SSmaStatItem *)taosMemoryCalloc(1, sizeof(SSmaStatItem)); - if (!pItem) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - pItem->state = state; - pItem->expiredWindows = taosHashInit(SMA_STATE_ITEM_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP), - true, HASH_ENTRY_LOCK); - if (!pItem->expiredWindows) { - taosMemoryFreeClear(pItem); - return NULL; - } - - return pItem; -} - -static int32_t tdSetExpiredWindow(SSma *pSma, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, - int64_t version) { - SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - if (!pItem) { - // TODO: use TSDB_SMA_STAT_EXPIRED and update by stream computing later - pItem = tdNewSmaStatItem(TSDB_SMA_STAT_OK); // TODO use the real state - if (!pItem) { - // Response to stream computing: OOM - // For query, if the indexUid not found, the TSDB should tell query module to query raw TS data. - return TSDB_CODE_FAILED; - } - - // cache smaMeta - STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid); - if (!pTSma) { - terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META; - taosHashCleanup(pItem->expiredWindows); - taosMemoryFree(pItem); - smaWarn("vgId:%d set expire window, get tsma meta failed for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - return TSDB_CODE_FAILED; - } - pItem->pTSma = pTSma; - - if (taosHashPut(pItemsHash, &indexUid, sizeof(indexUid), &pItem, sizeof(pItem)) != 0) { - // If error occurs during put smaStatItem, free the resources of pItem - taosHashCleanup(pItem->expiredWindows); - taosMemoryFree(pItem); - return TSDB_CODE_FAILED; - } - } else if (!(pItem = *(SSmaStatItem **)pItem)) { - terrno = TSDB_CODE_INVALID_PTR; - return TSDB_CODE_FAILED; - } - - if (taosHashPut(pItem->expiredWindows, &winSKey, sizeof(TSKEY), &version, sizeof(version)) != 0) { - // If error occurs during taosHashPut expired windows, remove the smaIndex from pSma->pSmaStat, thus TSDB would - // tell query module to query raw TS data. - // N.B. - // 1) It is assumed to be extemely little probability event of fail to taosHashPut. - // 2) This would solve the inconsistency to some extent, but not completely, unless we record all expired - // windows failed to put into hash table. - taosHashCleanup(pItem->expiredWindows); - taosMemoryFreeClear(pItem->pTSma); - taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid)); - smaWarn("vgId:%d smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window fail", SMA_VID(pSma), indexUid, - winSKey); - return TSDB_CODE_FAILED; - } - - smaDebug("vgId:%d smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window succeed", SMA_VID(pSma), indexUid, - winSKey); - return TSDB_CODE_SUCCESS; -} - -/** - * @brief Update expired window according to msg from stream computing module. - * - * @param pSma - * @param msg SSubmitReq - * @return int32_t - */ -int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t version) { - // no time-range-sma, just return success - if (atomic_load_16(&SMA_TSMA_NUM(pSma)) <= 0) { - smaTrace("vgId:%d not update expire window since no tSma", SMA_VID(pSma)); - return TSDB_CODE_SUCCESS; - } - - if (!SMA_META(pSma)) { - terrno = TSDB_CODE_INVALID_PTR; - smaError("vgId:%d update expire window failed since no meta ptr", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) < 0) { - smaError("vgId:%d init sma env failed since %s", SMA_VID(pSma), terrstr(terrno)); - terrno = TSDB_CODE_TDB_INIT_FAILED; - return TSDB_CODE_FAILED; - } - - // Firstly, assume that tSma can only be created on super table/normal table. - // getActiveTimeWindow - - SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); - SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); - - TASSERT(pEnv && pStat && pItemsHash); - - // basic procedure - // TODO: optimization - tdRefSmaStat(pSma, pStat); - - SSubmitMsgIter msgIter = {0}; - SSubmitBlk *pBlock = NULL; - SInterval interval = {0}; - TSKEY lastWinSKey = INT64_MIN; - - if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) { - return TSDB_CODE_FAILED; - } - - while (true) { - tGetSubmitMsgNext(&msgIter, &pBlock); - if (!pBlock) break; - - STSmaWrapper *pSW = NULL; - STSma *pTSma = NULL; - - SSubmitBlkIter blkIter = {0}; - if (tInitSubmitBlkIter(&msgIter, pBlock, &blkIter) < 0) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - - while (true) { - STSRow *row = tGetSubmitBlkNext(&blkIter); - if (!row) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - if (!pSW || (pTSma && (pTSma->tableUid != msgIter.suid))) { - if (pSW) { - pSW = tFreeTSmaWrapper(pSW, false); - } - if (!(pSW = metaGetSmaInfoByTable(SMA_META(pSma), msgIter.suid, false))) { - break; - } - if ((pSW->number) <= 0 || !pSW->tSma) { - pSW = tFreeTSmaWrapper(pSW, false); - break; - } - - pTSma = pSW->tSma; - - interval.interval = pTSma->interval; - interval.intervalUnit = pTSma->intervalUnit; - interval.offset = pTSma->offset; - interval.precision = SMA_TSDB_CFG(pSma)->precision; - interval.sliding = pTSma->sliding; - interval.slidingUnit = pTSma->slidingUnit; - } - - // TODO: process multiple tsma for one table uid - TSKEY winSKey = taosTimeTruncate(TD_ROW_KEY(row), &interval, interval.precision); - - if (lastWinSKey != winSKey) { - lastWinSKey = winSKey; - if (tdSetExpiredWindow(pSma, pItemsHash, pTSma->indexUid, winSKey, version) < 0) { - pSW = tFreeTSmaWrapper(pSW, false); - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - } else { - smaDebug("vgId:%d smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window ignore as duplicated", - SMA_VID(pSma), pTSma->indexUid, winSKey); - } - } - } - - tdUnRefSmaStat(pSma, pStat); - - return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 2f4d6c11c6..4a5ea49d79 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -130,7 +130,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset); STqHandle* pHandle = taosHashGet(pTq->handles, pReq->subKey, strlen(pReq->subKey)); - ASSERT(pHandle); + /*ASSERT(pHandle);*/ + if (pHandle == NULL) { + tqError("tmq poll: no consumer handle for consumer %ld in vg %d, subkey %s", consumerId, pTq->pVnode->config.vgId, + pReq->subKey); + return -1; + } + + if (pHandle->consumerId != consumerId) { + tqError("tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld", + consumerId, pTq->pVnode->config.vgId, pReq->subKey, pHandle->consumerId); + return -1; + } int32_t consumerEpoch = atomic_load_32(&pHandle->epoch); while (consumerEpoch < reqEpoch) { diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 9be94eb5b6..3af8901b2b 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -238,9 +238,6 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) if (msgType == TDMT_VND_SUBMIT) { if (taosHashGetSize(pTq->pStreamTasks) == 0) return 0; - if (tdUpdateExpireWindow(pTq->pVnode->pSma, msg, ver) != 0) { - // TODO handle sma error - } void* data = taosMemoryMalloc(msgLen); if (data == NULL) { return -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 17b8afda4b..90093f2510 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -150,7 +150,7 @@ int32_t tsdbCommit(STsdb *pTsdb) { return code; _err: - tsdbError("vgId:%d failed to commit since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, failed to commit since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index ffbef4e765..d8bc87d471 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -176,13 +176,13 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid pMemTable->nDelOp++; - tsdbError("vgId:%d delete data from table suid:%" PRId64 " uid:%" PRId64 " skey:%" PRId64 " eKey:%" PRId64 + tsdbError("vgId:%d, delete data from table suid:%" PRId64 " uid:%" PRId64 " skey:%" PRId64 " eKey:%" PRId64 " since %s", TD_VID(pTsdb->pVnode), suid, uid, sKey, eKey, tstrerror(code)); return code; _err: - tsdbError("vgId:%d failed to delete data from table suid:%" PRId64 " uid:%" PRId64 " skey:%" PRId64 " eKey:%" PRId64 + tsdbError("vgId:%d, failed to delete data from table suid:%" PRId64 " uid:%" PRId64 " skey:%" PRId64 " eKey:%" PRId64 " since %s", TD_VID(pTsdb->pVnode), suid, uid, sKey, eKey, tstrerror(code)); return code; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 51ed739693..ab2efa4791 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -225,6 +225,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("message in fetch queue is processing"); char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); + switch (pMsg->msgType) { case TDMT_VND_FETCH: return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg, 0); @@ -236,13 +237,10 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_VND_QUERY_HEARTBEAT: return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0); - case TDMT_VND_TABLE_META: return vnodeGetTableMeta(pVnode, pMsg); - case TDMT_VND_CONSUME: return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId); - case TDMT_STREAM_TASK_RUN: return tqProcessTaskRunReq(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_DISPATCH: @@ -279,7 +277,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, int64_t version, SRpcMsg *pMsg, SRp void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { // TODO - // blockDebugShowData(data); + // blockDebugShowData(data, __func__); tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } @@ -795,7 +793,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq msgIter.suid = 0; } +#ifdef TD_DEBUG_PRINT_ROW vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid"); +#endif tDecoderClear(&decoder); } else { submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN); diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 3b8c94e413..0161fac9b5 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -373,7 +373,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pTsdb->pTfs = tfsOpen(&pDisks, numOfDisks); EXPECT_NE(pTsdb->pTfs, nullptr); - // generate SSubmitReq msg and update expired window + // generate SSubmitReq msg and update expire window int16_t schemaVer = 0; uint32_t mockRowLen = sizeof(STSRow); uint32_t mockRowNum = 2; diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index b4308c37c2..424494bf6f 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -211,7 +211,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo SExplainResNode *pResNode = NULL; FOREACH(node, pPhysiChildren) { QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode)); - QRY_ERR_RET(nodesListAppend(*pChildren, pResNode)); + QRY_ERR_RET(nodesListAppend(*pChildren, (SNode*)pResNode)); } return TSDB_CODE_SUCCESS; @@ -715,7 +715,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, "Sort Key: "); if (pResNode->pExecInfo) { for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) { - SOrderByExprNode *ptn = nodesListGetNode(pSortNode->pSortKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pSortNode->pSortKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } } @@ -1045,7 +1045,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT); for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { - SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } EXPLAIN_ROW_END(); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 8110df3090..265f968d24 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -458,7 +458,6 @@ typedef struct STimeWindowSupp { int64_t waterMark; TSKEY maxTs; SColumnInfoData timeWindowData; // query time window info for scalar function execution. - SHashObj *winMap; } STimeWindowAggSupp; typedef struct SIntervalAggOperatorInfo { @@ -760,7 +759,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scan int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); void doSetOperatorCompleted(SOperatorInfo* pOperator); -void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree); +void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset); void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols); void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow); @@ -908,8 +907,6 @@ SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows, int32_t start, int64_t gap, SHashObj* pStDeleted); bool functionNeedToExecute(SqlFunctionCtx* pCtx); -int64_t getSmaWaterMark(int64_t interval, double filesFactor); -bool isSmaStream(int8_t triggerType); int32_t compareTimeWindow(const void* p1, const void* p2, const void* param); int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 726be6d0a2..a0cd93a1cd 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -202,7 +202,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData idata = {{0}}; - SSlotDescNode* pDescNode = nodesListGetNode(pNode->pSlots, i); + SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); // if (!pDescNode->output) { // todo disable it temporarily // continue; // } @@ -1819,9 +1819,9 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO } } -static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep, bool needFree); +static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep); -void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree) { +void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { if (pFilterNode == NULL) { return; } @@ -1840,30 +1840,29 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree) { bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols); filterFreeInfo(filter); - extractQualifiedTupleByFilterResult(pBlock, rowRes, keep, needFree); + extractQualifiedTupleByFilterResult(pBlock, rowRes, keep); blockDataUpdateTsWindow(pBlock, 0); } -void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep, bool needFree) { +void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) { if (keep) { return; } if (rowRes != NULL) { - SSDataBlock* px = createOneDataBlock(pBlock, false); - blockDataEnsureCapacity(px, pBlock->info.rows); + SSDataBlock* px = createOneDataBlock(pBlock, true); int32_t totalRows = pBlock->info.rows; - for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { - SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i); - SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i); - + SColumnInfoData* pSrc = taosArrayGet(px->pDataBlock, i); + SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i); // it is a reserved column for scalar function, and no data in this column yet. - if (pSrc->pData == NULL) { + if (pDst->pData == NULL) { continue; } + colInfoDataCleanup(pDst, pBlock->info.rows); + int32_t numOfRows = 0; for (int32_t j = 0; j < totalRows; ++j) { if (rowRes[j] == 0) { @@ -1883,20 +1882,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } else { ASSERT(pBlock->info.rows == numOfRows); } - - SColumnInfoData tmp = *pSrc; - *pSrc = *pDst; - *pDst = tmp; - - if (!needFree) { - if (IS_VAR_DATA_TYPE(pDst->info.type)) { // this elements do not need free - pDst->varmeta.offset = NULL; - } else { - pDst->nullbitmap = NULL; - } - pDst->pData = NULL; - } } + blockDataDestroy(px); // fix memory leak } else { // do nothing @@ -2137,11 +2124,6 @@ static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows, } int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t capacity) { - // for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { - // SColumnInfoData* pColInfoData = taosArrayGet(pOutput->pDataBlock, i); - // p[i] = pColInfoData->pData + (pColInfoData->info.bytes * pOutput->info.rows); - // } - int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, pBlock, capacity - pBlock->info.rows); pBlock->info.rows += numOfRows; @@ -2896,7 +2878,6 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) { return seqLoadRemoteData(pOperator); } else { return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo); - // return concurrentlyLoadRemoteData(pOperator); } } @@ -2922,9 +2903,14 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) { return TSDB_CODE_SUCCESS; } -static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* pInfo) { +static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* pInfo, const char* id) { size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints); + if (numOfSources == 0) { + qError("%s invalid number: %d of sources in exchange operator", id, (int32_t) numOfSources); + return TSDB_CODE_INVALID_PARA; + } + pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode)); pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo)); if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) { @@ -2932,7 +2918,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* } for (int32_t i = 0; i < numOfSources; ++i) { - SNodeListNode* pNode = nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); + SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); taosArrayPush(pInfo->pSources, pNode); } @@ -2946,7 +2932,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode goto _error; } - int32_t code = initExchangeOperator(pExNode, pInfo); + int32_t code = initExchangeOperator(pExNode, pInfo, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -2975,7 +2961,7 @@ _error: taosMemoryFreeClear(pInfo); taosMemoryFreeClear(pOperator); - pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + pTaskInfo->code = code; return NULL; } @@ -3744,7 +3730,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { longjmp(pTaskInfo->env, code); } - doFilter(pProjectInfo->pFilterNode, pBlock, true); + doFilter(pProjectInfo->pFilterNode, pBlock); setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order, scanFlag, false); blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows); @@ -4506,7 +4492,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* if (NULL == res) { // todo handle error } else { res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; - nodesListAppend(pFuncNode->pParameterList, res); + nodesListAppend(pFuncNode->pParameterList, (SNode*)res); } } #endif @@ -4722,18 +4708,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .waterMark = pIntervalPhyNode->window.watermark, .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, - .winMap = NULL, }; - if (isSmaStream(pIntervalPhyNode->window.triggerType)) { - if (FLT_LESS(pIntervalPhyNode->window.filesFactor, 1.000000)) { - as.calTrigger = STREAM_TRIGGER_AT_ONCE_SMA; - } else { - _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP); - as.winMap = taosHashInit(64, hashFn, true, HASH_NO_LOCK); - as.waterMark = getSmaWaterMark(interval.interval, pIntervalPhyNode->window.filesFactor); - as.calTrigger = STREAM_TRIGGER_WINDOW_CLOSE_SMA; - } - } int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; bool isStream = (QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type); @@ -5274,7 +5249,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead (*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoList, pPlan->pTagCond); if (NULL == (*pTaskInfo)->pRoot) { - code = terrno; + code = (*pTaskInfo)->code; goto _complete; } @@ -5287,7 +5262,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead _complete: taosMemoryFreeClear(*pTaskInfo); - terrno = code; return code; } @@ -5446,16 +5420,3 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlF return code; } -int64_t getSmaWaterMark(int64_t interval, double filesFactor) { - int64_t waterMark = 0; - ASSERT(FLT_GREATEREQUAL(filesFactor, 0.000000)); - waterMark = -1 * filesFactor; - return waterMark; -} - -bool isSmaStream(int8_t triggerType) { - if (triggerType == STREAM_TRIGGER_AT_ONCE || triggerType == STREAM_TRIGGER_WINDOW_CLOSE) { - return false; - } - return true; -} diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 5965f5d7ad..132f93a6a5 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -359,7 +359,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) { while(1) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); - doFilter(pInfo->pCondition, pRes, true); + doFilter(pInfo->pCondition, pRes); bool hasRemain = hashRemainDataInGroupInfo(&pInfo->groupResInfo); if (!hasRemain) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 6387802303..b5f8ad0ae2 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -267,7 +267,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca } int64_t st = taosGetTimestampMs(); - doFilter(pTableScanInfo->pFilterNode, pBlock, false); + doFilter(pTableScanInfo->pFilterNode, pBlock); int64_t et = taosGetTimestampMs(); pTableScanInfo->readRecorder.filterTime += (et - st); @@ -948,7 +948,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes); } - doFilter(pInfo->pCondition, pInfo->pRes, false); + doFilter(pInfo->pCondition, pInfo->pRes); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); break; } @@ -1028,10 +1028,6 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan goto _error; } - if (isSmaStream(pTableScanNode->triggerType)) { - pTwSup->waterMark = getSmaWaterMark(pSTInfo->interval.interval, pTableScanNode->filesFactor); - } - if (pSTInfo->interval.interval > 0 && pDataReader) { pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark); } else { @@ -1720,7 +1716,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { } pRes->info.rows = count; - doFilter(pInfo->pFilterNode, pRes, true); + doFilter(pInfo->pFilterNode, pRes); pOperator->resultInfo.totalRows += pRes->info.rows; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index dcaa95e28a..ff093741fa 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -296,7 +296,10 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { } SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, - SArray* pColMatchInfo, SMultiwaySortMergeOperatorInfo* pInfo) { + SArray* pColMatchInfo, SOperatorInfo* pOperator) { + SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + blockDataCleanup(pDataBlock); SSDataBlock* p = tsortGetSortedDataBlock(pHandle); @@ -354,6 +357,8 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData } blockDataDestroy(p); + + qDebug("%s get sorted row blocks, rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.rows); return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; } @@ -371,7 +376,7 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { } SSDataBlock* pBlock = getMultiwaySortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, - pOperator->resultInfo.capacity, pInfo->pColMatchInfo, pInfo); + pOperator->resultInfo.capacity, pInfo->pColMatchInfo, pOperator); if (pBlock != NULL) { pOperator->resultInfo.totalRows += pBlock->info.rows; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index c1c504a400..82954d20da 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -750,14 +750,15 @@ int64_t getReskey(void* data, int32_t index) { return *(int64_t*)pos->key; } -static int32_t saveResult(SResultRow* result, uint64_t groupId, SArray* pUpdated) { +static int32_t saveResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, + SArray* pUpdated) { int32_t size = taosArrayGetSize(pUpdated); - int32_t index = binarySearch(pUpdated, size, result->win.skey, TSDB_ORDER_DESC, getReskey); + int32_t index = binarySearch(pUpdated, size, ts, TSDB_ORDER_DESC, getReskey); if (index == -1) { index = 0; } else { TSKEY resTs = getReskey(pUpdated, index); - if (resTs < result->win.skey) { + if (resTs < ts) { index++; } else { return TSDB_CODE_SUCCESS; @@ -769,14 +770,18 @@ static int32_t saveResult(SResultRow* result, uint64_t groupId, SArray* pUpdated return TSDB_CODE_OUT_OF_MEMORY; } newPos->groupId = groupId; - newPos->pos = (SResultRowPosition){.pageId = result->pageId, .offset = result->offset}; - *(int64_t*)newPos->key = result->win.skey; + newPos->pos = (SResultRowPosition){.pageId = pageId, .offset = offset}; + *(int64_t*)newPos->key = ts; if (taosArrayInsert(pUpdated, index, &newPos) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } return TSDB_CODE_SUCCESS; } +static int32_t saveResultRow(SResultRow* result, uint64_t groupId, SArray* pUpdated) { + return saveResult(result->win.skey, result->pageId, result->offset, groupId, pUpdated); +} + static void removeResult(SArray* pUpdated, TSKEY key) { int32_t size = taosArrayGetSize(pUpdated); int32_t index = binarySearch(pUpdated, size, key, TSDB_ORDER_DESC, getReskey); @@ -818,12 +823,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE || - pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE_SMA) { - saveResult(pResult, tableGroupId, pUpdated); - } - if (pInfo->twAggSup.winMap) { - taosHashRemove(pInfo->twAggSup.winMap, &win.skey, sizeof(TSKEY)); + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { + saveResultRow(pResult, tableGroupId, pUpdated); } } @@ -872,12 +873,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE || - pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE_SMA) { - saveResult(pResult, tableGroupId, pUpdated); - } - if (pInfo->twAggSup.winMap) { - taosHashRemove(pInfo->twAggSup.winMap, &win.skey, sizeof(TSKEY)); + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { + saveResultRow(pResult, tableGroupId, pUpdated); } } @@ -1251,6 +1248,23 @@ static void doClearWindows(SAggSupporter* pSup, SOptrBasicInfo* pBinfo, SInterva } } +static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) { + void* pIte = NULL; + size_t keyLen = 0; + while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { + void* key = taosHashGetKey(pIte, &keyLen); + uint64_t groupId = *(uint64_t*)key; + ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))); + TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); + SResultRowPosition* pPos = (SResultRowPosition*)pIte; + int32_t code = saveResult(ts, pPos->pageId, pPos->offset, groupId, resWins); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + return TSDB_CODE_SUCCESS; +} + static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval, SArray* closeWins) { void* pIte = NULL; @@ -1264,28 +1278,16 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, pInterval->precision, NULL); if (win.ekey < pSup->maxTs - pSup->waterMark) { - if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE_SMA) { - if (taosHashGet(pSup->winMap, &win.skey, sizeof(TSKEY))) { - continue; - } - } char keyBuf[GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))]; SET_RES_WINDOW_KEY(keyBuf, &ts, sizeof(TSKEY), groupId); - if (pSup->calTrigger != STREAM_TRIGGER_AT_ONCE_SMA && pSup->calTrigger != STREAM_TRIGGER_WINDOW_CLOSE_SMA) { - taosHashRemove(pHashMap, keyBuf, keyLen); + taosHashRemove(pHashMap, keyBuf, keyLen); + SResultRowPosition* pPos = (SResultRowPosition*)pIte; + if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + int32_t code = saveResult(ts, pPos->pageId, pPos->offset, groupId, closeWins); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } - SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t)); - if (pos == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pos->groupId = groupId; - pos->pos = *(SResultRowPosition*)pIte; - *(int64_t*)pos->key = ts; - if (!taosArrayPush(closeWins, &pos)) { - taosMemoryFree(pos); - return TSDB_CODE_OUT_OF_MEMORY; - } - taosHashPut(pSup->winMap, &win.skey, sizeof(TSKEY), NULL, 0); } } return TSDB_CODE_SUCCESS; @@ -1312,8 +1314,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { SOperatorInfo* downstream = pOperator->pDownstream[0]; SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); - SArray* pClosed = taosArrayInit(4, POINTER_BYTES); - while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -1332,22 +1332,18 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval, 0, pOperator->numOfExprs, pBlock, NULL); qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo)); continue; + } else if (pBlock->info.type == STREAM_GET_ALL && + pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) { + getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated); + continue; } pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated); } + closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pUpdated); - closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pClosed); - finalizeUpdatedResult(pOperator->numOfExprs, pInfo->aggSup.pResultBuf, pClosed, pInfo->binfo.rowCellInfoOffset); - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE || - pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE_SMA) { - taosArrayAddAll(pUpdated, pClosed); - } - - taosArrayDestroy(pClosed); finalizeUpdatedResult(pOperator->numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset); - initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); @@ -1382,7 +1378,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChildOp); } } - nodesDestroyNode(pInfo->pPhyNode); + nodesDestroyNode((SNode*)pInfo->pPhyNode); } static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) { @@ -1917,7 +1913,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdated) { - saveResult(pResult, tableGroupId, pUpdated); + saveResultRow(pResult, tableGroupId, pUpdated); } // window start(end) key interpolation // doWindowBorderInterpolation(pInfo, pSDataBlock, numOfOutput, pInfo->binfo.pCtx, pResult, &nextWin, startPos, @@ -2012,7 +2008,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info; SOperatorInfo* downstream = pOperator->pDownstream[0]; SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); - SArray* pClosed = taosArrayInit(4, POINTER_BYTES); if (pOperator->status == OP_EXEC_DONE) { return NULL; @@ -2061,7 +2056,12 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { copyUpdateDataBlock(pInfo->pUpdateRes, pBlock, pInfo->primaryTsIndex); taosArrayDestroy(pUpWins); break; + } else if (pBlock->info.type == STREAM_GET_ALL && isFinalInterval(pInfo) && + pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) { + getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated); + continue; } + if (isFinalInterval(pInfo)) { int32_t chIndex = getChildIndex(pBlock); int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -2083,13 +2083,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } if (isFinalInterval(pInfo)) { - closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pClosed); - finalizeUpdatedResult(pOperator->numOfExprs, pInfo->aggSup.pResultBuf, pClosed, pInfo->binfo.rowCellInfoOffset); - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { - taosArrayAddAll(pUpdated, pClosed); - } + closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pUpdated); } - taosArrayDestroy(pClosed); finalizeUpdatedResult(pOperator->numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); @@ -2127,7 +2122,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, .waterMark = pIntervalPhyNode->window.watermark, .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, - .winMap = NULL, }; pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; @@ -2163,7 +2157,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pUpdateRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); pInfo->pUpdateRes->info.type = STREAM_REPROCESS; blockDataEnsureCapacity(pInfo->pUpdateRes, 128); - pInfo->pPhyNode = nodesCloneNode(pPhyNode); + pInfo->pPhyNode = (SPhysiNode*)nodesCloneNode((SNode*)pPhyNode); pOperator->name = "StreamFinalIntervalOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; @@ -2655,8 +2649,8 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*); SResultWindowInfo* getSessionWinInfo(void* pData) { return (SResultWindowInfo*)pData; } SResultWindowInfo* getStateWinInfo(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; } -int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pClosed, int8_t calTrigger, - __get_win_info_ fn) { +int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pClosed, + __get_win_info_ fn) { // Todo(liuyao) save window to tdb int32_t size = taosArrayGetSize(pWins); for (int32_t i = 0; i < size; i++) { @@ -2664,19 +2658,9 @@ int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pC SResultWindowInfo* pSeWin = fn(pWin); if (pSeWin->win.ekey < pTwSup->maxTs - pTwSup->waterMark) { if (!pSeWin->isClosed) { - SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t)); - if (pos == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pos->groupId = 0; - pos->pos = pSeWin->pos; - *(int64_t*)pos->key = pSeWin->win.ekey; - if (!taosArrayPush(pClosed, &pos)) { - taosMemoryFree(pos); - return TSDB_CODE_OUT_OF_MEMORY; - } pSeWin->isClosed = true; - if (calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + int32_t code = saveResult(pSeWin->win.skey, pSeWin->pos.pageId, pSeWin->pos.offset, 0, pClosed); pSeWin->isOutput = true; } } @@ -2687,6 +2671,19 @@ int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pC return TSDB_CODE_SUCCESS; } +int32_t getAllSessionWindow(SArray* pWins, SArray* pClosed, __get_win_info_ fn) { + int32_t size = taosArrayGetSize(pWins); + for (int32_t i = 0; i < size; i++) { + void* pWin = taosArrayGet(pWins, i); + SResultWindowInfo* pSeWin = fn(pWin); + if (!pSeWin->isClosed) { + int32_t code = saveResult(pSeWin->win.skey, pSeWin->pos.pageId, pSeWin->pos.offset, 0, pClosed); + pSeWin->isOutput = true; + } + } + return TSDB_CODE_SUCCESS; +} + static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { if (pOperator->status == OP_EXEC_DONE) { return NULL; @@ -2709,6 +2706,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pStUpdated = taosHashInit(64, hashFn, true, HASH_NO_LOCK); SOperatorInfo* downstream = pOperator->pDownstream[0]; + SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -2729,7 +2727,12 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } taosArrayDestroy(pWins); continue; + } else if (pBlock->info.type == STREAM_GET_ALL && + pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) { + getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getSessionWinInfo); + continue; } + if (isFinalSession(pInfo)) { int32_t childIndex = 0; // Todo(liuyao) get child id from SSDataBlock SOptrBasicInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); @@ -2741,15 +2744,10 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - SArray* pClosed = taosArrayInit(16, POINTER_BYTES); - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pClosed, pInfo->twAggSup.calTrigger, + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getSessionWinInfo); - SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); copyUpdateResult(pStUpdated, pUpdated, pBInfo->pRes->info.groupId); taosHashCleanup(pStUpdated); - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { - taosArrayAddAll(pUpdated, pClosed); - } finalizeUpdatedResult(pOperator->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset); @@ -3073,6 +3071,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pSeUpdated = taosHashInit(64, hashFn, true, HASH_NO_LOCK); SOperatorInfo* downstream = pOperator->pDownstream[0]; + SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -3084,6 +3083,10 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { doClearStateWindows(&pInfo->streamAggSup, pBlock, pInfo->primaryTsIndex, &pInfo->stateCol, pInfo->stateCol.slotId, pSeUpdated, pInfo->pSeDeleted); continue; + } else if (pBlock->info.type == STREAM_GET_ALL && + pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) { + getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getStateWinInfo); + continue; } doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); @@ -3091,15 +3094,10 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - SArray* pClosed = taosArrayInit(16, POINTER_BYTES); - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pClosed, pInfo->twAggSup.calTrigger, + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getStateWinInfo); - SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); copyUpdateResult(pSeUpdated, pUpdated, pBInfo->pRes->info.groupId); taosHashCleanup(pSeUpdated); - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { - taosArrayAddAll(pUpdated, pClosed); - } finalizeUpdatedResult(pOperator->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset); @@ -3141,7 +3139,6 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys .waterMark = pStateNode->window.watermark, .calTrigger = pStateNode->window.triggerType, .maxTs = INT64_MIN, - .winMap = NULL, }; initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index ea8ded2c30..f63a9351c6 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -227,6 +227,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { SSortSource* pSource = cmpParam->pSources[i]; pSource->src.pBlock = pHandle->fetchfp(pSource->param); + + // set current source id done if (pSource->src.pBlock == NULL) { pSource->src.rowIndex = -1; ++pHandle->numOfCompletedSources; @@ -426,8 +428,16 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { double sortPass = floorl(log2(numOfSources) / log2(pHandle->numOfPages)); pHandle->totalElapsed = taosGetTimestampUs() - pHandle->startTs; - qDebug("%s %d rounds mergesort required to complete the sort, first-round sorted data size:%"PRIzu", sort elapsed:%"PRId64", total elapsed:%"PRId64, - pHandle->idStr, (int32_t) (sortPass + 1), pHandle->pBuf ? getTotalBufSize(pHandle->pBuf) : 0, pHandle->sortElapsed, pHandle->totalElapsed); + + if (sortPass > 0) { + size_t s = pHandle->pBuf ? getTotalBufSize(pHandle->pBuf) : 0; + qDebug("%s %d rounds mergesort required to complete the sort, first-round sorted data size:%" PRIzu + ", sort elapsed:%" PRId64 ", total elapsed:%" PRId64, + pHandle->idStr, (int32_t)(sortPass + 1), s, pHandle->sortElapsed, pHandle->totalElapsed); + } else { + qDebug("%s ordered source:%"PRIzu", available buf:%d, no need internal sort", pHandle->idStr, numOfSources, + pHandle->numOfPages); + } int32_t numOfRows = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize); blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index b623c77110..8274a33eb1 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -112,6 +112,7 @@ int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx); int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t spreadPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getSpreadInfoSize(); +int32_t spreadCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); bool getElapsedFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool elapsedFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); @@ -120,6 +121,7 @@ int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx); int32_t elapsedFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t elapsedPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getElapsedInfoSize(); +int32_t elapsedCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); bool getHistogramFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); @@ -128,6 +130,7 @@ int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx); int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getHistogramInfoSize(); +int32_t histogramCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); bool getHLLFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t hllFunction(SqlFunctionCtx* pCtx); @@ -135,6 +138,7 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx); int32_t hllFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t hllPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getHLLInfoSize(); +int32_t hllCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 2d6c95c5f2..0961ff1cbd 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1220,7 +1220,7 @@ void static addTimezoneParam(SNodeList* pList) { varDataSetLen(pVal->datum.p, len); strncpy(varDataVal(pVal->datum.p), pVal->literal, len); - nodesListAppend(pList, pVal); + nodesListAppend(pList, (SNode*)pVal); } static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { @@ -1309,7 +1309,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - SExprNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + SExprNode* pPara = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); if (QUERY_NODE_VALUE != nodeType(pPara) || (!IS_VAR_DATA_TYPE(pPara->resType.type))) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1450,6 +1450,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = apercentileFunctionSetup, .processFunc = apercentileFunction, .finalizeFunc = apercentileFinalize, + .invertFunc = NULL, .combineFunc = apercentileCombine, .pPartialFunc = "_apercentile_partial", .pMergeFunc = "_apercentile_merge" @@ -1462,7 +1463,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getApercentileFuncEnv, .initFunc = apercentileFunctionSetup, .processFunc = apercentileFunction, - .finalizeFunc = apercentilePartialFinalize + .finalizeFunc = apercentilePartialFinalize, + .invertFunc = NULL, + .combineFunc = apercentileCombine, }, { .name = "_apercentile_merge", @@ -1472,7 +1475,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getApercentileFuncEnv, .initFunc = functionSetup, .processFunc = apercentileFunctionMerge, - .finalizeFunc = apercentileFinalize + .finalizeFunc = apercentileFinalize, + .invertFunc = NULL, + .combineFunc = apercentileCombine, }, { .name = "top", @@ -1506,6 +1511,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = spreadFunctionSetup, .processFunc = spreadFunction, .finalizeFunc = spreadFinalize, + .invertFunc = NULL, + .combineFunc = spreadCombine, .pPartialFunc = "_spread_partial", .pMergeFunc = "_spread_merge" }, @@ -1518,7 +1525,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getSpreadFuncEnv, .initFunc = spreadFunctionSetup, .processFunc = spreadFunction, - .finalizeFunc = spreadPartialFinalize + .finalizeFunc = spreadPartialFinalize, + .invertFunc = NULL, + .combineFunc = spreadCombine, }, { .name = "_spread_merge", @@ -1529,7 +1538,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getSpreadFuncEnv, .initFunc = spreadFunctionSetup, .processFunc = spreadFunctionMerge, - .finalizeFunc = spreadFinalize + .finalizeFunc = spreadFinalize, + .invertFunc = NULL, + .combineFunc = spreadCombine, }, { .name = "elapsed", @@ -1541,6 +1552,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = elapsedFunctionSetup, .processFunc = elapsedFunction, .finalizeFunc = elapsedFinalize, + .invertFunc = NULL, + .combineFunc = elapsedCombine, .pPartialFunc = "_elapsed_partial", .pMergeFunc = "_elapsed_merge" }, @@ -1553,7 +1566,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getElapsedFuncEnv, .initFunc = elapsedFunctionSetup, .processFunc = elapsedFunction, - .finalizeFunc = elapsedPartialFinalize + .finalizeFunc = elapsedPartialFinalize, + .invertFunc = NULL, + .combineFunc = elapsedCombine, }, { .name = "_elapsed_merge", @@ -1564,7 +1579,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getElapsedFuncEnv, .initFunc = elapsedFunctionSetup, .processFunc = elapsedFunctionMerge, - .finalizeFunc = elapsedFinalize + .finalizeFunc = elapsedFinalize, + .invertFunc = NULL, + .combineFunc = elapsedCombine, }, { .name = "last_row", @@ -1617,8 +1634,10 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = histogramFunctionSetup, .processFunc = histogramFunction, .finalizeFunc = histogramFinalize, + .invertFunc = NULL, + .combineFunc = histogramCombine, .pPartialFunc = "_histogram_partial", - .pMergeFunc = "_histogram_merge" + .pMergeFunc = "_histogram_merge", }, { .name = "_histogram_partial", @@ -1628,7 +1647,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getHistogramFuncEnv, .initFunc = histogramFunctionSetup, .processFunc = histogramFunction, - .finalizeFunc = histogramPartialFinalize + .finalizeFunc = histogramPartialFinalize, + .invertFunc = NULL, + .combineFunc = histogramCombine, }, { .name = "_histogram_merge", @@ -1638,7 +1659,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getHistogramFuncEnv, .initFunc = functionSetup, .processFunc = histogramFunctionMerge, - .finalizeFunc = histogramFinalize + .finalizeFunc = histogramFinalize, + .invertFunc = NULL, + .combineFunc = histogramCombine, }, { .name = "hyperloglog", @@ -1649,6 +1672,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = functionSetup, .processFunc = hllFunction, .finalizeFunc = hllFinalize, + .invertFunc = NULL, + .combineFunc = hllCombine, .pPartialFunc = "_hyperloglog_partial", .pMergeFunc = "_hyperloglog_merge" }, @@ -1660,7 +1685,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getHLLFuncEnv, .initFunc = functionSetup, .processFunc = hllFunction, - .finalizeFunc = hllPartialFinalize + .finalizeFunc = hllPartialFinalize, + .invertFunc = NULL, + .combineFunc = hllCombine, }, { .name = "_hyperloglog_merge", @@ -1670,7 +1697,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getHLLFuncEnv, .initFunc = functionSetup, .processFunc = hllFunctionMerge, - .finalizeFunc = hllFinalize + .finalizeFunc = hllFinalize, + .invertFunc = NULL, + .combineFunc = hllCombine, }, { .name = "diff", diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index ff838eb9c9..fb2d119229 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -142,10 +142,8 @@ typedef struct SElapsedInfo { typedef struct SHistoFuncBin { double lower; double upper; - union { - int64_t count; - double percentage; - }; + int64_t count; + double percentage; } SHistoFuncBin; typedef struct SHistoFuncInfo { @@ -2227,7 +2225,6 @@ int32_t apercentilePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SAPercentileInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SAPercentileInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); @@ -2245,13 +2242,13 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) } bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - SColumnNode* pNode = nodesListGetNode(pFunc->pParameterList, 0); + SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); pEnv->calcMemSize = pNode->node.resType.bytes + sizeof(int64_t); return true; } bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - SColumnNode* pNode = nodesListGetNode(pFunc->pParameterList, 0); + SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); pEnv->calcMemSize = pNode->node.resType.bytes; return true; } @@ -2845,6 +2842,7 @@ void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS for (int32_t i = 0; i < pSrcBlock->info.numOfCols; ++i) { SColumnInfoData* pCol = taosArrayGet(pSrcBlock->pDataBlock, i); if ((nullList[i] = colDataIsNull_s(pCol, rowIndex)) == true) { + offset += pCol->info.bytes; continue; } @@ -3100,6 +3098,17 @@ int32_t spreadPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } +int32_t spreadCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { + SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); + SSpreadInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + + SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); + SSpreadInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + spreadTransferInfo(pSBuf, pDBuf); + pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); + return TSDB_CODE_SUCCESS; +} + int32_t getElapsedInfoSize() { return (int32_t)sizeof(SElapsedInfo); } @@ -3259,6 +3268,18 @@ int32_t elapsedPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } +int32_t elapsedCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { + SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); + SElapsedInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + + SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); + SElapsedInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + + elapsedTransferInfo(pSBuf, pDBuf); + pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); + return TSDB_CODE_SUCCESS; +} + int32_t getHistogramInfoSize() { return (int32_t)sizeof(SHistoFuncInfo) + HISTOGRAM_MAX_BINS_NUM * sizeof(SHistoFuncBin); } @@ -3554,6 +3575,18 @@ int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return 1; } +int32_t histogramCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { + SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); + SHistoFuncInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + + SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); + SHistoFuncInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + + histogramTransferInfo(pSBuf, pDBuf); + pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); + return TSDB_CODE_SUCCESS; +} + int32_t getHLLInfoSize() { return (int32_t)sizeof(SHLLInfo); } @@ -3738,6 +3771,18 @@ int32_t hllPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } +int32_t hllCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { + SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); + SHLLInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + + SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); + SHLLInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + + hllTransferInfo(pSBuf, pDBuf); + pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); + return TSDB_CODE_SUCCESS; +} + bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SStateInfo); return true; @@ -4141,6 +4186,8 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; + int32_t alreadySampled = pInfo->numSampled; + int32_t startOffset = pCtx->offset; for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_s(pInputCol, i)) { diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index df09d3e529..81cd29fc54 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -218,7 +218,7 @@ static int32_t getFuncInfo(SFunctionNode* pFunc) { } static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return NULL; } @@ -226,14 +226,14 @@ static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterLis pFunc->pParameterList = pParameterList; if (TSDB_CODE_SUCCESS != getFuncInfo(pFunc)) { pFunc->pParameterList = NULL; - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return NULL; } return pFunc; } static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -270,7 +270,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc, SFunctionNode** pMergeFunc) { SNodeList* pParameterList = NULL; - nodesListMakeStrictAppend(&pParameterList, createColumnByFunc(pPartialFunc)); + nodesListMakeStrictAppend(&pParameterList, (SNode*)createColumnByFunc(pPartialFunc)); *pMergeFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList); if (NULL == *pMergeFunc) { nodesDestroyList(pParameterList); @@ -291,8 +291,8 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(*pPartialFunc); - nodesDestroyNode(*pMergeFunc); + nodesDestroyNode((SNode*)*pPartialFunc); + nodesDestroyNode((SNode*)*pMergeFunc); } return code; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 7e6a1f5e0c..1ef0ccf7f9 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -40,6 +40,10 @@ break; \ } \ (pDst)->fldname = strdup((pSrc)->fldname); \ + if (NULL == (pDst)->fldname) { \ + nodesDestroyNode((SNode*)pDst); \ + return NULL; \ + } \ } while (0) #define CLONE_NODE_FIELD(fldname) \ @@ -49,11 +53,23 @@ } \ (pDst)->fldname = nodesCloneNode((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) +#define CLONE_NODE_FIELD_EX(fldname, nodePtrType) \ + do { \ + if (NULL == (pSrc)->fldname) { \ + break; \ + } \ + (pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \ + if (NULL == (pDst)->fldname) { \ + nodesDestroyNode((SNode*)pDst); \ + return NULL; \ + } \ + } while (0) + #define CLONE_NODE_LIST_FIELD(fldname) \ do { \ if (NULL == (pSrc)->fldname) { \ @@ -61,7 +77,7 @@ } \ (pDst)->fldname = nodesCloneList((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -73,7 +89,7 @@ } \ (pDst)->fldname = cloneFunc((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -81,6 +97,7 @@ #define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ do { \ if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -147,7 +164,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = varDataTLen(pSrc->datum.p) + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - nodesDestroyNode(pDst); + nodesDestroyNode((SNode*)pDst); return NULL; } memcpy(pDst->datum.p, pSrc->datum.p, len); @@ -275,8 +292,8 @@ static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode } static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { - CLONE_NODE_FIELD(pCol); - CLONE_NODE_FIELD(pGap); + CLONE_NODE_FIELD_EX(pCol, SColumnNode*); + CLONE_NODE_FIELD_EX(pGap, SValueNode*); return (SNode*)pDst; } @@ -442,7 +459,7 @@ static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndef static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { COPY_OBJECT_FIELD(id, sizeof(SSubplanId)); - CLONE_NODE_FIELD(pNode); + CLONE_NODE_FIELD_EX(pNode, SLogicNode*); COPY_SCALAR_FIELD(subplanType); COPY_SCALAR_FIELD(level); COPY_SCALAR_FIELD(splitFlag); @@ -450,7 +467,7 @@ static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { } static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { - CLONE_NODE_FIELD(pOutputDataBlockDesc); + CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); return (SNode*)pDst; @@ -555,8 +572,8 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { CLONE_NODE_LIST_FIELD(pGroupByList); CLONE_NODE_FIELD(pHaving); CLONE_NODE_LIST_FIELD(pOrderByList); - CLONE_NODE_FIELD(pLimit); - CLONE_NODE_FIELD(pLimit); + CLONE_NODE_FIELD_EX(pLimit, SLimitNode*); + CLONE_NODE_FIELD_EX(pLimit, SLimitNode*); COPY_CHAR_ARRAY_FIELD(stmtName); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(isEmptyResult); @@ -566,7 +583,7 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { return (SNode*)pDst; } -SNodeptr nodesCloneNode(const SNodeptr pNode) { +SNode* nodesCloneNode(const SNode* pNode) { if (NULL == pNode) { return NULL; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index f7e65f100a..be1929d554 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4205,7 +4205,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p return makeNodeByJson(pJsonNode, pNode); } -int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) { +int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen) { if (NULL == pNode || NULL == pStr) { terrno = TSDB_CODE_FAILED; return TSDB_CODE_FAILED; diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 9887cbdbc5..681e99a452 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -137,7 +137,7 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) { return true; } -bool nodesEqualNode(const SNodeptr a, const SNodeptr b) { +bool nodesEqualNode(const SNode* a, const SNode* b) { if (a == b) { return true; } diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index d8130d5650..1fb2db9f23 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -168,7 +168,7 @@ static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalk return DEAL_RES_CONTINUE; } -void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext) { +void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext) { (void)walkExpr(pNode, TRAVERSAL_PREORDER, walker, pContext); } @@ -176,7 +176,7 @@ void nodesWalkExprs(SNodeList* pNodeList, FNodeWalker walker, void* pContext) { (void)walkExprs(pNodeList, TRAVERSAL_PREORDER, walker, pContext); } -void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext) { +void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext) { (void)walkExpr(pNode, TRAVERSAL_POSTORDER, walker, pContext); } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index bae014911c..72666f833d 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -30,7 +30,7 @@ static SNode* makeNode(ENodeType type, size_t size) { return p; } -SNodeptr nodesMakeNode(ENodeType type) { +SNode* nodesMakeNode(ENodeType type) { switch (type) { case QUERY_NODE_COLUMN: return makeNode(type, sizeof(SColumnNode)); @@ -327,7 +327,7 @@ static void destroyLogicNode(SLogicNode* pNode) { static void destroyPhysiNode(SPhysiNode* pNode) { nodesDestroyList(pNode->pChildren); nodesDestroyNode(pNode->pConditions); - nodesDestroyNode(pNode->pOutputDataBlockDesc); + nodesDestroyNode((SNode*)pNode->pOutputDataBlockDesc); } static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) { @@ -342,9 +342,9 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) { nodesDestroyList(pNode->pScanCols); } -static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode(pNode->pInputDataBlockDesc); } +static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); } -void nodesDestroyNode(SNodeptr pNode) { +void nodesDestroyNode(SNode* pNode) { if (NULL == pNode) { return; } @@ -401,8 +401,8 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_SESSION_WINDOW: { SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; - nodesDestroyNode(pSession->pCol); - nodesDestroyNode(pSession->pGap); + nodesDestroyNode((SNode*)pSession->pCol); + nodesDestroyNode((SNode*)pSession->pGap); break; } case QUERY_NODE_INTERVAL_WINDOW: { @@ -438,7 +438,7 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_DATABASE_OPTIONS: { SDatabaseOptions* pOptions = (SDatabaseOptions*)pNode; - nodesDestroyNode(pOptions->pDaysPerFile); + nodesDestroyNode((SNode*)pOptions->pDaysPerFile); nodesDestroyList(pOptions->pKeep); nodesDestroyList(pOptions->pRetentions); break; @@ -457,6 +457,13 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyNode(pOptions->pSliding); break; } + case QUERY_NODE_EXPLAIN_OPTIONS: // no pointer field + break; + case QUERY_NODE_STREAM_OPTIONS: + nodesDestroyNode(((SStreamOptions*)pNode)->pWatermark); + break; + case QUERY_NODE_LEFT_VALUE: // no pointer field + break; case QUERY_NODE_SET_OPERATOR: { SSetOperator* pStmt = (SSetOperator*)pNode; nodesDestroyNode(pStmt->pLeft); @@ -475,26 +482,26 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pStmt->pGroupByList); nodesDestroyNode(pStmt->pHaving); nodesDestroyList(pStmt->pOrderByList); - nodesDestroyNode(pStmt->pLimit); - nodesDestroyNode(pStmt->pSlimit); + nodesDestroyNode((SNode*)pStmt->pLimit); + nodesDestroyNode((SNode*)pStmt->pSlimit); break; } case QUERY_NODE_VNODE_MODIF_STMT: destroyVgDataBlockArray(((SVnodeModifOpStmt*)pNode)->pDataBlocks); break; case QUERY_NODE_CREATE_DATABASE_STMT: - nodesDestroyNode(((SCreateDatabaseStmt*)pNode)->pOptions); + nodesDestroyNode((SNode*)((SCreateDatabaseStmt*)pNode)->pOptions); break; case QUERY_NODE_DROP_DATABASE_STMT: // no pointer field break; case QUERY_NODE_ALTER_DATABASE_STMT: - nodesDestroyNode(((SAlterDatabaseStmt*)pNode)->pOptions); + nodesDestroyNode((SNode*)((SAlterDatabaseStmt*)pNode)->pOptions); break; case QUERY_NODE_CREATE_TABLE_STMT: { SCreateTableStmt* pStmt = (SCreateTableStmt*)pNode; nodesDestroyList(pStmt->pCols); nodesDestroyList(pStmt->pTags); - nodesDestroyNode(pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pOptions); break; } case QUERY_NODE_CREATE_SUBTABLE_CLAUSE: { @@ -509,14 +516,14 @@ void nodesDestroyNode(SNodeptr pNode) { case QUERY_NODE_DROP_TABLE_CLAUSE: // no pointer field break; case QUERY_NODE_DROP_TABLE_STMT: - nodesDestroyNode(((SDropTableStmt*)pNode)->pTables); + nodesDestroyList(((SDropTableStmt*)pNode)->pTables); break; case QUERY_NODE_DROP_SUPER_TABLE_STMT: // no pointer field break; case QUERY_NODE_ALTER_TABLE_STMT: { SAlterTableStmt* pStmt = (SAlterTableStmt*)pNode; - nodesDestroyNode(pStmt->pOptions); - nodesDestroyNode(pStmt->pVal); + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pVal); break; } case QUERY_NODE_CREATE_USER_STMT: // no pointer field @@ -529,37 +536,107 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_CREATE_INDEX_STMT: { SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pNode; - nodesDestroyNode(pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pOptions); nodesDestroyList(pStmt->pCols); break; } case QUERY_NODE_DROP_INDEX_STMT: // no pointer field case QUERY_NODE_CREATE_QNODE_STMT: // no pointer field case QUERY_NODE_DROP_QNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_BNODE_STMT: // no pointer field + case QUERY_NODE_DROP_BNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_SNODE_STMT: // no pointer field + case QUERY_NODE_DROP_SNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_MNODE_STMT: // no pointer field + case QUERY_NODE_DROP_MNODE_STMT: // no pointer field break; case QUERY_NODE_CREATE_TOPIC_STMT: nodesDestroyNode(((SCreateTopicStmt*)pNode)->pQuery); break; case QUERY_NODE_DROP_TOPIC_STMT: // no pointer field + case QUERY_NODE_DROP_CGROUP_STMT: // no pointer field case QUERY_NODE_ALTER_LOCAL_STMT: // no pointer field break; - case QUERY_NODE_SHOW_DATABASES_STMT: - case QUERY_NODE_SHOW_TABLES_STMT: - case QUERY_NODE_SHOW_STABLES_STMT: - case QUERY_NODE_SHOW_USERS_STMT: + case QUERY_NODE_EXPLAIN_STMT: { + SExplainStmt* pStmt = (SExplainStmt*)pNode; + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode(pStmt->pQuery); + break; + } + case QUERY_NODE_DESCRIBE_STMT: + taosMemoryFree(((SDescribeStmt*)pNode)->pMeta); + break; + case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field + case QUERY_NODE_COMPACT_STMT: // no pointer field + case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field + case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field + break; + case QUERY_NODE_CREATE_STREAM_STMT: { + SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode; + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode(pStmt->pQuery); + break; + } + case QUERY_NODE_DROP_STREAM_STMT: // no pointer field + case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field + case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field + break; + case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: + nodesDestroyList(((SRedistributeVgroupStmt*)pNode)->pDnodes); + break; + case QUERY_NODE_SPLIT_VGROUP_STMT: // no pointer field + case QUERY_NODE_SYNCDB_STMT: // no pointer field + case QUERY_NODE_GRANT_STMT: // no pointer field + case QUERY_NODE_REVOKE_STMT: // no pointer field + break; case QUERY_NODE_SHOW_DNODES_STMT: - case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: case QUERY_NODE_SHOW_MODULES_STMT: case QUERY_NODE_SHOW_QNODES_STMT: + case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_CLUSTER_STMT: + case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_FUNCTIONS_STMT: case QUERY_NODE_SHOW_INDEXES_STMT: - case QUERY_NODE_SHOW_STREAMS_STMT: { + case QUERY_NODE_SHOW_STABLES_STMT: + case QUERY_NODE_SHOW_STREAMS_STMT: + case QUERY_NODE_SHOW_TABLES_STMT: + case QUERY_NODE_SHOW_USERS_STMT: + case QUERY_NODE_SHOW_LICENCE_STMT: + case QUERY_NODE_SHOW_VGROUPS_STMT: + case QUERY_NODE_SHOW_TOPICS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIBES_STMT: + case QUERY_NODE_SHOW_SMAS_STMT: + case QUERY_NODE_SHOW_CONFIGS_STMT: + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + case QUERY_NODE_SHOW_VNODES_STMT: + case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_SCORES_STMT: + case QUERY_NODE_SHOW_VARIABLE_STMT: + case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: + case QUERY_NODE_SHOW_CREATE_TABLE_STMT: + case QUERY_NODE_SHOW_CREATE_STABLE_STMT: + case QUERY_NODE_SHOW_TRANSACTIONS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbNamePattern); break; } + case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field + case QUERY_NODE_KILL_QUERY_STMT: // no pointer field + case QUERY_NODE_KILL_TRANSACTION_STMT: // no pointer field + break; + case QUERY_NODE_DELETE_STMT: { + SDeleteStmt* pStmt = (SDeleteStmt*)pNode; + nodesDestroyNode(pStmt->pFromTable); + nodesDestroyNode(pStmt->pWhere); + nodesDestroyNode(pStmt->pCountFunc); + nodesDestroyNode(pStmt->pTagIndexCond); + break; + } case QUERY_NODE_QUERY: { SQuery* pQuery = (SQuery*)pNode; nodesDestroyNode(pQuery->pRoot); @@ -608,6 +685,13 @@ void nodesDestroyNode(SNodeptr pNode) { case QUERY_NODE_LOGIC_PLAN_EXCHANGE: destroyLogicNode((SLogicNode*)pNode); break; + case QUERY_NODE_LOGIC_PLAN_MERGE: { + SMergeLogicNode* pLogicNode = (SMergeLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyList(pLogicNode->pMergeKeys); + nodesDestroyList(pLogicNode->pInputs); + break; + } case QUERY_NODE_LOGIC_PLAN_WINDOW: { SWindowLogicNode* pLogicNode = (SWindowLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -615,6 +699,13 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyNode(pLogicNode->pTspk); break; } + case QUERY_NODE_LOGIC_PLAN_FILL: { + SFillLogicNode* pLogicNode = (SFillLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyNode(pLogicNode->pWStartTs); + nodesDestroyNode(pLogicNode->pValues); + break; + } case QUERY_NODE_LOGIC_PLAN_SORT: { SSortLogicNode* pLogicNode = (SSortLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -627,10 +718,16 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pLogicNode->pPartitionKeys); break; } + case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: { + SIndefRowsFuncLogicNode* pLogicNode = (SIndefRowsFuncLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyList(pLogicNode->pVectorFuncs); + break; + } case QUERY_NODE_LOGIC_SUBPLAN: { SLogicSubplan* pSubplan = (SLogicSubplan*)pNode; nodesDestroyList(pSubplan->pChildren); - nodesDestroyNode(pSubplan->pNode); + nodesDestroyNode((SNode*)pSubplan->pNode); nodesClearList(pSubplan->pParents); taosMemoryFreeClear(pSubplan->pVgroupList); break; @@ -639,17 +736,9 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(((SQueryLogicPlan*)pNode)->pTopSubplans); break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: destroyScanPhysiNode((SScanPhysiNode*)pNode); break; @@ -680,21 +769,62 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pPhyNode->pSrcEndPoints); break; } + case QUERY_NODE_PHYSICAL_PLAN_MERGE: { + SMergePhysiNode* pPhyNode = (SMergePhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pMergeKeys); + nodesDestroyList(pPhyNode->pTargets); + break; + } case QUERY_NODE_PHYSICAL_PLAN_SORT: { SSortPhysiNode* pPhyNode = (SSortPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); - nodesDestroyNode(pPhyNode->pExprs); - nodesDestroyNode(pPhyNode->pSortKeys); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pSortKeys); break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode); break; + case QUERY_NODE_PHYSICAL_PLAN_FILL: { + SFillPhysiNode* pPhyNode = (SFillPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyNode(pPhyNode->pWStartTs); + nodesDestroyNode(pPhyNode->pValues); + nodesDestroyList(pPhyNode->pTargets); + break; + } case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode); break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: { + SStateWinodwPhysiNode* pPhyNode = (SStateWinodwPhysiNode*)pNode; + destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode); + nodesDestroyNode(pPhyNode->pStateKey); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { + SPartitionPhysiNode* pPhyNode = (SPartitionPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pPartitionKeys); + nodesDestroyList(pPhyNode->pTargets); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: { + SIndefRowsFuncPhysiNode* pPhyNode = (SIndefRowsFuncPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pVectorFuncs); + break; + } case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: destroyDataSinkNode((SDataSinkNode*)pNode); break; @@ -704,11 +834,17 @@ void nodesDestroyNode(SNodeptr pNode) { taosMemoryFreeClear(pSink->pData); break; } + case QUERY_NODE_PHYSICAL_PLAN_DELETE: { + SDataDeleterNode* pSink = (SDataDeleterNode*)pNode; + destroyDataSinkNode((SDataSinkNode*)pSink); + nodesDestroyNode(pSink->pAffectedRows); + break; + } case QUERY_NODE_PHYSICAL_SUBPLAN: { SSubplan* pSubplan = (SSubplan*)pNode; nodesDestroyList(pSubplan->pChildren); - nodesDestroyNode(pSubplan->pNode); - nodesDestroyNode(pSubplan->pDataSink); + nodesDestroyNode((SNode*)pSubplan->pNode); + nodesDestroyNode((SNode*)pSubplan->pDataSink); nodesClearList(pSubplan->pParents); break; } @@ -746,7 +882,7 @@ SNodeList* nodesMakeList() { return p; } -int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListAppend(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } @@ -768,7 +904,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) { return TSDB_CODE_SUCCESS; } -int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode) { if (NULL == pNode) { terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY; @@ -780,7 +916,7 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) { return code; } -int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) { +int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode) { if (NULL == *pList) { *pList = nodesMakeList(); if (NULL == *pList) { @@ -791,7 +927,7 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) { return nodesListAppend(*pList, pNode); } -int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode) { +int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode) { if (NULL == *pList) { *pList = nodesMakeList(); if (NULL == *pList) { @@ -833,7 +969,7 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) { return code; } -int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } @@ -888,7 +1024,7 @@ void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) { taosMemoryFreeClear(pSrc); } -SNodeptr nodesListGetNode(SNodeList* pList, int32_t index) { +SNode* nodesListGetNode(SNodeList* pList, int32_t index) { SNode* node; FOREACH(node, pList) { if (0 == index--) { @@ -1422,7 +1558,7 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) { *pDst = nodesListGetNode(*pSrc, 0); nodesClearList(*pSrc); } else { - SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pLogicCond) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index ed338b89e8..83ad41aac0 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -461,6 +461,7 @@ into_opt(A) ::= INTO full_table_name(B). stream_options(A) ::= . { A = createStreamOptions(pCxt); } stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_AT_ONCE; A = B; } stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; } +stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } /************************************************ kill connection/query ***********************************************/ diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 054912d540..ca066c7056 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -338,7 +338,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera if (NULL == pCxt->pPlaceholderValues) { pCxt->pPlaceholderValues = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); if (NULL == pCxt->pPlaceholderValues) { - nodesDestroyNode(val); + nodesDestroyNode((SNode*)val); return NULL; } } @@ -368,7 +368,7 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ code = addParamToLogicConditionNode(cond, pParam2); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(cond); + nodesDestroyNode((SNode*)cond); return NULL; } return (SNode*)cond; @@ -399,7 +399,7 @@ SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); CHECK_OUT_OF_MEM(pCol); pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; strcpy(pCol->colName, PK_TS_COL_INTERNAL_NAME); @@ -541,7 +541,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { CHECK_OUT_OF_MEM(state); state->pCol = createPrimaryKeyCol(pCxt); if (NULL == state->pCol) { - nodesDestroyNode(state); + nodesDestroyNode((SNode*)state); CHECK_OUT_OF_MEM(state->pCol); } state->pExpr = pExpr; @@ -555,7 +555,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode CHECK_OUT_OF_MEM(interval); interval->pCol = createPrimaryKeyCol(pCxt); if (NULL == interval->pCol) { - nodesDestroyNode(interval); + nodesDestroyNode((SNode*)interval); CHECK_OUT_OF_MEM(interval->pCol); } interval->pInterval = pInterval; @@ -573,7 +573,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) { fill->pValues = pValues; fill->pWStartTs = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == fill->pWStartTs) { - nodesDestroyNode(fill); + nodesDestroyNode((SNode*)fill); CHECK_OUT_OF_MEM(fill->pWStartTs); } strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts"); @@ -689,7 +689,7 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); + SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE; pOptions->cachelast = TSDB_DEFAULT_CACHE_LAST_ROW; @@ -715,7 +715,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); + SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = -1; pOptions->cachelast = -1; @@ -801,7 +801,8 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti ((SDatabaseOptions*)pOptions)->pRetentions = pVal; break; case DB_OPTION_SCHEMALESS: - ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); +// ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + ((SDatabaseOptions*)pOptions)->schemaless = 1; break; default: break; @@ -851,7 +852,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* if (!checkDbName(pCxt, pDbName, false)) { return NULL; } - SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); + SAlterDatabaseStmt* pStmt = (SAlterDatabaseStmt*)nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->dbName, pDbName->z, pDbName->n); pStmt->pOptions = (SDatabaseOptions*)pOptions; @@ -860,7 +861,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); + STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR; pOptions->ttl = TSDB_DEFAULT_TABLE_TTL; @@ -869,7 +870,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { SNode* createAlterTableOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); + STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->filesFactor = -1; pOptions->ttl = -1; @@ -947,7 +948,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); - SCreateSubTableClause* pStmt = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); + SCreateSubTableClause* pStmt = (SCreateSubTableClause*)nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -958,12 +959,13 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN pStmt->pValsOfTags = pValsOfTags; nodesDestroyNode(pRealTable); nodesDestroyNode(pUseRealTable); + nodesDestroyNode(pOptions); return (SNode*)pStmt; } SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables) { CHECK_PARSER_STATUS(pCxt); - SCreateMultiTableStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT); + SCreateMultiTableStmt* pStmt = (SCreateMultiTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pSubTables = pSubTables; return (SNode*)pStmt; @@ -971,7 +973,7 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDropTableClause* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); + SDropTableClause* pStmt = (SDropTableClause*)nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -982,7 +984,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { CHECK_PARSER_STATUS(pCxt); - SDropTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); + SDropTableStmt* pStmt = (SDropTableStmt*)nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pTables = pTables; return (SNode*)pStmt; @@ -990,7 +992,7 @@ SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDropSuperTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT); + SDropSuperTableStmt* pStmt = (SDropSuperTableStmt*)nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -1008,7 +1010,7 @@ static SNode* createAlterTableStmtFinalize(SNode* pRealTable, SAlterTableStmt* p SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS; pStmt->pOptions = (STableOptions*)pOptions; @@ -1021,7 +1023,7 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, if (!checkColumnName(pCxt, pColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pColName->z, pColName->n); @@ -1034,7 +1036,7 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_ if (!checkColumnName(pCxt, pColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pColName->z, pColName->n); @@ -1047,7 +1049,7 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int if (!checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pOldColName->z, pOldColName->n); @@ -1060,7 +1062,7 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken if (!checkColumnName(pCxt, pTagName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; strncpy(pStmt->colName, pTagName->z, pTagName->n); @@ -1091,7 +1093,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; } - SShowStmt* pStmt = nodesMakeNode(type); + SShowStmt* pStmt = (SShowStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->pDbName = pDbName; pStmt->pTbNamePattern = pTbNamePattern; @@ -1136,7 +1138,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al if (TSDB_ALTER_USER_PASSWD == alterType) { char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkPassword(pCxt, pVal, password)) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); return NULL; } strcpy(pStmt->password, password); @@ -1186,7 +1188,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10); } else { if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); return NULL; } } @@ -1196,7 +1198,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue) { CHECK_PARSER_STATUS(pCxt); - SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); + SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10); trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); @@ -1212,7 +1214,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) { return NULL; } - SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); + SCreateIndexStmt* pStmt = (SCreateIndexStmt*)nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->indexType = type; pStmt->ignoreExists = ignoreExists; @@ -1226,7 +1228,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) { CHECK_PARSER_STATUS(pCxt); - SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); + SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->pFuncs = pFuncs; pOptions->pInterval = pInterval; @@ -1240,7 +1242,7 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { return NULL; } - SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); + SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); @@ -1250,26 +1252,24 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { CHECK_PARSER_STATUS(pCxt); - SCreateComponentNodeStmt* pStmt = nodesMakeNode(type); + SCreateComponentNodeStmt* pStmt = (SCreateComponentNodeStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); - ; return (SNode*)pStmt; } SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { CHECK_PARSER_STATUS(pCxt); - SDropComponentNodeStmt* pStmt = nodesMakeNode(type); + SDropComponentNodeStmt* pStmt = (SDropComponentNodeStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); - ; return (SNode*)pStmt; } SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubDbName, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); pStmt->ignoreExists = ignoreExists; @@ -1287,7 +1287,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); - SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); + SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); pStmt->ignoreNotExists = ignoreNotExists; @@ -1297,7 +1297,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, const SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); - SDropCGroupStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); + SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); @@ -1307,7 +1307,7 @@ SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) { CHECK_PARSER_STATUS(pCxt); - SAlterLocalStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); + SAlterLocalStmt* pStmt = (SAlterLocalStmt*)nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); CHECK_OUT_OF_MEM(pStmt); trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); if (NULL != pValue) { @@ -1318,7 +1318,7 @@ SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, cons SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SExplainOptions* pOptions = nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS); + SExplainOptions* pOptions = (SExplainOptions*)nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->verbose = TSDB_DEFAULT_EXPLAIN_VERBOSE; pOptions->ratio = TSDB_DEFAULT_EXPLAIN_RATIO; @@ -1339,7 +1339,7 @@ SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* p SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); - SExplainStmt* pStmt = nodesMakeNode(QUERY_NODE_EXPLAIN_STMT); + SExplainStmt* pStmt = (SExplainStmt*)nodesMakeNode(QUERY_NODE_EXPLAIN_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->analyze = analyze; pStmt->pOptions = (SExplainOptions*)pOptions; @@ -1349,7 +1349,7 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDescribeStmt* pStmt = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); + SDescribeStmt* pStmt = (SDescribeStmt*)nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -1378,7 +1378,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; } - SCreateFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); + SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreExists = ignoreExists; strncpy(pStmt->funcName, pFuncName->z, pFuncName->n); @@ -1391,7 +1391,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName) { CHECK_PARSER_STATUS(pCxt); - SDropFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); + SDropFunctionStmt* pStmt = (SDropFunctionStmt*)nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->funcName, pFuncName->z, pFuncName->n); @@ -1400,7 +1400,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con SNode* createStreamOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SStreamOptions* pOptions = nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); + SStreamOptions* pOptions = (SStreamOptions*)nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->triggerType = STREAM_TRIGGER_AT_ONCE; return (SNode*)pOptions; @@ -1409,7 +1409,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); - SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); + SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); if (NULL != pRealTable) { @@ -1425,7 +1425,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) { CHECK_PARSER_STATUS(pCxt); - SDropStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); + SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); pStmt->ignoreNotExists = ignoreNotExists; @@ -1434,7 +1434,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) { CHECK_PARSER_STATUS(pCxt); - SKillStmt* pStmt = nodesMakeNode(type); + SKillStmt* pStmt = (SKillStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->targetId = taosStr2Int32(pId->z, NULL, 10); return (SNode*)pStmt; @@ -1442,14 +1442,14 @@ SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SBalanceVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT); + SBalanceVgroupStmt* pStmt = (SBalanceVgroupStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); return (SNode*)pStmt; } SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) { CHECK_PARSER_STATUS(pCxt); - SMergeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); + SMergeVgroupStmt* pStmt = (SMergeVgroupStmt*)nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId1 = taosStr2Int32(pVgId1->z, NULL, 10); pStmt->vgId2 = taosStr2Int32(pVgId2->z, NULL, 10); @@ -1458,7 +1458,7 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes) { CHECK_PARSER_STATUS(pCxt); - SRedistributeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); + SRedistributeVgroupStmt* pStmt = (SRedistributeVgroupStmt*)nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10); pStmt->pDnodes = pDnodes; @@ -1467,7 +1467,7 @@ SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId) { CHECK_PARSER_STATUS(pCxt); - SSplitVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); + SSplitVgroupStmt* pStmt = (SSplitVgroupStmt*)nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10); return (SNode*)pStmt; @@ -1485,7 +1485,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } - SGrantStmt* pStmt = nodesMakeNode(QUERY_NODE_GRANT_STMT); + SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; strncpy(pStmt->dbName, pDbName->z, pDbName->n); @@ -1498,7 +1498,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } - SRevokeStmt* pStmt = nodesMakeNode(QUERY_NODE_REVOKE_STMT); + SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; strncpy(pStmt->dbName, pDbName->z, pDbName->n); @@ -1507,11 +1507,11 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb } SNode* createCountFuncForDelete(SAstCreateContext* pCxt) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); CHECK_OUT_OF_MEM(pFunc); strcpy(pFunc->functionName, "count"); if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt))) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); CHECK_OUT_OF_MEM(NULL); } return (SNode*)pFunc; @@ -1519,13 +1519,13 @@ SNode* createCountFuncForDelete(SAstCreateContext* pCxt) { SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) { CHECK_PARSER_STATUS(pCxt); - SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT); + SDeleteStmt* pStmt = (SDeleteStmt*)nodesMakeNode(QUERY_NODE_DELETE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pFromTable = pTable; pStmt->pWhere = pWhere; pStmt->pCountFunc = createCountFuncForDelete(pCxt); if (NULL == pStmt->pCountFunc) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); CHECK_OUT_OF_MEM(NULL); } return (SNode*)pStmt; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 79af47202a..f6467dbf23 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -77,7 +77,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { abort_parse: ParseFree(pParser, (FFree)taosMemoryFree); if (TSDB_CODE_SUCCESS == cxt.errCode) { - *pQuery = nodesMakeNode(QUERY_NODE_QUERY); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index b2cb67b1c3..22d7afd642 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -65,7 +65,7 @@ static bool isCondition(const SNode* pNode) { } static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) { - SOperatorNode* pOp = nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); if (NULL == pOp) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index c1b2ad963f..33f37a9513 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1285,6 +1285,8 @@ static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) { destroyCreateSubTbReq(&pCxt->createTblReq); } +static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); } + static void destroyInsertParseContext(SInsertParseContext* pCxt) { destroyInsertParseContextForTable(pCxt); taosHashCleanup(pCxt->pVgroupsHashObj); @@ -1297,11 +1299,12 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) { } static int32_t checkSchemalessDb(SInsertParseContext* pCxt, char* pDbName) { - SDbCfgInfo pInfo = {0}; - char fullName[TSDB_TABLE_FNAME_LEN]; - snprintf(fullName, sizeof(fullName), "%d.%s", pCxt->pComCxt->acctId, pDbName); - CHECK_CODE(getDBCfg(pCxt, fullName, &pInfo)); - return pInfo.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; +// SDbCfgInfo pInfo = {0}; +// char fullName[TSDB_TABLE_FNAME_LEN]; +// snprintf(fullName, sizeof(fullName), "%d.%s", pCxt->pComCxt->acctId, pDbName); +// CHECK_CODE(getDBCfg(pCxt, fullName, &pInfo)); +// return pInfo.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } // tb_name @@ -1468,13 +1471,14 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache NULL == context.pTableNameHashObj || NULL == context.pDbFNameHashObj || NULL == context.pOutput) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } + taosHashSetFreeFp(context.pSubTableHashObj, destroySubTableHashElem); if (pContext->pStmtCb) { TSDB_QUERY_SET_TYPE(context.pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT); } if (NULL == *pQuery) { - *pQuery = nodesMakeNode(QUERY_NODE_QUERY); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1686,7 +1690,7 @@ int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCa code = parseInsertBodySyntax(&context); } if (TSDB_CODE_SUCCESS == code) { - *pQuery = nodesMakeNode(QUERY_NODE_QUERY); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -2114,9 +2118,11 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS isOrdered = false; } if (index < 0) { + uError("smlBoundColumnData. index:%d", index); return TSDB_CODE_SML_INVALID_DATA; } if (pColList->cols[index].valStat == VAL_STAT_HAS) { + uError("smlBoundColumnData. already set. index:%d", index); return TSDB_CODE_SML_INVALID_DATA; } lastColIdx = index; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index e1ae727b66..a9d730e1ad 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -117,6 +117,7 @@ static SKeyword keywordTable[] = { {"LOCAL", TK_LOCAL}, {"MATCH", TK_MATCH}, {"MAXROWS", TK_MAXROWS}, + {"MAX_DELAY", TK_MAX_DELAY}, {"MERGE", TK_MERGE}, {"MINROWS", TK_MINROWS}, {"MINUS", TK_MINUS}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 02a32a6781..abcfb070c1 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -950,7 +950,7 @@ static bool isCountStar(SFunctionNode* pFunc) { // count(*) is rewritten as count(ts) for scannning optimization static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) { - SColumnNode* pCol = nodesListGetNode(pCount->pParameterList, 0); + SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pCount->pParameterList, 0); STableNode* pTable = NULL; int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) { @@ -1002,7 +1002,7 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionN return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); } } else { - SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0); + SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0); STableNode* pTable = NULL; pCxt->errCode = findTable(pCxt, pVal->literal, &pTable); if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) { @@ -1143,7 +1143,7 @@ typedef struct SCheckExprForGroupByCxt { } SCheckExprForGroupByCxt; static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; @@ -1158,7 +1158,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode *pNode = (SNode*)pFunc; pCxt->pCurrSelectStmt->hasSelectValFunc = true; } else { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); } return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; } @@ -1495,14 +1495,14 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { } static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return NULL; } pFunc->pParameterList = nodesMakeList(); if (NULL == pFunc->pParameterList || - TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) { - nodesDestroyNode(pFunc); + TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode((SNode*)pExpr))) { + nodesDestroyNode((SNode*)pFunc); return NULL; } @@ -2007,7 +2007,7 @@ static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { } static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* pTable, SNode** pPrimaryKey) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -2088,7 +2088,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { } static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -2100,20 +2100,20 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { } static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "cast"); pFunc->node.resType = dt; if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) { nodesClearList(pFunc->pParameterList); pFunc->pParameterList = NULL; - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName); } *pCast = (SNode*)pFunc; @@ -2417,11 +2417,11 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) { int32_t daysPerFile = pOptions->daysPerFile; - int32_t daysToKeep0 = pOptions->keep[0]; + int64_t daysToKeep0 = pOptions->keep[0]; if (-1 == daysPerFile && -1 == daysToKeep0) { return TSDB_CODE_SUCCESS; } else if (-1 == daysPerFile || -1 == daysToKeep0) { - SDbCfgInfo dbCfg; + SDbCfgInfo dbCfg = {0}; int32_t code = getDBCfg(pCxt, pDbName, &dbCfg); if (TSDB_CODE_SUCCESS != code) { return code; @@ -2525,16 +2525,14 @@ static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeF static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { SCreateDbReq createReq = {0}; - - int32_t code = checkCreateDatabase(pCxt, pStmt); + int32_t code = checkCreateDatabase(pCxt, pStmt); if (TSDB_CODE_SUCCESS == code) { code = buildCreateDbReq(pCxt, pStmt, &createReq); } - if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DB, (FSerializeFunc)tSerializeSCreateDbReq, &createReq); } - + tFreeSCreateDbReq(&createReq); return code; } @@ -2762,15 +2760,16 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt } static int32_t checkSchemalessDb(STranslateContext* pCxt, const char* pDbName) { - if (0 != pCxt->pParseCxt->schemalessType) { - return TSDB_CODE_SUCCESS; - } - SDbCfgInfo info = {0}; - int32_t code = getDBCfg(pCxt, pDbName, &info); - if (TSDB_CODE_SUCCESS == code) { - code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; - } - return code; + // if (0 != pCxt->pParseCxt->schemalessType) { + // return TSDB_CODE_SUCCESS; + // } + // SDbCfgInfo info = {0}; + // int32_t code = getDBCfg(pCxt, pDbName, &info); + // if (TSDB_CODE_SUCCESS == code) { + // code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; + // } + // return code; + return TSDB_CODE_SUCCESS; } static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { @@ -2817,15 +2816,15 @@ typedef struct SSampleAstInfo { static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, int32_t* pExprLen) { - SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT); + SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; } sprintf(pSelect->stmtName, "%p", pSelect); - SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE); + SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); if (NULL == pTable) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pTable->table.dbName, pInfo->pDbName); @@ -2834,19 +2833,19 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch pSelect->pFromTable = (SNode*)pTable; TSWAP(pSelect->pProjectionList, pInfo->pFuncs); - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pSelect->pProjectionList || NULL == pFunc) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "_wstartts"); - nodesListPushFront(pSelect->pProjectionList, pFunc); + nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); SNode* pProject = NULL; FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } - SIntervalWindowNode* pInterval = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); + SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); if (NULL == pInterval) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } pSelect->pWindow = (SNode*)pInterval; @@ -2855,7 +2854,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch TSWAP(pInterval->pSliding, pInfo->pSliding); pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pInterval->pCol) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } ((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID; @@ -2864,12 +2863,12 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch pCxt->createStream = true; int32_t code = translateQuery(pCxt, (SNode*)pSelect); if (TSDB_CODE_SUCCESS == code) { - code = nodesNodeToString(pSelect, false, pAst, pLen); + code = nodesNodeToString((SNode*)pSelect, false, pAst, pLen); } if (TSDB_CODE_SUCCESS == code && NULL != pExpr) { code = nodesListToString(pSelect->pProjectionList, false, pExpr, pExprLen); } - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return code; } @@ -2881,7 +2880,7 @@ static void clearSampleAstInfo(SSampleAstInfo* pInfo) { } static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { - SValueNode* pVal = nodesMakeNode(QUERY_NODE_VALUE); + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == pVal) { return NULL; } @@ -2890,7 +2889,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit); pVal->literal = strndup(buf, len); if (NULL == pVal->literal) { - nodesDestroyNode(pVal); + nodesDestroyNode((SNode*)pVal); return NULL; } pVal->isDuration = true; @@ -2901,7 +2900,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { } static SNode* createColumnFromDef(SColumnDefNode* pDef) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -2910,12 +2909,12 @@ static SNode* createColumnFromDef(SColumnDefNode* pDef) { } static SNode* createRollupFunc(SNode* pSrcFunc, SColumnDefNode* pColDef) { - SFunctionNode* pFunc = nodesCloneNode(pSrcFunc); + SFunctionNode* pFunc = (SFunctionNode*)nodesCloneNode(pSrcFunc); if (NULL == pFunc) { return NULL; } if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createColumnFromDef(pColDef))) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return NULL; } return (SNode*)pFunc; @@ -3065,7 +3064,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p } static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) { - SDropTableClause* pClause = nodesListGetNode(pStmt->pTables, 0); + SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0); SName tableName; return doTranslateDropSuperTable( pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists); @@ -3137,6 +3136,7 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_ALTER_STB, (FSerializeFunc)tSerializeSMAlterStbReq, &alterReq); } + tFreeSMAltertbReq(&alterReq); return code; } @@ -3543,6 +3543,16 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm } static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { + if (NULL != pStmt->pOptions->pWatermark && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark))) { + return pCxt->errCode; + } + + if (NULL != pStmt->pOptions->pDelay && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pDelay))) { + return pCxt->errCode; + } + if (NULL == pStmt->pQuery) { return TSDB_CODE_SUCCESS; } @@ -3590,12 +3600,9 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* } } - if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pWatermark) { - code = (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark)) ? pCxt->errCode - : TSDB_CODE_SUCCESS; - } if (TSDB_CODE_SUCCESS == code) { pReq->triggerType = pStmt->pOptions->triggerType; + pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0); pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); } @@ -4083,15 +4090,15 @@ static const char* getSysTableName(ENodeType type) { } static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) { - SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT); + SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; } sprintf(pSelect->stmtName, "%p", pSelect); - SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE); + SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); if (NULL == pTable) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pTable->table.dbName, getSysDbName(showType)); @@ -4109,7 +4116,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN return TSDB_CODE_SUCCESS; } - SOperatorNode* pOper = nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode* pOper = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); if (NULL == pOper) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -4118,7 +4125,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN pOper->pLeft = nodesMakeNode(QUERY_NODE_COLUMN); pOper->pRight = nodesCloneNode(pRight); if (NULL == pOper->pLeft || NULL == pOper->pRight) { - nodesDestroyNode(pOper); + nodesDestroyNode((SNode*)pOper); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(((SColumnNode*)pOper->pLeft)->colName, pColName); @@ -4132,19 +4139,19 @@ static const char* getTbNameColName(ENodeType type) { } static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) { - SLogicConditionNode* pCondition = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pCondition = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pCondition) { return TSDB_CODE_OUT_OF_MEMORY; } pCondition->condType = LOGIC_COND_TYPE_AND; pCondition->pParameterList = nodesMakeList(); if (NULL == pCondition->pParameterList) { - nodesDestroyNode(pCondition); + nodesDestroyNode((SNode*)pCondition); return TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond1) || TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond2)) { - nodesDestroyNode(pCondition); + nodesDestroyNode((SNode*)pCondition); return TSDB_CODE_OUT_OF_MEMORY; } @@ -4292,7 +4299,7 @@ static void destroyCreateTbReqBatch(SVgroupCreateTableBatch* pTbBatch) { } static int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) { - SVnodeModifOpStmt* pNewStmt = nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); + SVnodeModifOpStmt* pNewStmt = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); if (pNewStmt == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -5053,25 +5060,10 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) { taosMemoryFree(pReq->newComment); } -static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { - SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot; - STableMeta* pTableMeta = NULL; - int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - - if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); - } - - if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); - } - +static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, + SQuery* pQuery) { if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, - "can not drop tag if there is only one tag"); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE); } if (TSDB_SUPER_TABLE == pTableMeta->tableType) { @@ -5087,7 +5079,7 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { } SVAlterTbReq req = {0}; - code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req); + int32_t code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req); SArray* pArray = NULL; if (TSDB_CODE_SUCCESS == code) { @@ -5100,6 +5092,26 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { return code; } +static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { + SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot; + + if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); + } + + if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); + } + + STableMeta* pTableMeta = NULL; + int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteAlterTableImpl(pCxt, pStmt, pTableMeta, pQuery); + } + taosMemoryFree(pTableMeta); + return code; +} + static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pQuery->pRoot)) { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index a2fb31a697..c3ff4c63a4 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -552,9 +552,15 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog return code; } -static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj* pHash) { +static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) { + if (NULL == *pHash) { + *pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (NULL == *pHash) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } SMetaRes* pRes = taosArrayGet(pData, index); - return taosHashPut(pHash, pKey, len, &pRes, POINTER_BYTES); + return taosHashPut(*pHash, pKey, len, &pRes, POINTER_BYTES); } static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) { @@ -568,7 +574,7 @@ static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHas return (*pRes)->code; } -static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj* pTable) { +static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj** pTable) { int32_t ntables = taosArrayGetSize(pTableReq); for (int32_t i = 0; i < ntables; ++i) { char fullName[TSDB_TABLE_FNAME_LEN]; @@ -580,7 +586,7 @@ static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTable return TSDB_CODE_SUCCESS; } -static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj* pDb) { +static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj** pDb) { int32_t nvgs = taosArrayGetSize(pDbReq); for (int32_t i = 0; i < nvgs; ++i) { char* pDbFName = taosArrayGet(pDbReq, i); @@ -591,7 +597,7 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa return TSDB_CODE_SUCCESS; } -static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj* pUserAuth) { +static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj** pUserAuth) { int32_t nvgs = taosArrayGetSize(pUserAuthReq); for (int32_t i = 0; i < nvgs; ++i) { SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i); @@ -604,7 +610,7 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse return TSDB_CODE_SUCCESS; } -static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj* pUdf) { +static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj** pUdf) { int32_t num = taosArrayGetSize(pUdfReq); for (int32_t i = 0; i < num; ++i) { char* pFunc = taosArrayGet(pUdfReq, i); @@ -616,27 +622,27 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas } int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) { - int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, pMetaCache->pTableMeta); + int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta); if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, pMetaCache->pDbVgroup); + code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, &pMetaCache->pDbVgroup); } if (TSDB_CODE_SUCCESS == code) { - code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, pMetaCache->pTableVgroup); + code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup); } if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, pMetaCache->pDbCfg); + code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, &pMetaCache->pDbCfg); } if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, pMetaCache->pDbInfo); + code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, &pMetaCache->pDbInfo); } if (TSDB_CODE_SUCCESS == code) { - code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, pMetaCache->pUserAuth); + code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, &pMetaCache->pUserAuth); } if (TSDB_CODE_SUCCESS == code) { - code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, pMetaCache->pUdf); + code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, &pMetaCache->pUdf); } if (TSDB_CODE_SUCCESS == code) { - code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, pMetaCache->pTableIndex); + code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex); } return code; } diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index bce3906b7d..7c330158fa 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -180,21 +180,22 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata if (TSDB_CODE_SUCCESS == code) { if (NULL == pQuery->pRoot) { code = parseInsertSql(pCxt, &pQuery, &metaCache); + } else { + code = analyseSemantic(pCxt, pQuery, &metaCache); } - code = analyseSemantic(pCxt, pQuery, &metaCache); } destoryParseMetaCache(&metaCache); terrno = code; return code; } -void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode(pQueryNode); } +void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode((SNode*)pQueryNode); } int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { return extractResultSchema(pRoot, numOfCols, pSchema); } -int32_t qSetSTableIdForRSma(SNode* pStmt, int64_t uid) { +int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid) { if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { SNode* pTable = ((SSelectStmt*)pStmt)->pFromTable; if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 6fbee8cb11..b2de892f30 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,25 +104,25 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 359 +#define YYNOCODE 360 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy28; - int32_t yy42; - ENullOrder yy107; - EFillMode yy320; - SToken yy421; - SNodeList* yy530; - SAlterOption yy557; - EOrder yy610; - bool yy621; - EJoinType yy636; - int64_t yy669; - SNode* yy674; - SDataType yy690; + EFillMode yy54; + int32_t yy100; + bool yy137; + int64_t yy189; + SToken yy209; + ENullOrder yy217; + SDataType yy304; + EOperatorType yy380; + SNodeList* yy424; + EOrder yy578; + SAlterOption yy605; + EJoinType yy612; + SNode* yy632; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -138,17 +138,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 618 -#define YYNRULE 453 -#define YYNTOKEN 239 -#define YY_MAX_SHIFT 617 -#define YY_MIN_SHIFTREDUCE 904 -#define YY_MAX_SHIFTREDUCE 1356 -#define YY_ERROR_ACTION 1357 -#define YY_ACCEPT_ACTION 1358 -#define YY_NO_ACTION 1359 -#define YY_MIN_REDUCE 1360 -#define YY_MAX_REDUCE 1812 +#define YYNSTATE 619 +#define YYNRULE 454 +#define YYNTOKEN 240 +#define YY_MAX_SHIFT 618 +#define YY_MIN_SHIFTREDUCE 906 +#define YY_MAX_SHIFTREDUCE 1359 +#define YY_ERROR_ACTION 1360 +#define YY_ACCEPT_ACTION 1361 +#define YY_NO_ACTION 1362 +#define YY_MIN_REDUCE 1363 +#define YY_MAX_REDUCE 1816 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,602 +215,607 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2144) +#define YY_ACTTAB_COUNT (2152) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 28, 230, 1659, 1646, 610, 609, 296, 1646, 357, 1482, - /* 10 */ 313, 1480, 35, 33, 351, 36, 34, 32, 31, 30, - /* 20 */ 305, 24, 1170, 1643, 532, 441, 440, 1643, 79, 1643, - /* 30 */ 1675, 36, 34, 32, 31, 30, 152, 492, 516, 1639, - /* 40 */ 1645, 115, 277, 1639, 1645, 1639, 1645, 1168, 515, 1483, - /* 50 */ 535, 532, 1629, 1491, 535, 1790, 535, 496, 14, 1742, - /* 60 */ 35, 33, 1297, 355, 1176, 1659, 114, 147, 305, 1688, - /* 70 */ 1170, 1787, 82, 1660, 518, 1662, 1663, 514, 500, 535, - /* 80 */ 1491, 1, 1728, 1739, 1790, 1311, 278, 1724, 36, 34, - /* 90 */ 32, 31, 30, 1675, 531, 1168, 1789, 1647, 1790, 519, - /* 100 */ 1787, 516, 308, 614, 112, 1580, 14, 409, 35, 33, - /* 110 */ 149, 515, 1176, 1169, 1787, 1629, 305, 1643, 1170, 145, - /* 120 */ 1735, 1736, 1194, 1740, 36, 34, 32, 31, 30, 2, - /* 130 */ 381, 63, 1688, 1639, 1645, 84, 1660, 518, 1662, 1663, - /* 140 */ 514, 1361, 535, 1168, 535, 1728, 531, 1790, 56, 1727, - /* 150 */ 1724, 614, 142, 1487, 14, 391, 1171, 392, 1392, 148, - /* 160 */ 1176, 1169, 96, 1787, 1529, 95, 94, 93, 92, 91, - /* 170 */ 90, 89, 88, 87, 161, 160, 132, 2, 1372, 566, - /* 180 */ 1174, 1175, 934, 1221, 1222, 1224, 1225, 1226, 1227, 1228, - /* 190 */ 511, 533, 1236, 1237, 1238, 1239, 1240, 1241, 565, 614, - /* 200 */ 564, 563, 562, 399, 1171, 392, 1392, 38, 96, 1169, - /* 210 */ 150, 95, 94, 93, 92, 91, 90, 89, 88, 87, - /* 220 */ 938, 939, 65, 294, 1353, 55, 194, 1617, 1174, 1175, - /* 230 */ 1360, 1221, 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, - /* 240 */ 1236, 1237, 1238, 1239, 1240, 1241, 36, 34, 32, 31, - /* 250 */ 30, 531, 1171, 1358, 105, 104, 103, 102, 101, 100, - /* 260 */ 99, 98, 97, 1469, 501, 35, 33, 36, 34, 32, - /* 270 */ 31, 30, 330, 305, 55, 1170, 1174, 1175, 342, 1221, - /* 280 */ 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, 1236, 1237, - /* 290 */ 1238, 1239, 1240, 1241, 468, 532, 444, 443, 344, 340, - /* 300 */ 1168, 442, 486, 1659, 111, 439, 1352, 356, 438, 437, - /* 310 */ 436, 321, 39, 35, 33, 1242, 26, 1176, 133, 63, - /* 320 */ 409, 305, 1448, 1170, 1491, 72, 36, 34, 32, 31, - /* 330 */ 30, 1675, 110, 508, 8, 1790, 150, 1208, 1535, 516, - /* 340 */ 288, 1486, 55, 492, 458, 295, 1484, 147, 1168, 515, - /* 350 */ 1533, 1787, 1790, 1629, 150, 951, 614, 950, 496, 481, - /* 360 */ 1261, 35, 33, 1468, 147, 1176, 1169, 200, 1787, 305, - /* 370 */ 1688, 1170, 114, 82, 1660, 518, 1662, 1663, 514, 129, - /* 380 */ 535, 1266, 9, 1728, 952, 1790, 568, 278, 1724, 289, - /* 390 */ 1196, 287, 286, 55, 432, 66, 1168, 147, 434, 1790, - /* 400 */ 1422, 1787, 78, 150, 614, 1790, 32, 31, 30, 1171, - /* 410 */ 112, 147, 74, 1176, 1169, 1787, 350, 1788, 349, 25, - /* 420 */ 433, 1787, 396, 1467, 494, 144, 1735, 1736, 1192, 1740, - /* 430 */ 9, 487, 482, 1174, 1175, 583, 1221, 1222, 1224, 1225, - /* 440 */ 1226, 1227, 1228, 511, 533, 1236, 1237, 1238, 1239, 1240, - /* 450 */ 1241, 317, 614, 1003, 532, 1251, 566, 1171, 1571, 1573, - /* 460 */ 444, 443, 1169, 150, 1466, 442, 366, 1321, 111, 439, - /* 470 */ 1005, 150, 438, 437, 436, 565, 345, 564, 563, 562, - /* 480 */ 568, 1174, 1175, 1491, 1221, 1222, 1224, 1225, 1226, 1227, - /* 490 */ 1228, 511, 533, 1236, 1237, 1238, 1239, 1240, 1241, 157, - /* 500 */ 11, 10, 1195, 1675, 309, 1171, 478, 1319, 1320, 1322, - /* 510 */ 1323, 485, 130, 1535, 1383, 221, 584, 582, 35, 33, - /* 520 */ 310, 1493, 150, 1382, 61, 1533, 305, 60, 1170, 1174, - /* 530 */ 1175, 1193, 1221, 1222, 1224, 1225, 1226, 1227, 1228, 511, - /* 540 */ 533, 1236, 1237, 1238, 1239, 1240, 1241, 484, 390, 1572, - /* 550 */ 1573, 394, 1304, 1168, 1535, 532, 532, 566, 1194, 532, - /* 560 */ 276, 316, 1192, 1419, 1629, 975, 1533, 106, 106, 374, - /* 570 */ 1176, 367, 386, 1629, 430, 435, 565, 519, 564, 563, - /* 580 */ 562, 1273, 976, 1581, 1491, 1491, 532, 2, 1491, 131, - /* 590 */ 387, 532, 532, 532, 258, 1247, 1381, 1380, 408, 1379, - /* 600 */ 315, 1194, 1535, 1607, 1488, 466, 256, 53, 130, 614, - /* 610 */ 52, 1378, 561, 398, 1534, 1491, 394, 1493, 950, 1169, - /* 620 */ 1491, 1491, 1491, 590, 589, 588, 320, 162, 587, 586, - /* 630 */ 585, 116, 580, 579, 578, 577, 576, 575, 574, 573, - /* 640 */ 123, 569, 318, 428, 1568, 130, 1629, 1629, 1197, 1629, - /* 650 */ 130, 159, 55, 252, 1494, 572, 1521, 1463, 7, 1493, - /* 660 */ 385, 1629, 1171, 380, 379, 378, 377, 376, 373, 372, - /* 670 */ 371, 370, 369, 365, 364, 363, 362, 361, 360, 359, - /* 680 */ 358, 1377, 1376, 54, 492, 503, 1174, 1175, 81, 1221, - /* 690 */ 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, 1236, 1237, - /* 700 */ 1238, 1239, 1240, 1241, 532, 1375, 36, 34, 32, 31, - /* 710 */ 30, 532, 1374, 114, 532, 1194, 529, 938, 939, 59, - /* 720 */ 58, 354, 1223, 530, 156, 1659, 243, 532, 1371, 348, - /* 730 */ 1296, 1629, 1629, 1491, 36, 34, 32, 31, 30, 319, - /* 740 */ 1491, 275, 185, 1491, 338, 183, 336, 332, 328, 153, - /* 750 */ 323, 112, 279, 1675, 1370, 1629, 1491, 1369, 1476, 1742, - /* 760 */ 571, 495, 1629, 1742, 1368, 1223, 146, 1735, 1736, 1367, - /* 770 */ 1740, 515, 1366, 206, 1478, 1629, 1208, 1365, 1629, 1409, - /* 780 */ 279, 150, 1364, 1738, 1259, 1659, 1363, 1737, 1747, 1292, - /* 790 */ 1474, 187, 1688, 434, 186, 83, 1660, 518, 1662, 1663, - /* 800 */ 514, 445, 535, 189, 1629, 1728, 188, 1629, 197, 298, - /* 810 */ 1724, 143, 1259, 1675, 1629, 433, 1404, 191, 1402, 1629, - /* 820 */ 190, 495, 1629, 222, 456, 1153, 1154, 1629, 474, 1755, - /* 830 */ 1292, 515, 1629, 1260, 449, 1629, 1629, 454, 447, 1649, - /* 840 */ 450, 510, 120, 46, 560, 209, 37, 11, 10, 457, - /* 850 */ 1355, 1356, 1688, 465, 1265, 83, 1660, 518, 1662, 1663, - /* 860 */ 514, 1260, 535, 193, 1179, 1728, 37, 37, 232, 298, - /* 870 */ 1724, 143, 1373, 504, 118, 452, 1651, 1170, 1178, 1223, - /* 880 */ 446, 1449, 1265, 470, 1318, 192, 211, 1267, 225, 1756, - /* 890 */ 459, 119, 27, 303, 1254, 1255, 1256, 1257, 1258, 1262, - /* 900 */ 1263, 1264, 1168, 1659, 120, 498, 46, 1229, 1126, 234, - /* 910 */ 51, 540, 479, 50, 216, 524, 119, 1676, 120, 1176, - /* 920 */ 27, 303, 1254, 1255, 1256, 1257, 1258, 1262, 1263, 1264, - /* 930 */ 1182, 1675, 240, 1393, 427, 1659, 1758, 1295, 121, 516, - /* 940 */ 1530, 119, 493, 224, 1181, 1034, 227, 251, 229, 515, - /* 950 */ 3, 5, 1062, 1629, 1192, 322, 325, 1066, 614, 1072, - /* 960 */ 329, 1003, 284, 1675, 285, 1137, 248, 1659, 1169, 368, - /* 970 */ 1688, 516, 1570, 83, 1660, 518, 1662, 1663, 514, 1070, - /* 980 */ 535, 515, 122, 1728, 158, 1629, 383, 298, 1724, 1803, - /* 990 */ 375, 388, 1198, 382, 384, 1675, 389, 397, 1762, 1201, - /* 1000 */ 400, 165, 1688, 516, 401, 83, 1660, 518, 1662, 1663, - /* 1010 */ 514, 1171, 535, 515, 167, 1728, 1200, 1629, 1659, 298, - /* 1020 */ 1724, 1803, 1202, 402, 170, 405, 403, 172, 406, 1199, - /* 1030 */ 1785, 175, 407, 410, 1688, 1174, 1175, 83, 1660, 518, - /* 1040 */ 1662, 1663, 514, 62, 535, 178, 1675, 1728, 1659, 1176, - /* 1050 */ 431, 298, 1724, 1803, 516, 1481, 429, 182, 1477, 86, - /* 1060 */ 184, 1611, 1746, 124, 515, 293, 125, 1479, 1629, 1475, - /* 1070 */ 126, 249, 195, 496, 460, 198, 1675, 127, 467, 469, - /* 1080 */ 461, 472, 464, 1197, 516, 1688, 201, 471, 263, 1660, - /* 1090 */ 518, 1662, 1663, 514, 515, 535, 204, 1759, 1629, 480, - /* 1100 */ 522, 1769, 1768, 496, 6, 1749, 207, 477, 489, 215, - /* 1110 */ 1292, 476, 210, 137, 1790, 1688, 297, 113, 263, 1660, - /* 1120 */ 518, 1662, 1663, 514, 483, 535, 149, 1196, 40, 217, - /* 1130 */ 1787, 505, 502, 1041, 558, 557, 556, 1045, 555, 1047, - /* 1140 */ 1048, 554, 1050, 551, 1790, 1056, 548, 1058, 1059, 545, - /* 1150 */ 542, 1743, 18, 299, 1579, 1578, 147, 180, 520, 521, - /* 1160 */ 1787, 1786, 1709, 1659, 218, 307, 223, 525, 526, 141, - /* 1170 */ 236, 527, 238, 250, 1492, 426, 422, 418, 414, 179, - /* 1180 */ 71, 73, 1659, 538, 1464, 253, 1806, 245, 47, 499, - /* 1190 */ 226, 1675, 613, 506, 228, 136, 264, 274, 255, 516, - /* 1200 */ 257, 265, 1623, 1622, 64, 57, 1621, 177, 324, 515, - /* 1210 */ 1675, 1618, 327, 1629, 326, 1163, 1164, 154, 513, 331, - /* 1220 */ 1616, 333, 334, 335, 1615, 337, 1614, 339, 515, 1613, - /* 1230 */ 1688, 341, 1629, 84, 1660, 518, 1662, 1663, 514, 1612, - /* 1240 */ 535, 1659, 343, 1728, 1597, 155, 346, 507, 1724, 1688, - /* 1250 */ 1659, 347, 272, 1660, 518, 1662, 1663, 514, 512, 535, - /* 1260 */ 509, 1700, 1140, 1591, 176, 1139, 168, 1590, 173, 1675, - /* 1270 */ 404, 352, 353, 1589, 1588, 1109, 1563, 516, 1675, 1562, - /* 1280 */ 1561, 1560, 1559, 1558, 1557, 1556, 516, 515, 166, 1555, - /* 1290 */ 1554, 1629, 1553, 1552, 1551, 1550, 515, 1549, 1548, 1547, - /* 1300 */ 1629, 1546, 117, 1545, 1544, 1543, 1542, 1541, 1688, 1540, - /* 1310 */ 1111, 134, 1660, 518, 1662, 1663, 514, 1688, 535, 1539, - /* 1320 */ 84, 1660, 518, 1662, 1663, 514, 1538, 535, 1537, 1536, - /* 1330 */ 1728, 617, 1659, 1421, 1389, 1725, 163, 108, 941, 940, - /* 1340 */ 1388, 1659, 1605, 140, 1599, 247, 1587, 171, 164, 1586, - /* 1350 */ 109, 1576, 393, 169, 497, 1804, 1470, 107, 395, 174, - /* 1360 */ 1675, 1420, 1418, 606, 602, 598, 594, 246, 516, 1675, - /* 1370 */ 969, 1416, 413, 417, 411, 412, 416, 516, 515, 415, - /* 1380 */ 1414, 1412, 1629, 420, 419, 475, 423, 515, 424, 421, - /* 1390 */ 425, 1629, 80, 1659, 1401, 241, 1400, 1387, 1472, 1688, - /* 1400 */ 1075, 1076, 273, 1660, 518, 1662, 1663, 514, 1688, 535, - /* 1410 */ 45, 268, 1660, 518, 1662, 1663, 514, 1471, 535, 1002, - /* 1420 */ 1001, 1675, 1000, 999, 581, 583, 996, 1410, 528, 516, - /* 1430 */ 290, 1405, 995, 181, 994, 291, 448, 1403, 451, 515, - /* 1440 */ 292, 1386, 453, 1629, 1385, 455, 85, 1604, 488, 1147, - /* 1450 */ 1598, 462, 1659, 473, 1585, 1584, 202, 199, 1583, 1575, - /* 1460 */ 1688, 312, 311, 134, 1660, 518, 1662, 1663, 514, 203, - /* 1470 */ 535, 1184, 208, 67, 1145, 4, 196, 37, 128, 15, - /* 1480 */ 1675, 43, 1317, 1310, 1659, 135, 49, 212, 516, 213, - /* 1490 */ 205, 22, 463, 48, 1289, 214, 1177, 1649, 515, 41, - /* 1500 */ 1659, 23, 1629, 1288, 42, 302, 68, 1805, 220, 138, - /* 1510 */ 1346, 17, 1675, 1176, 1341, 1335, 1340, 10, 300, 1688, - /* 1520 */ 513, 1345, 273, 1660, 518, 1662, 1663, 514, 1675, 535, - /* 1530 */ 515, 1344, 301, 19, 1629, 16, 516, 13, 1231, 1252, - /* 1540 */ 139, 151, 29, 1216, 1230, 517, 515, 12, 523, 20, - /* 1550 */ 1629, 1688, 536, 304, 272, 1660, 518, 1662, 1663, 514, - /* 1560 */ 1659, 535, 1180, 1701, 21, 1574, 237, 1688, 231, 1315, - /* 1570 */ 273, 1660, 518, 1662, 1663, 514, 233, 535, 239, 235, - /* 1580 */ 69, 70, 74, 1648, 242, 1691, 1186, 1233, 1675, 1063, - /* 1590 */ 534, 44, 539, 537, 314, 541, 516, 543, 1060, 544, - /* 1600 */ 1659, 1057, 546, 547, 549, 1185, 515, 1051, 550, 552, - /* 1610 */ 1629, 1659, 1049, 306, 553, 1040, 1055, 1054, 1053, 559, - /* 1620 */ 1071, 1068, 1052, 75, 76, 77, 967, 1688, 1675, 1188, - /* 1630 */ 273, 1660, 518, 1662, 1663, 514, 516, 535, 567, 1675, - /* 1640 */ 533, 1236, 1237, 991, 1069, 1009, 515, 516, 570, 244, - /* 1650 */ 1629, 1659, 989, 988, 987, 984, 986, 515, 1006, 985, - /* 1660 */ 983, 1629, 982, 1004, 1659, 492, 979, 1688, 978, 977, - /* 1670 */ 259, 1660, 518, 1662, 1663, 514, 974, 535, 1688, 1675, - /* 1680 */ 1417, 267, 1660, 518, 1662, 1663, 514, 516, 535, 973, - /* 1690 */ 972, 591, 1675, 592, 114, 593, 1415, 515, 596, 595, - /* 1700 */ 516, 1629, 597, 1413, 599, 600, 601, 1411, 603, 604, - /* 1710 */ 515, 605, 1399, 496, 1629, 607, 608, 1659, 1688, 1398, - /* 1720 */ 1384, 269, 1660, 518, 1662, 1663, 514, 611, 535, 612, - /* 1730 */ 615, 1688, 112, 1172, 260, 1660, 518, 1662, 1663, 514, - /* 1740 */ 254, 535, 616, 1359, 1359, 1675, 1359, 219, 1735, 491, - /* 1750 */ 1659, 490, 1359, 516, 1790, 1359, 1359, 1359, 1359, 1359, - /* 1760 */ 1359, 1359, 1359, 515, 1359, 1659, 149, 1629, 1359, 1359, - /* 1770 */ 1787, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1675, 1359, - /* 1780 */ 1359, 1359, 1359, 1359, 1688, 1359, 516, 270, 1660, 518, - /* 1790 */ 1662, 1663, 514, 1675, 535, 1359, 515, 1359, 1659, 1359, - /* 1800 */ 1629, 516, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 1810 */ 1359, 515, 1359, 1659, 1359, 1629, 1359, 1688, 1359, 1359, - /* 1820 */ 261, 1660, 518, 1662, 1663, 514, 1675, 535, 1359, 1359, - /* 1830 */ 1359, 1359, 1688, 1359, 516, 271, 1660, 518, 1662, 1663, - /* 1840 */ 514, 1675, 535, 1359, 515, 1359, 1359, 1359, 1629, 516, - /* 1850 */ 1359, 1359, 1359, 1659, 1359, 1359, 1359, 1359, 1359, 515, - /* 1860 */ 1359, 1359, 1359, 1629, 1359, 1688, 1359, 1359, 262, 1660, - /* 1870 */ 518, 1662, 1663, 514, 1359, 535, 1359, 1359, 1359, 1359, - /* 1880 */ 1688, 1675, 1359, 1671, 1660, 518, 1662, 1663, 514, 516, - /* 1890 */ 535, 1359, 1359, 1659, 1359, 1359, 1359, 1359, 1359, 515, - /* 1900 */ 1359, 1359, 1359, 1629, 1659, 1359, 1359, 1359, 1359, 1359, - /* 1910 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 1920 */ 1688, 1675, 1359, 1670, 1660, 518, 1662, 1663, 514, 516, - /* 1930 */ 535, 1359, 1675, 1359, 1359, 1359, 1359, 1359, 1359, 515, - /* 1940 */ 516, 1359, 1359, 1629, 1659, 1359, 1359, 1359, 1359, 1359, - /* 1950 */ 515, 1359, 1359, 1359, 1629, 1359, 1359, 1659, 1359, 1359, - /* 1960 */ 1688, 1359, 1359, 1669, 1660, 518, 1662, 1663, 514, 1359, - /* 1970 */ 535, 1688, 1675, 1359, 282, 1660, 518, 1662, 1663, 514, - /* 1980 */ 516, 535, 1359, 1359, 1359, 1675, 1359, 1359, 1359, 1359, - /* 1990 */ 515, 1359, 1359, 516, 1629, 1359, 1359, 1359, 1359, 1359, - /* 2000 */ 1359, 1359, 1359, 515, 1359, 1359, 1359, 1629, 1659, 1359, - /* 2010 */ 1359, 1688, 1359, 1359, 281, 1660, 518, 1662, 1663, 514, - /* 2020 */ 1359, 535, 1359, 1359, 1688, 1359, 1359, 283, 1660, 518, - /* 2030 */ 1662, 1663, 514, 1359, 535, 1359, 1675, 1359, 492, 1359, - /* 2040 */ 1359, 1659, 1359, 1359, 516, 1359, 1359, 1359, 1359, 1359, - /* 2050 */ 1359, 1359, 1359, 1359, 515, 1359, 1359, 1359, 1629, 1359, - /* 2060 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 114, 1359, 1675, - /* 2070 */ 1359, 1359, 1359, 1359, 1359, 1688, 1359, 516, 280, 1660, - /* 2080 */ 518, 1662, 1663, 514, 1359, 535, 496, 515, 1359, 1359, - /* 2090 */ 1359, 1629, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 2100 */ 1359, 1359, 1359, 1359, 1359, 112, 1359, 1359, 1688, 1359, - /* 2110 */ 1359, 266, 1660, 518, 1662, 1663, 514, 1359, 535, 1359, - /* 2120 */ 219, 1735, 491, 1359, 490, 1359, 1359, 1790, 1359, 1359, - /* 2130 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 147, - /* 2140 */ 1359, 1359, 1359, 1787, + /* 0 */ 28, 231, 1663, 1650, 611, 610, 297, 1650, 358, 1485, + /* 10 */ 314, 1483, 35, 33, 352, 36, 34, 32, 31, 30, + /* 20 */ 306, 24, 1173, 1647, 533, 442, 441, 1647, 79, 1647, + /* 30 */ 1679, 36, 34, 32, 31, 30, 152, 493, 517, 1643, + /* 40 */ 1649, 115, 278, 1643, 1649, 1643, 1649, 1171, 516, 1486, + /* 50 */ 536, 533, 1633, 1494, 536, 1794, 536, 497, 14, 1746, + /* 60 */ 35, 33, 1300, 356, 1179, 1663, 114, 147, 306, 1692, + /* 70 */ 1173, 1791, 82, 1664, 519, 1666, 1667, 515, 532, 536, + /* 80 */ 1494, 1, 1732, 1743, 1794, 1314, 280, 1728, 36, 34, + /* 90 */ 32, 31, 30, 1679, 410, 1171, 1793, 1651, 1794, 520, + /* 100 */ 1791, 517, 309, 615, 112, 1583, 14, 1746, 35, 33, + /* 110 */ 149, 516, 1179, 1172, 1791, 1633, 306, 1647, 1173, 145, + /* 120 */ 1739, 1740, 532, 1744, 36, 34, 32, 31, 30, 2, + /* 130 */ 63, 1742, 1692, 1643, 1649, 84, 1664, 519, 1666, 1667, + /* 140 */ 515, 1364, 536, 1171, 536, 1732, 953, 1794, 952, 1731, + /* 150 */ 1728, 615, 1490, 72, 14, 392, 1174, 393, 1395, 148, + /* 160 */ 1179, 1172, 96, 1791, 532, 95, 94, 93, 92, 91, + /* 170 */ 90, 89, 88, 87, 1487, 954, 56, 2, 132, 201, + /* 180 */ 1375, 1177, 1178, 39, 1224, 1225, 1227, 1228, 1229, 1230, + /* 190 */ 1231, 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, 615, + /* 200 */ 400, 952, 393, 1395, 1174, 55, 1197, 66, 133, 1172, + /* 210 */ 96, 150, 1451, 95, 94, 93, 92, 91, 90, 89, + /* 220 */ 88, 87, 65, 279, 1356, 38, 429, 194, 567, 1177, + /* 230 */ 1178, 1363, 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, + /* 240 */ 534, 1239, 1240, 1241, 1242, 1243, 1244, 566, 487, 565, + /* 250 */ 564, 563, 1174, 55, 63, 105, 104, 103, 102, 101, + /* 260 */ 100, 99, 98, 97, 936, 35, 33, 110, 36, 34, + /* 270 */ 32, 31, 30, 306, 1746, 1173, 1489, 1177, 1178, 1198, + /* 280 */ 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, 534, 1239, + /* 290 */ 1240, 1241, 1242, 1243, 1244, 55, 445, 444, 1741, 1538, + /* 300 */ 1171, 443, 940, 941, 111, 440, 296, 1355, 439, 438, + /* 310 */ 437, 1536, 569, 35, 33, 1245, 1679, 1179, 26, 310, + /* 320 */ 1386, 306, 391, 1173, 486, 395, 290, 130, 36, 34, + /* 330 */ 32, 31, 30, 1196, 8, 150, 1496, 1043, 559, 558, + /* 340 */ 557, 1047, 556, 1049, 1050, 555, 1052, 552, 1171, 1058, + /* 350 */ 549, 1060, 1061, 546, 543, 150, 615, 450, 482, 618, + /* 360 */ 485, 35, 33, 585, 583, 1179, 1172, 142, 397, 306, + /* 370 */ 1633, 1173, 458, 248, 1195, 291, 1324, 289, 288, 1532, + /* 380 */ 433, 318, 9, 150, 435, 107, 193, 399, 1574, 1576, + /* 390 */ 395, 607, 603, 599, 595, 247, 1171, 1472, 453, 157, + /* 400 */ 533, 129, 1361, 447, 615, 1425, 434, 572, 192, 1174, + /* 410 */ 1794, 1385, 357, 1179, 1172, 479, 1322, 1323, 1325, 1326, + /* 420 */ 80, 1571, 1792, 242, 61, 150, 1791, 60, 159, 1494, + /* 430 */ 9, 488, 483, 51, 1177, 1178, 50, 1224, 1225, 1227, + /* 440 */ 1228, 1229, 1230, 1231, 512, 534, 1239, 1240, 1241, 1242, + /* 450 */ 1243, 1244, 615, 55, 410, 316, 529, 1174, 54, 319, + /* 460 */ 322, 1633, 1172, 130, 150, 445, 444, 130, 1538, 562, + /* 470 */ 443, 382, 1496, 111, 440, 311, 1496, 439, 438, 437, + /* 480 */ 1536, 474, 1177, 1178, 203, 1224, 1225, 1227, 1228, 1229, + /* 490 */ 1230, 1231, 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, + /* 500 */ 1384, 1794, 1147, 1199, 197, 1174, 1575, 1576, 36, 34, + /* 510 */ 32, 31, 30, 147, 1307, 161, 160, 1791, 35, 33, + /* 520 */ 1197, 1663, 1155, 1156, 195, 1470, 306, 351, 1173, 350, + /* 530 */ 1177, 1178, 493, 1224, 1225, 1227, 1228, 1229, 1230, 1231, + /* 540 */ 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, 253, 1679, + /* 550 */ 1633, 1524, 533, 1171, 1383, 1621, 533, 517, 1382, 1250, + /* 560 */ 277, 114, 1195, 1005, 367, 1197, 1479, 516, 106, 375, + /* 570 */ 1179, 1633, 387, 466, 533, 431, 497, 1422, 1211, 469, + /* 580 */ 1007, 1494, 569, 150, 1381, 1494, 368, 2, 1692, 343, + /* 590 */ 388, 82, 1664, 519, 1666, 1667, 515, 1481, 536, 112, + /* 600 */ 331, 1732, 1477, 1494, 1633, 280, 1728, 198, 1633, 615, + /* 610 */ 345, 341, 533, 495, 144, 1739, 1740, 1794, 1744, 1172, + /* 620 */ 1794, 940, 941, 1538, 106, 1376, 11, 10, 222, 147, + /* 630 */ 317, 436, 147, 1791, 1633, 1536, 1791, 591, 590, 589, + /* 640 */ 321, 1494, 588, 587, 586, 116, 581, 580, 579, 578, + /* 650 */ 577, 576, 575, 574, 123, 570, 32, 31, 30, 1380, + /* 660 */ 386, 1299, 1174, 381, 380, 379, 378, 377, 374, 373, + /* 670 */ 372, 371, 370, 366, 365, 364, 363, 362, 361, 360, + /* 680 */ 359, 499, 1663, 520, 1379, 1226, 1197, 1177, 1178, 1584, + /* 690 */ 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, 534, 1239, + /* 700 */ 1240, 1241, 1242, 1243, 1244, 1264, 131, 1276, 1378, 1633, + /* 710 */ 1679, 259, 573, 533, 1466, 7, 511, 533, 496, 1471, + /* 720 */ 1200, 533, 459, 257, 53, 409, 1269, 52, 516, 1491, + /* 730 */ 1226, 533, 1633, 1610, 1633, 533, 36, 34, 32, 31, + /* 740 */ 30, 1377, 1494, 244, 162, 1374, 1494, 467, 1663, 1692, + /* 750 */ 1494, 501, 83, 1664, 519, 1666, 1667, 515, 1633, 536, + /* 760 */ 1494, 1373, 1732, 1794, 1494, 25, 299, 1728, 143, 55, + /* 770 */ 36, 34, 32, 31, 30, 147, 1679, 1469, 533, 1791, + /* 780 */ 223, 533, 281, 130, 517, 475, 1759, 435, 533, 1372, + /* 790 */ 530, 1633, 1497, 531, 516, 1633, 185, 1371, 1633, 183, + /* 800 */ 320, 476, 1370, 1369, 1663, 81, 1211, 1494, 1368, 434, + /* 810 */ 1494, 1633, 567, 504, 1262, 1692, 281, 1494, 274, 1664, + /* 820 */ 519, 1666, 1667, 515, 509, 536, 1751, 1295, 493, 561, + /* 830 */ 457, 566, 1679, 565, 564, 563, 59, 58, 355, 1633, + /* 840 */ 514, 156, 1452, 455, 1538, 207, 349, 1633, 1262, 584, + /* 850 */ 516, 1226, 1633, 1633, 1633, 1367, 1537, 114, 1633, 276, + /* 860 */ 1173, 226, 339, 1263, 337, 333, 329, 153, 324, 1298, + /* 870 */ 567, 1692, 1412, 1182, 273, 1664, 519, 1666, 1667, 515, + /* 880 */ 513, 536, 510, 1704, 1268, 1171, 1366, 1407, 1295, 566, + /* 890 */ 346, 565, 564, 563, 446, 112, 120, 1263, 187, 150, + /* 900 */ 189, 186, 1179, 188, 191, 1633, 1663, 190, 46, 448, + /* 910 */ 146, 1739, 1740, 1405, 1744, 11, 10, 1653, 1268, 1358, + /* 920 */ 1359, 480, 1181, 27, 304, 1257, 1258, 1259, 1260, 1261, + /* 930 */ 1265, 1266, 1267, 210, 1679, 451, 1633, 471, 502, 1185, + /* 940 */ 78, 615, 496, 37, 37, 460, 37, 1254, 233, 1321, + /* 950 */ 74, 1172, 516, 217, 1655, 1680, 1633, 27, 304, 1257, + /* 960 */ 1258, 1259, 1260, 1261, 1265, 1266, 1267, 118, 1663, 1396, + /* 970 */ 119, 1533, 120, 1692, 212, 46, 83, 1664, 519, 1666, + /* 980 */ 1667, 515, 977, 536, 1270, 1232, 1732, 1128, 1184, 235, + /* 990 */ 299, 1728, 143, 541, 1174, 428, 1679, 1762, 494, 978, + /* 1000 */ 1663, 225, 505, 119, 517, 228, 120, 230, 525, 3, + /* 1010 */ 1760, 241, 5, 1036, 516, 121, 252, 119, 1633, 1177, + /* 1020 */ 1178, 323, 1195, 326, 330, 286, 287, 1005, 1679, 249, + /* 1030 */ 1139, 369, 1573, 376, 1064, 1692, 517, 158, 83, 1664, + /* 1040 */ 519, 1666, 1667, 515, 1068, 536, 516, 1074, 1732, 384, + /* 1050 */ 1633, 389, 299, 1728, 1807, 383, 1072, 1201, 122, 385, + /* 1060 */ 1663, 390, 1204, 1766, 401, 398, 165, 1692, 402, 167, + /* 1070 */ 83, 1664, 519, 1666, 1667, 515, 1203, 536, 1205, 404, + /* 1080 */ 1732, 403, 170, 406, 299, 1728, 1807, 172, 1679, 407, + /* 1090 */ 1202, 175, 1663, 408, 62, 1789, 517, 411, 178, 430, + /* 1100 */ 432, 1484, 182, 86, 1480, 184, 516, 295, 124, 1179, + /* 1110 */ 1633, 125, 1482, 1478, 1615, 126, 127, 1614, 196, 461, + /* 1120 */ 1679, 199, 250, 202, 465, 462, 1200, 1692, 517, 468, + /* 1130 */ 83, 1664, 519, 1666, 1667, 515, 472, 536, 516, 205, + /* 1140 */ 1732, 481, 1633, 1663, 299, 1728, 1807, 497, 470, 478, + /* 1150 */ 473, 523, 1773, 1772, 298, 1750, 490, 208, 1763, 1692, + /* 1160 */ 211, 6, 264, 1664, 519, 1666, 1667, 515, 1753, 536, + /* 1170 */ 484, 1679, 216, 1663, 477, 113, 1295, 218, 1199, 517, + /* 1180 */ 40, 300, 1747, 506, 503, 18, 527, 1582, 1794, 516, + /* 1190 */ 137, 521, 522, 1633, 219, 1581, 526, 308, 497, 237, + /* 1200 */ 149, 1679, 528, 224, 1791, 251, 1663, 1495, 1713, 517, + /* 1210 */ 1692, 1810, 1790, 264, 1664, 519, 1666, 1667, 515, 516, + /* 1220 */ 536, 239, 71, 1633, 73, 539, 246, 254, 500, 614, + /* 1230 */ 136, 227, 1467, 229, 1679, 507, 1663, 265, 47, 1794, + /* 1240 */ 1692, 256, 517, 84, 1664, 519, 1666, 1667, 515, 258, + /* 1250 */ 536, 147, 516, 1732, 275, 1791, 1633, 508, 1728, 266, + /* 1260 */ 1627, 1626, 57, 1625, 1679, 325, 1622, 327, 328, 332, + /* 1270 */ 1166, 1167, 517, 1692, 154, 1620, 134, 1664, 519, 1666, + /* 1280 */ 1667, 515, 516, 536, 334, 335, 1633, 1663, 336, 1619, + /* 1290 */ 338, 1618, 340, 1617, 342, 1616, 1663, 344, 1600, 155, + /* 1300 */ 1142, 347, 1141, 1692, 348, 1594, 84, 1664, 519, 1666, + /* 1310 */ 1667, 515, 1593, 536, 353, 1679, 1732, 354, 1592, 498, + /* 1320 */ 1808, 1729, 1591, 517, 1679, 1111, 1566, 1565, 1564, 1563, + /* 1330 */ 1562, 1561, 517, 516, 1560, 1559, 1558, 1633, 1557, 1556, + /* 1340 */ 1555, 1554, 516, 1553, 1552, 1551, 1633, 1550, 1549, 117, + /* 1350 */ 1663, 1548, 1547, 1546, 1692, 1545, 1544, 269, 1664, 519, + /* 1360 */ 1666, 1667, 515, 1692, 536, 1543, 134, 1664, 519, 1666, + /* 1370 */ 1667, 515, 1113, 536, 1542, 1541, 1540, 1539, 1679, 1424, + /* 1380 */ 1392, 943, 163, 108, 942, 1391, 517, 1608, 1602, 1590, + /* 1390 */ 1663, 171, 1589, 394, 489, 140, 516, 164, 109, 169, + /* 1400 */ 1633, 396, 1579, 303, 45, 174, 1663, 1473, 1423, 1421, + /* 1410 */ 1809, 1419, 1417, 412, 413, 414, 417, 1692, 1679, 971, + /* 1420 */ 274, 1664, 519, 1666, 1667, 515, 514, 536, 416, 420, + /* 1430 */ 418, 421, 422, 1415, 1679, 426, 516, 424, 1404, 425, + /* 1440 */ 1633, 1403, 517, 1390, 1475, 1077, 181, 1078, 1474, 1413, + /* 1450 */ 1004, 582, 516, 1003, 1663, 584, 1633, 1692, 292, 305, + /* 1460 */ 273, 1664, 519, 1666, 1667, 515, 1408, 536, 1002, 1705, + /* 1470 */ 449, 1001, 998, 1692, 997, 996, 274, 1664, 519, 1666, + /* 1480 */ 1667, 515, 1679, 536, 293, 1406, 1663, 294, 1389, 452, + /* 1490 */ 517, 180, 1388, 454, 456, 85, 1607, 1149, 1601, 463, + /* 1500 */ 516, 1588, 1587, 141, 1633, 1586, 1578, 307, 49, 427, + /* 1510 */ 423, 419, 415, 179, 1679, 67, 1663, 204, 464, 4, + /* 1520 */ 37, 1692, 517, 206, 274, 1664, 519, 1666, 1667, 515, + /* 1530 */ 15, 536, 516, 128, 209, 43, 1633, 1320, 64, 200, + /* 1540 */ 135, 177, 213, 215, 1679, 22, 48, 1653, 214, 1313, + /* 1550 */ 68, 23, 517, 1692, 42, 1292, 260, 1664, 519, 1666, + /* 1560 */ 1667, 515, 516, 536, 221, 1291, 1633, 1663, 138, 1349, + /* 1570 */ 17, 1338, 1344, 1343, 301, 1348, 10, 1347, 302, 19, + /* 1580 */ 1255, 139, 1234, 1692, 151, 29, 268, 1664, 519, 1666, + /* 1590 */ 1667, 515, 12, 536, 1233, 1679, 20, 1219, 176, 16, + /* 1600 */ 168, 518, 173, 517, 405, 41, 13, 1663, 1577, 238, + /* 1610 */ 74, 524, 1652, 516, 232, 21, 234, 1633, 1318, 1189, + /* 1620 */ 236, 240, 166, 69, 70, 243, 1695, 540, 1236, 535, + /* 1630 */ 44, 1071, 1065, 538, 1692, 1679, 315, 270, 1664, 519, + /* 1640 */ 1666, 1667, 515, 517, 536, 542, 544, 1663, 1062, 1059, + /* 1650 */ 545, 547, 548, 516, 550, 1053, 553, 1633, 551, 1057, + /* 1660 */ 1051, 1056, 1663, 554, 1055, 1054, 75, 1042, 76, 560, + /* 1670 */ 1073, 77, 1070, 568, 1692, 1679, 969, 261, 1664, 519, + /* 1680 */ 1666, 1667, 515, 517, 536, 993, 1011, 245, 991, 571, + /* 1690 */ 1679, 986, 1008, 516, 990, 989, 988, 1633, 517, 987, + /* 1700 */ 985, 984, 1006, 981, 980, 979, 976, 975, 516, 974, + /* 1710 */ 1420, 592, 1633, 1663, 1692, 593, 594, 271, 1664, 519, + /* 1720 */ 1666, 1667, 515, 1418, 536, 1663, 597, 596, 598, 1692, + /* 1730 */ 1416, 600, 262, 1664, 519, 1666, 1667, 515, 601, 536, + /* 1740 */ 602, 1679, 604, 605, 606, 1402, 608, 609, 1401, 517, + /* 1750 */ 1414, 1387, 613, 1679, 612, 1175, 255, 616, 617, 516, + /* 1760 */ 1362, 517, 1362, 1633, 1362, 1663, 1362, 1362, 1362, 1362, + /* 1770 */ 1362, 516, 1362, 1362, 1362, 1633, 1663, 1362, 1362, 1362, + /* 1780 */ 1692, 1362, 1362, 272, 1664, 519, 1666, 1667, 515, 1362, + /* 1790 */ 536, 1362, 1692, 1679, 1362, 263, 1664, 519, 1666, 1667, + /* 1800 */ 515, 517, 536, 1362, 1679, 1362, 1362, 1362, 1362, 1362, + /* 1810 */ 1362, 516, 517, 1362, 1362, 1633, 1362, 1362, 1362, 1362, + /* 1820 */ 1362, 1362, 516, 1362, 1362, 1362, 1633, 1663, 1362, 1362, + /* 1830 */ 1362, 1362, 1692, 1362, 1362, 1675, 1664, 519, 1666, 1667, + /* 1840 */ 515, 1362, 536, 1692, 1362, 1362, 1674, 1664, 519, 1666, + /* 1850 */ 1667, 515, 1362, 536, 1362, 1679, 1362, 1663, 1362, 1362, + /* 1860 */ 1362, 1362, 1362, 517, 1362, 1362, 1362, 1362, 1362, 1362, + /* 1870 */ 1362, 1362, 1362, 516, 1362, 1362, 1362, 1633, 1362, 1362, + /* 1880 */ 1362, 1362, 1362, 1362, 1362, 1679, 1362, 1663, 1362, 1362, + /* 1890 */ 1362, 1362, 1362, 517, 1692, 1362, 1362, 1673, 1664, 519, + /* 1900 */ 1666, 1667, 515, 516, 536, 1362, 1362, 1633, 1362, 1362, + /* 1910 */ 1362, 1362, 1362, 1362, 1362, 1679, 1362, 1362, 1362, 1663, + /* 1920 */ 1362, 1362, 1362, 517, 1692, 1362, 1362, 284, 1664, 519, + /* 1930 */ 1666, 1667, 515, 516, 536, 1362, 1362, 1633, 1362, 1362, + /* 1940 */ 1362, 1362, 1362, 313, 312, 1362, 1362, 1679, 1362, 1362, + /* 1950 */ 1362, 1362, 1663, 1187, 1692, 517, 1362, 283, 1664, 519, + /* 1960 */ 1666, 1667, 515, 1362, 536, 516, 1362, 1362, 1362, 1633, + /* 1970 */ 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1180, 1362, + /* 1980 */ 1679, 1362, 1362, 1362, 1362, 1663, 1692, 1362, 517, 285, + /* 1990 */ 1664, 519, 1666, 1667, 515, 1179, 536, 1362, 516, 1362, + /* 2000 */ 1362, 1362, 1633, 1362, 1362, 1362, 1362, 1362, 1362, 1362, + /* 2010 */ 1362, 1362, 1362, 1679, 1362, 1362, 493, 1362, 1362, 1692, + /* 2020 */ 1362, 517, 282, 1664, 519, 1666, 1667, 515, 1362, 536, + /* 2030 */ 1362, 516, 1362, 1362, 537, 1633, 1362, 1362, 1362, 1362, + /* 2040 */ 1362, 1362, 1362, 1362, 1183, 114, 493, 1362, 1362, 1362, + /* 2050 */ 1362, 1362, 1692, 1362, 1362, 267, 1664, 519, 1666, 1667, + /* 2060 */ 515, 1362, 536, 1362, 497, 1362, 1362, 1362, 1362, 1362, + /* 2070 */ 1362, 1362, 1362, 1362, 1362, 114, 1362, 1362, 1362, 1362, + /* 2080 */ 1362, 1362, 1362, 112, 1362, 1362, 1362, 1188, 1362, 1362, + /* 2090 */ 1362, 1362, 1362, 1362, 497, 1362, 1362, 1362, 220, 1739, + /* 2100 */ 492, 1362, 491, 1362, 1362, 1794, 1362, 1362, 1362, 1362, + /* 2110 */ 1362, 1362, 1191, 112, 1362, 1362, 1362, 149, 1362, 1362, + /* 2120 */ 1362, 1791, 1362, 534, 1239, 1240, 1362, 1362, 220, 1739, + /* 2130 */ 492, 1362, 491, 1362, 1362, 1794, 1362, 1362, 1362, 1362, + /* 2140 */ 1362, 1362, 1362, 1362, 1362, 1362, 1362, 147, 1362, 1362, + /* 2150 */ 1362, 1791, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 323, 324, 242, 272, 250, 251, 275, 272, 249, 272, - /* 10 */ 275, 271, 12, 13, 297, 12, 13, 14, 15, 16, - /* 20 */ 20, 2, 22, 292, 249, 256, 257, 292, 252, 292, - /* 30 */ 270, 12, 13, 14, 15, 16, 261, 249, 278, 308, - /* 40 */ 309, 265, 283, 308, 309, 308, 309, 47, 288, 273, - /* 50 */ 319, 249, 292, 278, 319, 338, 319, 297, 58, 310, - /* 60 */ 12, 13, 14, 261, 64, 242, 278, 350, 20, 309, - /* 70 */ 22, 354, 312, 313, 314, 315, 316, 317, 41, 319, - /* 80 */ 278, 81, 322, 334, 338, 82, 326, 327, 12, 13, - /* 90 */ 14, 15, 16, 270, 20, 47, 350, 272, 338, 288, - /* 100 */ 354, 278, 291, 103, 316, 294, 58, 57, 12, 13, - /* 110 */ 350, 288, 64, 113, 354, 292, 20, 292, 22, 331, - /* 120 */ 332, 333, 20, 335, 12, 13, 14, 15, 16, 81, - /* 130 */ 75, 254, 309, 308, 309, 312, 313, 314, 315, 316, - /* 140 */ 317, 0, 319, 47, 319, 322, 20, 338, 4, 326, - /* 150 */ 327, 103, 269, 276, 58, 245, 156, 247, 248, 350, - /* 160 */ 64, 113, 21, 354, 281, 24, 25, 26, 27, 28, - /* 170 */ 29, 30, 31, 32, 119, 120, 241, 81, 243, 93, - /* 180 */ 180, 181, 4, 183, 184, 185, 186, 187, 188, 189, - /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 112, 103, - /* 200 */ 114, 115, 116, 245, 156, 247, 248, 81, 21, 113, - /* 210 */ 210, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 220 */ 42, 43, 165, 166, 148, 81, 169, 0, 180, 181, - /* 230 */ 0, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 240 */ 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, - /* 250 */ 16, 20, 156, 239, 24, 25, 26, 27, 28, 29, - /* 260 */ 30, 31, 32, 0, 227, 12, 13, 12, 13, 14, - /* 270 */ 15, 16, 45, 20, 81, 22, 180, 181, 151, 183, + /* 0 */ 324, 325, 243, 273, 251, 252, 276, 273, 250, 273, + /* 10 */ 276, 272, 12, 13, 298, 12, 13, 14, 15, 16, + /* 20 */ 20, 2, 22, 293, 250, 257, 258, 293, 253, 293, + /* 30 */ 271, 12, 13, 14, 15, 16, 262, 250, 279, 309, + /* 40 */ 310, 266, 284, 309, 310, 309, 310, 47, 289, 274, + /* 50 */ 320, 250, 293, 279, 320, 339, 320, 298, 58, 311, + /* 60 */ 12, 13, 14, 262, 64, 243, 279, 351, 20, 310, + /* 70 */ 22, 355, 313, 314, 315, 316, 317, 318, 20, 320, + /* 80 */ 279, 81, 323, 335, 339, 82, 327, 328, 12, 13, + /* 90 */ 14, 15, 16, 271, 57, 47, 351, 273, 339, 289, + /* 100 */ 355, 279, 292, 103, 317, 295, 58, 311, 12, 13, + /* 110 */ 351, 289, 64, 113, 355, 293, 20, 293, 22, 332, + /* 120 */ 333, 334, 20, 336, 12, 13, 14, 15, 16, 81, + /* 130 */ 255, 335, 310, 309, 310, 313, 314, 315, 316, 317, + /* 140 */ 318, 0, 320, 47, 320, 323, 20, 339, 22, 327, + /* 150 */ 328, 103, 277, 253, 58, 246, 156, 248, 249, 351, + /* 160 */ 64, 113, 21, 355, 20, 24, 25, 26, 27, 28, + /* 170 */ 29, 30, 31, 32, 274, 49, 4, 81, 242, 55, + /* 180 */ 244, 181, 182, 81, 184, 185, 186, 187, 188, 189, + /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 103, + /* 200 */ 246, 22, 248, 249, 156, 81, 20, 83, 256, 113, + /* 210 */ 21, 211, 260, 24, 25, 26, 27, 28, 29, 30, + /* 220 */ 31, 32, 165, 166, 148, 81, 47, 170, 93, 181, + /* 230 */ 182, 0, 184, 185, 186, 187, 188, 189, 190, 191, + /* 240 */ 192, 193, 194, 195, 196, 197, 198, 112, 20, 114, + /* 250 */ 115, 116, 156, 81, 255, 24, 25, 26, 27, 28, + /* 260 */ 29, 30, 31, 32, 4, 12, 13, 268, 12, 13, + /* 270 */ 14, 15, 16, 20, 311, 22, 277, 181, 182, 20, /* 280 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 290 */ 194, 195, 196, 197, 297, 249, 60, 61, 171, 172, - /* 300 */ 47, 65, 20, 242, 68, 69, 230, 261, 72, 73, - /* 310 */ 74, 297, 81, 12, 13, 14, 2, 64, 255, 254, - /* 320 */ 57, 20, 259, 22, 278, 252, 12, 13, 14, 15, - /* 330 */ 16, 270, 267, 58, 81, 338, 210, 82, 270, 278, - /* 340 */ 35, 276, 81, 249, 297, 277, 273, 350, 47, 288, - /* 350 */ 282, 354, 338, 292, 210, 20, 103, 22, 297, 143, - /* 360 */ 139, 12, 13, 0, 350, 64, 113, 55, 354, 20, - /* 370 */ 309, 22, 278, 312, 313, 314, 315, 316, 317, 145, - /* 380 */ 319, 160, 81, 322, 49, 338, 57, 326, 327, 84, - /* 390 */ 20, 86, 87, 81, 89, 83, 47, 350, 93, 338, - /* 400 */ 0, 354, 81, 210, 103, 338, 14, 15, 16, 156, - /* 410 */ 316, 350, 91, 64, 113, 354, 155, 350, 157, 198, - /* 420 */ 115, 354, 14, 0, 330, 331, 332, 333, 20, 335, - /* 430 */ 81, 215, 216, 180, 181, 41, 183, 184, 185, 186, + /* 290 */ 194, 195, 196, 197, 198, 81, 60, 61, 335, 271, + /* 300 */ 47, 65, 42, 43, 68, 69, 278, 231, 72, 73, + /* 310 */ 74, 283, 57, 12, 13, 14, 271, 64, 2, 263, + /* 320 */ 243, 20, 247, 22, 279, 250, 35, 271, 12, 13, + /* 330 */ 14, 15, 16, 20, 81, 211, 280, 94, 95, 96, + /* 340 */ 97, 98, 99, 100, 101, 102, 103, 104, 47, 106, + /* 350 */ 107, 108, 109, 110, 111, 211, 103, 4, 143, 19, + /* 360 */ 315, 12, 13, 257, 258, 64, 113, 270, 14, 20, + /* 370 */ 293, 22, 19, 33, 20, 84, 181, 86, 87, 282, + /* 380 */ 89, 281, 81, 211, 93, 45, 33, 247, 288, 289, + /* 390 */ 250, 51, 52, 53, 54, 55, 47, 0, 45, 55, + /* 400 */ 250, 145, 240, 50, 103, 0, 115, 64, 55, 156, + /* 410 */ 339, 243, 262, 64, 113, 220, 221, 222, 223, 224, + /* 420 */ 80, 279, 351, 83, 80, 211, 355, 83, 286, 279, + /* 430 */ 81, 216, 217, 80, 181, 182, 83, 184, 185, 186, /* 440 */ 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, - /* 450 */ 197, 280, 103, 47, 249, 180, 93, 156, 287, 288, - /* 460 */ 60, 61, 113, 210, 0, 65, 261, 180, 68, 69, - /* 470 */ 64, 210, 72, 73, 74, 112, 82, 114, 115, 116, - /* 480 */ 57, 180, 181, 278, 183, 184, 185, 186, 187, 188, - /* 490 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 55, - /* 500 */ 1, 2, 20, 270, 262, 156, 219, 220, 221, 222, - /* 510 */ 223, 278, 270, 270, 242, 145, 256, 257, 12, 13, - /* 520 */ 277, 279, 210, 242, 80, 282, 20, 83, 22, 180, - /* 530 */ 181, 20, 183, 184, 185, 186, 187, 188, 189, 190, - /* 540 */ 191, 192, 193, 194, 195, 196, 197, 314, 246, 287, - /* 550 */ 288, 249, 14, 47, 270, 249, 249, 93, 20, 249, - /* 560 */ 18, 277, 20, 0, 292, 47, 282, 261, 261, 27, - /* 570 */ 64, 261, 30, 292, 268, 268, 112, 288, 114, 115, - /* 580 */ 116, 82, 64, 294, 278, 278, 249, 81, 278, 18, - /* 590 */ 48, 249, 249, 249, 23, 14, 242, 242, 261, 242, - /* 600 */ 262, 20, 270, 261, 261, 261, 35, 36, 270, 103, - /* 610 */ 39, 242, 92, 246, 282, 278, 249, 279, 22, 113, - /* 620 */ 278, 278, 278, 60, 61, 62, 63, 56, 65, 66, - /* 630 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - /* 640 */ 77, 78, 262, 47, 278, 270, 292, 292, 20, 292, - /* 650 */ 270, 285, 81, 263, 279, 258, 266, 260, 37, 279, - /* 660 */ 118, 292, 156, 121, 122, 123, 124, 125, 126, 127, + /* 450 */ 197, 198, 103, 81, 57, 263, 116, 156, 3, 263, + /* 460 */ 298, 293, 113, 271, 211, 60, 61, 271, 271, 92, + /* 470 */ 65, 75, 280, 68, 69, 278, 280, 72, 73, 74, + /* 480 */ 283, 141, 181, 182, 144, 184, 185, 186, 187, 188, + /* 490 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 500 */ 243, 339, 162, 20, 164, 156, 288, 289, 12, 13, + /* 510 */ 14, 15, 16, 351, 14, 119, 120, 355, 12, 13, + /* 520 */ 20, 243, 167, 168, 169, 0, 20, 155, 22, 157, + /* 530 */ 181, 182, 250, 184, 185, 186, 187, 188, 189, 190, + /* 540 */ 191, 192, 193, 194, 195, 196, 197, 198, 264, 271, + /* 550 */ 293, 267, 250, 47, 243, 0, 250, 279, 243, 14, + /* 560 */ 18, 279, 20, 47, 262, 20, 272, 289, 262, 27, + /* 570 */ 64, 293, 30, 302, 250, 269, 298, 0, 82, 298, + /* 580 */ 64, 279, 57, 211, 243, 279, 262, 81, 310, 151, + /* 590 */ 48, 313, 314, 315, 316, 317, 318, 272, 320, 317, + /* 600 */ 45, 323, 272, 279, 293, 327, 328, 272, 293, 103, + /* 610 */ 172, 173, 250, 331, 332, 333, 334, 339, 336, 113, + /* 620 */ 339, 42, 43, 271, 262, 244, 1, 2, 145, 351, + /* 630 */ 278, 269, 351, 355, 293, 283, 355, 60, 61, 62, + /* 640 */ 63, 279, 65, 66, 67, 68, 69, 70, 71, 72, + /* 650 */ 73, 74, 75, 76, 77, 78, 14, 15, 16, 243, + /* 660 */ 118, 4, 156, 121, 122, 123, 124, 125, 126, 127, /* 670 */ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - /* 680 */ 138, 242, 242, 3, 249, 41, 180, 181, 117, 183, + /* 680 */ 138, 226, 243, 289, 243, 185, 20, 181, 182, 295, /* 690 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 700 */ 194, 195, 196, 197, 249, 242, 12, 13, 14, 15, - /* 710 */ 16, 249, 242, 278, 249, 20, 261, 42, 43, 148, - /* 720 */ 149, 150, 184, 261, 153, 242, 261, 249, 242, 158, - /* 730 */ 4, 292, 292, 278, 12, 13, 14, 15, 16, 261, - /* 740 */ 278, 170, 85, 278, 173, 88, 175, 176, 177, 178, - /* 750 */ 179, 316, 58, 270, 242, 292, 278, 242, 271, 310, - /* 760 */ 64, 278, 292, 310, 242, 184, 331, 332, 333, 242, - /* 770 */ 335, 288, 242, 145, 271, 292, 82, 242, 292, 0, - /* 780 */ 58, 210, 242, 334, 90, 242, 242, 334, 208, 209, - /* 790 */ 271, 85, 309, 93, 88, 312, 313, 314, 315, 316, - /* 800 */ 317, 22, 319, 85, 292, 322, 88, 292, 271, 326, - /* 810 */ 327, 328, 90, 270, 292, 115, 0, 85, 0, 292, - /* 820 */ 88, 278, 292, 340, 21, 167, 168, 292, 345, 346, - /* 830 */ 209, 288, 292, 139, 4, 292, 292, 34, 22, 44, - /* 840 */ 22, 271, 41, 41, 271, 41, 41, 1, 2, 19, - /* 850 */ 195, 196, 309, 301, 160, 312, 313, 314, 315, 316, - /* 860 */ 317, 139, 319, 33, 47, 322, 41, 41, 41, 326, - /* 870 */ 327, 328, 243, 229, 41, 45, 81, 22, 47, 184, - /* 880 */ 50, 259, 160, 82, 82, 55, 82, 82, 357, 346, - /* 890 */ 305, 41, 198, 199, 200, 201, 202, 203, 204, 205, - /* 900 */ 206, 207, 47, 242, 41, 225, 41, 82, 82, 82, - /* 910 */ 80, 41, 348, 83, 342, 82, 41, 270, 41, 64, - /* 920 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - /* 930 */ 113, 270, 82, 248, 250, 242, 311, 211, 41, 278, - /* 940 */ 281, 41, 336, 351, 113, 82, 351, 82, 351, 288, - /* 950 */ 339, 212, 82, 292, 20, 307, 249, 82, 103, 82, - /* 960 */ 45, 47, 306, 270, 256, 154, 299, 242, 113, 249, - /* 970 */ 309, 278, 249, 312, 313, 314, 315, 316, 317, 82, - /* 980 */ 319, 288, 82, 322, 40, 292, 139, 326, 327, 328, - /* 990 */ 286, 249, 20, 284, 284, 270, 244, 244, 337, 20, - /* 1000 */ 303, 254, 309, 278, 288, 312, 313, 314, 315, 316, - /* 1010 */ 317, 156, 319, 288, 254, 322, 20, 292, 242, 326, - /* 1020 */ 327, 328, 20, 296, 254, 296, 298, 254, 278, 20, - /* 1030 */ 337, 254, 289, 249, 309, 180, 181, 312, 313, 314, - /* 1040 */ 315, 316, 317, 254, 319, 254, 270, 322, 242, 64, - /* 1050 */ 270, 326, 327, 328, 278, 270, 244, 270, 270, 249, - /* 1060 */ 270, 292, 337, 270, 288, 244, 270, 270, 292, 270, - /* 1070 */ 270, 303, 252, 297, 163, 252, 270, 270, 249, 296, - /* 1080 */ 302, 289, 288, 20, 278, 309, 252, 278, 312, 313, - /* 1090 */ 314, 315, 316, 317, 288, 319, 252, 311, 292, 218, - /* 1100 */ 217, 347, 347, 297, 224, 344, 293, 292, 147, 343, - /* 1110 */ 209, 213, 293, 341, 338, 309, 292, 278, 312, 313, - /* 1120 */ 314, 315, 316, 317, 292, 319, 350, 20, 40, 307, - /* 1130 */ 354, 228, 226, 94, 95, 96, 97, 98, 99, 100, - /* 1140 */ 101, 102, 103, 104, 338, 106, 107, 108, 109, 110, - /* 1150 */ 111, 310, 81, 231, 293, 293, 350, 33, 292, 292, - /* 1160 */ 354, 353, 325, 242, 329, 292, 352, 142, 290, 45, - /* 1170 */ 278, 289, 252, 266, 278, 51, 52, 53, 54, 55, - /* 1180 */ 252, 81, 242, 274, 260, 249, 358, 252, 300, 353, - /* 1190 */ 352, 270, 244, 353, 352, 304, 264, 264, 253, 278, - /* 1200 */ 240, 264, 0, 0, 80, 40, 0, 83, 72, 288, - /* 1210 */ 270, 0, 174, 292, 47, 47, 47, 47, 278, 174, - /* 1220 */ 0, 47, 47, 174, 0, 174, 0, 47, 288, 0, - /* 1230 */ 309, 47, 292, 312, 313, 314, 315, 316, 317, 0, - /* 1240 */ 319, 242, 47, 322, 0, 81, 160, 326, 327, 309, - /* 1250 */ 242, 159, 312, 313, 314, 315, 316, 317, 318, 319, - /* 1260 */ 320, 321, 113, 0, 140, 156, 142, 0, 144, 270, - /* 1270 */ 146, 152, 151, 0, 0, 44, 0, 278, 270, 0, - /* 1280 */ 0, 0, 0, 0, 0, 0, 278, 288, 164, 0, - /* 1290 */ 0, 292, 0, 0, 0, 0, 288, 0, 0, 0, - /* 1300 */ 292, 0, 40, 0, 0, 0, 0, 0, 309, 0, - /* 1310 */ 22, 312, 313, 314, 315, 316, 317, 309, 319, 0, - /* 1320 */ 312, 313, 314, 315, 316, 317, 0, 319, 0, 0, - /* 1330 */ 322, 19, 242, 0, 0, 327, 40, 37, 14, 14, - /* 1340 */ 0, 242, 0, 41, 0, 33, 0, 147, 38, 0, - /* 1350 */ 37, 0, 44, 37, 355, 356, 0, 45, 44, 37, - /* 1360 */ 270, 0, 0, 51, 52, 53, 54, 55, 278, 270, - /* 1370 */ 59, 0, 37, 37, 47, 45, 45, 278, 288, 47, - /* 1380 */ 0, 0, 292, 45, 47, 295, 47, 288, 45, 37, - /* 1390 */ 37, 292, 80, 242, 0, 83, 0, 0, 0, 309, - /* 1400 */ 22, 47, 312, 313, 314, 315, 316, 317, 309, 319, - /* 1410 */ 90, 312, 313, 314, 315, 316, 317, 0, 319, 47, - /* 1420 */ 47, 270, 47, 47, 41, 41, 47, 0, 116, 278, - /* 1430 */ 22, 0, 47, 88, 47, 22, 48, 0, 47, 288, - /* 1440 */ 22, 0, 22, 292, 0, 22, 20, 0, 349, 47, - /* 1450 */ 0, 22, 242, 141, 0, 0, 144, 142, 0, 0, - /* 1460 */ 309, 12, 13, 312, 313, 314, 315, 316, 317, 37, - /* 1470 */ 319, 22, 82, 81, 162, 41, 164, 41, 161, 214, - /* 1480 */ 270, 41, 82, 82, 242, 81, 145, 81, 278, 41, - /* 1490 */ 140, 81, 145, 145, 82, 44, 47, 44, 288, 208, - /* 1500 */ 242, 41, 292, 82, 41, 295, 81, 356, 44, 44, - /* 1510 */ 82, 41, 270, 64, 47, 82, 47, 2, 47, 309, - /* 1520 */ 278, 47, 312, 313, 314, 315, 316, 317, 270, 319, - /* 1530 */ 288, 47, 47, 41, 292, 214, 278, 214, 82, 180, - /* 1540 */ 44, 44, 81, 22, 82, 182, 288, 81, 143, 81, - /* 1550 */ 292, 309, 103, 295, 312, 313, 314, 315, 316, 317, - /* 1560 */ 242, 319, 113, 321, 81, 0, 37, 309, 82, 82, - /* 1570 */ 312, 313, 314, 315, 316, 317, 81, 319, 140, 81, - /* 1580 */ 81, 81, 91, 44, 44, 81, 22, 82, 270, 82, - /* 1590 */ 81, 81, 47, 92, 47, 81, 278, 47, 82, 81, - /* 1600 */ 242, 82, 47, 81, 47, 156, 288, 82, 81, 47, - /* 1610 */ 292, 242, 82, 295, 81, 22, 105, 105, 105, 93, - /* 1620 */ 47, 22, 105, 81, 81, 81, 59, 309, 270, 180, - /* 1630 */ 312, 313, 314, 315, 316, 317, 278, 319, 58, 270, - /* 1640 */ 191, 192, 193, 47, 113, 64, 288, 278, 79, 41, - /* 1650 */ 292, 242, 47, 47, 47, 22, 47, 288, 64, 47, - /* 1660 */ 47, 292, 47, 47, 242, 249, 47, 309, 47, 47, - /* 1670 */ 312, 313, 314, 315, 316, 317, 47, 319, 309, 270, - /* 1680 */ 0, 312, 313, 314, 315, 316, 317, 278, 319, 47, - /* 1690 */ 47, 47, 270, 45, 278, 37, 0, 288, 45, 47, - /* 1700 */ 278, 292, 37, 0, 47, 45, 37, 0, 47, 45, - /* 1710 */ 288, 37, 0, 297, 292, 47, 46, 242, 309, 0, - /* 1720 */ 0, 312, 313, 314, 315, 316, 317, 22, 319, 21, - /* 1730 */ 21, 309, 316, 22, 312, 313, 314, 315, 316, 317, - /* 1740 */ 22, 319, 20, 359, 359, 270, 359, 331, 332, 333, - /* 1750 */ 242, 335, 359, 278, 338, 359, 359, 359, 359, 359, - /* 1760 */ 359, 359, 359, 288, 359, 242, 350, 292, 359, 359, - /* 1770 */ 354, 359, 359, 359, 359, 359, 359, 359, 270, 359, - /* 1780 */ 359, 359, 359, 359, 309, 359, 278, 312, 313, 314, - /* 1790 */ 315, 316, 317, 270, 319, 359, 288, 359, 242, 359, - /* 1800 */ 292, 278, 359, 359, 359, 359, 359, 359, 359, 359, - /* 1810 */ 359, 288, 359, 242, 359, 292, 359, 309, 359, 359, - /* 1820 */ 312, 313, 314, 315, 316, 317, 270, 319, 359, 359, - /* 1830 */ 359, 359, 309, 359, 278, 312, 313, 314, 315, 316, - /* 1840 */ 317, 270, 319, 359, 288, 359, 359, 359, 292, 278, - /* 1850 */ 359, 359, 359, 242, 359, 359, 359, 359, 359, 288, - /* 1860 */ 359, 359, 359, 292, 359, 309, 359, 359, 312, 313, - /* 1870 */ 314, 315, 316, 317, 359, 319, 359, 359, 359, 359, - /* 1880 */ 309, 270, 359, 312, 313, 314, 315, 316, 317, 278, - /* 1890 */ 319, 359, 359, 242, 359, 359, 359, 359, 359, 288, - /* 1900 */ 359, 359, 359, 292, 242, 359, 359, 359, 359, 359, - /* 1910 */ 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, - /* 1920 */ 309, 270, 359, 312, 313, 314, 315, 316, 317, 278, - /* 1930 */ 319, 359, 270, 359, 359, 359, 359, 359, 359, 288, - /* 1940 */ 278, 359, 359, 292, 242, 359, 359, 359, 359, 359, - /* 1950 */ 288, 359, 359, 359, 292, 359, 359, 242, 359, 359, - /* 1960 */ 309, 359, 359, 312, 313, 314, 315, 316, 317, 359, - /* 1970 */ 319, 309, 270, 359, 312, 313, 314, 315, 316, 317, - /* 1980 */ 278, 319, 359, 359, 359, 270, 359, 359, 359, 359, - /* 1990 */ 288, 359, 359, 278, 292, 359, 359, 359, 359, 359, - /* 2000 */ 359, 359, 359, 288, 359, 359, 359, 292, 242, 359, - /* 2010 */ 359, 309, 359, 359, 312, 313, 314, 315, 316, 317, - /* 2020 */ 359, 319, 359, 359, 309, 359, 359, 312, 313, 314, - /* 2030 */ 315, 316, 317, 359, 319, 359, 270, 359, 249, 359, - /* 2040 */ 359, 242, 359, 359, 278, 359, 359, 359, 359, 359, - /* 2050 */ 359, 359, 359, 359, 288, 359, 359, 359, 292, 359, - /* 2060 */ 359, 359, 359, 359, 359, 359, 359, 278, 359, 270, - /* 2070 */ 359, 359, 359, 359, 359, 309, 359, 278, 312, 313, - /* 2080 */ 314, 315, 316, 317, 359, 319, 297, 288, 359, 359, - /* 2090 */ 359, 292, 359, 359, 359, 359, 359, 359, 359, 359, - /* 2100 */ 359, 359, 359, 359, 359, 316, 359, 359, 309, 359, - /* 2110 */ 359, 312, 313, 314, 315, 316, 317, 359, 319, 359, - /* 2120 */ 331, 332, 333, 359, 335, 359, 359, 338, 359, 359, - /* 2130 */ 359, 359, 359, 359, 359, 359, 359, 359, 359, 350, - /* 2140 */ 359, 359, 359, 354, + /* 700 */ 194, 195, 196, 197, 198, 139, 18, 82, 243, 293, + /* 710 */ 271, 23, 259, 250, 261, 37, 272, 250, 279, 0, + /* 720 */ 20, 250, 298, 35, 36, 262, 160, 39, 289, 262, + /* 730 */ 185, 250, 293, 262, 293, 250, 12, 13, 14, 15, + /* 740 */ 16, 243, 279, 262, 56, 243, 279, 262, 243, 310, + /* 750 */ 279, 41, 313, 314, 315, 316, 317, 318, 293, 320, + /* 760 */ 279, 243, 323, 339, 279, 199, 327, 328, 329, 81, + /* 770 */ 12, 13, 14, 15, 16, 351, 271, 0, 250, 355, + /* 780 */ 341, 250, 58, 271, 279, 346, 347, 93, 250, 243, + /* 790 */ 262, 293, 280, 262, 289, 293, 85, 243, 293, 88, + /* 800 */ 262, 296, 243, 243, 243, 117, 82, 279, 243, 115, + /* 810 */ 279, 293, 93, 41, 90, 310, 58, 279, 313, 314, + /* 820 */ 315, 316, 317, 318, 58, 320, 209, 210, 250, 272, + /* 830 */ 21, 112, 271, 114, 115, 116, 148, 149, 150, 293, + /* 840 */ 279, 153, 260, 34, 271, 145, 158, 293, 90, 41, + /* 850 */ 289, 185, 293, 293, 293, 243, 283, 279, 293, 171, + /* 860 */ 22, 358, 174, 139, 176, 177, 178, 179, 180, 212, + /* 870 */ 93, 310, 0, 47, 313, 314, 315, 316, 317, 318, + /* 880 */ 319, 320, 321, 322, 160, 47, 243, 0, 210, 112, + /* 890 */ 82, 114, 115, 116, 22, 317, 41, 139, 85, 211, + /* 900 */ 85, 88, 64, 88, 85, 293, 243, 88, 41, 22, + /* 910 */ 332, 333, 334, 0, 336, 1, 2, 44, 160, 196, + /* 920 */ 197, 349, 47, 199, 200, 201, 202, 203, 204, 205, + /* 930 */ 206, 207, 208, 41, 271, 22, 293, 82, 228, 113, + /* 940 */ 81, 103, 279, 41, 41, 306, 41, 181, 41, 82, + /* 950 */ 91, 113, 289, 343, 81, 271, 293, 199, 200, 201, + /* 960 */ 202, 203, 204, 205, 206, 207, 208, 41, 243, 249, + /* 970 */ 41, 282, 41, 310, 82, 41, 313, 314, 315, 316, + /* 980 */ 317, 318, 47, 320, 82, 82, 323, 82, 113, 82, + /* 990 */ 327, 328, 329, 41, 156, 251, 271, 312, 337, 64, + /* 1000 */ 243, 352, 230, 41, 279, 352, 41, 352, 82, 340, + /* 1010 */ 347, 82, 213, 82, 289, 41, 82, 41, 293, 181, + /* 1020 */ 182, 308, 20, 250, 45, 307, 257, 47, 271, 300, + /* 1030 */ 154, 250, 250, 287, 82, 310, 279, 40, 313, 314, + /* 1040 */ 315, 316, 317, 318, 82, 320, 289, 82, 323, 139, + /* 1050 */ 293, 250, 327, 328, 329, 285, 82, 20, 82, 285, + /* 1060 */ 243, 245, 20, 338, 304, 245, 255, 310, 289, 255, + /* 1070 */ 313, 314, 315, 316, 317, 318, 20, 320, 20, 299, + /* 1080 */ 323, 297, 255, 297, 327, 328, 329, 255, 271, 279, + /* 1090 */ 20, 255, 243, 290, 255, 338, 279, 250, 255, 245, + /* 1100 */ 271, 271, 271, 250, 271, 271, 289, 245, 271, 64, + /* 1110 */ 293, 271, 271, 271, 293, 271, 271, 293, 253, 163, + /* 1120 */ 271, 253, 304, 253, 289, 303, 20, 310, 279, 250, + /* 1130 */ 313, 314, 315, 316, 317, 318, 279, 320, 289, 253, + /* 1140 */ 323, 219, 293, 243, 327, 328, 329, 298, 297, 293, + /* 1150 */ 290, 218, 348, 348, 293, 338, 147, 294, 312, 310, + /* 1160 */ 294, 225, 313, 314, 315, 316, 317, 318, 345, 320, + /* 1170 */ 293, 271, 344, 243, 214, 279, 210, 308, 20, 279, + /* 1180 */ 40, 232, 311, 229, 227, 81, 291, 294, 339, 289, + /* 1190 */ 342, 293, 293, 293, 330, 294, 142, 293, 298, 279, + /* 1200 */ 351, 271, 290, 353, 355, 267, 243, 279, 326, 279, + /* 1210 */ 310, 359, 354, 313, 314, 315, 316, 317, 318, 289, + /* 1220 */ 320, 253, 253, 293, 81, 275, 253, 250, 354, 245, + /* 1230 */ 305, 353, 261, 353, 271, 354, 243, 265, 301, 339, + /* 1240 */ 310, 254, 279, 313, 314, 315, 316, 317, 318, 241, + /* 1250 */ 320, 351, 289, 323, 265, 355, 293, 327, 328, 265, + /* 1260 */ 0, 0, 40, 0, 271, 72, 0, 47, 175, 175, + /* 1270 */ 47, 47, 279, 310, 47, 0, 313, 314, 315, 316, + /* 1280 */ 317, 318, 289, 320, 47, 47, 293, 243, 175, 0, + /* 1290 */ 175, 0, 47, 0, 47, 0, 243, 47, 0, 81, + /* 1300 */ 113, 160, 156, 310, 159, 0, 313, 314, 315, 316, + /* 1310 */ 317, 318, 0, 320, 152, 271, 323, 151, 0, 356, + /* 1320 */ 357, 328, 0, 279, 271, 44, 0, 0, 0, 0, + /* 1330 */ 0, 0, 279, 289, 0, 0, 0, 293, 0, 0, + /* 1340 */ 0, 0, 289, 0, 0, 0, 293, 0, 0, 40, + /* 1350 */ 243, 0, 0, 0, 310, 0, 0, 313, 314, 315, + /* 1360 */ 316, 317, 318, 310, 320, 0, 313, 314, 315, 316, + /* 1370 */ 317, 318, 22, 320, 0, 0, 0, 0, 271, 0, + /* 1380 */ 0, 14, 40, 37, 14, 0, 279, 0, 0, 0, + /* 1390 */ 243, 147, 0, 44, 350, 41, 289, 38, 37, 37, + /* 1400 */ 293, 44, 0, 296, 90, 37, 243, 0, 0, 0, + /* 1410 */ 357, 0, 0, 47, 45, 37, 45, 310, 271, 59, + /* 1420 */ 313, 314, 315, 316, 317, 318, 279, 320, 47, 47, + /* 1430 */ 37, 45, 37, 0, 271, 37, 289, 47, 0, 45, + /* 1440 */ 293, 0, 279, 0, 0, 22, 88, 47, 0, 0, + /* 1450 */ 47, 41, 289, 47, 243, 41, 293, 310, 22, 296, + /* 1460 */ 313, 314, 315, 316, 317, 318, 0, 320, 47, 322, + /* 1470 */ 48, 47, 47, 310, 47, 47, 313, 314, 315, 316, + /* 1480 */ 317, 318, 271, 320, 22, 0, 243, 22, 0, 47, + /* 1490 */ 279, 33, 0, 22, 22, 20, 0, 47, 0, 22, + /* 1500 */ 289, 0, 0, 45, 293, 0, 0, 296, 145, 51, + /* 1510 */ 52, 53, 54, 55, 271, 81, 243, 37, 145, 41, + /* 1520 */ 41, 310, 279, 140, 313, 314, 315, 316, 317, 318, + /* 1530 */ 215, 320, 289, 161, 82, 41, 293, 82, 80, 142, + /* 1540 */ 81, 83, 81, 44, 271, 81, 145, 44, 41, 82, + /* 1550 */ 81, 41, 279, 310, 41, 82, 313, 314, 315, 316, + /* 1560 */ 317, 318, 289, 320, 44, 82, 293, 243, 44, 82, + /* 1570 */ 41, 82, 47, 47, 47, 47, 2, 47, 47, 41, + /* 1580 */ 181, 44, 82, 310, 44, 81, 313, 314, 315, 316, + /* 1590 */ 317, 318, 81, 320, 82, 271, 81, 22, 140, 215, + /* 1600 */ 142, 183, 144, 279, 146, 209, 215, 243, 0, 37, + /* 1610 */ 91, 143, 44, 289, 82, 81, 81, 293, 82, 22, + /* 1620 */ 81, 140, 164, 81, 81, 44, 81, 47, 82, 81, + /* 1630 */ 81, 113, 82, 92, 310, 271, 47, 313, 314, 315, + /* 1640 */ 316, 317, 318, 279, 320, 81, 47, 243, 82, 82, + /* 1650 */ 81, 47, 81, 289, 47, 82, 47, 293, 81, 105, + /* 1660 */ 82, 105, 243, 81, 105, 105, 81, 22, 81, 93, + /* 1670 */ 47, 81, 22, 58, 310, 271, 59, 313, 314, 315, + /* 1680 */ 316, 317, 318, 279, 320, 47, 64, 41, 47, 79, + /* 1690 */ 271, 22, 64, 289, 47, 47, 47, 293, 279, 47, + /* 1700 */ 47, 47, 47, 47, 47, 47, 47, 47, 289, 47, + /* 1710 */ 0, 47, 293, 243, 310, 45, 37, 313, 314, 315, + /* 1720 */ 316, 317, 318, 0, 320, 243, 45, 47, 37, 310, + /* 1730 */ 0, 47, 313, 314, 315, 316, 317, 318, 45, 320, + /* 1740 */ 37, 271, 47, 45, 37, 0, 47, 46, 0, 279, + /* 1750 */ 0, 0, 21, 271, 22, 22, 22, 21, 20, 289, + /* 1760 */ 360, 279, 360, 293, 360, 243, 360, 360, 360, 360, + /* 1770 */ 360, 289, 360, 360, 360, 293, 243, 360, 360, 360, + /* 1780 */ 310, 360, 360, 313, 314, 315, 316, 317, 318, 360, + /* 1790 */ 320, 360, 310, 271, 360, 313, 314, 315, 316, 317, + /* 1800 */ 318, 279, 320, 360, 271, 360, 360, 360, 360, 360, + /* 1810 */ 360, 289, 279, 360, 360, 293, 360, 360, 360, 360, + /* 1820 */ 360, 360, 289, 360, 360, 360, 293, 243, 360, 360, + /* 1830 */ 360, 360, 310, 360, 360, 313, 314, 315, 316, 317, + /* 1840 */ 318, 360, 320, 310, 360, 360, 313, 314, 315, 316, + /* 1850 */ 317, 318, 360, 320, 360, 271, 360, 243, 360, 360, + /* 1860 */ 360, 360, 360, 279, 360, 360, 360, 360, 360, 360, + /* 1870 */ 360, 360, 360, 289, 360, 360, 360, 293, 360, 360, + /* 1880 */ 360, 360, 360, 360, 360, 271, 360, 243, 360, 360, + /* 1890 */ 360, 360, 360, 279, 310, 360, 360, 313, 314, 315, + /* 1900 */ 316, 317, 318, 289, 320, 360, 360, 293, 360, 360, + /* 1910 */ 360, 360, 360, 360, 360, 271, 360, 360, 360, 243, + /* 1920 */ 360, 360, 360, 279, 310, 360, 360, 313, 314, 315, + /* 1930 */ 316, 317, 318, 289, 320, 360, 360, 293, 360, 360, + /* 1940 */ 360, 360, 360, 12, 13, 360, 360, 271, 360, 360, + /* 1950 */ 360, 360, 243, 22, 310, 279, 360, 313, 314, 315, + /* 1960 */ 316, 317, 318, 360, 320, 289, 360, 360, 360, 293, + /* 1970 */ 360, 360, 360, 360, 360, 360, 360, 360, 47, 360, + /* 1980 */ 271, 360, 360, 360, 360, 243, 310, 360, 279, 313, + /* 1990 */ 314, 315, 316, 317, 318, 64, 320, 360, 289, 360, + /* 2000 */ 360, 360, 293, 360, 360, 360, 360, 360, 360, 360, + /* 2010 */ 360, 360, 360, 271, 360, 360, 250, 360, 360, 310, + /* 2020 */ 360, 279, 313, 314, 315, 316, 317, 318, 360, 320, + /* 2030 */ 360, 289, 360, 360, 103, 293, 360, 360, 360, 360, + /* 2040 */ 360, 360, 360, 360, 113, 279, 250, 360, 360, 360, + /* 2050 */ 360, 360, 310, 360, 360, 313, 314, 315, 316, 317, + /* 2060 */ 318, 360, 320, 360, 298, 360, 360, 360, 360, 360, + /* 2070 */ 360, 360, 360, 360, 360, 279, 360, 360, 360, 360, + /* 2080 */ 360, 360, 360, 317, 360, 360, 360, 156, 360, 360, + /* 2090 */ 360, 360, 360, 360, 298, 360, 360, 360, 332, 333, + /* 2100 */ 334, 360, 336, 360, 360, 339, 360, 360, 360, 360, + /* 2110 */ 360, 360, 181, 317, 360, 360, 360, 351, 360, 360, + /* 2120 */ 360, 355, 360, 192, 193, 194, 360, 360, 332, 333, + /* 2130 */ 334, 360, 336, 360, 360, 339, 360, 360, 360, 360, + /* 2140 */ 360, 360, 360, 360, 360, 360, 360, 351, 360, 360, + /* 2150 */ 360, 355, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2160 */ 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2170 */ 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2180 */ 360, 360, 360, 360, }; -#define YY_SHIFT_COUNT (617) +#define YY_SHIFT_COUNT (618) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1722) +#define YY_SHIFT_MAX (1931) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 571, 0, 0, 48, 96, 96, 96, 96, 253, 253, + /* 0 */ 688, 0, 0, 48, 96, 96, 96, 96, 253, 253, /* 10 */ 96, 96, 301, 349, 506, 349, 349, 349, 349, 349, /* 20 */ 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - /* 30 */ 349, 349, 349, 349, 349, 349, 349, 349, 126, 126, - /* 40 */ 231, 231, 231, 1449, 1449, 1449, 1449, 261, 312, 193, - /* 50 */ 74, 74, 178, 178, 144, 193, 193, 74, 74, 74, - /* 60 */ 74, 74, 74, 74, 50, 74, 74, 102, 282, 482, - /* 70 */ 102, 74, 74, 102, 74, 102, 102, 482, 102, 74, - /* 80 */ 329, 542, 694, 722, 722, 187, 236, 855, 855, 855, - /* 90 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 100 */ 855, 855, 855, 855, 855, 855, 305, 335, 408, 408, - /* 110 */ 263, 406, 370, 370, 370, 423, 406, 511, 482, 102, - /* 120 */ 102, 482, 520, 696, 1039, 1039, 1039, 1039, 1039, 1039, - /* 130 */ 1039, 1312, 141, 400, 76, 287, 57, 216, 538, 581, - /* 140 */ 675, 596, 700, 628, 580, 621, 580, 680, 680, 680, - /* 150 */ 726, 695, 739, 934, 915, 914, 811, 934, 934, 944, - /* 160 */ 847, 847, 934, 972, 972, 979, 50, 482, 50, 996, - /* 170 */ 1002, 50, 996, 50, 511, 1009, 50, 50, 934, 50, - /* 180 */ 972, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 190 */ 102, 102, 934, 972, 985, 979, 329, 911, 482, 329, - /* 200 */ 934, 996, 329, 511, 1009, 329, 1063, 881, 883, 985, - /* 210 */ 881, 883, 985, 985, 102, 880, 961, 898, 739, 901, - /* 220 */ 511, 1107, 1088, 903, 906, 922, 903, 906, 903, 906, - /* 230 */ 1071, 883, 985, 985, 883, 985, 1025, 511, 1009, 329, - /* 240 */ 520, 329, 511, 1100, 696, 934, 329, 972, 2144, 2144, - /* 250 */ 2144, 2144, 2144, 2144, 2144, 563, 1124, 230, 830, 3, - /* 260 */ 19, 314, 234, 255, 363, 464, 112, 112, 112, 112, - /* 270 */ 112, 112, 112, 112, 86, 127, 444, 55, 499, 221, - /* 280 */ 392, 392, 392, 392, 227, 394, 657, 706, 718, 732, - /* 290 */ 779, 816, 818, 803, 658, 801, 802, 804, 846, 655, - /* 300 */ 37, 644, 805, 275, 825, 795, 826, 827, 833, 850, - /* 310 */ 863, 817, 831, 865, 870, 875, 877, 897, 900, 321, - /* 320 */ 518, 1202, 1203, 1165, 1206, 1136, 1211, 1167, 1038, 1168, - /* 330 */ 1169, 1170, 1045, 1220, 1174, 1175, 1049, 1224, 1051, 1226, - /* 340 */ 1180, 1229, 1184, 1239, 1195, 1244, 1164, 1086, 1092, 1149, - /* 350 */ 1109, 1263, 1267, 1119, 1121, 1273, 1274, 1231, 1276, 1279, - /* 360 */ 1280, 1281, 1282, 1283, 1284, 1285, 1289, 1290, 1292, 1293, - /* 370 */ 1294, 1295, 1297, 1298, 1299, 1301, 1262, 1303, 1304, 1305, - /* 380 */ 1306, 1307, 1309, 1288, 1319, 1326, 1328, 1329, 1333, 1334, - /* 390 */ 1296, 1300, 1302, 1324, 1308, 1325, 1314, 1340, 1310, 1313, - /* 400 */ 1342, 1344, 1346, 1316, 1200, 1349, 1351, 1322, 1356, 1311, - /* 410 */ 1361, 1362, 1327, 1330, 1335, 1371, 1332, 1331, 1336, 1380, - /* 420 */ 1337, 1338, 1352, 1381, 1339, 1343, 1353, 1394, 1396, 1397, - /* 430 */ 1398, 1320, 1345, 1354, 1378, 1417, 1372, 1373, 1375, 1376, - /* 440 */ 1383, 1384, 1379, 1385, 1387, 1427, 1408, 1431, 1413, 1388, - /* 450 */ 1437, 1418, 1391, 1441, 1420, 1444, 1423, 1426, 1447, 1341, - /* 460 */ 1402, 1450, 1317, 1429, 1347, 1315, 1454, 1455, 1458, 1348, - /* 470 */ 1459, 1392, 1432, 1350, 1434, 1436, 1265, 1390, 1440, 1400, - /* 480 */ 1404, 1406, 1410, 1401, 1448, 1451, 1453, 1425, 1460, 1321, - /* 490 */ 1412, 1421, 1464, 1291, 1463, 1465, 1428, 1470, 1323, 1433, - /* 500 */ 1467, 1469, 1471, 1474, 1484, 1485, 1433, 1515, 1359, 1492, - /* 510 */ 1456, 1461, 1462, 1496, 1466, 1468, 1497, 1521, 1363, 1483, - /* 520 */ 1486, 1487, 1495, 1498, 1405, 1499, 1565, 1529, 1438, 1500, - /* 530 */ 1491, 1539, 1540, 1504, 1505, 1509, 1564, 1510, 1501, 1507, - /* 540 */ 1545, 1547, 1514, 1516, 1550, 1518, 1519, 1555, 1522, 1525, - /* 550 */ 1557, 1527, 1530, 1562, 1533, 1511, 1512, 1513, 1517, 1593, - /* 560 */ 1526, 1542, 1543, 1573, 1544, 1531, 1599, 1567, 1580, 1596, - /* 570 */ 1581, 1569, 1608, 1605, 1606, 1607, 1609, 1612, 1633, 1613, - /* 580 */ 1615, 1594, 1383, 1616, 1384, 1619, 1621, 1622, 1629, 1642, - /* 590 */ 1643, 1680, 1644, 1648, 1658, 1696, 1652, 1653, 1665, 1703, - /* 600 */ 1657, 1660, 1669, 1707, 1661, 1664, 1674, 1712, 1668, 1670, - /* 610 */ 1719, 1720, 1705, 1708, 1711, 1718, 1709, 1722, + /* 30 */ 349, 349, 349, 349, 349, 349, 349, 349, 144, 144, + /* 40 */ 102, 102, 102, 1931, 1931, 1931, 1931, 372, 124, 214, + /* 50 */ 58, 58, 260, 260, 172, 214, 214, 58, 58, 58, + /* 60 */ 58, 58, 58, 58, 37, 58, 58, 186, 228, 259, + /* 70 */ 186, 58, 58, 186, 58, 186, 186, 259, 186, 58, + /* 80 */ 255, 542, 724, 758, 758, 189, 236, 838, 838, 838, + /* 90 */ 838, 838, 838, 838, 838, 838, 838, 838, 838, 838, + /* 100 */ 838, 838, 838, 838, 838, 838, 291, 126, 354, 354, + /* 110 */ 397, 516, 483, 483, 483, 525, 516, 313, 259, 186, + /* 120 */ 186, 259, 377, 343, 243, 243, 243, 243, 243, 243, + /* 130 */ 243, 340, 141, 405, 76, 195, 57, 215, 500, 545, + /* 140 */ 579, 179, 694, 700, 617, 678, 617, 455, 455, 455, + /* 150 */ 657, 666, 799, 1002, 979, 980, 876, 1002, 1002, 997, + /* 160 */ 910, 910, 1002, 1037, 1037, 1042, 37, 259, 37, 1056, + /* 170 */ 1058, 37, 1056, 37, 313, 1070, 37, 37, 1002, 37, + /* 180 */ 1037, 186, 186, 186, 186, 186, 186, 186, 186, 186, + /* 190 */ 186, 186, 1002, 1037, 1045, 1045, 1042, 255, 956, 259, + /* 200 */ 255, 1002, 1056, 255, 313, 1070, 255, 1106, 922, 933, + /* 210 */ 1045, 922, 933, 1045, 1045, 186, 936, 1009, 960, 799, + /* 220 */ 966, 313, 1158, 1140, 954, 957, 949, 954, 957, 954, + /* 230 */ 957, 1104, 933, 1045, 1045, 933, 1045, 1054, 313, 1070, + /* 240 */ 255, 377, 255, 313, 1143, 343, 1002, 255, 1037, 2152, + /* 250 */ 2152, 2152, 2152, 2152, 2152, 2152, 577, 1458, 231, 353, + /* 260 */ 3, 19, 316, 256, 496, 719, 777, 112, 112, 112, + /* 270 */ 112, 112, 112, 112, 112, 135, 438, 344, 396, 355, + /* 280 */ 625, 566, 642, 642, 642, 642, 555, 808, 711, 813, + /* 290 */ 815, 819, 872, 887, 913, 809, 855, 867, 892, 914, + /* 300 */ 723, 710, 772, 902, 766, 903, 873, 905, 907, 926, + /* 310 */ 929, 931, 826, 875, 934, 952, 962, 965, 974, 976, + /* 320 */ 859, 935, 1260, 1261, 1222, 1263, 1193, 1266, 1220, 1093, + /* 330 */ 1223, 1224, 1227, 1094, 1275, 1237, 1238, 1113, 1289, 1115, + /* 340 */ 1291, 1245, 1293, 1247, 1295, 1250, 1298, 1218, 1141, 1145, + /* 350 */ 1187, 1146, 1305, 1312, 1162, 1166, 1318, 1322, 1281, 1326, + /* 360 */ 1327, 1328, 1329, 1330, 1331, 1334, 1335, 1336, 1338, 1339, + /* 370 */ 1340, 1341, 1343, 1344, 1345, 1347, 1348, 1309, 1351, 1352, + /* 380 */ 1353, 1355, 1356, 1365, 1350, 1374, 1375, 1376, 1377, 1379, + /* 390 */ 1380, 1342, 1346, 1354, 1367, 1349, 1370, 1357, 1385, 1359, + /* 400 */ 1361, 1387, 1388, 1389, 1362, 1244, 1392, 1402, 1368, 1407, + /* 410 */ 1360, 1408, 1409, 1366, 1369, 1378, 1411, 1381, 1371, 1393, + /* 420 */ 1412, 1382, 1386, 1395, 1433, 1390, 1394, 1398, 1438, 1441, + /* 430 */ 1443, 1444, 1314, 1358, 1400, 1423, 1448, 1403, 1406, 1421, + /* 440 */ 1424, 1410, 1414, 1425, 1427, 1428, 1449, 1436, 1466, 1462, + /* 450 */ 1422, 1485, 1465, 1442, 1488, 1471, 1492, 1472, 1475, 1496, + /* 460 */ 1363, 1450, 1498, 1372, 1477, 1373, 1397, 1501, 1502, 1505, + /* 470 */ 1401, 1506, 1434, 1480, 1383, 1478, 1479, 1315, 1452, 1494, + /* 480 */ 1455, 1459, 1461, 1464, 1467, 1507, 1499, 1503, 1469, 1510, + /* 490 */ 1384, 1473, 1483, 1520, 1396, 1513, 1524, 1487, 1529, 1391, + /* 500 */ 1489, 1525, 1526, 1527, 1528, 1530, 1531, 1489, 1574, 1399, + /* 510 */ 1538, 1500, 1504, 1512, 1537, 1511, 1515, 1540, 1575, 1418, + /* 520 */ 1534, 1532, 1536, 1535, 1539, 1468, 1542, 1608, 1572, 1481, + /* 530 */ 1543, 1519, 1568, 1581, 1545, 1546, 1548, 1597, 1549, 1541, + /* 540 */ 1550, 1580, 1589, 1564, 1566, 1599, 1569, 1567, 1604, 1571, + /* 550 */ 1573, 1607, 1577, 1578, 1609, 1582, 1554, 1556, 1559, 1560, + /* 560 */ 1645, 1576, 1585, 1587, 1623, 1590, 1518, 1650, 1617, 1615, + /* 570 */ 1638, 1622, 1610, 1646, 1641, 1647, 1648, 1649, 1652, 1669, + /* 580 */ 1653, 1654, 1628, 1410, 1655, 1414, 1656, 1657, 1658, 1659, + /* 590 */ 1660, 1662, 1710, 1664, 1670, 1679, 1723, 1680, 1681, 1691, + /* 600 */ 1730, 1684, 1693, 1703, 1750, 1695, 1698, 1707, 1745, 1699, + /* 610 */ 1701, 1748, 1751, 1732, 1731, 1733, 1734, 1736, 1738, }; -#define YY_REDUCE_COUNT (254) -#define YY_REDUCE_MIN (-323) -#define YY_REDUCE_MAX (1799) +#define YY_REDUCE_COUNT (255) +#define YY_REDUCE_MIN (-324) +#define YY_REDUCE_MAX (1796) static const short yy_reduce_ofst[] = { - /* 0 */ 14, -240, 61, 483, 543, 661, 693, 725, 776, 806, - /* 10 */ -177, 921, 940, 999, 1008, 1090, 1099, 1151, 1210, 1242, - /* 20 */ 1258, 1318, 1358, 1369, 1409, 1422, 1475, 1508, 1523, 1556, - /* 30 */ 1571, 1611, 1651, 1662, 1702, 1715, 1766, 1799, 1416, 1789, - /* 40 */ 94, -212, 435, -269, -265, -263, -175, -283, -3, 47, - /* 50 */ 306, 307, -90, -42, -254, -191, 67, -225, -198, 46, - /* 60 */ 205, 310, 337, 343, 65, 342, 344, 68, 233, -189, - /* 70 */ 242, 455, 462, 243, 465, 338, 284, 171, 380, 478, - /* 80 */ -224, -241, -323, -323, -323, -65, 63, 272, 281, 354, - /* 90 */ 355, 357, 369, 439, 440, 463, 470, 486, 512, 515, - /* 100 */ 522, 527, 530, 535, 540, 544, -117, -246, 302, 367, - /* 110 */ -123, -231, -251, 449, 453, 73, 260, 366, 289, 375, - /* 120 */ 332, 262, 390, 397, -260, 487, 503, 519, 537, 570, - /* 130 */ 573, 552, 629, 622, 531, 564, 585, 572, 647, 647, - /* 140 */ 685, 684, 659, 625, 606, 606, 606, 592, 595, 597, - /* 150 */ 611, 647, 648, 707, 656, 708, 667, 720, 723, 704, - /* 160 */ 709, 710, 742, 752, 753, 697, 747, 716, 760, 727, - /* 170 */ 728, 770, 729, 773, 750, 743, 777, 789, 784, 791, - /* 180 */ 812, 780, 785, 787, 788, 790, 793, 796, 797, 799, - /* 190 */ 800, 807, 810, 821, 769, 768, 820, 778, 794, 823, - /* 200 */ 829, 783, 834, 809, 792, 844, 786, 754, 813, 815, - /* 210 */ 755, 819, 824, 832, 647, 761, 766, 772, 822, 606, - /* 220 */ 839, 841, 835, 808, 814, 828, 836, 838, 840, 842, - /* 230 */ 837, 861, 866, 867, 862, 873, 878, 892, 882, 920, - /* 240 */ 907, 928, 896, 909, 924, 936, 935, 948, 888, 891, - /* 250 */ 932, 933, 937, 945, 960, + /* 0 */ 162, -241, 278, 439, 663, 725, 757, 817, 849, 900, + /* 10 */ -178, 930, 561, 963, 993, 505, 1044, 1053, 1107, 1147, + /* 20 */ 1163, 1211, 1243, 1273, 1324, 1364, 1404, 1419, 1470, 1482, + /* 30 */ 1522, 1533, 1584, 1614, 1644, 1676, 1709, 1742, 1766, 1796, + /* 40 */ 282, -213, 578, -270, -266, -264, -176, -284, 281, 424, + /* 50 */ 306, 362, -91, -46, -255, -192, 71, -226, -199, 150, + /* 60 */ 302, 324, 463, 467, -1, 471, 485, 28, 45, -190, + /* 70 */ 56, 528, 531, 197, 481, 192, 352, 100, 196, 538, + /* 80 */ -225, -242, -324, -324, -324, -64, -48, 77, 168, 257, + /* 90 */ 311, 315, 341, 416, 441, 465, 498, 502, 518, 546, + /* 100 */ 554, 559, 560, 565, 612, 643, 97, -247, 75, 140, + /* 110 */ -125, -232, -252, -204, -37, -100, 106, 142, 394, 512, + /* 120 */ 573, 218, 284, 453, -261, 294, 325, 330, 335, 444, + /* 130 */ 557, 271, 381, 582, 503, 572, 639, 610, 684, 684, + /* 140 */ 720, 744, 689, 685, 661, 661, 661, 649, 653, 655, + /* 150 */ 669, 684, 713, 773, 718, 769, 729, 781, 782, 746, + /* 160 */ 770, 774, 801, 816, 820, 760, 811, 779, 814, 784, + /* 170 */ 780, 827, 786, 832, 810, 803, 836, 839, 847, 843, + /* 180 */ 854, 829, 830, 831, 833, 834, 837, 840, 841, 842, + /* 190 */ 844, 845, 853, 862, 821, 824, 818, 865, 822, 835, + /* 200 */ 868, 879, 851, 870, 857, 860, 886, 846, 804, 863, + /* 210 */ 856, 805, 866, 861, 877, 684, 823, 828, 848, 869, + /* 220 */ 661, 896, 871, 864, 858, 850, 852, 874, 878, 881, + /* 230 */ 880, 882, 893, 898, 899, 901, 904, 895, 920, 912, + /* 240 */ 968, 938, 969, 928, 950, 971, 977, 973, 984, 937, + /* 250 */ 925, 972, 989, 994, 987, 1008, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 10 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 20 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 30 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 40 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 50 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 60 */ 1357, 1357, 1357, 1357, 1426, 1357, 1357, 1357, 1357, 1357, - /* 70 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 80 */ 1424, 1564, 1357, 1730, 1357, 1357, 1357, 1357, 1357, 1357, - /* 90 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 100 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 110 */ 1426, 1357, 1741, 1741, 1741, 1424, 1357, 1357, 1357, 1357, - /* 120 */ 1357, 1357, 1520, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 130 */ 1357, 1600, 1357, 1357, 1807, 1357, 1606, 1765, 1357, 1357, - /* 140 */ 1357, 1357, 1473, 1757, 1733, 1747, 1734, 1792, 1792, 1792, - /* 150 */ 1750, 1357, 1761, 1357, 1357, 1357, 1592, 1357, 1357, 1569, - /* 160 */ 1566, 1566, 1357, 1357, 1357, 1357, 1426, 1357, 1426, 1357, - /* 170 */ 1357, 1426, 1357, 1426, 1357, 1357, 1426, 1426, 1357, 1426, - /* 180 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 190 */ 1357, 1357, 1357, 1357, 1357, 1357, 1424, 1602, 1357, 1424, - /* 200 */ 1357, 1357, 1424, 1357, 1357, 1424, 1357, 1772, 1770, 1357, - /* 210 */ 1772, 1770, 1357, 1357, 1357, 1784, 1780, 1763, 1761, 1747, - /* 220 */ 1357, 1357, 1357, 1798, 1794, 1810, 1798, 1794, 1798, 1794, - /* 230 */ 1357, 1770, 1357, 1357, 1770, 1357, 1577, 1357, 1357, 1424, - /* 240 */ 1357, 1424, 1357, 1489, 1357, 1357, 1424, 1357, 1594, 1608, - /* 250 */ 1523, 1523, 1523, 1427, 1362, 1357, 1357, 1357, 1357, 1357, - /* 260 */ 1357, 1357, 1357, 1357, 1357, 1357, 1674, 1783, 1782, 1706, - /* 270 */ 1705, 1704, 1702, 1673, 1485, 1357, 1357, 1357, 1357, 1357, - /* 280 */ 1667, 1668, 1666, 1665, 1357, 1357, 1357, 1357, 1357, 1357, - /* 290 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1731, 1357, - /* 300 */ 1795, 1799, 1357, 1357, 1357, 1650, 1357, 1357, 1357, 1357, - /* 310 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 320 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 330 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 340 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 350 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 360 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 370 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 380 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 390 */ 1357, 1357, 1391, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 400 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 410 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 420 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 430 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 440 */ 1454, 1453, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 450 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 460 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 470 */ 1357, 1357, 1357, 1357, 1754, 1764, 1357, 1357, 1357, 1357, - /* 480 */ 1357, 1357, 1357, 1357, 1357, 1357, 1650, 1357, 1781, 1357, - /* 490 */ 1740, 1736, 1357, 1357, 1732, 1357, 1357, 1793, 1357, 1357, - /* 500 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1726, 1357, 1699, - /* 510 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1661, 1357, - /* 520 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 530 */ 1357, 1649, 1357, 1690, 1357, 1357, 1357, 1357, 1357, 1357, - /* 540 */ 1357, 1357, 1517, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 550 */ 1357, 1357, 1357, 1357, 1357, 1502, 1500, 1499, 1498, 1357, - /* 560 */ 1495, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 570 */ 1357, 1357, 1446, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 580 */ 1357, 1357, 1437, 1357, 1436, 1357, 1357, 1357, 1357, 1357, - /* 590 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 600 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 610 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, + /* 0 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 10 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 20 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 30 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 40 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 50 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 60 */ 1360, 1360, 1360, 1360, 1429, 1360, 1360, 1360, 1360, 1360, + /* 70 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 80 */ 1427, 1567, 1360, 1734, 1360, 1360, 1360, 1360, 1360, 1360, + /* 90 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 100 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 110 */ 1429, 1360, 1745, 1745, 1745, 1427, 1360, 1360, 1360, 1360, + /* 120 */ 1360, 1360, 1523, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 130 */ 1360, 1603, 1360, 1360, 1811, 1360, 1609, 1769, 1360, 1360, + /* 140 */ 1360, 1360, 1476, 1761, 1737, 1751, 1738, 1796, 1796, 1796, + /* 150 */ 1754, 1360, 1765, 1360, 1360, 1360, 1595, 1360, 1360, 1572, + /* 160 */ 1569, 1569, 1360, 1360, 1360, 1360, 1429, 1360, 1429, 1360, + /* 170 */ 1360, 1429, 1360, 1429, 1360, 1360, 1429, 1429, 1360, 1429, + /* 180 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 190 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1427, 1605, 1360, + /* 200 */ 1427, 1360, 1360, 1427, 1360, 1360, 1427, 1360, 1776, 1774, + /* 210 */ 1360, 1776, 1774, 1360, 1360, 1360, 1788, 1784, 1767, 1765, + /* 220 */ 1751, 1360, 1360, 1360, 1802, 1798, 1814, 1802, 1798, 1802, + /* 230 */ 1798, 1360, 1774, 1360, 1360, 1774, 1360, 1580, 1360, 1360, + /* 240 */ 1427, 1360, 1427, 1360, 1492, 1360, 1360, 1427, 1360, 1597, + /* 250 */ 1611, 1526, 1526, 1526, 1430, 1365, 1360, 1360, 1360, 1360, + /* 260 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1678, 1787, 1786, + /* 270 */ 1710, 1709, 1708, 1706, 1677, 1488, 1360, 1360, 1360, 1360, + /* 280 */ 1360, 1360, 1671, 1672, 1670, 1669, 1360, 1360, 1360, 1360, + /* 290 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1735, + /* 300 */ 1360, 1799, 1803, 1360, 1360, 1360, 1654, 1360, 1360, 1360, + /* 310 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 320 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 330 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 340 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 350 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 360 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 370 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 380 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 390 */ 1360, 1360, 1360, 1394, 1360, 1360, 1360, 1360, 1360, 1360, + /* 400 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 410 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 420 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 430 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 440 */ 1360, 1457, 1456, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 450 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 460 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 470 */ 1360, 1360, 1360, 1360, 1360, 1758, 1768, 1360, 1360, 1360, + /* 480 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1654, 1360, 1785, + /* 490 */ 1360, 1744, 1740, 1360, 1360, 1736, 1360, 1360, 1797, 1360, + /* 500 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1730, 1360, + /* 510 */ 1703, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1665, + /* 520 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 530 */ 1360, 1360, 1653, 1360, 1694, 1360, 1360, 1360, 1360, 1360, + /* 540 */ 1360, 1360, 1360, 1520, 1360, 1360, 1360, 1360, 1360, 1360, + /* 550 */ 1360, 1360, 1360, 1360, 1360, 1360, 1505, 1503, 1502, 1501, + /* 560 */ 1360, 1498, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 570 */ 1360, 1360, 1360, 1449, 1360, 1360, 1360, 1360, 1360, 1360, + /* 580 */ 1360, 1360, 1360, 1440, 1360, 1439, 1360, 1360, 1360, 1360, + /* 590 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 600 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 610 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, }; /********** End of lemon-generated parsing tables *****************************/ @@ -999,6 +1004,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* TRIGGER => nothing */ 0, /* AT_ONCE => nothing */ 0, /* WINDOW_CLOSE => nothing */ + 0, /* MAX_DELAY => nothing */ 0, /* WATERMARK => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ @@ -1063,12 +1069,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 232, /* NK_BITNOT => ID */ - 232, /* INSERT => ID */ - 232, /* VALUES => ID */ - 232, /* IMPORT => ID */ - 232, /* NK_SEMI => ID */ - 232, /* FILE => ID */ + 233, /* NK_BITNOT => ID */ + 233, /* INSERT => ID */ + 233, /* VALUES => ID */ + 233, /* IMPORT => ID */ + 233, /* NK_SEMI => ID */ + 233, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1325,196 +1331,197 @@ static const char *const yyTokenName[] = { /* 166 */ "TRIGGER", /* 167 */ "AT_ONCE", /* 168 */ "WINDOW_CLOSE", - /* 169 */ "WATERMARK", - /* 170 */ "KILL", - /* 171 */ "CONNECTION", - /* 172 */ "TRANSACTION", - /* 173 */ "BALANCE", - /* 174 */ "VGROUP", - /* 175 */ "MERGE", - /* 176 */ "REDISTRIBUTE", - /* 177 */ "SPLIT", - /* 178 */ "SYNCDB", - /* 179 */ "DELETE", - /* 180 */ "NULL", - /* 181 */ "NK_QUESTION", - /* 182 */ "NK_ARROW", - /* 183 */ "ROWTS", - /* 184 */ "TBNAME", - /* 185 */ "QSTARTTS", - /* 186 */ "QENDTS", - /* 187 */ "WSTARTTS", - /* 188 */ "WENDTS", - /* 189 */ "WDURATION", - /* 190 */ "CAST", - /* 191 */ "NOW", - /* 192 */ "TODAY", - /* 193 */ "TIMEZONE", - /* 194 */ "COUNT", - /* 195 */ "FIRST", - /* 196 */ "LAST", - /* 197 */ "LAST_ROW", - /* 198 */ "BETWEEN", - /* 199 */ "IS", - /* 200 */ "NK_LT", - /* 201 */ "NK_GT", - /* 202 */ "NK_LE", - /* 203 */ "NK_GE", - /* 204 */ "NK_NE", - /* 205 */ "MATCH", - /* 206 */ "NMATCH", - /* 207 */ "CONTAINS", - /* 208 */ "JOIN", - /* 209 */ "INNER", - /* 210 */ "SELECT", - /* 211 */ "DISTINCT", - /* 212 */ "WHERE", - /* 213 */ "PARTITION", - /* 214 */ "BY", - /* 215 */ "SESSION", - /* 216 */ "STATE_WINDOW", - /* 217 */ "SLIDING", - /* 218 */ "FILL", - /* 219 */ "VALUE", - /* 220 */ "NONE", - /* 221 */ "PREV", - /* 222 */ "LINEAR", - /* 223 */ "NEXT", - /* 224 */ "HAVING", - /* 225 */ "ORDER", - /* 226 */ "SLIMIT", - /* 227 */ "SOFFSET", - /* 228 */ "LIMIT", - /* 229 */ "OFFSET", - /* 230 */ "ASC", - /* 231 */ "NULLS", - /* 232 */ "ID", - /* 233 */ "NK_BITNOT", - /* 234 */ "INSERT", - /* 235 */ "VALUES", - /* 236 */ "IMPORT", - /* 237 */ "NK_SEMI", - /* 238 */ "FILE", - /* 239 */ "cmd", - /* 240 */ "account_options", - /* 241 */ "alter_account_options", - /* 242 */ "literal", - /* 243 */ "alter_account_option", - /* 244 */ "user_name", - /* 245 */ "privileges", - /* 246 */ "priv_level", - /* 247 */ "priv_type_list", - /* 248 */ "priv_type", - /* 249 */ "db_name", - /* 250 */ "dnode_endpoint", - /* 251 */ "dnode_host_name", - /* 252 */ "not_exists_opt", - /* 253 */ "db_options", - /* 254 */ "exists_opt", - /* 255 */ "alter_db_options", - /* 256 */ "integer_list", - /* 257 */ "variable_list", - /* 258 */ "retention_list", - /* 259 */ "alter_db_option", - /* 260 */ "retention", - /* 261 */ "full_table_name", - /* 262 */ "column_def_list", - /* 263 */ "tags_def_opt", - /* 264 */ "table_options", - /* 265 */ "multi_create_clause", - /* 266 */ "tags_def", - /* 267 */ "multi_drop_clause", - /* 268 */ "alter_table_clause", - /* 269 */ "alter_table_options", - /* 270 */ "column_name", - /* 271 */ "type_name", - /* 272 */ "signed_literal", - /* 273 */ "create_subtable_clause", - /* 274 */ "specific_tags_opt", - /* 275 */ "literal_list", - /* 276 */ "drop_table_clause", - /* 277 */ "col_name_list", - /* 278 */ "table_name", - /* 279 */ "column_def", - /* 280 */ "func_name_list", - /* 281 */ "alter_table_option", - /* 282 */ "col_name", - /* 283 */ "db_name_cond_opt", - /* 284 */ "like_pattern_opt", - /* 285 */ "table_name_cond", - /* 286 */ "from_db_opt", - /* 287 */ "func_name", - /* 288 */ "function_name", - /* 289 */ "index_name", - /* 290 */ "index_options", - /* 291 */ "func_list", - /* 292 */ "duration_literal", - /* 293 */ "sliding_opt", - /* 294 */ "func", - /* 295 */ "expression_list", - /* 296 */ "topic_name", - /* 297 */ "query_expression", - /* 298 */ "cgroup_name", - /* 299 */ "analyze_opt", - /* 300 */ "explain_options", - /* 301 */ "agg_func_opt", - /* 302 */ "bufsize_opt", - /* 303 */ "stream_name", - /* 304 */ "stream_options", - /* 305 */ "into_opt", - /* 306 */ "dnode_list", - /* 307 */ "where_clause_opt", - /* 308 */ "signed", - /* 309 */ "literal_func", - /* 310 */ "table_alias", - /* 311 */ "column_alias", - /* 312 */ "expression", - /* 313 */ "pseudo_column", - /* 314 */ "column_reference", - /* 315 */ "function_expression", - /* 316 */ "subquery", - /* 317 */ "star_func", - /* 318 */ "star_func_para_list", - /* 319 */ "noarg_func", - /* 320 */ "other_para_list", - /* 321 */ "star_func_para", - /* 322 */ "predicate", - /* 323 */ "compare_op", - /* 324 */ "in_op", - /* 325 */ "in_predicate_value", - /* 326 */ "boolean_value_expression", - /* 327 */ "boolean_primary", - /* 328 */ "common_expression", - /* 329 */ "from_clause", - /* 330 */ "table_reference_list", - /* 331 */ "table_reference", - /* 332 */ "table_primary", - /* 333 */ "joined_table", - /* 334 */ "alias_opt", - /* 335 */ "parenthesized_joined_table", - /* 336 */ "join_type", - /* 337 */ "search_condition", - /* 338 */ "query_specification", - /* 339 */ "set_quantifier_opt", - /* 340 */ "select_list", - /* 341 */ "partition_by_clause_opt", - /* 342 */ "twindow_clause_opt", - /* 343 */ "group_by_clause_opt", - /* 344 */ "having_clause_opt", - /* 345 */ "select_sublist", - /* 346 */ "select_item", - /* 347 */ "fill_opt", - /* 348 */ "fill_mode", - /* 349 */ "group_by_list", - /* 350 */ "query_expression_body", - /* 351 */ "order_by_clause_opt", - /* 352 */ "slimit_clause_opt", - /* 353 */ "limit_clause_opt", - /* 354 */ "query_primary", - /* 355 */ "sort_specification_list", - /* 356 */ "sort_specification", - /* 357 */ "ordering_specification_opt", - /* 358 */ "null_ordering_opt", + /* 169 */ "MAX_DELAY", + /* 170 */ "WATERMARK", + /* 171 */ "KILL", + /* 172 */ "CONNECTION", + /* 173 */ "TRANSACTION", + /* 174 */ "BALANCE", + /* 175 */ "VGROUP", + /* 176 */ "MERGE", + /* 177 */ "REDISTRIBUTE", + /* 178 */ "SPLIT", + /* 179 */ "SYNCDB", + /* 180 */ "DELETE", + /* 181 */ "NULL", + /* 182 */ "NK_QUESTION", + /* 183 */ "NK_ARROW", + /* 184 */ "ROWTS", + /* 185 */ "TBNAME", + /* 186 */ "QSTARTTS", + /* 187 */ "QENDTS", + /* 188 */ "WSTARTTS", + /* 189 */ "WENDTS", + /* 190 */ "WDURATION", + /* 191 */ "CAST", + /* 192 */ "NOW", + /* 193 */ "TODAY", + /* 194 */ "TIMEZONE", + /* 195 */ "COUNT", + /* 196 */ "FIRST", + /* 197 */ "LAST", + /* 198 */ "LAST_ROW", + /* 199 */ "BETWEEN", + /* 200 */ "IS", + /* 201 */ "NK_LT", + /* 202 */ "NK_GT", + /* 203 */ "NK_LE", + /* 204 */ "NK_GE", + /* 205 */ "NK_NE", + /* 206 */ "MATCH", + /* 207 */ "NMATCH", + /* 208 */ "CONTAINS", + /* 209 */ "JOIN", + /* 210 */ "INNER", + /* 211 */ "SELECT", + /* 212 */ "DISTINCT", + /* 213 */ "WHERE", + /* 214 */ "PARTITION", + /* 215 */ "BY", + /* 216 */ "SESSION", + /* 217 */ "STATE_WINDOW", + /* 218 */ "SLIDING", + /* 219 */ "FILL", + /* 220 */ "VALUE", + /* 221 */ "NONE", + /* 222 */ "PREV", + /* 223 */ "LINEAR", + /* 224 */ "NEXT", + /* 225 */ "HAVING", + /* 226 */ "ORDER", + /* 227 */ "SLIMIT", + /* 228 */ "SOFFSET", + /* 229 */ "LIMIT", + /* 230 */ "OFFSET", + /* 231 */ "ASC", + /* 232 */ "NULLS", + /* 233 */ "ID", + /* 234 */ "NK_BITNOT", + /* 235 */ "INSERT", + /* 236 */ "VALUES", + /* 237 */ "IMPORT", + /* 238 */ "NK_SEMI", + /* 239 */ "FILE", + /* 240 */ "cmd", + /* 241 */ "account_options", + /* 242 */ "alter_account_options", + /* 243 */ "literal", + /* 244 */ "alter_account_option", + /* 245 */ "user_name", + /* 246 */ "privileges", + /* 247 */ "priv_level", + /* 248 */ "priv_type_list", + /* 249 */ "priv_type", + /* 250 */ "db_name", + /* 251 */ "dnode_endpoint", + /* 252 */ "dnode_host_name", + /* 253 */ "not_exists_opt", + /* 254 */ "db_options", + /* 255 */ "exists_opt", + /* 256 */ "alter_db_options", + /* 257 */ "integer_list", + /* 258 */ "variable_list", + /* 259 */ "retention_list", + /* 260 */ "alter_db_option", + /* 261 */ "retention", + /* 262 */ "full_table_name", + /* 263 */ "column_def_list", + /* 264 */ "tags_def_opt", + /* 265 */ "table_options", + /* 266 */ "multi_create_clause", + /* 267 */ "tags_def", + /* 268 */ "multi_drop_clause", + /* 269 */ "alter_table_clause", + /* 270 */ "alter_table_options", + /* 271 */ "column_name", + /* 272 */ "type_name", + /* 273 */ "signed_literal", + /* 274 */ "create_subtable_clause", + /* 275 */ "specific_tags_opt", + /* 276 */ "literal_list", + /* 277 */ "drop_table_clause", + /* 278 */ "col_name_list", + /* 279 */ "table_name", + /* 280 */ "column_def", + /* 281 */ "func_name_list", + /* 282 */ "alter_table_option", + /* 283 */ "col_name", + /* 284 */ "db_name_cond_opt", + /* 285 */ "like_pattern_opt", + /* 286 */ "table_name_cond", + /* 287 */ "from_db_opt", + /* 288 */ "func_name", + /* 289 */ "function_name", + /* 290 */ "index_name", + /* 291 */ "index_options", + /* 292 */ "func_list", + /* 293 */ "duration_literal", + /* 294 */ "sliding_opt", + /* 295 */ "func", + /* 296 */ "expression_list", + /* 297 */ "topic_name", + /* 298 */ "query_expression", + /* 299 */ "cgroup_name", + /* 300 */ "analyze_opt", + /* 301 */ "explain_options", + /* 302 */ "agg_func_opt", + /* 303 */ "bufsize_opt", + /* 304 */ "stream_name", + /* 305 */ "stream_options", + /* 306 */ "into_opt", + /* 307 */ "dnode_list", + /* 308 */ "where_clause_opt", + /* 309 */ "signed", + /* 310 */ "literal_func", + /* 311 */ "table_alias", + /* 312 */ "column_alias", + /* 313 */ "expression", + /* 314 */ "pseudo_column", + /* 315 */ "column_reference", + /* 316 */ "function_expression", + /* 317 */ "subquery", + /* 318 */ "star_func", + /* 319 */ "star_func_para_list", + /* 320 */ "noarg_func", + /* 321 */ "other_para_list", + /* 322 */ "star_func_para", + /* 323 */ "predicate", + /* 324 */ "compare_op", + /* 325 */ "in_op", + /* 326 */ "in_predicate_value", + /* 327 */ "boolean_value_expression", + /* 328 */ "boolean_primary", + /* 329 */ "common_expression", + /* 330 */ "from_clause", + /* 331 */ "table_reference_list", + /* 332 */ "table_reference", + /* 333 */ "table_primary", + /* 334 */ "joined_table", + /* 335 */ "alias_opt", + /* 336 */ "parenthesized_joined_table", + /* 337 */ "join_type", + /* 338 */ "search_condition", + /* 339 */ "query_specification", + /* 340 */ "set_quantifier_opt", + /* 341 */ "select_list", + /* 342 */ "partition_by_clause_opt", + /* 343 */ "twindow_clause_opt", + /* 344 */ "group_by_clause_opt", + /* 345 */ "having_clause_opt", + /* 346 */ "select_sublist", + /* 347 */ "select_item", + /* 348 */ "fill_opt", + /* 349 */ "fill_mode", + /* 350 */ "group_by_list", + /* 351 */ "query_expression_body", + /* 352 */ "order_by_clause_opt", + /* 353 */ "slimit_clause_opt", + /* 354 */ "limit_clause_opt", + /* 355 */ "query_primary", + /* 356 */ "sort_specification_list", + /* 357 */ "sort_specification", + /* 358 */ "ordering_specification_opt", + /* 359 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1773,208 +1780,209 @@ static const char *const yyRuleName[] = { /* 248 */ "stream_options ::=", /* 249 */ "stream_options ::= stream_options TRIGGER AT_ONCE", /* 250 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 251 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 252 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 253 */ "cmd ::= KILL QUERY NK_INTEGER", - /* 254 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 255 */ "cmd ::= BALANCE VGROUP", - /* 256 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 257 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 258 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 259 */ "dnode_list ::= DNODE NK_INTEGER", - /* 260 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 261 */ "cmd ::= SYNCDB db_name REPLICA", - /* 262 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 263 */ "cmd ::= query_expression", - /* 264 */ "literal ::= NK_INTEGER", - /* 265 */ "literal ::= NK_FLOAT", - /* 266 */ "literal ::= NK_STRING", - /* 267 */ "literal ::= NK_BOOL", - /* 268 */ "literal ::= TIMESTAMP NK_STRING", - /* 269 */ "literal ::= duration_literal", - /* 270 */ "literal ::= NULL", - /* 271 */ "literal ::= NK_QUESTION", - /* 272 */ "duration_literal ::= NK_VARIABLE", - /* 273 */ "signed ::= NK_INTEGER", - /* 274 */ "signed ::= NK_PLUS NK_INTEGER", - /* 275 */ "signed ::= NK_MINUS NK_INTEGER", - /* 276 */ "signed ::= NK_FLOAT", - /* 277 */ "signed ::= NK_PLUS NK_FLOAT", - /* 278 */ "signed ::= NK_MINUS NK_FLOAT", - /* 279 */ "signed_literal ::= signed", - /* 280 */ "signed_literal ::= NK_STRING", - /* 281 */ "signed_literal ::= NK_BOOL", - /* 282 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 283 */ "signed_literal ::= duration_literal", - /* 284 */ "signed_literal ::= NULL", - /* 285 */ "signed_literal ::= literal_func", - /* 286 */ "literal_list ::= signed_literal", - /* 287 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 288 */ "db_name ::= NK_ID", - /* 289 */ "table_name ::= NK_ID", - /* 290 */ "column_name ::= NK_ID", - /* 291 */ "function_name ::= NK_ID", - /* 292 */ "table_alias ::= NK_ID", - /* 293 */ "column_alias ::= NK_ID", - /* 294 */ "user_name ::= NK_ID", - /* 295 */ "index_name ::= NK_ID", - /* 296 */ "topic_name ::= NK_ID", - /* 297 */ "stream_name ::= NK_ID", - /* 298 */ "cgroup_name ::= NK_ID", - /* 299 */ "expression ::= literal", - /* 300 */ "expression ::= pseudo_column", - /* 301 */ "expression ::= column_reference", - /* 302 */ "expression ::= function_expression", - /* 303 */ "expression ::= subquery", - /* 304 */ "expression ::= NK_LP expression NK_RP", - /* 305 */ "expression ::= NK_PLUS expression", - /* 306 */ "expression ::= NK_MINUS expression", - /* 307 */ "expression ::= expression NK_PLUS expression", - /* 308 */ "expression ::= expression NK_MINUS expression", - /* 309 */ "expression ::= expression NK_STAR expression", - /* 310 */ "expression ::= expression NK_SLASH expression", - /* 311 */ "expression ::= expression NK_REM expression", - /* 312 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 313 */ "expression_list ::= expression", - /* 314 */ "expression_list ::= expression_list NK_COMMA expression", - /* 315 */ "column_reference ::= column_name", - /* 316 */ "column_reference ::= table_name NK_DOT column_name", - /* 317 */ "pseudo_column ::= ROWTS", - /* 318 */ "pseudo_column ::= TBNAME", - /* 319 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 320 */ "pseudo_column ::= QSTARTTS", - /* 321 */ "pseudo_column ::= QENDTS", - /* 322 */ "pseudo_column ::= WSTARTTS", - /* 323 */ "pseudo_column ::= WENDTS", - /* 324 */ "pseudo_column ::= WDURATION", - /* 325 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 326 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 327 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 328 */ "function_expression ::= literal_func", - /* 329 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 330 */ "literal_func ::= NOW", - /* 331 */ "noarg_func ::= NOW", - /* 332 */ "noarg_func ::= TODAY", - /* 333 */ "noarg_func ::= TIMEZONE", - /* 334 */ "star_func ::= COUNT", - /* 335 */ "star_func ::= FIRST", - /* 336 */ "star_func ::= LAST", - /* 337 */ "star_func ::= LAST_ROW", - /* 338 */ "star_func_para_list ::= NK_STAR", - /* 339 */ "star_func_para_list ::= other_para_list", - /* 340 */ "other_para_list ::= star_func_para", - /* 341 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 342 */ "star_func_para ::= expression", - /* 343 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 344 */ "predicate ::= expression compare_op expression", - /* 345 */ "predicate ::= expression BETWEEN expression AND expression", - /* 346 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 347 */ "predicate ::= expression IS NULL", - /* 348 */ "predicate ::= expression IS NOT NULL", - /* 349 */ "predicate ::= expression in_op in_predicate_value", - /* 350 */ "compare_op ::= NK_LT", - /* 351 */ "compare_op ::= NK_GT", - /* 352 */ "compare_op ::= NK_LE", - /* 353 */ "compare_op ::= NK_GE", - /* 354 */ "compare_op ::= NK_NE", - /* 355 */ "compare_op ::= NK_EQ", - /* 356 */ "compare_op ::= LIKE", - /* 357 */ "compare_op ::= NOT LIKE", - /* 358 */ "compare_op ::= MATCH", - /* 359 */ "compare_op ::= NMATCH", - /* 360 */ "compare_op ::= CONTAINS", - /* 361 */ "in_op ::= IN", - /* 362 */ "in_op ::= NOT IN", - /* 363 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 364 */ "boolean_value_expression ::= boolean_primary", - /* 365 */ "boolean_value_expression ::= NOT boolean_primary", - /* 366 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 367 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 368 */ "boolean_primary ::= predicate", - /* 369 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 370 */ "common_expression ::= expression", - /* 371 */ "common_expression ::= boolean_value_expression", - /* 372 */ "from_clause ::= FROM table_reference_list", - /* 373 */ "table_reference_list ::= table_reference", - /* 374 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 375 */ "table_reference ::= table_primary", - /* 376 */ "table_reference ::= joined_table", - /* 377 */ "table_primary ::= table_name alias_opt", - /* 378 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 379 */ "table_primary ::= subquery alias_opt", - /* 380 */ "table_primary ::= parenthesized_joined_table", - /* 381 */ "alias_opt ::=", - /* 382 */ "alias_opt ::= table_alias", - /* 383 */ "alias_opt ::= AS table_alias", - /* 384 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 385 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 386 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 387 */ "join_type ::=", - /* 388 */ "join_type ::= INNER", - /* 389 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 390 */ "set_quantifier_opt ::=", - /* 391 */ "set_quantifier_opt ::= DISTINCT", - /* 392 */ "set_quantifier_opt ::= ALL", - /* 393 */ "select_list ::= NK_STAR", - /* 394 */ "select_list ::= select_sublist", - /* 395 */ "select_sublist ::= select_item", - /* 396 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 397 */ "select_item ::= common_expression", - /* 398 */ "select_item ::= common_expression column_alias", - /* 399 */ "select_item ::= common_expression AS column_alias", - /* 400 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 401 */ "where_clause_opt ::=", - /* 402 */ "where_clause_opt ::= WHERE search_condition", - /* 403 */ "partition_by_clause_opt ::=", - /* 404 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 405 */ "twindow_clause_opt ::=", - /* 406 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 407 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 408 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 409 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 410 */ "sliding_opt ::=", - /* 411 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 412 */ "fill_opt ::=", - /* 413 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 414 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 415 */ "fill_mode ::= NONE", - /* 416 */ "fill_mode ::= PREV", - /* 417 */ "fill_mode ::= NULL", - /* 418 */ "fill_mode ::= LINEAR", - /* 419 */ "fill_mode ::= NEXT", - /* 420 */ "group_by_clause_opt ::=", - /* 421 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 422 */ "group_by_list ::= expression", - /* 423 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 424 */ "having_clause_opt ::=", - /* 425 */ "having_clause_opt ::= HAVING search_condition", - /* 426 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 427 */ "query_expression_body ::= query_primary", - /* 428 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 429 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 430 */ "query_primary ::= query_specification", - /* 431 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 432 */ "order_by_clause_opt ::=", - /* 433 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 434 */ "slimit_clause_opt ::=", - /* 435 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 436 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 437 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 438 */ "limit_clause_opt ::=", - /* 439 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 440 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 441 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 442 */ "subquery ::= NK_LP query_expression NK_RP", - /* 443 */ "search_condition ::= common_expression", - /* 444 */ "sort_specification_list ::= sort_specification", - /* 445 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 446 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 447 */ "ordering_specification_opt ::=", - /* 448 */ "ordering_specification_opt ::= ASC", - /* 449 */ "ordering_specification_opt ::= DESC", - /* 450 */ "null_ordering_opt ::=", - /* 451 */ "null_ordering_opt ::= NULLS FIRST", - /* 452 */ "null_ordering_opt ::= NULLS LAST", + /* 251 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 252 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 253 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 254 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 255 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 256 */ "cmd ::= BALANCE VGROUP", + /* 257 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 258 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 259 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 260 */ "dnode_list ::= DNODE NK_INTEGER", + /* 261 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 262 */ "cmd ::= SYNCDB db_name REPLICA", + /* 263 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 264 */ "cmd ::= query_expression", + /* 265 */ "literal ::= NK_INTEGER", + /* 266 */ "literal ::= NK_FLOAT", + /* 267 */ "literal ::= NK_STRING", + /* 268 */ "literal ::= NK_BOOL", + /* 269 */ "literal ::= TIMESTAMP NK_STRING", + /* 270 */ "literal ::= duration_literal", + /* 271 */ "literal ::= NULL", + /* 272 */ "literal ::= NK_QUESTION", + /* 273 */ "duration_literal ::= NK_VARIABLE", + /* 274 */ "signed ::= NK_INTEGER", + /* 275 */ "signed ::= NK_PLUS NK_INTEGER", + /* 276 */ "signed ::= NK_MINUS NK_INTEGER", + /* 277 */ "signed ::= NK_FLOAT", + /* 278 */ "signed ::= NK_PLUS NK_FLOAT", + /* 279 */ "signed ::= NK_MINUS NK_FLOAT", + /* 280 */ "signed_literal ::= signed", + /* 281 */ "signed_literal ::= NK_STRING", + /* 282 */ "signed_literal ::= NK_BOOL", + /* 283 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 284 */ "signed_literal ::= duration_literal", + /* 285 */ "signed_literal ::= NULL", + /* 286 */ "signed_literal ::= literal_func", + /* 287 */ "literal_list ::= signed_literal", + /* 288 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 289 */ "db_name ::= NK_ID", + /* 290 */ "table_name ::= NK_ID", + /* 291 */ "column_name ::= NK_ID", + /* 292 */ "function_name ::= NK_ID", + /* 293 */ "table_alias ::= NK_ID", + /* 294 */ "column_alias ::= NK_ID", + /* 295 */ "user_name ::= NK_ID", + /* 296 */ "index_name ::= NK_ID", + /* 297 */ "topic_name ::= NK_ID", + /* 298 */ "stream_name ::= NK_ID", + /* 299 */ "cgroup_name ::= NK_ID", + /* 300 */ "expression ::= literal", + /* 301 */ "expression ::= pseudo_column", + /* 302 */ "expression ::= column_reference", + /* 303 */ "expression ::= function_expression", + /* 304 */ "expression ::= subquery", + /* 305 */ "expression ::= NK_LP expression NK_RP", + /* 306 */ "expression ::= NK_PLUS expression", + /* 307 */ "expression ::= NK_MINUS expression", + /* 308 */ "expression ::= expression NK_PLUS expression", + /* 309 */ "expression ::= expression NK_MINUS expression", + /* 310 */ "expression ::= expression NK_STAR expression", + /* 311 */ "expression ::= expression NK_SLASH expression", + /* 312 */ "expression ::= expression NK_REM expression", + /* 313 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 314 */ "expression_list ::= expression", + /* 315 */ "expression_list ::= expression_list NK_COMMA expression", + /* 316 */ "column_reference ::= column_name", + /* 317 */ "column_reference ::= table_name NK_DOT column_name", + /* 318 */ "pseudo_column ::= ROWTS", + /* 319 */ "pseudo_column ::= TBNAME", + /* 320 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 321 */ "pseudo_column ::= QSTARTTS", + /* 322 */ "pseudo_column ::= QENDTS", + /* 323 */ "pseudo_column ::= WSTARTTS", + /* 324 */ "pseudo_column ::= WENDTS", + /* 325 */ "pseudo_column ::= WDURATION", + /* 326 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 327 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 328 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 329 */ "function_expression ::= literal_func", + /* 330 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 331 */ "literal_func ::= NOW", + /* 332 */ "noarg_func ::= NOW", + /* 333 */ "noarg_func ::= TODAY", + /* 334 */ "noarg_func ::= TIMEZONE", + /* 335 */ "star_func ::= COUNT", + /* 336 */ "star_func ::= FIRST", + /* 337 */ "star_func ::= LAST", + /* 338 */ "star_func ::= LAST_ROW", + /* 339 */ "star_func_para_list ::= NK_STAR", + /* 340 */ "star_func_para_list ::= other_para_list", + /* 341 */ "other_para_list ::= star_func_para", + /* 342 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 343 */ "star_func_para ::= expression", + /* 344 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 345 */ "predicate ::= expression compare_op expression", + /* 346 */ "predicate ::= expression BETWEEN expression AND expression", + /* 347 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 348 */ "predicate ::= expression IS NULL", + /* 349 */ "predicate ::= expression IS NOT NULL", + /* 350 */ "predicate ::= expression in_op in_predicate_value", + /* 351 */ "compare_op ::= NK_LT", + /* 352 */ "compare_op ::= NK_GT", + /* 353 */ "compare_op ::= NK_LE", + /* 354 */ "compare_op ::= NK_GE", + /* 355 */ "compare_op ::= NK_NE", + /* 356 */ "compare_op ::= NK_EQ", + /* 357 */ "compare_op ::= LIKE", + /* 358 */ "compare_op ::= NOT LIKE", + /* 359 */ "compare_op ::= MATCH", + /* 360 */ "compare_op ::= NMATCH", + /* 361 */ "compare_op ::= CONTAINS", + /* 362 */ "in_op ::= IN", + /* 363 */ "in_op ::= NOT IN", + /* 364 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 365 */ "boolean_value_expression ::= boolean_primary", + /* 366 */ "boolean_value_expression ::= NOT boolean_primary", + /* 367 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 368 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 369 */ "boolean_primary ::= predicate", + /* 370 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 371 */ "common_expression ::= expression", + /* 372 */ "common_expression ::= boolean_value_expression", + /* 373 */ "from_clause ::= FROM table_reference_list", + /* 374 */ "table_reference_list ::= table_reference", + /* 375 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 376 */ "table_reference ::= table_primary", + /* 377 */ "table_reference ::= joined_table", + /* 378 */ "table_primary ::= table_name alias_opt", + /* 379 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 380 */ "table_primary ::= subquery alias_opt", + /* 381 */ "table_primary ::= parenthesized_joined_table", + /* 382 */ "alias_opt ::=", + /* 383 */ "alias_opt ::= table_alias", + /* 384 */ "alias_opt ::= AS table_alias", + /* 385 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 386 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 387 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 388 */ "join_type ::=", + /* 389 */ "join_type ::= INNER", + /* 390 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 391 */ "set_quantifier_opt ::=", + /* 392 */ "set_quantifier_opt ::= DISTINCT", + /* 393 */ "set_quantifier_opt ::= ALL", + /* 394 */ "select_list ::= NK_STAR", + /* 395 */ "select_list ::= select_sublist", + /* 396 */ "select_sublist ::= select_item", + /* 397 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 398 */ "select_item ::= common_expression", + /* 399 */ "select_item ::= common_expression column_alias", + /* 400 */ "select_item ::= common_expression AS column_alias", + /* 401 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 402 */ "where_clause_opt ::=", + /* 403 */ "where_clause_opt ::= WHERE search_condition", + /* 404 */ "partition_by_clause_opt ::=", + /* 405 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 406 */ "twindow_clause_opt ::=", + /* 407 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 408 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 409 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 410 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 411 */ "sliding_opt ::=", + /* 412 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 413 */ "fill_opt ::=", + /* 414 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 415 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 416 */ "fill_mode ::= NONE", + /* 417 */ "fill_mode ::= PREV", + /* 418 */ "fill_mode ::= NULL", + /* 419 */ "fill_mode ::= LINEAR", + /* 420 */ "fill_mode ::= NEXT", + /* 421 */ "group_by_clause_opt ::=", + /* 422 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 423 */ "group_by_list ::= expression", + /* 424 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 425 */ "having_clause_opt ::=", + /* 426 */ "having_clause_opt ::= HAVING search_condition", + /* 427 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 428 */ "query_expression_body ::= query_primary", + /* 429 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 430 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 431 */ "query_primary ::= query_specification", + /* 432 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 433 */ "order_by_clause_opt ::=", + /* 434 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 435 */ "slimit_clause_opt ::=", + /* 436 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 437 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 438 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 439 */ "limit_clause_opt ::=", + /* 440 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 441 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 442 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 443 */ "subquery ::= NK_LP query_expression NK_RP", + /* 444 */ "search_condition ::= common_expression", + /* 445 */ "sort_specification_list ::= sort_specification", + /* 446 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 447 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 448 */ "ordering_specification_opt ::=", + /* 449 */ "ordering_specification_opt ::= ASC", + /* 450 */ "ordering_specification_opt ::= DESC", + /* 451 */ "null_ordering_opt ::=", + /* 452 */ "null_ordering_opt ::= NULLS FIRST", + /* 453 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2101,174 +2109,174 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 239: /* cmd */ - case 242: /* literal */ - case 253: /* db_options */ - case 255: /* alter_db_options */ - case 260: /* retention */ - case 261: /* full_table_name */ - case 264: /* table_options */ - case 268: /* alter_table_clause */ - case 269: /* alter_table_options */ - case 272: /* signed_literal */ - case 273: /* create_subtable_clause */ - case 276: /* drop_table_clause */ - case 279: /* column_def */ - case 282: /* col_name */ - case 283: /* db_name_cond_opt */ - case 284: /* like_pattern_opt */ - case 285: /* table_name_cond */ - case 286: /* from_db_opt */ - case 287: /* func_name */ - case 290: /* index_options */ - case 292: /* duration_literal */ - case 293: /* sliding_opt */ - case 294: /* func */ - case 297: /* query_expression */ - case 300: /* explain_options */ - case 304: /* stream_options */ - case 305: /* into_opt */ - case 307: /* where_clause_opt */ - case 308: /* signed */ - case 309: /* literal_func */ - case 312: /* expression */ - case 313: /* pseudo_column */ - case 314: /* column_reference */ - case 315: /* function_expression */ - case 316: /* subquery */ - case 321: /* star_func_para */ - case 322: /* predicate */ - case 325: /* in_predicate_value */ - case 326: /* boolean_value_expression */ - case 327: /* boolean_primary */ - case 328: /* common_expression */ - case 329: /* from_clause */ - case 330: /* table_reference_list */ - case 331: /* table_reference */ - case 332: /* table_primary */ - case 333: /* joined_table */ - case 335: /* parenthesized_joined_table */ - case 337: /* search_condition */ - case 338: /* query_specification */ - case 342: /* twindow_clause_opt */ - case 344: /* having_clause_opt */ - case 346: /* select_item */ - case 347: /* fill_opt */ - case 350: /* query_expression_body */ - case 352: /* slimit_clause_opt */ - case 353: /* limit_clause_opt */ - case 354: /* query_primary */ - case 356: /* sort_specification */ + case 240: /* cmd */ + case 243: /* literal */ + case 254: /* db_options */ + case 256: /* alter_db_options */ + case 261: /* retention */ + case 262: /* full_table_name */ + case 265: /* table_options */ + case 269: /* alter_table_clause */ + case 270: /* alter_table_options */ + case 273: /* signed_literal */ + case 274: /* create_subtable_clause */ + case 277: /* drop_table_clause */ + case 280: /* column_def */ + case 283: /* col_name */ + case 284: /* db_name_cond_opt */ + case 285: /* like_pattern_opt */ + case 286: /* table_name_cond */ + case 287: /* from_db_opt */ + case 288: /* func_name */ + case 291: /* index_options */ + case 293: /* duration_literal */ + case 294: /* sliding_opt */ + case 295: /* func */ + case 298: /* query_expression */ + case 301: /* explain_options */ + case 305: /* stream_options */ + case 306: /* into_opt */ + case 308: /* where_clause_opt */ + case 309: /* signed */ + case 310: /* literal_func */ + case 313: /* expression */ + case 314: /* pseudo_column */ + case 315: /* column_reference */ + case 316: /* function_expression */ + case 317: /* subquery */ + case 322: /* star_func_para */ + case 323: /* predicate */ + case 326: /* in_predicate_value */ + case 327: /* boolean_value_expression */ + case 328: /* boolean_primary */ + case 329: /* common_expression */ + case 330: /* from_clause */ + case 331: /* table_reference_list */ + case 332: /* table_reference */ + case 333: /* table_primary */ + case 334: /* joined_table */ + case 336: /* parenthesized_joined_table */ + case 338: /* search_condition */ + case 339: /* query_specification */ + case 343: /* twindow_clause_opt */ + case 345: /* having_clause_opt */ + case 347: /* select_item */ + case 348: /* fill_opt */ + case 351: /* query_expression_body */ + case 353: /* slimit_clause_opt */ + case 354: /* limit_clause_opt */ + case 355: /* query_primary */ + case 357: /* sort_specification */ { - nodesDestroyNode((yypminor->yy674)); + nodesDestroyNode((yypminor->yy632)); } break; - case 240: /* account_options */ - case 241: /* alter_account_options */ - case 243: /* alter_account_option */ - case 302: /* bufsize_opt */ + case 241: /* account_options */ + case 242: /* alter_account_options */ + case 244: /* alter_account_option */ + case 303: /* bufsize_opt */ { } break; - case 244: /* user_name */ - case 246: /* priv_level */ - case 249: /* db_name */ - case 250: /* dnode_endpoint */ - case 251: /* dnode_host_name */ - case 270: /* column_name */ - case 278: /* table_name */ - case 288: /* function_name */ - case 289: /* index_name */ - case 296: /* topic_name */ - case 298: /* cgroup_name */ - case 303: /* stream_name */ - case 310: /* table_alias */ - case 311: /* column_alias */ - case 317: /* star_func */ - case 319: /* noarg_func */ - case 334: /* alias_opt */ + case 245: /* user_name */ + case 247: /* priv_level */ + case 250: /* db_name */ + case 251: /* dnode_endpoint */ + case 252: /* dnode_host_name */ + case 271: /* column_name */ + case 279: /* table_name */ + case 289: /* function_name */ + case 290: /* index_name */ + case 297: /* topic_name */ + case 299: /* cgroup_name */ + case 304: /* stream_name */ + case 311: /* table_alias */ + case 312: /* column_alias */ + case 318: /* star_func */ + case 320: /* noarg_func */ + case 335: /* alias_opt */ { } break; - case 245: /* privileges */ - case 247: /* priv_type_list */ - case 248: /* priv_type */ + case 246: /* privileges */ + case 248: /* priv_type_list */ + case 249: /* priv_type */ { } break; - case 252: /* not_exists_opt */ - case 254: /* exists_opt */ - case 299: /* analyze_opt */ - case 301: /* agg_func_opt */ - case 339: /* set_quantifier_opt */ + case 253: /* not_exists_opt */ + case 255: /* exists_opt */ + case 300: /* analyze_opt */ + case 302: /* agg_func_opt */ + case 340: /* set_quantifier_opt */ { } break; - case 256: /* integer_list */ - case 257: /* variable_list */ - case 258: /* retention_list */ - case 262: /* column_def_list */ - case 263: /* tags_def_opt */ - case 265: /* multi_create_clause */ - case 266: /* tags_def */ - case 267: /* multi_drop_clause */ - case 274: /* specific_tags_opt */ - case 275: /* literal_list */ - case 277: /* col_name_list */ - case 280: /* func_name_list */ - case 291: /* func_list */ - case 295: /* expression_list */ - case 306: /* dnode_list */ - case 318: /* star_func_para_list */ - case 320: /* other_para_list */ - case 340: /* select_list */ - case 341: /* partition_by_clause_opt */ - case 343: /* group_by_clause_opt */ - case 345: /* select_sublist */ - case 349: /* group_by_list */ - case 351: /* order_by_clause_opt */ - case 355: /* sort_specification_list */ + case 257: /* integer_list */ + case 258: /* variable_list */ + case 259: /* retention_list */ + case 263: /* column_def_list */ + case 264: /* tags_def_opt */ + case 266: /* multi_create_clause */ + case 267: /* tags_def */ + case 268: /* multi_drop_clause */ + case 275: /* specific_tags_opt */ + case 276: /* literal_list */ + case 278: /* col_name_list */ + case 281: /* func_name_list */ + case 292: /* func_list */ + case 296: /* expression_list */ + case 307: /* dnode_list */ + case 319: /* star_func_para_list */ + case 321: /* other_para_list */ + case 341: /* select_list */ + case 342: /* partition_by_clause_opt */ + case 344: /* group_by_clause_opt */ + case 346: /* select_sublist */ + case 350: /* group_by_list */ + case 352: /* order_by_clause_opt */ + case 356: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy530)); + nodesDestroyList((yypminor->yy424)); } break; - case 259: /* alter_db_option */ - case 281: /* alter_table_option */ + case 260: /* alter_db_option */ + case 282: /* alter_table_option */ { } break; - case 271: /* type_name */ + case 272: /* type_name */ { } break; - case 323: /* compare_op */ - case 324: /* in_op */ + case 324: /* compare_op */ + case 325: /* in_op */ { } break; - case 336: /* join_type */ + case 337: /* join_type */ { } break; - case 348: /* fill_mode */ + case 349: /* fill_mode */ { } break; - case 357: /* ordering_specification_opt */ + case 358: /* ordering_specification_opt */ { } break; - case 358: /* null_ordering_opt */ + case 359: /* null_ordering_opt */ { } @@ -2567,459 +2575,460 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 239, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 239, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 240, 0 }, /* (2) account_options ::= */ - { 240, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 240, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 240, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 240, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 240, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 240, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 240, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 240, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 240, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 241, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 241, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 243, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 243, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 243, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 243, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 243, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 243, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 243, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 243, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 243, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 243, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 239, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 239, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 239, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 239, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 239, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 239, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 245, -1 }, /* (30) privileges ::= ALL */ - { 245, -1 }, /* (31) privileges ::= priv_type_list */ - { 247, -1 }, /* (32) priv_type_list ::= priv_type */ - { 247, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 248, -1 }, /* (34) priv_type ::= READ */ - { 248, -1 }, /* (35) priv_type ::= WRITE */ - { 246, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 246, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ - { 239, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ - { 239, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 239, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ - { 239, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ - { 239, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 239, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 239, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ - { 239, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 250, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ - { 251, -1 }, /* (47) dnode_host_name ::= NK_ID */ - { 251, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ - { 239, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ - { 239, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 239, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 239, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ - { 239, -2 }, /* (61) cmd ::= USE db_name */ - { 239, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 252, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ - { 252, 0 }, /* (64) not_exists_opt ::= */ - { 254, -2 }, /* (65) exists_opt ::= IF EXISTS */ - { 254, 0 }, /* (66) exists_opt ::= */ - { 253, 0 }, /* (67) db_options ::= */ - { 253, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ - { 253, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ - { 253, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ - { 253, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ - { 253, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ - { 253, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ - { 253, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ - { 253, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ - { 253, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ - { 253, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ - { 253, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ - { 253, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 253, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ - { 253, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ - { 253, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ - { 253, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ - { 253, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ - { 253, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 253, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ - { 253, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 255, -1 }, /* (88) alter_db_options ::= alter_db_option */ - { 255, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ - { 259, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ - { 259, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ - { 259, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ - { 259, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ - { 259, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ - { 259, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ - { 259, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ - { 259, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ - { 259, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ - { 256, -1 }, /* (99) integer_list ::= NK_INTEGER */ - { 256, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 257, -1 }, /* (101) variable_list ::= NK_VARIABLE */ - { 257, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 258, -1 }, /* (103) retention_list ::= retention */ - { 258, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ - { 260, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 239, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 239, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ - { 239, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 239, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ - { 239, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ - { 239, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ - { 239, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ - { 268, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ - { 268, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 268, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 268, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 268, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 268, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 268, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 268, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 268, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 268, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 265, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ - { 265, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 273, -10 }, /* (125) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 267, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ - { 267, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 276, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ - { 274, 0 }, /* (129) specific_tags_opt ::= */ - { 274, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 261, -1 }, /* (131) full_table_name ::= table_name */ - { 261, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ - { 262, -1 }, /* (133) column_def_list ::= column_def */ - { 262, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ - { 279, -2 }, /* (135) column_def ::= column_name type_name */ - { 279, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ - { 271, -1 }, /* (137) type_name ::= BOOL */ - { 271, -1 }, /* (138) type_name ::= TINYINT */ - { 271, -1 }, /* (139) type_name ::= SMALLINT */ - { 271, -1 }, /* (140) type_name ::= INT */ - { 271, -1 }, /* (141) type_name ::= INTEGER */ - { 271, -1 }, /* (142) type_name ::= BIGINT */ - { 271, -1 }, /* (143) type_name ::= FLOAT */ - { 271, -1 }, /* (144) type_name ::= DOUBLE */ - { 271, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (146) type_name ::= TIMESTAMP */ - { 271, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 271, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ - { 271, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ - { 271, -2 }, /* (150) type_name ::= INT UNSIGNED */ - { 271, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ - { 271, -1 }, /* (152) type_name ::= JSON */ - { 271, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (154) type_name ::= MEDIUMBLOB */ - { 271, -1 }, /* (155) type_name ::= BLOB */ - { 271, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (157) type_name ::= DECIMAL */ - { 271, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 271, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 263, 0 }, /* (160) tags_def_opt ::= */ - { 263, -1 }, /* (161) tags_def_opt ::= tags_def */ - { 266, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 264, 0 }, /* (163) table_options ::= */ - { 264, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ - { 264, -3 }, /* (165) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 264, -5 }, /* (166) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 264, -3 }, /* (167) table_options ::= table_options TTL NK_INTEGER */ - { 264, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 269, -1 }, /* (169) alter_table_options ::= alter_table_option */ - { 269, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ - { 281, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ - { 281, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ - { 277, -1 }, /* (173) col_name_list ::= col_name */ - { 277, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ - { 282, -1 }, /* (175) col_name ::= column_name */ - { 239, -2 }, /* (176) cmd ::= SHOW DNODES */ - { 239, -2 }, /* (177) cmd ::= SHOW USERS */ - { 239, -2 }, /* (178) cmd ::= SHOW DATABASES */ - { 239, -4 }, /* (179) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 239, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 239, -3 }, /* (181) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 239, -2 }, /* (182) cmd ::= SHOW MNODES */ - { 239, -2 }, /* (183) cmd ::= SHOW MODULES */ - { 239, -2 }, /* (184) cmd ::= SHOW QNODES */ - { 239, -2 }, /* (185) cmd ::= SHOW FUNCTIONS */ - { 239, -5 }, /* (186) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 239, -2 }, /* (187) cmd ::= SHOW STREAMS */ - { 239, -2 }, /* (188) cmd ::= SHOW ACCOUNTS */ - { 239, -2 }, /* (189) cmd ::= SHOW APPS */ - { 239, -2 }, /* (190) cmd ::= SHOW CONNECTIONS */ - { 239, -2 }, /* (191) cmd ::= SHOW LICENCE */ - { 239, -2 }, /* (192) cmd ::= SHOW GRANTS */ - { 239, -4 }, /* (193) cmd ::= SHOW CREATE DATABASE db_name */ - { 239, -4 }, /* (194) cmd ::= SHOW CREATE TABLE full_table_name */ - { 239, -4 }, /* (195) cmd ::= SHOW CREATE STABLE full_table_name */ - { 239, -2 }, /* (196) cmd ::= SHOW QUERIES */ - { 239, -2 }, /* (197) cmd ::= SHOW SCORES */ - { 239, -2 }, /* (198) cmd ::= SHOW TOPICS */ - { 239, -2 }, /* (199) cmd ::= SHOW VARIABLES */ - { 239, -2 }, /* (200) cmd ::= SHOW BNODES */ - { 239, -2 }, /* (201) cmd ::= SHOW SNODES */ - { 239, -2 }, /* (202) cmd ::= SHOW CLUSTER */ - { 239, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ - { 283, 0 }, /* (204) db_name_cond_opt ::= */ - { 283, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ - { 284, 0 }, /* (206) like_pattern_opt ::= */ - { 284, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ - { 285, -1 }, /* (208) table_name_cond ::= table_name */ - { 286, 0 }, /* (209) from_db_opt ::= */ - { 286, -2 }, /* (210) from_db_opt ::= FROM db_name */ - { 280, -1 }, /* (211) func_name_list ::= func_name */ - { 280, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ - { 287, -1 }, /* (213) func_name ::= function_name */ - { 239, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 239, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 239, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 290, 0 }, /* (217) index_options ::= */ - { 290, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 290, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 291, -1 }, /* (220) func_list ::= func */ - { 291, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ - { 294, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ - { 239, -6 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 239, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 239, -7 }, /* (225) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 239, -4 }, /* (226) cmd ::= DROP TOPIC exists_opt topic_name */ - { 239, -7 }, /* (227) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 239, -2 }, /* (228) cmd ::= DESC full_table_name */ - { 239, -2 }, /* (229) cmd ::= DESCRIBE full_table_name */ - { 239, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ - { 239, -4 }, /* (231) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 299, 0 }, /* (232) analyze_opt ::= */ - { 299, -1 }, /* (233) analyze_opt ::= ANALYZE */ - { 300, 0 }, /* (234) explain_options ::= */ - { 300, -3 }, /* (235) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 300, -3 }, /* (236) explain_options ::= explain_options RATIO NK_FLOAT */ - { 239, -6 }, /* (237) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 239, -10 }, /* (238) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 239, -4 }, /* (239) cmd ::= DROP FUNCTION exists_opt function_name */ - { 301, 0 }, /* (240) agg_func_opt ::= */ - { 301, -1 }, /* (241) agg_func_opt ::= AGGREGATE */ - { 302, 0 }, /* (242) bufsize_opt ::= */ - { 302, -2 }, /* (243) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 239, -8 }, /* (244) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 239, -4 }, /* (245) cmd ::= DROP STREAM exists_opt stream_name */ - { 305, 0 }, /* (246) into_opt ::= */ - { 305, -2 }, /* (247) into_opt ::= INTO full_table_name */ - { 304, 0 }, /* (248) stream_options ::= */ - { 304, -3 }, /* (249) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 304, -3 }, /* (250) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 304, -3 }, /* (251) stream_options ::= stream_options WATERMARK duration_literal */ - { 239, -3 }, /* (252) cmd ::= KILL CONNECTION NK_INTEGER */ - { 239, -3 }, /* (253) cmd ::= KILL QUERY NK_INTEGER */ - { 239, -3 }, /* (254) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 239, -2 }, /* (255) cmd ::= BALANCE VGROUP */ - { 239, -4 }, /* (256) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 239, -4 }, /* (257) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 239, -3 }, /* (258) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 306, -2 }, /* (259) dnode_list ::= DNODE NK_INTEGER */ - { 306, -3 }, /* (260) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 239, -3 }, /* (261) cmd ::= SYNCDB db_name REPLICA */ - { 239, -4 }, /* (262) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 239, -1 }, /* (263) cmd ::= query_expression */ - { 242, -1 }, /* (264) literal ::= NK_INTEGER */ - { 242, -1 }, /* (265) literal ::= NK_FLOAT */ - { 242, -1 }, /* (266) literal ::= NK_STRING */ - { 242, -1 }, /* (267) literal ::= NK_BOOL */ - { 242, -2 }, /* (268) literal ::= TIMESTAMP NK_STRING */ - { 242, -1 }, /* (269) literal ::= duration_literal */ - { 242, -1 }, /* (270) literal ::= NULL */ - { 242, -1 }, /* (271) literal ::= NK_QUESTION */ - { 292, -1 }, /* (272) duration_literal ::= NK_VARIABLE */ - { 308, -1 }, /* (273) signed ::= NK_INTEGER */ - { 308, -2 }, /* (274) signed ::= NK_PLUS NK_INTEGER */ - { 308, -2 }, /* (275) signed ::= NK_MINUS NK_INTEGER */ - { 308, -1 }, /* (276) signed ::= NK_FLOAT */ - { 308, -2 }, /* (277) signed ::= NK_PLUS NK_FLOAT */ - { 308, -2 }, /* (278) signed ::= NK_MINUS NK_FLOAT */ - { 272, -1 }, /* (279) signed_literal ::= signed */ - { 272, -1 }, /* (280) signed_literal ::= NK_STRING */ - { 272, -1 }, /* (281) signed_literal ::= NK_BOOL */ - { 272, -2 }, /* (282) signed_literal ::= TIMESTAMP NK_STRING */ - { 272, -1 }, /* (283) signed_literal ::= duration_literal */ - { 272, -1 }, /* (284) signed_literal ::= NULL */ - { 272, -1 }, /* (285) signed_literal ::= literal_func */ - { 275, -1 }, /* (286) literal_list ::= signed_literal */ - { 275, -3 }, /* (287) literal_list ::= literal_list NK_COMMA signed_literal */ - { 249, -1 }, /* (288) db_name ::= NK_ID */ - { 278, -1 }, /* (289) table_name ::= NK_ID */ - { 270, -1 }, /* (290) column_name ::= NK_ID */ - { 288, -1 }, /* (291) function_name ::= NK_ID */ - { 310, -1 }, /* (292) table_alias ::= NK_ID */ - { 311, -1 }, /* (293) column_alias ::= NK_ID */ - { 244, -1 }, /* (294) user_name ::= NK_ID */ - { 289, -1 }, /* (295) index_name ::= NK_ID */ - { 296, -1 }, /* (296) topic_name ::= NK_ID */ - { 303, -1 }, /* (297) stream_name ::= NK_ID */ - { 298, -1 }, /* (298) cgroup_name ::= NK_ID */ - { 312, -1 }, /* (299) expression ::= literal */ - { 312, -1 }, /* (300) expression ::= pseudo_column */ - { 312, -1 }, /* (301) expression ::= column_reference */ - { 312, -1 }, /* (302) expression ::= function_expression */ - { 312, -1 }, /* (303) expression ::= subquery */ - { 312, -3 }, /* (304) expression ::= NK_LP expression NK_RP */ - { 312, -2 }, /* (305) expression ::= NK_PLUS expression */ - { 312, -2 }, /* (306) expression ::= NK_MINUS expression */ - { 312, -3 }, /* (307) expression ::= expression NK_PLUS expression */ - { 312, -3 }, /* (308) expression ::= expression NK_MINUS expression */ - { 312, -3 }, /* (309) expression ::= expression NK_STAR expression */ - { 312, -3 }, /* (310) expression ::= expression NK_SLASH expression */ - { 312, -3 }, /* (311) expression ::= expression NK_REM expression */ - { 312, -3 }, /* (312) expression ::= column_reference NK_ARROW NK_STRING */ - { 295, -1 }, /* (313) expression_list ::= expression */ - { 295, -3 }, /* (314) expression_list ::= expression_list NK_COMMA expression */ - { 314, -1 }, /* (315) column_reference ::= column_name */ - { 314, -3 }, /* (316) column_reference ::= table_name NK_DOT column_name */ - { 313, -1 }, /* (317) pseudo_column ::= ROWTS */ - { 313, -1 }, /* (318) pseudo_column ::= TBNAME */ - { 313, -3 }, /* (319) pseudo_column ::= table_name NK_DOT TBNAME */ - { 313, -1 }, /* (320) pseudo_column ::= QSTARTTS */ - { 313, -1 }, /* (321) pseudo_column ::= QENDTS */ - { 313, -1 }, /* (322) pseudo_column ::= WSTARTTS */ - { 313, -1 }, /* (323) pseudo_column ::= WENDTS */ - { 313, -1 }, /* (324) pseudo_column ::= WDURATION */ - { 315, -4 }, /* (325) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 315, -4 }, /* (326) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 315, -6 }, /* (327) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 315, -1 }, /* (328) function_expression ::= literal_func */ - { 309, -3 }, /* (329) literal_func ::= noarg_func NK_LP NK_RP */ - { 309, -1 }, /* (330) literal_func ::= NOW */ - { 319, -1 }, /* (331) noarg_func ::= NOW */ - { 319, -1 }, /* (332) noarg_func ::= TODAY */ - { 319, -1 }, /* (333) noarg_func ::= TIMEZONE */ - { 317, -1 }, /* (334) star_func ::= COUNT */ - { 317, -1 }, /* (335) star_func ::= FIRST */ - { 317, -1 }, /* (336) star_func ::= LAST */ - { 317, -1 }, /* (337) star_func ::= LAST_ROW */ - { 318, -1 }, /* (338) star_func_para_list ::= NK_STAR */ - { 318, -1 }, /* (339) star_func_para_list ::= other_para_list */ - { 320, -1 }, /* (340) other_para_list ::= star_func_para */ - { 320, -3 }, /* (341) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 321, -1 }, /* (342) star_func_para ::= expression */ - { 321, -3 }, /* (343) star_func_para ::= table_name NK_DOT NK_STAR */ - { 322, -3 }, /* (344) predicate ::= expression compare_op expression */ - { 322, -5 }, /* (345) predicate ::= expression BETWEEN expression AND expression */ - { 322, -6 }, /* (346) predicate ::= expression NOT BETWEEN expression AND expression */ - { 322, -3 }, /* (347) predicate ::= expression IS NULL */ - { 322, -4 }, /* (348) predicate ::= expression IS NOT NULL */ - { 322, -3 }, /* (349) predicate ::= expression in_op in_predicate_value */ - { 323, -1 }, /* (350) compare_op ::= NK_LT */ - { 323, -1 }, /* (351) compare_op ::= NK_GT */ - { 323, -1 }, /* (352) compare_op ::= NK_LE */ - { 323, -1 }, /* (353) compare_op ::= NK_GE */ - { 323, -1 }, /* (354) compare_op ::= NK_NE */ - { 323, -1 }, /* (355) compare_op ::= NK_EQ */ - { 323, -1 }, /* (356) compare_op ::= LIKE */ - { 323, -2 }, /* (357) compare_op ::= NOT LIKE */ - { 323, -1 }, /* (358) compare_op ::= MATCH */ - { 323, -1 }, /* (359) compare_op ::= NMATCH */ - { 323, -1 }, /* (360) compare_op ::= CONTAINS */ - { 324, -1 }, /* (361) in_op ::= IN */ - { 324, -2 }, /* (362) in_op ::= NOT IN */ - { 325, -3 }, /* (363) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 326, -1 }, /* (364) boolean_value_expression ::= boolean_primary */ - { 326, -2 }, /* (365) boolean_value_expression ::= NOT boolean_primary */ - { 326, -3 }, /* (366) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 326, -3 }, /* (367) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 327, -1 }, /* (368) boolean_primary ::= predicate */ - { 327, -3 }, /* (369) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 328, -1 }, /* (370) common_expression ::= expression */ - { 328, -1 }, /* (371) common_expression ::= boolean_value_expression */ - { 329, -2 }, /* (372) from_clause ::= FROM table_reference_list */ - { 330, -1 }, /* (373) table_reference_list ::= table_reference */ - { 330, -3 }, /* (374) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 331, -1 }, /* (375) table_reference ::= table_primary */ - { 331, -1 }, /* (376) table_reference ::= joined_table */ - { 332, -2 }, /* (377) table_primary ::= table_name alias_opt */ - { 332, -4 }, /* (378) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 332, -2 }, /* (379) table_primary ::= subquery alias_opt */ - { 332, -1 }, /* (380) table_primary ::= parenthesized_joined_table */ - { 334, 0 }, /* (381) alias_opt ::= */ - { 334, -1 }, /* (382) alias_opt ::= table_alias */ - { 334, -2 }, /* (383) alias_opt ::= AS table_alias */ - { 335, -3 }, /* (384) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 335, -3 }, /* (385) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 333, -6 }, /* (386) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 336, 0 }, /* (387) join_type ::= */ - { 336, -1 }, /* (388) join_type ::= INNER */ - { 338, -9 }, /* (389) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 339, 0 }, /* (390) set_quantifier_opt ::= */ - { 339, -1 }, /* (391) set_quantifier_opt ::= DISTINCT */ - { 339, -1 }, /* (392) set_quantifier_opt ::= ALL */ - { 340, -1 }, /* (393) select_list ::= NK_STAR */ - { 340, -1 }, /* (394) select_list ::= select_sublist */ - { 345, -1 }, /* (395) select_sublist ::= select_item */ - { 345, -3 }, /* (396) select_sublist ::= select_sublist NK_COMMA select_item */ - { 346, -1 }, /* (397) select_item ::= common_expression */ - { 346, -2 }, /* (398) select_item ::= common_expression column_alias */ - { 346, -3 }, /* (399) select_item ::= common_expression AS column_alias */ - { 346, -3 }, /* (400) select_item ::= table_name NK_DOT NK_STAR */ - { 307, 0 }, /* (401) where_clause_opt ::= */ - { 307, -2 }, /* (402) where_clause_opt ::= WHERE search_condition */ - { 341, 0 }, /* (403) partition_by_clause_opt ::= */ - { 341, -3 }, /* (404) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 342, 0 }, /* (405) twindow_clause_opt ::= */ - { 342, -6 }, /* (406) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 342, -4 }, /* (407) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 342, -6 }, /* (408) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 342, -8 }, /* (409) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 293, 0 }, /* (410) sliding_opt ::= */ - { 293, -4 }, /* (411) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 347, 0 }, /* (412) fill_opt ::= */ - { 347, -4 }, /* (413) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 347, -6 }, /* (414) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 348, -1 }, /* (415) fill_mode ::= NONE */ - { 348, -1 }, /* (416) fill_mode ::= PREV */ - { 348, -1 }, /* (417) fill_mode ::= NULL */ - { 348, -1 }, /* (418) fill_mode ::= LINEAR */ - { 348, -1 }, /* (419) fill_mode ::= NEXT */ - { 343, 0 }, /* (420) group_by_clause_opt ::= */ - { 343, -3 }, /* (421) group_by_clause_opt ::= GROUP BY group_by_list */ - { 349, -1 }, /* (422) group_by_list ::= expression */ - { 349, -3 }, /* (423) group_by_list ::= group_by_list NK_COMMA expression */ - { 344, 0 }, /* (424) having_clause_opt ::= */ - { 344, -2 }, /* (425) having_clause_opt ::= HAVING search_condition */ - { 297, -4 }, /* (426) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 350, -1 }, /* (427) query_expression_body ::= query_primary */ - { 350, -4 }, /* (428) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 350, -3 }, /* (429) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 354, -1 }, /* (430) query_primary ::= query_specification */ - { 354, -6 }, /* (431) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 351, 0 }, /* (432) order_by_clause_opt ::= */ - { 351, -3 }, /* (433) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 352, 0 }, /* (434) slimit_clause_opt ::= */ - { 352, -2 }, /* (435) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 352, -4 }, /* (436) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 352, -4 }, /* (437) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 353, 0 }, /* (438) limit_clause_opt ::= */ - { 353, -2 }, /* (439) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 353, -4 }, /* (440) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 353, -4 }, /* (441) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 316, -3 }, /* (442) subquery ::= NK_LP query_expression NK_RP */ - { 337, -1 }, /* (443) search_condition ::= common_expression */ - { 355, -1 }, /* (444) sort_specification_list ::= sort_specification */ - { 355, -3 }, /* (445) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 356, -3 }, /* (446) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 357, 0 }, /* (447) ordering_specification_opt ::= */ - { 357, -1 }, /* (448) ordering_specification_opt ::= ASC */ - { 357, -1 }, /* (449) ordering_specification_opt ::= DESC */ - { 358, 0 }, /* (450) null_ordering_opt ::= */ - { 358, -2 }, /* (451) null_ordering_opt ::= NULLS FIRST */ - { 358, -2 }, /* (452) null_ordering_opt ::= NULLS LAST */ + { 240, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 240, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 241, 0 }, /* (2) account_options ::= */ + { 241, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 241, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 241, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 241, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 241, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 241, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 241, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 241, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 241, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 242, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 242, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 244, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 244, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 244, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 244, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 244, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 244, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 244, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 244, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 244, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 244, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 240, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 240, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 240, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 240, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 240, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 240, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 246, -1 }, /* (30) privileges ::= ALL */ + { 246, -1 }, /* (31) privileges ::= priv_type_list */ + { 248, -1 }, /* (32) priv_type_list ::= priv_type */ + { 248, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 249, -1 }, /* (34) priv_type ::= READ */ + { 249, -1 }, /* (35) priv_type ::= WRITE */ + { 247, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 247, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ + { 240, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ + { 240, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 240, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ + { 240, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ + { 240, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 240, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 240, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ + { 240, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 251, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ + { 252, -1 }, /* (47) dnode_host_name ::= NK_ID */ + { 252, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ + { 240, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ + { 240, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 240, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 240, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ + { 240, -2 }, /* (61) cmd ::= USE db_name */ + { 240, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 253, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ + { 253, 0 }, /* (64) not_exists_opt ::= */ + { 255, -2 }, /* (65) exists_opt ::= IF EXISTS */ + { 255, 0 }, /* (66) exists_opt ::= */ + { 254, 0 }, /* (67) db_options ::= */ + { 254, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ + { 254, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ + { 254, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ + { 254, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ + { 254, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ + { 254, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ + { 254, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ + { 254, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ + { 254, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ + { 254, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ + { 254, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ + { 254, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 254, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ + { 254, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ + { 254, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ + { 254, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ + { 254, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ + { 254, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 254, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ + { 254, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 256, -1 }, /* (88) alter_db_options ::= alter_db_option */ + { 256, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ + { 260, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ + { 260, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ + { 260, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ + { 260, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ + { 260, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ + { 260, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ + { 260, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ + { 260, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ + { 260, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ + { 257, -1 }, /* (99) integer_list ::= NK_INTEGER */ + { 257, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 258, -1 }, /* (101) variable_list ::= NK_VARIABLE */ + { 258, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 259, -1 }, /* (103) retention_list ::= retention */ + { 259, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ + { 261, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 240, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 240, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ + { 240, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 240, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ + { 240, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ + { 240, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ + { 240, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ + { 269, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ + { 269, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 269, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 269, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 269, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 269, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 269, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 269, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 269, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 269, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 266, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ + { 266, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 274, -10 }, /* (125) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 268, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ + { 268, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 277, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ + { 275, 0 }, /* (129) specific_tags_opt ::= */ + { 275, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 262, -1 }, /* (131) full_table_name ::= table_name */ + { 262, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ + { 263, -1 }, /* (133) column_def_list ::= column_def */ + { 263, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ + { 280, -2 }, /* (135) column_def ::= column_name type_name */ + { 280, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ + { 272, -1 }, /* (137) type_name ::= BOOL */ + { 272, -1 }, /* (138) type_name ::= TINYINT */ + { 272, -1 }, /* (139) type_name ::= SMALLINT */ + { 272, -1 }, /* (140) type_name ::= INT */ + { 272, -1 }, /* (141) type_name ::= INTEGER */ + { 272, -1 }, /* (142) type_name ::= BIGINT */ + { 272, -1 }, /* (143) type_name ::= FLOAT */ + { 272, -1 }, /* (144) type_name ::= DOUBLE */ + { 272, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (146) type_name ::= TIMESTAMP */ + { 272, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ + { 272, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ + { 272, -2 }, /* (150) type_name ::= INT UNSIGNED */ + { 272, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ + { 272, -1 }, /* (152) type_name ::= JSON */ + { 272, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (154) type_name ::= MEDIUMBLOB */ + { 272, -1 }, /* (155) type_name ::= BLOB */ + { 272, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (157) type_name ::= DECIMAL */ + { 272, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 272, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 264, 0 }, /* (160) tags_def_opt ::= */ + { 264, -1 }, /* (161) tags_def_opt ::= tags_def */ + { 267, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 265, 0 }, /* (163) table_options ::= */ + { 265, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ + { 265, -3 }, /* (165) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 265, -5 }, /* (166) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 265, -3 }, /* (167) table_options ::= table_options TTL NK_INTEGER */ + { 265, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 270, -1 }, /* (169) alter_table_options ::= alter_table_option */ + { 270, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ + { 282, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ + { 282, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ + { 278, -1 }, /* (173) col_name_list ::= col_name */ + { 278, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ + { 283, -1 }, /* (175) col_name ::= column_name */ + { 240, -2 }, /* (176) cmd ::= SHOW DNODES */ + { 240, -2 }, /* (177) cmd ::= SHOW USERS */ + { 240, -2 }, /* (178) cmd ::= SHOW DATABASES */ + { 240, -4 }, /* (179) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 240, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 240, -3 }, /* (181) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 240, -2 }, /* (182) cmd ::= SHOW MNODES */ + { 240, -2 }, /* (183) cmd ::= SHOW MODULES */ + { 240, -2 }, /* (184) cmd ::= SHOW QNODES */ + { 240, -2 }, /* (185) cmd ::= SHOW FUNCTIONS */ + { 240, -5 }, /* (186) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 240, -2 }, /* (187) cmd ::= SHOW STREAMS */ + { 240, -2 }, /* (188) cmd ::= SHOW ACCOUNTS */ + { 240, -2 }, /* (189) cmd ::= SHOW APPS */ + { 240, -2 }, /* (190) cmd ::= SHOW CONNECTIONS */ + { 240, -2 }, /* (191) cmd ::= SHOW LICENCE */ + { 240, -2 }, /* (192) cmd ::= SHOW GRANTS */ + { 240, -4 }, /* (193) cmd ::= SHOW CREATE DATABASE db_name */ + { 240, -4 }, /* (194) cmd ::= SHOW CREATE TABLE full_table_name */ + { 240, -4 }, /* (195) cmd ::= SHOW CREATE STABLE full_table_name */ + { 240, -2 }, /* (196) cmd ::= SHOW QUERIES */ + { 240, -2 }, /* (197) cmd ::= SHOW SCORES */ + { 240, -2 }, /* (198) cmd ::= SHOW TOPICS */ + { 240, -2 }, /* (199) cmd ::= SHOW VARIABLES */ + { 240, -2 }, /* (200) cmd ::= SHOW BNODES */ + { 240, -2 }, /* (201) cmd ::= SHOW SNODES */ + { 240, -2 }, /* (202) cmd ::= SHOW CLUSTER */ + { 240, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ + { 284, 0 }, /* (204) db_name_cond_opt ::= */ + { 284, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ + { 285, 0 }, /* (206) like_pattern_opt ::= */ + { 285, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ + { 286, -1 }, /* (208) table_name_cond ::= table_name */ + { 287, 0 }, /* (209) from_db_opt ::= */ + { 287, -2 }, /* (210) from_db_opt ::= FROM db_name */ + { 281, -1 }, /* (211) func_name_list ::= func_name */ + { 281, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ + { 288, -1 }, /* (213) func_name ::= function_name */ + { 240, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 240, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 240, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 291, 0 }, /* (217) index_options ::= */ + { 291, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 291, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 292, -1 }, /* (220) func_list ::= func */ + { 292, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ + { 295, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ + { 240, -6 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 240, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 240, -7 }, /* (225) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 240, -4 }, /* (226) cmd ::= DROP TOPIC exists_opt topic_name */ + { 240, -7 }, /* (227) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 240, -2 }, /* (228) cmd ::= DESC full_table_name */ + { 240, -2 }, /* (229) cmd ::= DESCRIBE full_table_name */ + { 240, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ + { 240, -4 }, /* (231) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 300, 0 }, /* (232) analyze_opt ::= */ + { 300, -1 }, /* (233) analyze_opt ::= ANALYZE */ + { 301, 0 }, /* (234) explain_options ::= */ + { 301, -3 }, /* (235) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 301, -3 }, /* (236) explain_options ::= explain_options RATIO NK_FLOAT */ + { 240, -6 }, /* (237) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 240, -10 }, /* (238) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 240, -4 }, /* (239) cmd ::= DROP FUNCTION exists_opt function_name */ + { 302, 0 }, /* (240) agg_func_opt ::= */ + { 302, -1 }, /* (241) agg_func_opt ::= AGGREGATE */ + { 303, 0 }, /* (242) bufsize_opt ::= */ + { 303, -2 }, /* (243) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 240, -8 }, /* (244) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 240, -4 }, /* (245) cmd ::= DROP STREAM exists_opt stream_name */ + { 306, 0 }, /* (246) into_opt ::= */ + { 306, -2 }, /* (247) into_opt ::= INTO full_table_name */ + { 305, 0 }, /* (248) stream_options ::= */ + { 305, -3 }, /* (249) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 305, -3 }, /* (250) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 305, -4 }, /* (251) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 305, -3 }, /* (252) stream_options ::= stream_options WATERMARK duration_literal */ + { 240, -3 }, /* (253) cmd ::= KILL CONNECTION NK_INTEGER */ + { 240, -3 }, /* (254) cmd ::= KILL QUERY NK_INTEGER */ + { 240, -3 }, /* (255) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 240, -2 }, /* (256) cmd ::= BALANCE VGROUP */ + { 240, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 240, -4 }, /* (258) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 240, -3 }, /* (259) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 307, -2 }, /* (260) dnode_list ::= DNODE NK_INTEGER */ + { 307, -3 }, /* (261) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 240, -3 }, /* (262) cmd ::= SYNCDB db_name REPLICA */ + { 240, -4 }, /* (263) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 240, -1 }, /* (264) cmd ::= query_expression */ + { 243, -1 }, /* (265) literal ::= NK_INTEGER */ + { 243, -1 }, /* (266) literal ::= NK_FLOAT */ + { 243, -1 }, /* (267) literal ::= NK_STRING */ + { 243, -1 }, /* (268) literal ::= NK_BOOL */ + { 243, -2 }, /* (269) literal ::= TIMESTAMP NK_STRING */ + { 243, -1 }, /* (270) literal ::= duration_literal */ + { 243, -1 }, /* (271) literal ::= NULL */ + { 243, -1 }, /* (272) literal ::= NK_QUESTION */ + { 293, -1 }, /* (273) duration_literal ::= NK_VARIABLE */ + { 309, -1 }, /* (274) signed ::= NK_INTEGER */ + { 309, -2 }, /* (275) signed ::= NK_PLUS NK_INTEGER */ + { 309, -2 }, /* (276) signed ::= NK_MINUS NK_INTEGER */ + { 309, -1 }, /* (277) signed ::= NK_FLOAT */ + { 309, -2 }, /* (278) signed ::= NK_PLUS NK_FLOAT */ + { 309, -2 }, /* (279) signed ::= NK_MINUS NK_FLOAT */ + { 273, -1 }, /* (280) signed_literal ::= signed */ + { 273, -1 }, /* (281) signed_literal ::= NK_STRING */ + { 273, -1 }, /* (282) signed_literal ::= NK_BOOL */ + { 273, -2 }, /* (283) signed_literal ::= TIMESTAMP NK_STRING */ + { 273, -1 }, /* (284) signed_literal ::= duration_literal */ + { 273, -1 }, /* (285) signed_literal ::= NULL */ + { 273, -1 }, /* (286) signed_literal ::= literal_func */ + { 276, -1 }, /* (287) literal_list ::= signed_literal */ + { 276, -3 }, /* (288) literal_list ::= literal_list NK_COMMA signed_literal */ + { 250, -1 }, /* (289) db_name ::= NK_ID */ + { 279, -1 }, /* (290) table_name ::= NK_ID */ + { 271, -1 }, /* (291) column_name ::= NK_ID */ + { 289, -1 }, /* (292) function_name ::= NK_ID */ + { 311, -1 }, /* (293) table_alias ::= NK_ID */ + { 312, -1 }, /* (294) column_alias ::= NK_ID */ + { 245, -1 }, /* (295) user_name ::= NK_ID */ + { 290, -1 }, /* (296) index_name ::= NK_ID */ + { 297, -1 }, /* (297) topic_name ::= NK_ID */ + { 304, -1 }, /* (298) stream_name ::= NK_ID */ + { 299, -1 }, /* (299) cgroup_name ::= NK_ID */ + { 313, -1 }, /* (300) expression ::= literal */ + { 313, -1 }, /* (301) expression ::= pseudo_column */ + { 313, -1 }, /* (302) expression ::= column_reference */ + { 313, -1 }, /* (303) expression ::= function_expression */ + { 313, -1 }, /* (304) expression ::= subquery */ + { 313, -3 }, /* (305) expression ::= NK_LP expression NK_RP */ + { 313, -2 }, /* (306) expression ::= NK_PLUS expression */ + { 313, -2 }, /* (307) expression ::= NK_MINUS expression */ + { 313, -3 }, /* (308) expression ::= expression NK_PLUS expression */ + { 313, -3 }, /* (309) expression ::= expression NK_MINUS expression */ + { 313, -3 }, /* (310) expression ::= expression NK_STAR expression */ + { 313, -3 }, /* (311) expression ::= expression NK_SLASH expression */ + { 313, -3 }, /* (312) expression ::= expression NK_REM expression */ + { 313, -3 }, /* (313) expression ::= column_reference NK_ARROW NK_STRING */ + { 296, -1 }, /* (314) expression_list ::= expression */ + { 296, -3 }, /* (315) expression_list ::= expression_list NK_COMMA expression */ + { 315, -1 }, /* (316) column_reference ::= column_name */ + { 315, -3 }, /* (317) column_reference ::= table_name NK_DOT column_name */ + { 314, -1 }, /* (318) pseudo_column ::= ROWTS */ + { 314, -1 }, /* (319) pseudo_column ::= TBNAME */ + { 314, -3 }, /* (320) pseudo_column ::= table_name NK_DOT TBNAME */ + { 314, -1 }, /* (321) pseudo_column ::= QSTARTTS */ + { 314, -1 }, /* (322) pseudo_column ::= QENDTS */ + { 314, -1 }, /* (323) pseudo_column ::= WSTARTTS */ + { 314, -1 }, /* (324) pseudo_column ::= WENDTS */ + { 314, -1 }, /* (325) pseudo_column ::= WDURATION */ + { 316, -4 }, /* (326) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 316, -4 }, /* (327) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 316, -6 }, /* (328) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 316, -1 }, /* (329) function_expression ::= literal_func */ + { 310, -3 }, /* (330) literal_func ::= noarg_func NK_LP NK_RP */ + { 310, -1 }, /* (331) literal_func ::= NOW */ + { 320, -1 }, /* (332) noarg_func ::= NOW */ + { 320, -1 }, /* (333) noarg_func ::= TODAY */ + { 320, -1 }, /* (334) noarg_func ::= TIMEZONE */ + { 318, -1 }, /* (335) star_func ::= COUNT */ + { 318, -1 }, /* (336) star_func ::= FIRST */ + { 318, -1 }, /* (337) star_func ::= LAST */ + { 318, -1 }, /* (338) star_func ::= LAST_ROW */ + { 319, -1 }, /* (339) star_func_para_list ::= NK_STAR */ + { 319, -1 }, /* (340) star_func_para_list ::= other_para_list */ + { 321, -1 }, /* (341) other_para_list ::= star_func_para */ + { 321, -3 }, /* (342) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 322, -1 }, /* (343) star_func_para ::= expression */ + { 322, -3 }, /* (344) star_func_para ::= table_name NK_DOT NK_STAR */ + { 323, -3 }, /* (345) predicate ::= expression compare_op expression */ + { 323, -5 }, /* (346) predicate ::= expression BETWEEN expression AND expression */ + { 323, -6 }, /* (347) predicate ::= expression NOT BETWEEN expression AND expression */ + { 323, -3 }, /* (348) predicate ::= expression IS NULL */ + { 323, -4 }, /* (349) predicate ::= expression IS NOT NULL */ + { 323, -3 }, /* (350) predicate ::= expression in_op in_predicate_value */ + { 324, -1 }, /* (351) compare_op ::= NK_LT */ + { 324, -1 }, /* (352) compare_op ::= NK_GT */ + { 324, -1 }, /* (353) compare_op ::= NK_LE */ + { 324, -1 }, /* (354) compare_op ::= NK_GE */ + { 324, -1 }, /* (355) compare_op ::= NK_NE */ + { 324, -1 }, /* (356) compare_op ::= NK_EQ */ + { 324, -1 }, /* (357) compare_op ::= LIKE */ + { 324, -2 }, /* (358) compare_op ::= NOT LIKE */ + { 324, -1 }, /* (359) compare_op ::= MATCH */ + { 324, -1 }, /* (360) compare_op ::= NMATCH */ + { 324, -1 }, /* (361) compare_op ::= CONTAINS */ + { 325, -1 }, /* (362) in_op ::= IN */ + { 325, -2 }, /* (363) in_op ::= NOT IN */ + { 326, -3 }, /* (364) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 327, -1 }, /* (365) boolean_value_expression ::= boolean_primary */ + { 327, -2 }, /* (366) boolean_value_expression ::= NOT boolean_primary */ + { 327, -3 }, /* (367) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 327, -3 }, /* (368) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 328, -1 }, /* (369) boolean_primary ::= predicate */ + { 328, -3 }, /* (370) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 329, -1 }, /* (371) common_expression ::= expression */ + { 329, -1 }, /* (372) common_expression ::= boolean_value_expression */ + { 330, -2 }, /* (373) from_clause ::= FROM table_reference_list */ + { 331, -1 }, /* (374) table_reference_list ::= table_reference */ + { 331, -3 }, /* (375) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 332, -1 }, /* (376) table_reference ::= table_primary */ + { 332, -1 }, /* (377) table_reference ::= joined_table */ + { 333, -2 }, /* (378) table_primary ::= table_name alias_opt */ + { 333, -4 }, /* (379) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 333, -2 }, /* (380) table_primary ::= subquery alias_opt */ + { 333, -1 }, /* (381) table_primary ::= parenthesized_joined_table */ + { 335, 0 }, /* (382) alias_opt ::= */ + { 335, -1 }, /* (383) alias_opt ::= table_alias */ + { 335, -2 }, /* (384) alias_opt ::= AS table_alias */ + { 336, -3 }, /* (385) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 336, -3 }, /* (386) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 334, -6 }, /* (387) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 337, 0 }, /* (388) join_type ::= */ + { 337, -1 }, /* (389) join_type ::= INNER */ + { 339, -9 }, /* (390) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 340, 0 }, /* (391) set_quantifier_opt ::= */ + { 340, -1 }, /* (392) set_quantifier_opt ::= DISTINCT */ + { 340, -1 }, /* (393) set_quantifier_opt ::= ALL */ + { 341, -1 }, /* (394) select_list ::= NK_STAR */ + { 341, -1 }, /* (395) select_list ::= select_sublist */ + { 346, -1 }, /* (396) select_sublist ::= select_item */ + { 346, -3 }, /* (397) select_sublist ::= select_sublist NK_COMMA select_item */ + { 347, -1 }, /* (398) select_item ::= common_expression */ + { 347, -2 }, /* (399) select_item ::= common_expression column_alias */ + { 347, -3 }, /* (400) select_item ::= common_expression AS column_alias */ + { 347, -3 }, /* (401) select_item ::= table_name NK_DOT NK_STAR */ + { 308, 0 }, /* (402) where_clause_opt ::= */ + { 308, -2 }, /* (403) where_clause_opt ::= WHERE search_condition */ + { 342, 0 }, /* (404) partition_by_clause_opt ::= */ + { 342, -3 }, /* (405) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 343, 0 }, /* (406) twindow_clause_opt ::= */ + { 343, -6 }, /* (407) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 343, -4 }, /* (408) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 343, -6 }, /* (409) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 343, -8 }, /* (410) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 294, 0 }, /* (411) sliding_opt ::= */ + { 294, -4 }, /* (412) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 348, 0 }, /* (413) fill_opt ::= */ + { 348, -4 }, /* (414) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 348, -6 }, /* (415) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 349, -1 }, /* (416) fill_mode ::= NONE */ + { 349, -1 }, /* (417) fill_mode ::= PREV */ + { 349, -1 }, /* (418) fill_mode ::= NULL */ + { 349, -1 }, /* (419) fill_mode ::= LINEAR */ + { 349, -1 }, /* (420) fill_mode ::= NEXT */ + { 344, 0 }, /* (421) group_by_clause_opt ::= */ + { 344, -3 }, /* (422) group_by_clause_opt ::= GROUP BY group_by_list */ + { 350, -1 }, /* (423) group_by_list ::= expression */ + { 350, -3 }, /* (424) group_by_list ::= group_by_list NK_COMMA expression */ + { 345, 0 }, /* (425) having_clause_opt ::= */ + { 345, -2 }, /* (426) having_clause_opt ::= HAVING search_condition */ + { 298, -4 }, /* (427) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 351, -1 }, /* (428) query_expression_body ::= query_primary */ + { 351, -4 }, /* (429) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 351, -3 }, /* (430) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 355, -1 }, /* (431) query_primary ::= query_specification */ + { 355, -6 }, /* (432) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 352, 0 }, /* (433) order_by_clause_opt ::= */ + { 352, -3 }, /* (434) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 353, 0 }, /* (435) slimit_clause_opt ::= */ + { 353, -2 }, /* (436) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 353, -4 }, /* (437) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 353, -4 }, /* (438) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 354, 0 }, /* (439) limit_clause_opt ::= */ + { 354, -2 }, /* (440) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 354, -4 }, /* (441) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 354, -4 }, /* (442) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 317, -3 }, /* (443) subquery ::= NK_LP query_expression NK_RP */ + { 338, -1 }, /* (444) search_condition ::= common_expression */ + { 356, -1 }, /* (445) sort_specification_list ::= sort_specification */ + { 356, -3 }, /* (446) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 357, -3 }, /* (447) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 358, 0 }, /* (448) ordering_specification_opt ::= */ + { 358, -1 }, /* (449) ordering_specification_opt ::= ASC */ + { 358, -1 }, /* (450) ordering_specification_opt ::= DESC */ + { 359, 0 }, /* (451) null_ordering_opt ::= */ + { 359, -2 }, /* (452) null_ordering_opt ::= NULLS FIRST */ + { 359, -2 }, /* (453) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3108,11 +3117,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,240,&yymsp[0].minor); + yy_destructor(yypParser,241,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,241,&yymsp[0].minor); + yy_destructor(yypParser,242,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3126,20 +3135,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,240,&yymsp[-2].minor); +{ yy_destructor(yypParser,241,&yymsp[-2].minor); { } - yy_destructor(yypParser,242,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,243,&yymsp[0].minor); +{ yy_destructor(yypParser,244,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,241,&yymsp[-1].minor); +{ yy_destructor(yypParser,242,&yymsp[-1].minor); { } - yy_destructor(yypParser,243,&yymsp[0].minor); + yy_destructor(yypParser,244,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3153,63 +3162,63 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,242,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy421, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy421, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } break; case 28: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy669, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy189, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 29: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy669, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy189, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 30: /* privileges ::= ALL */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_ALL; } break; case 31: /* privileges ::= priv_type_list */ case 32: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==32); -{ yylhsminor.yy669 = yymsp[0].minor.yy669; } - yymsp[0].minor.yy669 = yylhsminor.yy669; +{ yylhsminor.yy189 = yymsp[0].minor.yy189; } + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 33: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy669 = yymsp[-2].minor.yy669 | yymsp[0].minor.yy669; } - yymsp[-2].minor.yy669 = yylhsminor.yy669; +{ yylhsminor.yy189 = yymsp[-2].minor.yy189 | yymsp[0].minor.yy189; } + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 34: /* priv_type ::= READ */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_READ; } break; case 35: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_WRITE; } break; case 36: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy421 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy209 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 37: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy421 = yymsp[-2].minor.yy421; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy209 = yymsp[-2].minor.yy209; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 38: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy421, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL); } break; case 39: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } break; case 40: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 41: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209); } break; case 42: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3226,26 +3235,26 @@ static YYACTIONTYPE yy_reduce( case 46: /* dnode_endpoint ::= NK_STRING */ case 47: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==47); case 48: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==48); - case 288: /* db_name ::= NK_ID */ yytestcase(yyruleno==288); - case 289: /* table_name ::= NK_ID */ yytestcase(yyruleno==289); - case 290: /* column_name ::= NK_ID */ yytestcase(yyruleno==290); - case 291: /* function_name ::= NK_ID */ yytestcase(yyruleno==291); - case 292: /* table_alias ::= NK_ID */ yytestcase(yyruleno==292); - case 293: /* column_alias ::= NK_ID */ yytestcase(yyruleno==293); - case 294: /* user_name ::= NK_ID */ yytestcase(yyruleno==294); - case 295: /* index_name ::= NK_ID */ yytestcase(yyruleno==295); - case 296: /* topic_name ::= NK_ID */ yytestcase(yyruleno==296); - case 297: /* stream_name ::= NK_ID */ yytestcase(yyruleno==297); - case 298: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==298); - case 331: /* noarg_func ::= NOW */ yytestcase(yyruleno==331); - case 332: /* noarg_func ::= TODAY */ yytestcase(yyruleno==332); - case 333: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==333); - case 334: /* star_func ::= COUNT */ yytestcase(yyruleno==334); - case 335: /* star_func ::= FIRST */ yytestcase(yyruleno==335); - case 336: /* star_func ::= LAST */ yytestcase(yyruleno==336); - case 337: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==337); -{ yylhsminor.yy421 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 289: /* db_name ::= NK_ID */ yytestcase(yyruleno==289); + case 290: /* table_name ::= NK_ID */ yytestcase(yyruleno==290); + case 291: /* column_name ::= NK_ID */ yytestcase(yyruleno==291); + case 292: /* function_name ::= NK_ID */ yytestcase(yyruleno==292); + case 293: /* table_alias ::= NK_ID */ yytestcase(yyruleno==293); + case 294: /* column_alias ::= NK_ID */ yytestcase(yyruleno==294); + case 295: /* user_name ::= NK_ID */ yytestcase(yyruleno==295); + case 296: /* index_name ::= NK_ID */ yytestcase(yyruleno==296); + case 297: /* topic_name ::= NK_ID */ yytestcase(yyruleno==297); + case 298: /* stream_name ::= NK_ID */ yytestcase(yyruleno==298); + case 299: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==299); + case 332: /* noarg_func ::= NOW */ yytestcase(yyruleno==332); + case 333: /* noarg_func ::= TODAY */ yytestcase(yyruleno==333); + case 334: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==334); + case 335: /* star_func ::= COUNT */ yytestcase(yyruleno==335); + case 336: /* star_func ::= FIRST */ yytestcase(yyruleno==336); + case 337: /* star_func ::= LAST */ yytestcase(yyruleno==337); + case 338: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==338); +{ yylhsminor.yy209 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 49: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3278,156 +3287,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 59: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy621, &yymsp[-1].minor.yy421, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy137, &yymsp[-1].minor.yy209, yymsp[0].minor.yy632); } break; case 60: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 61: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } break; case 62: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy421, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy632); } break; case 63: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy621 = true; } +{ yymsp[-2].minor.yy137 = true; } break; case 64: /* not_exists_opt ::= */ case 66: /* exists_opt ::= */ yytestcase(yyruleno==66); case 232: /* analyze_opt ::= */ yytestcase(yyruleno==232); case 240: /* agg_func_opt ::= */ yytestcase(yyruleno==240); - case 390: /* set_quantifier_opt ::= */ yytestcase(yyruleno==390); -{ yymsp[1].minor.yy621 = false; } + case 391: /* set_quantifier_opt ::= */ yytestcase(yyruleno==391); +{ yymsp[1].minor.yy137 = false; } break; case 65: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy621 = true; } +{ yymsp[-1].minor.yy137 = true; } break; case 67: /* db_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultDatabaseOptions(pCxt); } break; case 68: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 69: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 70: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 71: /* db_options ::= db_options DAYS NK_INTEGER */ case 72: /* db_options ::= db_options DAYS NK_VARIABLE */ yytestcase(yyruleno==72); -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 73: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 74: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 75: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 76: /* db_options ::= db_options KEEP integer_list */ case 77: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==77); -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_KEEP, yymsp[0].minor.yy530); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_KEEP, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 78: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 79: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 80: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 81: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 82: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 83: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 84: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 85: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 86: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_RETENTIONS, yymsp[0].minor.yy530); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_RETENTIONS, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 87: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 88: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy674 = createAlterDatabaseOptions(pCxt); yylhsminor.yy674 = setAlterDatabaseOption(pCxt, yylhsminor.yy674, &yymsp[0].minor.yy557); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterDatabaseOptions(pCxt); yylhsminor.yy632 = setAlterDatabaseOption(pCxt, yylhsminor.yy632, &yymsp[0].minor.yy605); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 89: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy674 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy674, &yymsp[0].minor.yy557); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy632, &yymsp[0].minor.yy605); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 90: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 91: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 92: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 93: /* alter_db_option ::= KEEP integer_list */ case 94: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==94); -{ yymsp[-1].minor.yy557.type = DB_OPTION_KEEP; yymsp[-1].minor.yy557.pList = yymsp[0].minor.yy530; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_KEEP; yymsp[-1].minor.yy605.pList = yymsp[0].minor.yy424; } break; case 95: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_PAGES; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_PAGES; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 97: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_STRICT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_STRICT; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 98: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_WAL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_WAL; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 99: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy530 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 100: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 260: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==260); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 261: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==261); +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 101: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy530 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 102: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 103: /* retention_list ::= retention */ case 123: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==123); @@ -3436,242 +3445,242 @@ static YYACTIONTYPE yy_reduce( case 173: /* col_name_list ::= col_name */ yytestcase(yyruleno==173); case 211: /* func_name_list ::= func_name */ yytestcase(yyruleno==211); case 220: /* func_list ::= func */ yytestcase(yyruleno==220); - case 286: /* literal_list ::= signed_literal */ yytestcase(yyruleno==286); - case 340: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==340); - case 395: /* select_sublist ::= select_item */ yytestcase(yyruleno==395); - case 444: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==444); -{ yylhsminor.yy530 = createNodeList(pCxt, yymsp[0].minor.yy674); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 287: /* literal_list ::= signed_literal */ yytestcase(yyruleno==287); + case 341: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==341); + case 396: /* select_sublist ::= select_item */ yytestcase(yyruleno==396); + case 445: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==445); +{ yylhsminor.yy424 = createNodeList(pCxt, yymsp[0].minor.yy632); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 104: /* retention_list ::= retention_list NK_COMMA retention */ case 134: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==134); case 174: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==174); case 212: /* func_name_list ::= func_name_list NK_COMMA func_name */ yytestcase(yyruleno==212); case 221: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==221); - case 287: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==287); - case 341: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==341); - case 396: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==396); - case 445: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==445); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 288: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==288); + case 342: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==342); + case 397: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==397); + case 446: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==446); +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 105: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy674 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 106: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 108: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==108); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy621, yymsp[-5].minor.yy674, yymsp[-3].minor.yy530, yymsp[-1].minor.yy530, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy137, yymsp[-5].minor.yy632, yymsp[-3].minor.yy424, yymsp[-1].minor.yy424, yymsp[0].minor.yy632); } break; case 107: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy530); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 109: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy530); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 110: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy621, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy137, yymsp[0].minor.yy632); } break; case 111: /* cmd ::= ALTER TABLE alter_table_clause */ case 112: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==112); - case 263: /* cmd ::= query_expression */ yytestcase(yyruleno==263); -{ pCxt->pRootNode = yymsp[0].minor.yy674; } + case 264: /* cmd ::= query_expression */ yytestcase(yyruleno==264); +{ pCxt->pRootNode = yymsp[0].minor.yy632; } break; case 113: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy674 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 114: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 115: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy674 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy674, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy632, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 116: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 117: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy674 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 118: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 119: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy674 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy674, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy632, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 120: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 121: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy674 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 122: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy674 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy674, &yymsp[-2].minor.yy421, yymsp[0].minor.yy674); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy632, &yymsp[-2].minor.yy209, yymsp[0].minor.yy632); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; case 124: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 127: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==127); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-1].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-1].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy424 = yylhsminor.yy424; break; case 125: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy674 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy621, yymsp[-8].minor.yy674, yymsp[-6].minor.yy674, yymsp[-5].minor.yy530, yymsp[-2].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-9].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy137, yymsp[-8].minor.yy632, yymsp[-6].minor.yy632, yymsp[-5].minor.yy424, yymsp[-2].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-9].minor.yy632 = yylhsminor.yy632; break; case 128: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy674 = createDropTableClause(pCxt, yymsp[-1].minor.yy621, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createDropTableClause(pCxt, yymsp[-1].minor.yy137, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 129: /* specific_tags_opt ::= */ case 160: /* tags_def_opt ::= */ yytestcase(yyruleno==160); - case 403: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==403); - case 420: /* group_by_clause_opt ::= */ yytestcase(yyruleno==420); - case 432: /* order_by_clause_opt ::= */ yytestcase(yyruleno==432); -{ yymsp[1].minor.yy530 = NULL; } + case 404: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==404); + case 421: /* group_by_clause_opt ::= */ yytestcase(yyruleno==421); + case 433: /* order_by_clause_opt ::= */ yytestcase(yyruleno==433); +{ yymsp[1].minor.yy424 = NULL; } break; case 130: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy530 = yymsp[-1].minor.yy530; } +{ yymsp[-2].minor.yy424 = yymsp[-1].minor.yy424; } break; case 131: /* full_table_name ::= table_name */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy421, NULL); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 132: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421, NULL); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 135: /* column_def ::= column_name type_name */ -{ yylhsminor.yy674 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690, NULL); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 136: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy674 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-2].minor.yy690, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 137: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 138: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 139: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 140: /* type_name ::= INT */ case 141: /* type_name ::= INTEGER */ yytestcase(yyruleno==141); -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } break; case 142: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 143: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 144: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 145: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 147: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 148: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 149: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 150: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 151: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 152: /* type_name ::= JSON */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 153: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 154: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 155: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 156: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 158: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 159: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* tags_def_opt ::= tags_def */ - case 339: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==339); - case 394: /* select_list ::= select_sublist */ yytestcase(yyruleno==394); -{ yylhsminor.yy530 = yymsp[0].minor.yy530; } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 340: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==340); + case 395: /* select_list ::= select_sublist */ yytestcase(yyruleno==395); +{ yylhsminor.yy424 = yymsp[0].minor.yy424; } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 162: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy530 = yymsp[-1].minor.yy530; } +{ yymsp[-3].minor.yy424 = yymsp[-1].minor.yy424; } break; case 163: /* table_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultTableOptions(pCxt); } break; case 164: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 165: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 166: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-4].minor.yy674, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy530); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-4].minor.yy632, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 167: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 168: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-4].minor.yy674, TABLE_OPTION_SMA, yymsp[-1].minor.yy530); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-4].minor.yy632, TABLE_OPTION_SMA, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 169: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy674 = createAlterTableOptions(pCxt); yylhsminor.yy674 = setTableOption(pCxt, yylhsminor.yy674, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableOptions(pCxt); yylhsminor.yy632 = setTableOption(pCxt, yylhsminor.yy632, yymsp[0].minor.yy605.type, &yymsp[0].minor.yy605.val); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 170: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy605.type, &yymsp[0].minor.yy605.val); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 171: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy557.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 172: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 175: /* col_name ::= column_name */ -{ yylhsminor.yy674 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy421); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 176: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } @@ -3683,13 +3692,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; case 179: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } break; case 180: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } break; case 181: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy674, NULL); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy632, NULL); } break; case 182: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } @@ -3704,7 +3713,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; case 186: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; case 187: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } @@ -3723,13 +3732,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; case 193: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } break; case 194: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy632); } break; case 195: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy632); } break; case 196: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } @@ -3757,672 +3766,676 @@ static YYACTIONTYPE yy_reduce( break; case 204: /* db_name_cond_opt ::= */ case 209: /* from_db_opt ::= */ yytestcase(yyruleno==209); -{ yymsp[1].minor.yy674 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultDatabaseCondValue(pCxt); } break; case 205: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 206: /* like_pattern_opt ::= */ case 217: /* index_options ::= */ yytestcase(yyruleno==217); case 246: /* into_opt ::= */ yytestcase(yyruleno==246); - case 401: /* where_clause_opt ::= */ yytestcase(yyruleno==401); - case 405: /* twindow_clause_opt ::= */ yytestcase(yyruleno==405); - case 410: /* sliding_opt ::= */ yytestcase(yyruleno==410); - case 412: /* fill_opt ::= */ yytestcase(yyruleno==412); - case 424: /* having_clause_opt ::= */ yytestcase(yyruleno==424); - case 434: /* slimit_clause_opt ::= */ yytestcase(yyruleno==434); - case 438: /* limit_clause_opt ::= */ yytestcase(yyruleno==438); -{ yymsp[1].minor.yy674 = NULL; } + case 402: /* where_clause_opt ::= */ yytestcase(yyruleno==402); + case 406: /* twindow_clause_opt ::= */ yytestcase(yyruleno==406); + case 411: /* sliding_opt ::= */ yytestcase(yyruleno==411); + case 413: /* fill_opt ::= */ yytestcase(yyruleno==413); + case 425: /* having_clause_opt ::= */ yytestcase(yyruleno==425); + case 435: /* slimit_clause_opt ::= */ yytestcase(yyruleno==435); + case 439: /* limit_clause_opt ::= */ yytestcase(yyruleno==439); +{ yymsp[1].minor.yy632 = NULL; } break; case 207: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 208: /* table_name_cond ::= table_name */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy421); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 210: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy421); } +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } break; case 213: /* func_name ::= function_name */ -{ yylhsminor.yy674 = createFunctionNode(pCxt, &yymsp[0].minor.yy421, NULL); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createFunctionNode(pCxt, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 214: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, &yymsp[-1].minor.yy421, NULL, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy632); } break; case 215: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy621, &yymsp[-5].minor.yy421, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy137, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424, NULL); } break; case 216: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 218: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy674 = createIndexOption(pCxt, yymsp[-6].minor.yy530, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), NULL, yymsp[0].minor.yy674); } +{ yymsp[-8].minor.yy632 = createIndexOption(pCxt, yymsp[-6].minor.yy424, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), NULL, yymsp[0].minor.yy632); } break; case 219: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy674 = createIndexOption(pCxt, yymsp[-8].minor.yy530, releaseRawExprNode(pCxt, yymsp[-4].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), yymsp[0].minor.yy674); } +{ yymsp[-10].minor.yy632 = createIndexOption(pCxt, yymsp[-8].minor.yy424, releaseRawExprNode(pCxt, yymsp[-4].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), yymsp[0].minor.yy632); } break; case 222: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy674 = createFunctionNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 223: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, yymsp[0].minor.yy674, NULL, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, yymsp[0].minor.yy632, NULL, NULL); } break; case 224: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, NULL, &yymsp[0].minor.yy421, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, NULL, &yymsp[0].minor.yy209, NULL); } break; case 225: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, NULL, NULL, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, NULL, NULL, yymsp[0].minor.yy632); } break; case 226: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 227: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 228: /* cmd ::= DESC full_table_name */ case 229: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==229); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy632); } break; case 230: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 231: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy621, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy137, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; case 233: /* analyze_opt ::= ANALYZE */ case 241: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==241); - case 391: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==391); -{ yymsp[0].minor.yy621 = true; } + case 392: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==392); +{ yymsp[0].minor.yy137 = true; } break; case 234: /* explain_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultExplainOptions(pCxt); } break; case 235: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy674 = setExplainVerbose(pCxt, yymsp[-2].minor.yy674, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setExplainVerbose(pCxt, yymsp[-2].minor.yy632, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 236: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy674 = setExplainRatio(pCxt, yymsp[-2].minor.yy674, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setExplainRatio(pCxt, yymsp[-2].minor.yy632, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 237: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy530); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy424); } break; case 238: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy621, yymsp[-8].minor.yy621, &yymsp[-5].minor.yy421, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy690, yymsp[0].minor.yy42); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy137, yymsp[-8].minor.yy137, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy304, yymsp[0].minor.yy100); } break; case 239: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 242: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy42 = 0; } +{ yymsp[1].minor.yy100 = 0; } break; case 243: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy42 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy100 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 244: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy621, &yymsp[-4].minor.yy421, yymsp[-2].minor.yy674, yymsp[-3].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy137, &yymsp[-4].minor.yy209, yymsp[-2].minor.yy632, yymsp[-3].minor.yy632, yymsp[0].minor.yy632); } break; case 245: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 247: /* into_opt ::= INTO full_table_name */ - case 372: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==372); - case 402: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==402); - case 425: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==425); -{ yymsp[-1].minor.yy674 = yymsp[0].minor.yy674; } + case 373: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==373); + case 403: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==403); + case 426: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==426); +{ yymsp[-1].minor.yy632 = yymsp[0].minor.yy632; } break; case 248: /* stream_options ::= */ -{ yymsp[1].minor.yy674 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy632 = createStreamOptions(pCxt); } break; case 249: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 250: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 251: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy674); yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 251: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy632)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy632)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); yylhsminor.yy632 = yymsp[-3].minor.yy632; } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 252: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 252: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; + break; + case 253: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 253: /* cmd ::= KILL QUERY NK_INTEGER */ + case 254: /* cmd ::= KILL QUERY NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 254: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 255: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 255: /* cmd ::= BALANCE VGROUP */ + case 256: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 256: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 257: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 257: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy530); } + case 258: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy424); } break; - case 258: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 259: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 259: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy530 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 260: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 261: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy421); } + case 262: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy209); } break; - case 262: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 263: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 264: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 265: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 265: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 266: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 266: /* literal ::= NK_STRING */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 267: /* literal ::= NK_STRING */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 267: /* literal ::= NK_BOOL */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 268: /* literal ::= NK_BOOL */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 268: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 269: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 269: /* literal ::= duration_literal */ - case 279: /* signed_literal ::= signed */ yytestcase(yyruleno==279); - case 299: /* expression ::= literal */ yytestcase(yyruleno==299); - case 300: /* expression ::= pseudo_column */ yytestcase(yyruleno==300); - case 301: /* expression ::= column_reference */ yytestcase(yyruleno==301); - case 302: /* expression ::= function_expression */ yytestcase(yyruleno==302); - case 303: /* expression ::= subquery */ yytestcase(yyruleno==303); - case 328: /* function_expression ::= literal_func */ yytestcase(yyruleno==328); - case 364: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==364); - case 368: /* boolean_primary ::= predicate */ yytestcase(yyruleno==368); - case 370: /* common_expression ::= expression */ yytestcase(yyruleno==370); - case 371: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==371); - case 373: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==373); - case 375: /* table_reference ::= table_primary */ yytestcase(yyruleno==375); - case 376: /* table_reference ::= joined_table */ yytestcase(yyruleno==376); - case 380: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==380); - case 427: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==427); - case 430: /* query_primary ::= query_specification */ yytestcase(yyruleno==430); -{ yylhsminor.yy674 = yymsp[0].minor.yy674; } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 270: /* literal ::= duration_literal */ + case 280: /* signed_literal ::= signed */ yytestcase(yyruleno==280); + case 300: /* expression ::= literal */ yytestcase(yyruleno==300); + case 301: /* expression ::= pseudo_column */ yytestcase(yyruleno==301); + case 302: /* expression ::= column_reference */ yytestcase(yyruleno==302); + case 303: /* expression ::= function_expression */ yytestcase(yyruleno==303); + case 304: /* expression ::= subquery */ yytestcase(yyruleno==304); + case 329: /* function_expression ::= literal_func */ yytestcase(yyruleno==329); + case 365: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==365); + case 369: /* boolean_primary ::= predicate */ yytestcase(yyruleno==369); + case 371: /* common_expression ::= expression */ yytestcase(yyruleno==371); + case 372: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==372); + case 374: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==374); + case 376: /* table_reference ::= table_primary */ yytestcase(yyruleno==376); + case 377: /* table_reference ::= joined_table */ yytestcase(yyruleno==377); + case 381: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==381); + case 428: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==428); + case 431: /* query_primary ::= query_specification */ yytestcase(yyruleno==431); +{ yylhsminor.yy632 = yymsp[0].minor.yy632; } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 270: /* literal ::= NULL */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 271: /* literal ::= NULL */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 271: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 272: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 272: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 273: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 273: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 274: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 274: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 275: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 275: /* signed ::= NK_MINUS NK_INTEGER */ + case 276: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 276: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 277: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 277: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 278: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 278: /* signed ::= NK_MINUS NK_FLOAT */ + case 279: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 280: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 281: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 281: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 282: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 282: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 283: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 283: /* signed_literal ::= duration_literal */ - case 285: /* signed_literal ::= literal_func */ yytestcase(yyruleno==285); - case 342: /* star_func_para ::= expression */ yytestcase(yyruleno==342); - case 397: /* select_item ::= common_expression */ yytestcase(yyruleno==397); - case 443: /* search_condition ::= common_expression */ yytestcase(yyruleno==443); -{ yylhsminor.yy674 = releaseRawExprNode(pCxt, yymsp[0].minor.yy674); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 284: /* signed_literal ::= duration_literal */ + case 286: /* signed_literal ::= literal_func */ yytestcase(yyruleno==286); + case 343: /* star_func_para ::= expression */ yytestcase(yyruleno==343); + case 398: /* select_item ::= common_expression */ yytestcase(yyruleno==398); + case 444: /* search_condition ::= common_expression */ yytestcase(yyruleno==444); +{ yylhsminor.yy632 = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 284: /* signed_literal ::= NULL */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 285: /* signed_literal ::= NULL */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 304: /* expression ::= NK_LP expression NK_RP */ - case 369: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==369); -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 305: /* expression ::= NK_LP expression NK_RP */ + case 370: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==370); +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 305: /* expression ::= NK_PLUS expression */ + case 306: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 306: /* expression ::= NK_MINUS expression */ + case 307: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy674), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy632), NULL)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 307: /* expression ::= expression NK_PLUS expression */ + case 308: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 308: /* expression ::= expression NK_MINUS expression */ + case 309: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 309: /* expression ::= expression NK_STAR expression */ + case 310: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 310: /* expression ::= expression NK_SLASH expression */ + case 311: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 311: /* expression ::= expression NK_REM expression */ + case 312: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 312: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 313: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 313: /* expression_list ::= expression */ -{ yylhsminor.yy530 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 314: /* expression_list ::= expression */ +{ yylhsminor.yy424 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 314: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 315: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; - case 315: /* column_reference ::= column_name */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy421, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy421)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 316: /* column_reference ::= column_name */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 316: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421, createColumnNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 317: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 317: /* pseudo_column ::= ROWTS */ - case 318: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==318); - case 320: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==320); - case 321: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==321); - case 322: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==322); - case 323: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==323); - case 324: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==324); - case 330: /* literal_func ::= NOW */ yytestcase(yyruleno==330); -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 318: /* pseudo_column ::= ROWTS */ + case 319: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==319); + case 321: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==321); + case 322: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==322); + case 323: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==323); + case 324: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==324); + case 325: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==325); + case 331: /* literal_func ::= NOW */ yytestcase(yyruleno==331); +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 319: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy421)))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 320: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy209)))); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 325: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 326: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==326); -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530)); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 326: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 327: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==327); +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424)); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 327: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), yymsp[-1].minor.yy690)); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + case 328: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), yymsp[-1].minor.yy304)); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 329: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy421, NULL)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 330: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy209, NULL)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 338: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy530 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 339: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy424 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 343: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 400: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==400); -{ yylhsminor.yy674 = createColumnNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 344: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 401: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==401); +{ yylhsminor.yy632 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 344: /* predicate ::= expression compare_op expression */ - case 349: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==349); + case 345: /* predicate ::= expression compare_op expression */ + case 350: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==350); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy28, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy380, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 345: /* predicate ::= expression BETWEEN expression AND expression */ + case 346: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; - case 346: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 347: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 347: /* predicate ::= expression IS NULL */ + case 348: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), NULL)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 348: /* predicate ::= expression IS NOT NULL */ + case 349: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), NULL)); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 350: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy28 = OP_TYPE_LOWER_THAN; } + case 351: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } break; - case 351: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy28 = OP_TYPE_GREATER_THAN; } + case 352: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } break; - case 352: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy28 = OP_TYPE_LOWER_EQUAL; } + case 353: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } break; - case 353: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy28 = OP_TYPE_GREATER_EQUAL; } + case 354: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } break; - case 354: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy28 = OP_TYPE_NOT_EQUAL; } + case 355: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } break; - case 355: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy28 = OP_TYPE_EQUAL; } + case 356: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } break; - case 356: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy28 = OP_TYPE_LIKE; } + case 357: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy380 = OP_TYPE_LIKE; } break; - case 357: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy28 = OP_TYPE_NOT_LIKE; } + case 358: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } break; - case 358: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy28 = OP_TYPE_MATCH; } + case 359: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy380 = OP_TYPE_MATCH; } break; - case 359: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy28 = OP_TYPE_NMATCH; } + case 360: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } break; - case 360: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy28 = OP_TYPE_JSON_CONTAINS; } + case 361: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy380 = OP_TYPE_JSON_CONTAINS; } break; - case 361: /* in_op ::= IN */ -{ yymsp[0].minor.yy28 = OP_TYPE_IN; } + case 362: /* in_op ::= IN */ +{ yymsp[0].minor.yy380 = OP_TYPE_IN; } break; - case 362: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy28 = OP_TYPE_NOT_IN; } + case 363: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } break; - case 363: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy530)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 364: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 365: /* boolean_value_expression ::= NOT boolean_primary */ + case 366: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy674), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy632), NULL)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 366: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 367: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 367: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 368: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 374: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy674 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy674, yymsp[0].minor.yy674, NULL); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 375: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy632 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy632, yymsp[0].minor.yy632, NULL); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 377: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 378: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy632 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 378: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, &yymsp[-3].minor.yy421, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 379: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy632 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 379: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy674 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 380: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy632 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 381: /* alias_opt ::= */ -{ yymsp[1].minor.yy421 = nil_token; } + case 382: /* alias_opt ::= */ +{ yymsp[1].minor.yy209 = nil_token; } break; - case 382: /* alias_opt ::= table_alias */ -{ yylhsminor.yy421 = yymsp[0].minor.yy421; } - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 383: /* alias_opt ::= table_alias */ +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; - case 383: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } + case 384: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } break; - case 384: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 385: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==385); -{ yymsp[-2].minor.yy674 = yymsp[-1].minor.yy674; } + case 385: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 386: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==386); +{ yymsp[-2].minor.yy632 = yymsp[-1].minor.yy632; } break; - case 386: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy674 = createJoinTableNode(pCxt, yymsp[-4].minor.yy636, yymsp[-5].minor.yy674, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + case 387: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy632 = createJoinTableNode(pCxt, yymsp[-4].minor.yy612, yymsp[-5].minor.yy632, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 387: /* join_type ::= */ -{ yymsp[1].minor.yy636 = JOIN_TYPE_INNER; } + case 388: /* join_type ::= */ +{ yymsp[1].minor.yy612 = JOIN_TYPE_INNER; } break; - case 388: /* join_type ::= INNER */ -{ yymsp[0].minor.yy636 = JOIN_TYPE_INNER; } + case 389: /* join_type ::= INNER */ +{ yymsp[0].minor.yy612 = JOIN_TYPE_INNER; } break; - case 389: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 390: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy674 = createSelectStmt(pCxt, yymsp[-7].minor.yy621, yymsp[-6].minor.yy530, yymsp[-5].minor.yy674); - yymsp[-8].minor.yy674 = addWhereClause(pCxt, yymsp[-8].minor.yy674, yymsp[-4].minor.yy674); - yymsp[-8].minor.yy674 = addPartitionByClause(pCxt, yymsp[-8].minor.yy674, yymsp[-3].minor.yy530); - yymsp[-8].minor.yy674 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy674, yymsp[-2].minor.yy674); - yymsp[-8].minor.yy674 = addGroupByClause(pCxt, yymsp[-8].minor.yy674, yymsp[-1].minor.yy530); - yymsp[-8].minor.yy674 = addHavingClause(pCxt, yymsp[-8].minor.yy674, yymsp[0].minor.yy674); + yymsp[-8].minor.yy632 = createSelectStmt(pCxt, yymsp[-7].minor.yy137, yymsp[-6].minor.yy424, yymsp[-5].minor.yy632); + yymsp[-8].minor.yy632 = addWhereClause(pCxt, yymsp[-8].minor.yy632, yymsp[-4].minor.yy632); + yymsp[-8].minor.yy632 = addPartitionByClause(pCxt, yymsp[-8].minor.yy632, yymsp[-3].minor.yy424); + yymsp[-8].minor.yy632 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy632, yymsp[-2].minor.yy632); + yymsp[-8].minor.yy632 = addGroupByClause(pCxt, yymsp[-8].minor.yy632, yymsp[-1].minor.yy424); + yymsp[-8].minor.yy632 = addHavingClause(pCxt, yymsp[-8].minor.yy632, yymsp[0].minor.yy632); } break; - case 392: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy621 = false; } + case 393: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy137 = false; } break; - case 393: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy530 = NULL; } + case 394: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy424 = NULL; } break; - case 398: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy674 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 399: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy632 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 399: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy674 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 400: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy632 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 404: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 421: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==421); - case 433: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==433); -{ yymsp[-2].minor.yy530 = yymsp[0].minor.yy530; } + case 405: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 422: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==422); + case 434: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==434); +{ yymsp[-2].minor.yy424 = yymsp[0].minor.yy424; } break; - case 406: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy674 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } + case 407: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy632 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 407: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy674 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } + case 408: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy632 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 408: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy674 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), NULL, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 409: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy632 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), NULL, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 409: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy674 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy674), releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 410: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy632 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy632), releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 411: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy674 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy674); } + case 412: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy632 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy632); } break; - case 413: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy674 = createFillNode(pCxt, yymsp[-1].minor.yy320, NULL); } + case 414: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy632 = createFillNode(pCxt, yymsp[-1].minor.yy54, NULL); } break; - case 414: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy674 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy530)); } + case 415: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy632 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } break; - case 415: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy320 = FILL_MODE_NONE; } + case 416: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy54 = FILL_MODE_NONE; } break; - case 416: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy320 = FILL_MODE_PREV; } + case 417: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy54 = FILL_MODE_PREV; } break; - case 417: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy320 = FILL_MODE_NULL; } + case 418: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy54 = FILL_MODE_NULL; } break; - case 418: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy320 = FILL_MODE_LINEAR; } + case 419: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy54 = FILL_MODE_LINEAR; } break; - case 419: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy320 = FILL_MODE_NEXT; } + case 420: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy54 = FILL_MODE_NEXT; } break; - case 422: /* group_by_list ::= expression */ -{ yylhsminor.yy530 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 423: /* group_by_list ::= expression */ +{ yylhsminor.yy424 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 423: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 424: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; - case 426: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 427: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy674 = addOrderByClause(pCxt, yymsp[-3].minor.yy674, yymsp[-2].minor.yy530); - yylhsminor.yy674 = addSlimitClause(pCxt, yylhsminor.yy674, yymsp[-1].minor.yy674); - yylhsminor.yy674 = addLimitClause(pCxt, yylhsminor.yy674, yymsp[0].minor.yy674); + yylhsminor.yy632 = addOrderByClause(pCxt, yymsp[-3].minor.yy632, yymsp[-2].minor.yy424); + yylhsminor.yy632 = addSlimitClause(pCxt, yylhsminor.yy632, yymsp[-1].minor.yy632); + yylhsminor.yy632 = addLimitClause(pCxt, yylhsminor.yy632, yymsp[0].minor.yy632); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 428: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy674 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 429: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy632 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 429: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy674 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 430: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy632 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 431: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy674 = yymsp[-4].minor.yy674; } - yy_destructor(yypParser,351,&yymsp[-3].minor); - yy_destructor(yypParser,352,&yymsp[-2].minor); - yy_destructor(yypParser,353,&yymsp[-1].minor); + case 432: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy632 = yymsp[-4].minor.yy632; } + yy_destructor(yypParser,352,&yymsp[-3].minor); + yy_destructor(yypParser,353,&yymsp[-2].minor); + yy_destructor(yypParser,354,&yymsp[-1].minor); break; - case 435: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 439: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==439); -{ yymsp[-1].minor.yy674 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 436: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 440: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==440); +{ yymsp[-1].minor.yy632 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 436: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 440: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==440); -{ yymsp[-3].minor.yy674 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 437: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 441: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==441); +{ yymsp[-3].minor.yy632 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 437: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 441: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==441); -{ yymsp[-3].minor.yy674 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 438: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 442: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==442); +{ yymsp[-3].minor.yy632 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 442: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy674); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 443: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy632); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 446: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy674 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), yymsp[-1].minor.yy610, yymsp[0].minor.yy107); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 447: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy632 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), yymsp[-1].minor.yy578, yymsp[0].minor.yy217); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 447: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy610 = ORDER_ASC; } + case 448: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy578 = ORDER_ASC; } break; - case 448: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy610 = ORDER_ASC; } + case 449: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy578 = ORDER_ASC; } break; - case 449: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy610 = ORDER_DESC; } + case 450: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy578 = ORDER_DESC; } break; - case 450: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy107 = NULL_ORDER_DEFAULT; } + case 451: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } break; - case 451: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy107 = NULL_ORDER_FIRST; } + case 452: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } break; - case 452: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy107 = NULL_ORDER_LAST; } + case 453: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInitialATest.cpp b/source/libs/parser/test/parInitialATest.cpp index 9e45185a90..3c1d931f37 100644 --- a/source/libs/parser/test/parInitialATest.cpp +++ b/source/libs/parser/test/parInitialATest.cpp @@ -76,6 +76,11 @@ TEST_F(ParserInitialATest, alterSTable) { SMAlterStbReq expect = {0}; + auto clearAlterStbReq = [&]() { + tFreeSMAltertbReq(&expect); + memset(&expect, 0, sizeof(SMAlterStbReq)); + }; + auto setAlterStbReqFunc = [&](const char* pTbname, int8_t alterType, int32_t numOfFields = 0, const char* pField1Name = nullptr, int8_t field1Type = 0, int32_t field1Bytes = 0, const char* pField2Name = nullptr, const char* pComment = nullptr, @@ -139,39 +144,49 @@ TEST_F(ParserInitialATest, alterSTable) { ASSERT_EQ(pField->type, pExpectField->type); ASSERT_EQ(pField->bytes, pExpectField->bytes); } + tFreeSMAltertbReq(&req); }); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10); run("ALTER TABLE st1 TTL 10"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test"); run("ALTER TABLE st1 COMMENT 'test'"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_COLUMN, 1, "cc1", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE st1 ADD COLUMN cc1 BIGINT"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_COLUMN, 1, "c1"); run("ALTER TABLE st1 DROP COLUMN c1"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c1", TSDB_DATA_TYPE_VARCHAR, 20 + VARSTR_HEADER_SIZE); run("ALTER TABLE st1 MODIFY COLUMN c1 VARCHAR(20)"); + clearAlterStbReq(); // setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1"); // run("ALTER TABLE st1 RENAME COLUMN c1 cc1"); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_TAG, 1, "tag11", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE st1 ADD TAG tag11 BIGINT"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_TAG, 1, "tag1"); run("ALTER TABLE st1 DROP TAG tag1"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag1", TSDB_DATA_TYPE_VARCHAR, 20 + VARSTR_HEADER_SIZE); run("ALTER TABLE st1 MODIFY TAG tag1 VARCHAR(20)"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_NAME, 2, "tag1", 0, 0, "tag11"); run("ALTER TABLE st1 RENAME TAG tag1 tag11"); + clearAlterStbReq(); // todo // ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option] @@ -188,16 +203,16 @@ TEST_F(ParserInitialATest, alterTable) { SVAlterTbReq expect = {0}; - auto initAlterTbReq = [](SVAlterTbReq* pReq) { - free(pReq->tbName); - free(pReq->colName); - free(pReq->colNewName); - memset(pReq, 0, sizeof(SVAlterTbReq)); + auto clearAlterTbReq = [&]() { + free(expect.tbName); + free(expect.colName); + free(expect.colNewName); + free(expect.tagName); + memset(&expect, 0, sizeof(SVAlterTbReq)); }; auto setAlterColFunc = [&](const char* pTbname, int8_t alterType, const char* pColName, int8_t dataType = 0, int32_t dataBytes = 0, const char* pNewColName = nullptr) { - initAlterTbReq(&expect); expect.tbName = strdup(pTbname); expect.action = alterType; expect.colName = strdup(pColName); @@ -220,7 +235,6 @@ TEST_F(ParserInitialATest, alterTable) { }; auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) { - initAlterTbReq(&expect); expect.tbName = strdup(pTbname); expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; expect.tagName = strdup(pTagName); @@ -231,7 +245,6 @@ TEST_F(ParserInitialATest, alterTable) { }; auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) { - initAlterTbReq(&expect); expect.tbName = strdup(pTbname); expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS; if (-1 != ttl) { @@ -288,25 +301,32 @@ TEST_F(ParserInitialATest, alterTable) { setAlterOptionsFunc("t1", 10, nullptr); run("ALTER TABLE t1 TTL 10"); + clearAlterTbReq(); setAlterOptionsFunc("t1", -1, (char*)"test"); run("ALTER TABLE t1 COMMENT 'test'"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_DROP_COLUMN, "c1"); run("ALTER TABLE t1 DROP COLUMN c1"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE); run("ALTER TABLE t1 MODIFY COLUMN c2 VARCHAR(30)"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, "c1", 0, 0, "cc1"); run("ALTER TABLE t1 RENAME COLUMN c1 cc1"); + clearAlterTbReq(); int32_t val = 10; setAlterTagFunc("st1s1", "tag1", (uint8_t*)&val, sizeof(val)); run("ALTER TABLE st1s1 SET TAG tag1=10"); + clearAlterTbReq(); // todo // ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option] diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index f306947f76..919d4c041d 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -67,8 +67,12 @@ TEST_F(ParserInitialCTest, createDatabase) { SCreateDbReq expect = {0}; - auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) { + auto clearCreateDbReq = [&]() { + tFreeSCreateDbReq(&expect); memset(&expect, 0, sizeof(SCreateDbReq)); + }; + + auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) { int32_t len = snprintf(expect.db, sizeof(expect.db), "0.%s", pDbname); expect.db[len] = '\0'; expect.ignoreExist = igExists; @@ -166,10 +170,12 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit); } } + tFreeSCreateDbReq(&req); }); setCreateDbReqFunc("wxy_db"); run("CREATE DATABASE wxy_db"); + clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); setDbBufferFunc(64); @@ -211,6 +217,7 @@ TEST_F(ParserInitialCTest, createDatabase) { "VGROUPS 100 " "SINGLE_STABLE 1 " "SCHEMALESS 1"); + clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); setDbDaysFunc(100); @@ -218,6 +225,7 @@ TEST_F(ParserInitialCTest, createDatabase) { run("CREATE DATABASE IF NOT EXISTS wxy_db " "DAYS 100m " "KEEP 1440m,300h,400d "); + clearCreateDbReq(); } TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) { @@ -309,10 +317,14 @@ TEST_F(ParserInitialCTest, createStable) { SMCreateStbReq expect = {0}; + auto clearCreateStbReq = [&]() { + tFreeSMCreateStbReq(&expect); + memset(&expect, 0, sizeof(SMCreateStbReq)); + }; + auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0, float xFilesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR, int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) { - memset(&expect, 0, sizeof(SMCreateStbReq)); int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname); expect.name[len] = '\0'; expect.igExists = igExists; @@ -396,6 +408,7 @@ TEST_F(ParserInitialCTest, createStable) { if (expect.ast2Len > 0) { ASSERT_EQ(std::string(req.pAst2), std::string(expect.pAst2)); } + tFreeSMCreateStbReq(&req); }); setCreateStbReqFunc("t1"); @@ -403,6 +416,7 @@ TEST_F(ParserInitialCTest, createStable) { addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT); addFieldToCreateStbReqFunc(false, "id", TSDB_DATA_TYPE_INT); run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)"); + clearCreateStbReq(); setCreateStbReqFunc("t1", 1, 0.1, 100, "test create table"); addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0); @@ -443,6 +457,7 @@ TEST_F(ParserInitialCTest, createStable) { "a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, " "a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1"); + clearCreateStbReq(); } TEST_F(ParserInitialCTest, createStableSemanticCheck) { @@ -455,13 +470,62 @@ TEST_F(ParserInitialCTest, createStableSemanticCheck) { TEST_F(ParserInitialCTest, createStream) { useDb("root", "test"); + SCMCreateStreamReq expect = {0}; + + auto clearCreateStreamReq = [&]() { + tFreeSCMCreateStreamReq(&expect); + memset(&expect, 0, sizeof(SCMCreateStreamReq)); + }; + + auto setCreateStbReqFunc = + [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0, + int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) { + snprintf(expect.name, sizeof(expect.name), "0.%s", pStream); + snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb); + if (NULL != pDstStb) { + snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb); + } + expect.igExists = igExists; + expect.sql = strdup(pSql); + expect.triggerType = triggerType; + expect.maxDelay = maxDelay; + expect.watermark = watermark; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT); + SCMCreateStreamReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == + tDeserializeSCMCreateStreamReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(std::string(req.name), std::string(expect.name)); + ASSERT_EQ(std::string(req.sourceDB), std::string(expect.sourceDB)); + ASSERT_EQ(std::string(req.targetStbFullName), std::string(expect.targetStbFullName)); + ASSERT_EQ(req.igExists, expect.igExists); + ASSERT_EQ(std::string(req.sql), std::string(expect.sql)); + ASSERT_EQ(req.triggerType, expect.triggerType); + ASSERT_EQ(req.maxDelay, expect.maxDelay); + ASSERT_EQ(req.watermark, expect.watermark); + tFreeSCMCreateStreamReq(&req); + }); + + setCreateStbReqFunc("s1", "test", "create stream s1 as select * from t1"); run("CREATE STREAM s1 AS SELECT * FROM t1"); + clearCreateStreamReq(); + setCreateStbReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1); run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1"); + clearCreateStreamReq(); + setCreateStbReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1"); run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1"); + clearCreateStreamReq(); - run("CREATE STREAM IF NOT EXISTS s1 TRIGGER WINDOW_CLOSE WATERMARK 10s INTO st1 AS SELECT * FROM t1"); + setCreateStbReqFunc("s1", "test", + "create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1", + "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1"); + clearCreateStreamReq(); } TEST_F(ParserInitialCTest, createTable) { @@ -497,9 +561,10 @@ TEST_F(ParserInitialCTest, createTopic) { SCMCreateTopicReq expect = {0}; + auto clearCreateTopicReq = [&]() { memset(&expect, 0, sizeof(SCMCreateTopicReq)); }; + auto setCreateTopicReqFunc = [&](const char* pTopicName, int8_t igExists, const char* pSql, const char* pAst, const char* pDbName = nullptr, const char* pTbname = nullptr) { - memset(&expect, 0, sizeof(SMCreateStbReq)); snprintf(expect.name, sizeof(expect.name), "0.%s", pTopicName); expect.igExists = igExists; expect.sql = (char*)pSql; @@ -538,19 +603,24 @@ TEST_F(ParserInitialCTest, createTopic) { default: ASSERT_TRUE(false); } + tFreeSCMCreateTopicReq(&req); }); setCreateTopicReqFunc("tp1", 0, "create topic tp1 as select * from t1", "ast"); run("CREATE TOPIC tp1 AS SELECT * FROM t1"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as select ts, ceil(c1) from t1", "ast"); run("CREATE TOPIC IF NOT EXISTS tp1 AS SELECT ts, CEIL(c1) FROM t1"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 0, "create topic tp1 as database test", nullptr, "test"); run("CREATE TOPIC tp1 AS DATABASE test"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as stable st1", nullptr, "test", "st1"); run("CREATE TOPIC IF NOT EXISTS tp1 AS STABLE st1"); + clearCreateTopicReq(); } TEST_F(ParserInitialCTest, createUser) { diff --git a/source/libs/parser/test/parInsertTest.cpp b/source/libs/parser/test/parInsertTest.cpp index bd2cc2a91a..3cea494b92 100644 --- a/source/libs/parser/test/parInsertTest.cpp +++ b/source/libs/parser/test/parInsertTest.cpp @@ -35,6 +35,8 @@ string toString(int32_t code) { return tstrerror(code); } // [...]; class InsertTest : public Test { protected: + ~InsertTest() { reset(); } + void setDatabase(const string& acctId, const string& db) { acctId_ = acctId; db_ = db; @@ -60,8 +62,8 @@ class InsertTest : public Test { int32_t runAsync() { cxt_.async = true; - SParseMetaCache metaCache = {0}; - code_ = parseInsertSyntax(&cxt_, &res_, &metaCache); + unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache); + code_ = parseInsertSyntax(&cxt_, &res_, metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; @@ -69,7 +71,7 @@ class InsertTest : public Test { unique_ptr catalogReq(new SCatalogReq(), MockCatalogService::destoryCatalogReq); - code_ = buildCatalogReq(&metaCache, catalogReq.get()); + code_ = buildCatalogReq(metaCache.get(), catalogReq.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "buildCatalogReq code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; @@ -78,13 +80,13 @@ class InsertTest : public Test { unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); g_mockCatalogService->catalogGetAllMeta(catalogReq.get(), metaData.get()); - code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), &metaCache); + code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "putMetaDataToCache code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; } - code_ = parseInsertSql(&cxt_, &res_, &metaCache); + code_ = parseInsertSql(&cxt_, &res_, metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "parseInsertSql code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; @@ -141,12 +143,18 @@ class InsertTest : public Test { static const int max_err_len = 1024; static const int max_sql_len = 1024 * 1024; + static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) { + destoryParseMetaCache(pMetaCache); + delete pMetaCache; + } + void reset() { memset(&cxt_, 0, sizeof(cxt_)); memset(errMagBuf_, 0, max_err_len); cxt_.pMsg = errMagBuf_; cxt_.msgLen = max_err_len; code_ = TSDB_CODE_SUCCESS; + qDestroyQuery(res_); res_ = nullptr; } diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp index d771f3163d..13ab116552 100644 --- a/source/libs/parser/test/parTestUtil.cpp +++ b/source/libs/parser/test/parTestUtil.cpp @@ -78,34 +78,12 @@ class ParserTestBaseImpl { return; } - reset(expect, checkStage); - try { - SParseContext cxt = {0}; - setParseContext(sql, &cxt); - - SQuery* pQuery = nullptr; - doParse(&cxt, &pQuery); - unique_ptr query(pQuery, qDestroyQuery); - - doAuthenticate(&cxt, pQuery, nullptr); - - doTranslate(&cxt, pQuery, nullptr); - - doCalculateConstant(&cxt, pQuery); - - if (g_dump) { - dump(); - } - } catch (const TerminateFlag& e) { - // success and terminate - return; - } catch (...) { - dump(); - throw; - } + runInternalFuncs(sql, expect, checkStage); + runApis(sql, expect, checkStage); if (g_testAsyncApis) { - runAsync(sql, expect, checkStage); + runAsyncInternalFuncs(sql, expect, checkStage); + runAsyncApis(sql, expect, checkStage); } } @@ -132,34 +110,63 @@ class ParserTestBaseImpl { string calcConstAst_; }; + enum TestInterfaceType { + TEST_INTERFACE_INTERNAL = 1, + TEST_INTERFACE_API, + TEST_INTERFACE_ASYNC_INTERNAL, + TEST_INTERFACE_ASYNC_API + }; + + static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) { + destoryParseMetaCache(pMetaCache); + delete pMetaCache; + } + bool checkResultCode(const string& pFunc, int32_t resultCode) { return !(stmtEnv_.checkFunc_.empty()) - ? (("*" == stmtEnv_.checkFunc_ || stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode - : TSDB_CODE_SUCCESS == resultCode) + ? ((stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode : TSDB_CODE_SUCCESS == resultCode) : true; } - string stageFunc(ParserStage stage) { - switch (stage) { - case PARSER_STAGE_PARSE: - return "parse"; - case PARSER_STAGE_TRANSLATE: - return "translate"; - case PARSER_STAGE_CALC_CONST: - return "calculateConstant"; - case PARSER_STAGE_ALL: - return "*"; + string stageFunc(ParserStage stage, TestInterfaceType type) { + switch (type) { + case TEST_INTERFACE_INTERNAL: + case TEST_INTERFACE_ASYNC_INTERNAL: + switch (stage) { + case PARSER_STAGE_PARSE: + return "parse"; + case PARSER_STAGE_TRANSLATE: + return "translate"; + case PARSER_STAGE_CALC_CONST: + return "calculateConstant"; + default: + break; + } + break; + case TEST_INTERFACE_API: + return "qParseSql"; + case TEST_INTERFACE_ASYNC_API: + switch (stage) { + case PARSER_STAGE_PARSE: + return "qParseSqlSyntax"; + case PARSER_STAGE_TRANSLATE: + case PARSER_STAGE_CALC_CONST: + return "qAnalyseSqlSemantic"; + default: + break; + } + break; default: break; } return "unknown"; } - void reset(int32_t expect, ParserStage checkStage) { + void reset(int32_t expect, ParserStage checkStage, TestInterfaceType type) { stmtEnv_.sql_.clear(); stmtEnv_.msgBuf_.fill(0); stmtEnv_.expect_ = expect; - stmtEnv_.checkFunc_ = stageFunc(checkStage); + stmtEnv_.checkFunc_ = stageFunc(checkStage, type); res_.parsedAst_.clear(); res_.translatedAst_.clear(); @@ -168,12 +175,18 @@ class ParserTestBaseImpl { void dump() { cout << "==========================================sql : [" << stmtEnv_.sql_ << "]" << endl; - cout << "raw syntax tree : " << endl; - cout << res_.parsedAst_ << endl; - cout << "translated syntax tree : " << endl; - cout << res_.translatedAst_ << endl; - cout << "optimized syntax tree : " << endl; - cout << res_.calcConstAst_ << endl; + if (!res_.parsedAst_.empty()) { + cout << "raw syntax tree : " << endl; + cout << res_.parsedAst_ << endl; + } + if (!res_.translatedAst_.empty()) { + cout << "translated syntax tree : " << endl; + cout << res_.translatedAst_ << endl; + } + if (!res_.calcConstAst_.empty()) { + cout << "optimized syntax tree : " << endl; + cout << res_.calcConstAst_ << endl; + } } void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) { @@ -228,6 +241,24 @@ class ParserTestBaseImpl { res_.calcConstAst_ = toString(pQuery->pRoot); } + void doParseSql(SParseContext* pCxt, SQuery** pQuery) { + DO_WITH_THROW(qParseSql, pCxt, pQuery); + ASSERT_NE(*pQuery, nullptr); + res_.calcConstAst_ = toString((*pQuery)->pRoot); + } + + void doParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq) { + DO_WITH_THROW(qParseSqlSyntax, pCxt, pQuery, pCatalogReq); + ASSERT_NE(*pQuery, nullptr); + res_.parsedAst_ = toString((*pQuery)->pRoot); + } + + void doAnalyseSqlSemantic(SParseContext* pCxt, const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, + SQuery* pQuery) { + DO_WITH_THROW(qAnalyseSqlSemantic, pCxt, pCatalogReq, pMetaData, pQuery); + res_.calcConstAst_ = toString(pQuery->pRoot); + } + string toString(const SNode* pRoot) { char* pStr = NULL; int32_t len = 0; @@ -239,8 +270,58 @@ class ParserTestBaseImpl { void checkQuery(const SQuery* pQuery, ParserStage stage) { pBase_->checkDdl(pQuery, stage); } - void runAsync(const string& sql, int32_t expect, ParserStage checkStage) { - reset(expect, checkStage); + void runInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_INTERNAL); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + SQuery* pQuery = nullptr; + doParse(&cxt, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); + + doAuthenticate(&cxt, pQuery, nullptr); + + doTranslate(&cxt, pQuery, nullptr); + + doCalculateConstant(&cxt, pQuery); + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + + void runApis(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_API); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + SQuery* pQuery = nullptr; + doParseSql(&cxt, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + + void runAsyncInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_ASYNC_INTERNAL); try { SParseContext cxt = {0}; setParseContext(sql, &cxt, true); @@ -249,12 +330,12 @@ class ParserTestBaseImpl { doParse(&cxt, &pQuery); unique_ptr query(pQuery, qDestroyQuery); - SParseMetaCache metaCache = {0}; - doCollectMetaKey(&cxt, pQuery, &metaCache); + unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache); + doCollectMetaKey(&cxt, pQuery, metaCache.get()); unique_ptr catalogReq(new SCatalogReq(), MockCatalogService::destoryCatalogReq); - doBuildCatalogReq(&metaCache, catalogReq.get()); + doBuildCatalogReq(metaCache.get(), catalogReq.get()); string err; thread t1([&]() { @@ -262,11 +343,11 @@ class ParserTestBaseImpl { unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); doGetAllMeta(catalogReq.get(), metaData.get()); - doPutMetaDataToCache(catalogReq.get(), metaData.get(), &metaCache); + doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get()); - doAuthenticate(&cxt, pQuery, &metaCache); + doAuthenticate(&cxt, pQuery, metaCache.get()); - doTranslate(&cxt, pQuery, &metaCache); + doTranslate(&cxt, pQuery, metaCache.get()); doCalculateConstant(&cxt, pQuery); } catch (const TerminateFlag& e) { @@ -295,6 +376,51 @@ class ParserTestBaseImpl { } } + void runAsyncApis(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_ASYNC_API); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + unique_ptr catalogReq(new SCatalogReq(), + MockCatalogService::destoryCatalogReq); + SQuery* pQuery = nullptr; + doParseSqlSyntax(&cxt, &pQuery, catalogReq.get()); + unique_ptr query(pQuery, qDestroyQuery); + + string err; + thread t1([&]() { + try { + unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); + doGetAllMeta(catalogReq.get(), metaData.get()); + + doAnalyseSqlSemantic(&cxt, catalogReq.get(), metaData.get(), pQuery); + } catch (const TerminateFlag& e) { + // success and terminate + } catch (const runtime_error& e) { + err = e.what(); + } catch (...) { + err = "unknown error"; + } + }); + + t1.join(); + if (!err.empty()) { + throw runtime_error(err); + } + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + caseEnv caseEnv_; stmtEnv stmtEnv_; stmtRes res_; diff --git a/source/libs/parser/test/parTestUtil.h b/source/libs/parser/test/parTestUtil.h index ad21252c2b..afdb763448 100644 --- a/source/libs/parser/test/parTestUtil.h +++ b/source/libs/parser/test/parTestUtil.h @@ -27,7 +27,7 @@ namespace ParserTest { class ParserTestBaseImpl; -enum ParserStage { PARSER_STAGE_PARSE, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST, PARSER_STAGE_ALL }; +enum ParserStage { PARSER_STAGE_PARSE = 1, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST }; class ParserTestBase : public testing::Test { public: diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index d67b194192..17ab06cac9 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -138,7 +138,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t code = pushLogicNode(pCxt, pRoot, pNode); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pNode); + nodesDestroyNode((SNode*)pNode); } return code; } @@ -173,8 +173,8 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols return SCAN_TYPE_TAG; } -static SNodeptr createPrimaryKeyCol(uint64_t tableId) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); +static SNode* createPrimaryKeyCol(uint64_t tableId) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -184,7 +184,7 @@ static SNodeptr createPrimaryKeyCol(uint64_t tableId) { pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; pCol->colType = COLUMN_TYPE_COLUMN; strcpy(pCol->colName, "#primarykey"); - return pCol; + return (SNode*)pCol; } static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) { @@ -282,7 +282,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -349,7 +349,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pJoin; } else { - nodesDestroyNode(pJoin); + nodesDestroyNode((SNode*)pJoin); } return code; @@ -377,7 +377,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel if (TSDB_CODE_SUCCESS == code) { pNode->pConditions = nodesCloneNode(pSelect->pWhere); if (NULL != pSelect->pWhere && NULL == pNode->pConditions) { - nodesDestroyNode(pNode); + nodesDestroyNode((SNode*)pNode); return TSDB_CODE_OUT_OF_MEMORY; } pNode->precision = pSelect->precision; @@ -387,7 +387,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel } static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -451,7 +451,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -482,7 +482,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pIdfRowsFunc; } else { - nodesDestroyNode(pIdfRowsFunc); + nodesDestroyNode((SNode*)pIdfRowsFunc); } return code; @@ -514,7 +514,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pWindow; } else { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); } return code; @@ -522,7 +522,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -532,7 +532,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo pWindow->pTspk = nodesCloneNode(pState->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -541,7 +541,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -549,9 +549,9 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW pWindow->winType = WINDOW_TYPE_SESSION; pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i; - pWindow->pTspk = nodesCloneNode(pSession->pCol); + pWindow->pTspk = nodesCloneNode((SNode*)pSession->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -560,7 +560,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -576,7 +576,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva pWindow->pTspk = nodesCloneNode(pInterval->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -610,7 +610,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect SFillNode* pFillNode = (SFillNode*)(((SIntervalWindowNode*)pSelect->pWindow)->pFill); - SFillLogicNode* pFill = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL); + SFillLogicNode* pFill = (SFillLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL); if (NULL == pFill) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -628,7 +628,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pFill; } else { - nodesDestroyNode(pFill); + nodesDestroyNode((SNode*)pFill); } return code; @@ -639,7 +639,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return TSDB_CODE_SUCCESS; } - SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); + SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -656,7 +656,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -671,7 +671,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pS SNode* pNode; FOREACH(pNode, pExprs) { - if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr(pStmtName, (SExprNode*)pNode))) { + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, (SNode*)createColumnByExpr(pStmtName, (SExprNode*)pNode))) { nodesDestroyList(pList); return TSDB_CODE_OUT_OF_MEMORY; } @@ -718,7 +718,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -729,7 +729,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS return TSDB_CODE_SUCCESS; } - SPartitionLogicNode* pPartition = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION); + SPartitionLogicNode* pPartition = (SPartitionLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION); if (NULL == pPartition) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -747,7 +747,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pPartition; } else { - nodesDestroyNode(pPartition); + nodesDestroyNode((SNode*)pPartition); } return code; @@ -783,7 +783,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -820,7 +820,7 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -836,7 +836,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p return TSDB_CODE_SUCCESS; } - SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); + SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -858,7 +858,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -894,7 +894,7 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -925,7 +925,7 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -964,7 +964,7 @@ static int32_t createSetOpLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetO if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSetOp; } else { - nodesDestroyNode(pSetOp); + nodesDestroyNode((SNode*)pSetOp); } return code; @@ -981,7 +981,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator* if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -1003,7 +1003,7 @@ static int32_t getMsgType(ENodeType sqlType) { } static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) { - SVnodeModifyLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY); + SVnodeModifyLogicNode* pModif = (SVnodeModifyLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY); if (NULL == pModif) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1047,7 +1047,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -1071,7 +1071,7 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -1094,7 +1094,7 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet pModify->deleteTimeRange = pDelete->timeRange; pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc); if (NULL == pModify->pAffectedRows) { - nodesDestroyNode(pModify); + nodesDestroyNode((SNode*)pModify); return TSDB_CODE_OUT_OF_MEMORY; } @@ -1115,7 +1115,7 @@ static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDele if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -1171,7 +1171,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) { if (TSDB_CODE_SUCCESS == code) { *pLogicSubplan = pSubplan; } else { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); } return code; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index ae689c53d6..65d73b4cdb 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -247,7 +247,7 @@ static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) } static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { - SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pLogicCond) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -262,7 +262,7 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { if (TSDB_CODE_SUCCESS == code) { *pDst = (SNode*)pLogicCond; } else { - nodesDestroyNode(pLogicCond); + nodesDestroyNode((SNode*)pLogicCond); } return code; } @@ -662,13 +662,13 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: if (TSDB_SUPER_TABLE != ((SScanLogicNode*)pNode)->tableType) { - return nodesListMakeAppend(pScanNodes, pNode); + return nodesListMakeAppend(pScanNodes, (SNode*)pNode); } break; case QUERY_NODE_LOGIC_PLAN_JOIN: - code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); if (TSDB_CODE_SUCCESS == code) { - code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); + code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); } return code; case QUERY_NODE_LOGIC_PLAN_AGG: @@ -683,7 +683,7 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL return TSDB_CODE_SUCCESS; } - return opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + return opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); } static int32_t opkGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) { @@ -721,12 +721,12 @@ static int32_t opkDoOptimized(SOptimizeContext* pCxt, SSortLogicNode* pSort, SNo SNode* pDownNode = opkRewriteDownNode(pSort); SNode* pNode; FOREACH(pNode, pSort->node.pParent->pChildren) { - if (nodesEqualNode(pNode, pSort)) { + if (nodesEqualNode(pNode, (SNode*)pSort)) { REPLACE_NODE(pDownNode); break; } } - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); return TSDB_CODE_SUCCESS; } @@ -736,7 +736,7 @@ static int32_t opkOptimizeImpl(SOptimizeContext* pCxt, SSortLogicNode* pSort) { return TSDB_CODE_SUCCESS; } SNodeList* pScanNodes = NULL; - int32_t code = opkGetScanNodes(nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); + int32_t code = opkGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) { code = opkDoOptimized(pCxt, pSort, pScanNodes); } @@ -768,7 +768,7 @@ static bool smaOptMayBeOptimized(SLogicNode* pNode) { } static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNodeList* pTargets, SLogicNode** pOutput) { - SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); + SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -778,7 +778,7 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod pMerge->node.pTargets = pTargets; pMerge->pInputs = nodesCloneList(pChild->pTargets); if (NULL == pMerge->pInputs) { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); return TSDB_CODE_OUT_OF_MEMORY; } @@ -788,9 +788,9 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* pInterval, SLogicNode* pMerge, SLogicNode* pSmaScan) { - int32_t code = nodesListMakeAppend(&pMerge->pChildren, pInterval); + int32_t code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pInterval); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pMerge->pChildren, pSmaScan); + code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pSmaScan); } if (TSDB_CODE_SUCCESS == code) { code = replaceLogicNode(pLogicSubplan, pInterval, pMerge); @@ -802,7 +802,7 @@ static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList* pCols, SLogicNode** pOutput) { - SScanLogicNode* pSmaScan = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); + SScanLogicNode* pSmaScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); if (NULL == pSmaScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -819,7 +819,7 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); pSmaScan->node.pTargets = nodesCloneList(pCols); if (NULL == pSmaScan->pVgroupList || NULL == pSmaScan->node.pTargets) { - nodesDestroyNode(pSmaScan); + nodesDestroyNode((SNode*)pSmaScan); return TSDB_CODE_OUT_OF_MEMORY; } pSmaScan->pVgroupList->numOfVgroups = 1; @@ -851,7 +851,7 @@ static bool smaOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow } static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -926,32 +926,32 @@ static int32_t smaOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIn } static SNode* smaOptCreateWStartTs() { - SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pWStart) { return NULL; } strcpy(pWStart->functionName, "_wstartts"); snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) { - nodesDestroyNode(pWStart); + nodesDestroyNode((SNode*)pWStart); return NULL; } return (SNode*)pWStart; } static int32_t smaOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) { - SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pMergeKey) { return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->pExpr = nodesCloneNode(pCol); if (NULL == pMergeKey->pExpr) { - nodesDestroyNode(pMergeKey); + nodesDestroyNode((SNode*)pMergeKey); return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->order = ORDER_ASC; pMergeKey->nullOrder = NULL_ORDER_FIRST; - return nodesListMakeStrictAppend(pMergeKeys, pMergeKey); + return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey); } static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 6391772abe..ecf2d3ca21 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -147,7 +147,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD } static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode** pDataBlockDesc) { - SDataBlockDescNode* pDesc = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC); + SDataBlockDescNode* pDesc = (SDataBlockDescNode*)nodesMakeNode(QUERY_NODE_DATABLOCK_DESC); if (NULL == pDesc) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -162,7 +162,7 @@ static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SD if (TSDB_CODE_SUCCESS == code) { *pDataBlockDesc = pDesc; } else { - nodesDestroyNode(pDesc); + nodesDestroyNode((SNode*)pDesc); } return code; @@ -350,7 +350,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc); if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pPhysiNode); + nodesDestroyNode((SNode*)pPhysiNode); return NULL; } pPhysiNode->pOutputDataBlockDesc->precision = pLogicNode->precision; @@ -439,7 +439,7 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScanPhysiNode; } else { - nodesDestroyNode(pScanPhysiNode); + nodesDestroyNode((SNode*)pScanPhysiNode); } return code; @@ -486,7 +486,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->dataRequired = pScanLogicNode->dataRequired; pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs); if (NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) { - nodesDestroyNode(pTableScan); + nodesDestroyNode((SNode*)pTableScan); return TSDB_CODE_OUT_OF_MEMORY; } pTableScan->interval = pScanLogicNode->interval; @@ -584,7 +584,7 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pJoin; } else { - nodesDestroyNode(pJoin); + nodesDestroyNode((SNode*)pJoin); } return code; @@ -635,7 +635,7 @@ static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNo } pOper->pLeft = nodesMakeNode(QUERY_NODE_LEFT_VALUE); if (NULL == pOper->pLeft) { - nodesDestroyNode(pOper); + nodesDestroyNode((SNode*)pOper); return TSDB_CODE_OUT_OF_MEMORY; } SValueNode* pVal = (SValueNode*)*pNode; @@ -782,7 +782,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } nodesDestroyList(pPrecalcExprs); @@ -823,7 +823,7 @@ static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList* if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pIdfRowsFunc; } else { - nodesDestroyNode(pIdfRowsFunc); + nodesDestroyNode((SNode*)pIdfRowsFunc); } return code; @@ -855,7 +855,7 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -904,7 +904,7 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -952,7 +952,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pWindow; } else { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); } return code; @@ -1037,7 +1037,7 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pState); + nodesDestroyNode((SNode*)pState); return code; } @@ -1094,7 +1094,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -1135,7 +1135,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pPart; } else { - nodesDestroyNode(pPart); + nodesDestroyNode((SNode*)pPart); } return code; @@ -1174,28 +1174,28 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pFill; } else { - nodesDestroyNode(pFill); + nodesDestroyNode((SNode*)pFill); } return code; } static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) { - SExchangePhysiNode* pExchange = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); + SExchangePhysiNode* pExchange = (SExchangePhysiNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } pExchange->srcGroupId = pMerge->srcGroupId; pExchange->singleChannel = true; pExchange->node.pParent = (SPhysiNode*)pMerge; - pExchange->node.pOutputDataBlockDesc = nodesCloneNode(pMerge->node.pOutputDataBlockDesc); + pExchange->node.pOutputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pMerge->node.pOutputDataBlockDesc); if (NULL == pExchange->node.pOutputDataBlockDesc) { - nodesDestroyNode(pExchange); + nodesDestroyNode((SNode*)pExchange); return TSDB_CODE_OUT_OF_MEMORY; } SNode* pSlot = NULL; FOREACH(pSlot, pExchange->node.pOutputDataBlockDesc->pSlots) { ((SSlotDescNode*)pSlot)->output = true; } - return nodesListMakeStrictAppend(&pMerge->node.pChildren, pExchange); + return nodesListMakeStrictAppend(&pMerge->node.pChildren, (SNode*)pExchange); } static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) { @@ -1235,7 +1235,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pMerge; } else { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); } return code; @@ -1287,7 +1287,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SPhysiNode* pChild = NULL; code = createPhysiNode(pCxt, (SLogicNode*)pLogicChild, pSubplan, &pChild); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pChildren, pChild); + code = nodesListStrictAppend(pChildren, (SNode*)pChild); } } @@ -1311,7 +1311,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, } static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks, SDataSinkNode** pSink) { - SDataInserterNode* pInserter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); + SDataInserterNode* pInserter = (SDataInserterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); if (NULL == pInserter) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1325,14 +1325,14 @@ static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlock } static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot, SDataSinkNode** pSink) { - SDataDispatcherNode* pDispatcher = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH); + SDataDispatcherNode* pDispatcher = (SDataDispatcherNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH); if (NULL == pDispatcher) { return TSDB_CODE_OUT_OF_MEMORY; } - pDispatcher->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc); + pDispatcher->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc); if (NULL == pDispatcher->sink.pInputDataBlockDesc) { - nodesDestroyNode(pDispatcher); + nodesDestroyNode((SNode*)pDispatcher); return TSDB_CODE_OUT_OF_MEMORY; } @@ -1341,7 +1341,7 @@ static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* p } static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan) { - SSubplan* pSubplan = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + SSubplan* pSubplan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -1361,7 +1361,7 @@ static int32_t buildInsertSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot, SDataSinkNode** pSink) { - SDataDeleterNode* pDeleter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE); + SDataDeleterNode* pDeleter = (SDataDeleterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE); if (NULL == pDeleter) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1374,7 +1374,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows, &pDeleter->pAffectedRows); if (TSDB_CODE_SUCCESS == code) { - pDeleter->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc); + pDeleter->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc); if (NULL == pDeleter->sink.pInputDataBlockDesc) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -1383,7 +1383,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* if (TSDB_CODE_SUCCESS == code) { *pSink = (SDataSinkNode*)pDeleter; } else { - nodesDestroyNode(pDeleter); + nodesDestroyNode((SNode*)pDeleter); } return TSDB_CODE_SUCCESS; @@ -1437,38 +1437,38 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic if (TSDB_CODE_SUCCESS == code) { *pPhysiSubplan = pSubplan; } else { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); } return code; } static SQueryPlan* makeQueryPhysiPlan(SPhysiPlanContext* pCxt) { - SQueryPlan* pPlan = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); + SQueryPlan* pPlan = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); if (NULL == pPlan) { return NULL; } pPlan->pSubplans = nodesMakeList(); if (NULL == pPlan->pSubplans) { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); return NULL; } pPlan->queryId = pCxt->pPlanCxt->queryId; return pPlan; } -static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t level, SNodeList* pSubplans) { - SNodeListNode* pGroup; +static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNode* pSubplan, int32_t level, SNodeList* pSubplans) { + SNodeListNode* pGroup = NULL; if (level >= LIST_LENGTH(pSubplans)) { - pGroup = nodesMakeNode(QUERY_NODE_NODE_LIST); + pGroup = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); if (NULL == pGroup) { return TSDB_CODE_OUT_OF_MEMORY; } - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, pGroup)) { + if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, (SNode*)pGroup)) { return TSDB_CODE_OUT_OF_MEMORY; } } else { - pGroup = nodesListGetNode(pSubplans, level); + pGroup = (SNodeListNode*)nodesListGetNode(pSubplans, level); } if (NULL == pGroup->pNodeList) { pGroup->pNodeList = nodesMakeList(); @@ -1476,7 +1476,7 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l return TSDB_CODE_OUT_OF_MEMORY; } } - return nodesListStrictAppend(pGroup->pNodeList, pSubplan); + return nodesListStrictAppend(pGroup->pNodeList, (SNode*)pSubplan); } static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent, @@ -1485,19 +1485,19 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp int32_t code = createPhysiSubplan(pCxt, pLogicSubplan, &pSubplan); if (TSDB_CODE_SUCCESS == code) { - code = pushSubplan(pCxt, pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans); + code = pushSubplan(pCxt, (SNode*)pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans); ++(pQueryPlan->numOfSubplans); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); return code; } if (TSDB_CODE_SUCCESS == code && NULL != pParent) { - code = nodesListMakeAppend(&pParent->pChildren, pSubplan); + code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pSubplan); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pSubplan->pParents, pParent); + code = nodesListMakeAppend(&pSubplan->pParents, (SNode*)pParent); } } @@ -1515,7 +1515,7 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp } static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPhysiPlan) { - SQueryPlan* pPlan = makeQueryPhysiPlan(pCxt); + SQueryPlan* pPlan = (SQueryPlan*)makeQueryPhysiPlan(pCxt); if (NULL == pPlan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1533,7 +1533,7 @@ static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogi if (TSDB_CODE_SUCCESS == code) { *pPhysiPlan = pPlan; } else { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); } return code; diff --git a/source/libs/planner/src/planScaleOut.c b/source/libs/planner/src/planScaleOut.c index 5dd016afb8..9707b36f4a 100644 --- a/source/libs/planner/src/planScaleOut.c +++ b/source/libs/planner/src/planScaleOut.c @@ -21,13 +21,13 @@ typedef struct SScaleOutContext { } SScaleOutContext; static SLogicSubplan* singleCloneSubLogicPlan(SScaleOutContext* pCxt, SLogicSubplan* pSrc, int32_t level) { - SLogicSubplan* pDst = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pDst = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pDst) { return NULL; } - pDst->pNode = nodesCloneNode(pSrc->pNode); + pDst->pNode = (SLogicNode*)nodesCloneNode((SNode*)pSrc->pNode); if (NULL == pDst->pNode) { - nodesDestroyNode(pDst); + nodesDestroyNode((SNode*)pDst); return NULL; } pDst->subplanType = pSrc->subplanType; @@ -73,7 +73,7 @@ static int32_t scaleOutByVgroups(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } code = setScanVgroup(pNewSubplan->pNode, pSubplan->pVgroupList->vgroups + i); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pGroup, pNewSubplan); + code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan); } if (TSDB_CODE_SUCCESS != code) { break; @@ -95,7 +95,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } ((SVnodeModifyLogicNode*)pNewSubplan->pNode)->pVgDataBlocks = (SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i); - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, pNewSubplan)) { + if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, (SNode*)pNewSubplan)) { return TSDB_CODE_OUT_OF_MEMORY; } } @@ -104,7 +104,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } static int32_t scaleOutForMerge(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) { - return nodesListStrictAppend(pGroup, singleCloneSubLogicPlan(pCxt, pSubplan, level)); + return nodesListStrictAppend(pGroup, (SNode*)singleCloneSubLogicPlan(pCxt, pSubplan, level)); } static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) { @@ -189,7 +189,7 @@ static SQueryLogicPlan* makeQueryLogicPlan() { } pLogicPlan->pTopSubplans = nodesMakeList(); if (NULL == pLogicPlan->pTopSubplans) { - nodesDestroyNode(pLogicPlan); + nodesDestroyNode((SNode*)pLogicPlan); return NULL; } return pLogicPlan; @@ -206,7 +206,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue if (TSDB_CODE_SUCCESS == code) { *pLogicPlan = pPlan; } else { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); } return code; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index f33856c4ce..2fc79255af 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -50,7 +50,7 @@ static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) { } static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNode, int32_t flag) { - SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -65,7 +65,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNod } static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SExchangeLogicNode** pOutput) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -90,7 +90,7 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla if (TSDB_CODE_SUCCESS == code) { pSubplan->subplanType = subplanType; } else { - nodesDestroyNode(pExchange); + nodesDestroyNode((SNode*)pExchange); } return code; } @@ -191,21 +191,21 @@ static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFu SFunctionNode* pMergeFunc = NULL; int32_t code = TSDB_CODE_SUCCESS; if (fmIsWindowPseudoColumnFunc(pFunc->funcId)) { - pPartFunc = nodesCloneNode(pFunc); - pMergeFunc = nodesCloneNode(pFunc); + pPartFunc = (SFunctionNode*)nodesCloneNode(pNode); + pMergeFunc = (SFunctionNode*)nodesCloneNode(pNode); if (NULL == pPartFunc || NULL == pMergeFunc) { - nodesDestroyNode(pPartFunc); - nodesDestroyNode(pMergeFunc); + nodesDestroyNode((SNode*)pPartFunc); + nodesDestroyNode((SNode*)pMergeFunc); code = TSDB_CODE_OUT_OF_MEMORY; } } else { code = fmGetDistMethod(pFunc, &pPartFunc, &pMergeFunc); } if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(pPartialFuncs, pPartFunc); + code = nodesListMakeStrictAppend(pPartialFuncs, (SNode*)pPartFunc); } if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(pMergeFuncs, pMergeFunc); + code = nodesListMakeStrictAppend(pMergeFuncs, (SNode*)pMergeFunc); } if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(*pPartialFuncs); @@ -227,7 +227,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) { ++index; } - SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pWStart) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -235,7 +235,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) { snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); int32_t code = fmGetFuncInfo(pWStart, NULL, 0); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pFuncs, pWStart); + code = nodesListStrictAppend(pFuncs, (SNode*)pWStart); } *pIndex = index; return code; @@ -250,7 +250,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic pMergeWindow->node.pChildren = NULL; int32_t code = TSDB_CODE_SUCCESS; - SWindowLogicNode* pPartWin = nodesCloneNode(pMergeWindow); + SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow); if (NULL == pPartWin) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -279,7 +279,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic if (TSDB_CODE_SUCCESS == code) { *pPartWindow = (SLogicNode*)pPartWin; } else { - nodesDestroyNode(pPartWin); + nodesDestroyNode((SNode*)pPartWin); } return code; @@ -287,7 +287,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode, SNodeList* pMergeKeys, SLogicNode* pPartChild) { - SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); + SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -309,13 +309,13 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla } if (TSDB_CODE_SUCCESS == code) { if (NULL == pSubplan) { - code = nodesListMakeAppend(&pSplitNode->pChildren, pMerge); + code = nodesListMakeAppend(&pSplitNode->pChildren, (SNode*)pMerge); } else { code = replaceLogicNode(pSubplan, pSplitNode, (SLogicNode*)pMerge); } } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); } return code; } @@ -324,24 +324,24 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent SExchangeLogicNode* pExchange = NULL; int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pParent->pChildren, pExchange); + code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pExchange); } return code; } static int32_t stbSplCreateMergeKeysForInterval(SNode* pWStartTs, SNodeList** pMergeKeys) { - SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pMergeKey) { return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->pExpr = nodesCloneNode(pWStartTs); if (NULL == pMergeKey->pExpr) { - nodesDestroyNode(pMergeKey); + nodesDestroyNode((SNode*)pMergeKey); return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->order = ORDER_ASC; pMergeKey->nullOrder = NULL_ORDER_FIRST; - return nodesListMakeStrictAppend(pMergeKeys, pMergeKey); + return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey); } static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) { @@ -361,7 +361,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -377,7 +377,7 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -418,7 +418,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO pMergeAgg->node.pChildren = NULL; int32_t code = TSDB_CODE_SUCCESS; - SAggLogicNode* pPartAgg = nodesCloneNode(pMergeAgg); + SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg); if (NULL == pPartAgg) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -447,7 +447,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO if (TSDB_CODE_SUCCESS == code) { *pOutput = (SLogicNode*)pPartAgg; } else { - nodesDestroyNode(pPartAgg); + nodesDestroyNode((SNode*)pPartAgg); } return code; @@ -461,14 +461,14 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; } static SNode* stbSplCreateColumnNode(SExprNode* pExpr) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -482,13 +482,13 @@ static SNode* stbSplCreateColumnNode(SExprNode* pExpr) { } static SNode* stbSplCreateOrderByExpr(SOrderByExprNode* pSortKey, SNode* pCol) { - SOrderByExprNode* pOutput = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + SOrderByExprNode* pOutput = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pOutput) { return NULL; } pOutput->pExpr = nodesCloneNode(pCol); if (NULL == pOutput->pExpr) { - nodesDestroyNode(pOutput); + nodesDestroyNode((SNode*)pOutput); return NULL; } pOutput->order = pSortKey->order; @@ -542,7 +542,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut pSort->node.pChildren = NULL; int32_t code = TSDB_CODE_SUCCESS; - SSortLogicNode* pPartSort = nodesCloneNode(pSort); + SSortLogicNode* pPartSort = (SSortLogicNode*)nodesCloneNode((SNode*)pSort); if (NULL == pPartSort) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -558,7 +558,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut *pOutputPartSort = (SLogicNode*)pPartSort; *pOutputMergeKeys = pMergeKeys; } else { - nodesDestroyNode(pPartSort); + nodesDestroyNode((SNode*)pPartSort); nodesDestroyList(pMergeKeys); } @@ -574,7 +574,7 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -584,7 +584,7 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pInfo->pSplitNode, SUBPLAN_TYPE_MERGE); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); } return code; } @@ -654,7 +654,7 @@ static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubpl SJoinLogicNode* pJoin = sigTbJoinSplMatchByNode(pSubplan->pNode); if (NULL != pJoin) { pInfo->pJoin = pJoin; - pInfo->pSplitNode = nodesListGetNode(pJoin->node.pChildren, 1); + pInfo->pSplitNode = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1); pInfo->pSubplan = pSubplan; } return NULL != pJoin; @@ -667,7 +667,7 @@ static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan } int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pSplitNode, 0)); + code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0)); } ++(pCxt->groupId); pCxt->split = true; @@ -708,7 +708,7 @@ static int32_t unionMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) { } static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode) { - SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -729,7 +729,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl SNode* pChild = NULL; FOREACH(pChild, pSplitNode->pChildren) { SLogicSubplan* pNewSubplan = unionCreateSubplan(pCxt, (SLogicNode*)pChild); - code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, pNewSubplan); + code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan); if (TSDB_CODE_SUCCESS == code) { REPLACE_NODE(NULL); code = unionMountSubplan(pNewSubplan, pSubplanChildren); @@ -774,7 +774,7 @@ static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, } static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -789,20 +789,20 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS if (NULL == pProject->node.pParent) { pSubplan->pNode = (SLogicNode*)pExchange; - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); return TSDB_CODE_SUCCESS; } SNode* pNode; FOREACH(pNode, pProject->node.pParent->pChildren) { - if (nodesEqualNode(pNode, pProject)) { + if (nodesEqualNode(pNode, (SNode*)pProject)) { REPLACE_NODE(pExchange); nodesDestroyNode(pNode); return TSDB_CODE_SUCCESS; } } - nodesDestroyNode(pExchange); - return TSDB_CODE_FAILED; + nodesDestroyNode((SNode*)pExchange); + return TSDB_CODE_PLAN_INTERNAL_ERROR; } static int32_t unionAllSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { @@ -840,7 +840,7 @@ static SLogicNode* unDistSplMatchByNode(SLogicNode* pNode) { } static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -853,7 +853,7 @@ static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* p pSubplan->subplanType = SUBPLAN_TYPE_MERGE; - return nodesListMakeAppend(&pAgg->node.pChildren, pExchange); + return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange); } static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionDistinctSplitInfo* pInfo) { @@ -937,7 +937,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { char* pStr = NULL; - nodesNodeToString(pSubplan, false, &pStr, NULL); + nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL); qDebugL("apply %s rule: %s", pRuleName, pStr); taosMemoryFree(pStr); } diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index 232a49ee3a..7f650c7c9a 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -60,7 +60,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) { } pCol->node.resType = pExpr->resType; strcpy(pCol->colName, pExpr->aliasName); - return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); + return (TSDB_CODE_SUCCESS == nodesListStrictAppend(pCxt->pList, (SNode*)pCol) ? DEAL_RES_IGNORE_CHILD + : DEAL_RES_ERROR); } default: break; @@ -111,7 +112,7 @@ int32_t replaceLogicNode(SLogicSubplan* pSubplan, SLogicNode* pOld, SLogicNode* SNode* pNode; FOREACH(pNode, pOld->pParent->pChildren) { - if (nodesEqualNode(pNode, pOld)) { + if (nodesEqualNode(pNode, (SNode*)pOld)) { REPLACE_NODE(pNew); pNew->pParent = pOld->pParent; return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index 83657d27d0..c4385d576e 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -20,7 +20,7 @@ static void dumpQueryPlan(SQueryPlan* pPlan) { char* pStr = NULL; - nodesNodeToString(pPlan, false, &pStr, NULL); + nodesNodeToString((SNode*)pPlan, false, &pStr, NULL); planDebugL("Query Plan: %s", pStr); taosMemoryFree(pStr); } @@ -46,8 +46,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo dumpQueryPlan(*pPlan); } - nodesDestroyNode(pLogicSubplan); - nodesDestroyNode(pLogicPlan); + nodesDestroyNode((SNode*)pLogicSubplan); + nodesDestroyNode((SNode*)pLogicPlan); terrno = code; return code; } @@ -56,7 +56,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == nodeType(pNode)) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode; if (pExchange->srcGroupId == groupId) { - return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource)); + return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource)); } } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) { SMergePhysiNode* pMerge = (SMergePhysiNode*)pNode; @@ -68,7 +68,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown } else { --(pMerge->numOfChannels); } - return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource)); + return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource)); } } @@ -101,7 +101,7 @@ int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesSt char* qQueryPlanToString(const SQueryPlan* pPlan) { char* pStr = NULL; int32_t len = 0; - if (TSDB_CODE_SUCCESS != nodesNodeToString(pPlan, false, &pStr, &len)) { + if (TSDB_CODE_SUCCESS != nodesNodeToString((SNode*)pPlan, false, &pStr, &len)) { return NULL; } return pStr; @@ -115,4 +115,4 @@ SQueryPlan* qStringToQueryPlan(const char* pStr) { return pPlan; } -void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode(pPlan); } +void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode((SNode*)pPlan); } diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index e5dd9e71df..8d310be460 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -308,7 +308,7 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { } if (ctx->plan) { - nodesDestroyNode(ctx->plan); + nodesDestroyNode((SNode*)ctx->plan); ctx->plan = NULL; } } diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 069595390d..d3828d9ee4 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -110,9 +110,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SMsgCb* pMsgCb, SStreamDisp return 0; } // continue dispatch - if (pTask->dispatchType != TASK_DISPATCH__NONE) { - streamDispatch(pTask, pMsgCb); - } + streamDispatch(pTask, pMsgCb); return 0; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 6fb5d75d86..59ec2b5ceb 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -100,7 +100,6 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM .upstreamNodeId = pTask->nodeId, .blockNum = blockNum, }; - qInfo("dispatch from task %d (child id %d)", pTask->taskId, pTask->childId); req.data = taosArrayInit(blockNum, sizeof(void*)); req.dataLen = taosArrayInit(blockNum, sizeof(int32_t)); @@ -142,11 +141,14 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM break; } } - ASSERT(vgId != 0); } + ASSERT(vgId != 0); req.taskId = downstreamTaskId; + qInfo("dispatch from task %d (child id %d) to down stream task %d in vnode %d", pTask->taskId, pTask->childId, + downstreamTaskId, vgId); + // serialize int32_t tlen; tEncodeSize(tEncodeStreamDispatchReq, &req, tlen, code); @@ -180,6 +182,7 @@ FAIL: } int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { + ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); #if 1 int8_t old = atomic_val_compare_exchange_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL, TASK_OUTPUT_STATUS__WAIT); diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 83f0bd7dd8..e7777af749 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -159,7 +159,7 @@ typedef struct SSyncNode { SSyncSnapshotSender* senders[TSDB_MAX_REPLICA]; SSyncSnapshotReceiver* pNewNodeReceiver; - SSnapshotMeta sMeta; + // SSnapshotMeta sMeta; } SSyncNode; @@ -194,7 +194,7 @@ int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, S cJSON* syncNode2Json(const SSyncNode* pSyncNode); char* syncNode2Str(const SSyncNode* pSyncNode); char* syncNode2SimpleStr(const SSyncNode* pSyncNode); -void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, bool* isDrop); +void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex lastConfigChangeIndex, bool* isDrop); SSyncNode* syncNodeAcquire(int64_t rid); void syncNodeRelease(SSyncNode* pNode); diff --git a/source/libs/sync/inc/syncRaftCfg.h b/source/libs/sync/inc/syncRaftCfg.h index 86c5fab87c..e72e1e7be7 100644 --- a/source/libs/sync/inc/syncRaftCfg.h +++ b/source/libs/sync/inc/syncRaftCfg.h @@ -35,6 +35,7 @@ typedef struct SRaftCfg { char path[TSDB_FILENAME_LEN * 2]; int8_t isStandBy; int8_t snapshotEnable; + SyncIndex lastConfigIndex; } SRaftCfg; SRaftCfg *raftCfgOpen(const char *path); @@ -52,8 +53,9 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg); int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg); typedef struct SRaftCfgMeta { - int8_t isStandBy; - int8_t snapshotEnable; + int8_t isStandBy; + int8_t snapshotEnable; + SyncIndex lastConfigIndex; } SRaftCfgMeta; int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path); diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 9fbcdf138b..a6170a92e3 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -43,6 +43,7 @@ typedef struct SSyncSnapshotSender { void * pCurrentBlock; int32_t blockLen; SSnapshot snapshot; + SSyncCfg lastConfig; int64_t sendingMS; SSyncNode *pSyncNode; int32_t replicaIndex; diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 01c95d8241..29ee263756 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -88,6 +88,245 @@ // /\ UNCHANGED <> // /\ UNCHANGED <> // + +int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { + int32_t ret = 0; + + char logBuf[128] = {0}; + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesCb== term:%lu", ths->pRaftStore->currentTerm); + syncAppendEntriesLog2(logBuf, pMsg); + + if (pMsg->term > ths->pRaftStore->currentTerm) { + syncNodeUpdateTerm(ths, pMsg->term); + } + assert(pMsg->term <= ths->pRaftStore->currentTerm); + + // reset elect timer + if (pMsg->term == ths->pRaftStore->currentTerm) { + ths->leaderCache = pMsg->srcId; + syncNodeResetElectTimer(ths); + } + assert(pMsg->dataLen >= 0); + + SyncTerm localPreLogTerm = 0; + if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { + SSyncRaftEntry* pEntry = ths->pLogStore->getEntry(ths->pLogStore, pMsg->prevLogIndex); + assert(pEntry != NULL); + localPreLogTerm = pEntry->term; + syncEntryDestory(pEntry); + } + + bool logOK = + (pMsg->prevLogIndex == SYNC_INDEX_INVALID) || + ((pMsg->prevLogIndex >= SYNC_INDEX_BEGIN) && + (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogTerm == localPreLogTerm)); + + // reject request + if ((pMsg->term < ths->pRaftStore->currentTerm) || + ((pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK)) { + sTrace( + "syncNodeOnAppendEntriesCb --> reject, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, " + "logOK:%d", + pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK); + + SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->success = false; + pReply->matchIndex = SYNC_INDEX_INVALID; + + SRpcMsg rpcMsg; + syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); + syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + syncAppendEntriesReplyDestroy(pReply); + + return ret; + } + + // return to follower state + if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE) { + sTrace( + "syncNodeOnAppendEntriesCb --> return to follower, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, " + "ths->state:%d, logOK:%d", + pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK); + + syncNodeBecomeFollower(ths, "from candidate by append entries"); + + // ret or reply? + return ret; + } + + // accept request + if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_FOLLOWER && logOK) { + // preIndex = -1, or has preIndex entry in local log + assert(pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)); + + // has extra entries (> preIndex) in local log + bool hasExtraEntries = pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore); + + // has entries in SyncAppendEntries msg + bool hasAppendEntries = pMsg->dataLen > 0; + + sTrace( + "syncNodeOnAppendEntriesCb --> accept, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, " + "logOK:%d, hasExtraEntries:%d, hasAppendEntries:%d", + pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK, hasExtraEntries, hasAppendEntries); + + if (hasExtraEntries && hasAppendEntries) { + // not conflict by default + bool conflict = false; + + SyncIndex extraIndex = pMsg->prevLogIndex + 1; + SSyncRaftEntry* pExtraEntry = ths->pLogStore->getEntry(ths->pLogStore, extraIndex); + assert(pExtraEntry != NULL); + + SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); + assert(pAppendEntry != NULL); + + // log not match, conflict + assert(extraIndex == pAppendEntry->index); + if (pExtraEntry->term != pAppendEntry->term) { + conflict = true; + } + + if (conflict) { + // roll back + SyncIndex delBegin = ths->pLogStore->getLastIndex(ths->pLogStore); + SyncIndex delEnd = extraIndex; + + sTrace("syncNodeOnAppendEntriesCb --> conflict:%d, delBegin:%ld, delEnd:%ld", conflict, delBegin, delEnd); + + // notice! reverse roll back! + for (SyncIndex index = delEnd; index >= delBegin; --index) { + if (ths->pFsm->FpRollBackCb != NULL) { + SSyncRaftEntry* pRollBackEntry = ths->pLogStore->getEntry(ths->pLogStore, index); + assert(pRollBackEntry != NULL); + + // if (pRollBackEntry->msgType != TDMT_SYNC_NOOP) { + if (syncUtilUserRollback(pRollBackEntry->msgType)) { + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pRollBackEntry, &rpcMsg); + + SFsmCbMeta cbMeta; + cbMeta.index = pRollBackEntry->index; + cbMeta.isWeak = pRollBackEntry->isWeak; + cbMeta.code = 0; + cbMeta.state = ths->state; + cbMeta.seqNum = pRollBackEntry->seqNum; + ths->pFsm->FpRollBackCb(ths->pFsm, &rpcMsg, cbMeta); + rpcFreeCont(rpcMsg.pCont); + } + + syncEntryDestory(pRollBackEntry); + } + } + + // delete confict entries + ths->pLogStore->truncate(ths->pLogStore, extraIndex); + + // append new entries + ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); + + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); + if (ths->pFsm != NULL) { + // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { + if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { + SFsmCbMeta cbMeta; + cbMeta.index = pAppendEntry->index; + cbMeta.isWeak = pAppendEntry->isWeak; + cbMeta.code = 2; + cbMeta.state = ths->state; + cbMeta.seqNum = pAppendEntry->seqNum; + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); + } + } + rpcFreeCont(rpcMsg.pCont); + } + + // free memory + syncEntryDestory(pExtraEntry); + syncEntryDestory(pAppendEntry); + + } else if (hasExtraEntries && !hasAppendEntries) { + // do nothing + + } else if (!hasExtraEntries && hasAppendEntries) { + SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); + assert(pAppendEntry != NULL); + + // append new entries + ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); + + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); + if (ths->pFsm != NULL) { + // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { + if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { + SFsmCbMeta cbMeta; + cbMeta.index = pAppendEntry->index; + cbMeta.isWeak = pAppendEntry->isWeak; + cbMeta.code = 3; + cbMeta.state = ths->state; + cbMeta.seqNum = pAppendEntry->seqNum; + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); + } + } + rpcFreeCont(rpcMsg.pCont); + + // free memory + syncEntryDestory(pAppendEntry); + + } else if (!hasExtraEntries && !hasAppendEntries) { + // do nothing + + } else { + assert(0); + } + + SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->success = true; + + if (hasAppendEntries) { + pReply->matchIndex = pMsg->prevLogIndex + 1; + } else { + pReply->matchIndex = pMsg->prevLogIndex; + } + + SRpcMsg rpcMsg; + syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); + syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + syncAppendEntriesReplyDestroy(pReply); + + // maybe update commit index from leader + if (pMsg->commitIndex > ths->commitIndex) { + // has commit entry in local + if (pMsg->commitIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { + SyncIndex beginIndex = ths->commitIndex + 1; + SyncIndex endIndex = pMsg->commitIndex; + + // update commit index + ths->commitIndex = pMsg->commitIndex; + + // call back Wal + ths->pLogStore->updateCommitIndex(ths->pLogStore, ths->commitIndex); + + int32_t code = syncNodeCommit(ths, beginIndex, endIndex, ths->state); + ASSERT(code == 0); + } + } + } + + return ret; +} + +#if 0 int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t ret = 0; @@ -375,7 +614,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { // I am in newConfig if (hit) { - syncNodeUpdateConfig(ths, &newSyncCfg, &isDrop); + syncNodeUpdateConfig(ths, &newSyncCfg, pEntry->index, &isDrop); // change isStandBy to normal if (!isDrop) { @@ -437,6 +676,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { return ret; } +#endif static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t code; @@ -473,7 +713,7 @@ static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) { // delete confict entries code = ths->pLogStore->syncLogTruncate(ths->pLogStore, delBegin); ASSERT(code == 0); - sInfo("sync event vgId:%d log truncate, from %ld to %ld", ths->vgId, delBegin, delEnd); + sDebug("vgId:%d sync event log truncate, from %ld to %ld", ths->vgId, delBegin, delEnd); logStoreSimpleLog2("after syncNodeMakeLogSame", ths->pLogStore); return code; @@ -754,7 +994,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs SyncIndex commitEnd = snapshot.lastApplyIndex; ths->commitIndex = snapshot.lastApplyIndex; - sInfo("sync event vgId:%d commit by snapshot from index:%ld to index:%ld, %s", ths->vgId, commitBegin, + sDebug("vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s", ths->vgId, commitBegin, commitEnd, syncUtilState2String(ths->state)); } diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 7fc35afbb1..0e116e13ee 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -189,16 +189,19 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries if (gRaftDetailLog) { char* s = snapshotSender2Str(pSender); - sInfo( - "sync event vgId:%d snapshot send to %s:%d start sender first time, lastApplyIndex:%ld lastApplyTerm:%lu " + sDebug( + "vgId:%d sync event snapshot send to %s:%d start sender first time, lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld" "sender:%s", - ths->vgId, host, port, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, s); + ths->vgId, host, port, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, + pSender->snapshot.lastConfigIndex, s); taosMemoryFree(s); } else { - sInfo( - "sync event vgId:%d snapshot send to %s:%d start sender first time, lastApplyIndex:%ld " - "lastApplyTerm:%lu", - ths->vgId, host, port, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm); + sDebug( + "vgId:%d sync event snapshot send to %s:%d start sender first time, lastApplyIndex:%ld " + "lastApplyTerm:%lu lastConfigIndex:%ld", + ths->vgId, host, port, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, + pSender->snapshot.lastConfigIndex); } } diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 8236301f8e..eac9c1fbd8 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -56,7 +56,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex commitEnd = snapshot.lastApplyIndex; pSyncNode->commitIndex = snapshot.lastApplyIndex; - sInfo("sync event vgId:%d commit by snapshot from index:%ld to index:%ld, %s", pSyncNode->vgId, + sDebug("vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s", pSyncNode->vgId, pSyncNode->commitIndex, snapshot.lastApplyIndex, syncUtilState2String(pSyncNode->state)); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 0a19e16d5c..4d410644bb 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -192,6 +192,40 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) { return ret; } +int32_t syncLeaderTransfer(int64_t rid) { + int32_t ret = 0; + + return ret; +} + +int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return false; + } + assert(rid == pSyncNode->rid); + int32_t ret = 0; + + if (pSyncNode->replicaNum == 1) { + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + sError("only one replica, cannot drop leader"); + return TAOS_SYNC_ONLY_ONE_REPLICA; + } + + SyncLeaderTransfer* pMsg = syncLeaderTransferBuild(pSyncNode->vgId); + pMsg->newLeaderId.addr = syncUtilAddr2U64(newLeader.nodeFqdn, newLeader.nodePort); + pMsg->newLeaderId.vgId = pSyncNode->vgId; + ASSERT(pMsg != NULL); + SRpcMsg rpcMsg = {0}; + syncLeaderTransfer2RpcMsg(pMsg, &rpcMsg); + syncLeaderTransferDestroy(pMsg); + + ret = syncPropose(rid, &rpcMsg, false); + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return ret; +} + int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) { int32_t ret = 0; char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); @@ -206,6 +240,40 @@ int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) return ret; } +bool syncCanLeaderTransfer(int64_t rid) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return false; + } + assert(rid == pSyncNode->rid); + + if (pSyncNode->replicaNum == 1) { + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return false; + } + + if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return true; + } + + bool matchOK = true; + if (pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE || pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + SyncIndex myCommitIndex = pSyncNode->commitIndex; + for (int i = 0; i < pSyncNode->peersNum; ++i) { + SyncIndex peerMatchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, &(pSyncNode->peersId)[i]); + if (peerMatchIndex < myCommitIndex) { + matchOK = false; + } + } + } + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return matchOK; +} + +int32_t syncGiveUpLeader(int64_t rid) { return 0; } + int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { int32_t ret = syncPropose(rid, pMsg, isWeak); return ret; @@ -241,7 +309,9 @@ int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta) { return -1; } assert(rid == pSyncNode->rid); - *sMeta = pSyncNode->sMeta; + sMeta->lastConfigIndex = pSyncNode->pRaftCfg->lastConfigIndex; + + sTrace("sync get snapshot meta: lastConfigIndex:%ld", pSyncNode->pRaftCfg->lastConfigIndex); taosReleaseRef(tsNodeRefId, pSyncNode->rid); return 0; @@ -400,7 +470,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { return TAOS_SYNC_PROPOSE_OTHER_ERROR; } assert(rid == pSyncNode->rid); - sTrace("sync event vgId:%d propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType)); + sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType)); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { SRespStub stub; @@ -431,7 +501,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { SSyncInfo* pSyncInfo = (SSyncInfo*)pOldSyncInfo; - sInfo("sync event vgId:%d sync open", pSyncInfo->vgId); + sDebug("vgId:%d sync event sync open", pSyncInfo->vgId); SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode)); assert(pSyncNode != NULL); @@ -452,6 +522,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { SRaftCfgMeta meta; meta.isStandBy = pSyncInfo->isStandBy; meta.snapshotEnable = pSyncInfo->snapshotEnable; + meta.lastConfigIndex = SYNC_INDEX_INVALID; ret = raftCfgCreateFile((SSyncCfg*)&(pSyncInfo->syncCfg), meta, pSyncNode->configPath); assert(ret == 0); @@ -643,7 +714,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // syncNodeBecomeFollower(pSyncNode); // snapshot meta - pSyncNode->sMeta.lastConfigIndex = -1; + // pSyncNode->sMeta.lastConfigIndex = -1; return pSyncNode; } @@ -690,7 +761,7 @@ void syncNodeStartStandBy(SSyncNode* pSyncNode) { } void syncNodeClose(SSyncNode* pSyncNode) { - sInfo("sync event vgId:%d sync close", pSyncNode->vgId); + sDebug("vgId:%d sync event sync close", pSyncNode->vgId); int32_t ret; assert(pSyncNode != NULL); @@ -1076,9 +1147,11 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { return s; } -void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, bool* isDrop) { +void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex lastConfigChangeIndex, bool* isDrop) { SSyncCfg oldConfig = pSyncNode->pRaftCfg->cfg; pSyncNode->pRaftCfg->cfg = *newConfig; + pSyncNode->pRaftCfg->lastConfigIndex = lastConfigChangeIndex; + int32_t ret = 0; // init internal @@ -1111,13 +1184,12 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, bool* isDro pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); - // isDrop - *isDrop = true; - bool IamInOld, IamInNew; + bool IamInOld = false; + bool IamInNew = false; for (int i = 0; i < oldConfig.replicaNum; ++i) { if (strcmp((oldConfig.nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && (oldConfig.nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { - *isDrop = false; + IamInOld = true; break; } } @@ -1125,16 +1197,21 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, bool* isDro for (int i = 0; i < newConfig->replicaNum; ++i) { if (strcmp((newConfig->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && (newConfig->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { - *isDrop = false; + IamInNew = true; break; } } - if (!(*isDrop)) { - // change isStandBy to normal - pSyncNode->pRaftCfg->isStandBy = 0; + *isDrop = true; + if (IamInOld && !IamInNew) { + *isDrop = true; + } else { + *isDrop = false; } + if (IamInNew) { + pSyncNode->pRaftCfg->isStandBy = 0; // change isStandBy to normal + } raftCfgPersist(pSyncNode->pRaftCfg); if (gRaftDetailLog) { @@ -1163,7 +1240,8 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) { } void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { - sInfo("sync event vgId:%d become follower, %s", pSyncNode->vgId, debugStr); + sDebug("vgId:%d sync event become follower, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy, + debugStr); // maybe clear leader cache if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { @@ -1197,7 +1275,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // /\ UNCHANGED <> // void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { - sInfo("sync event vgId:%d become leader, %s", pSyncNode->vgId, debugStr); + sDebug("vgId:%d sync event become leader, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy, + debugStr); // state change pSyncNode->state = TAOS_SYNC_STATE_LEADER; @@ -1735,23 +1814,79 @@ const char* syncStr(ESyncState state) { } } +static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* pEntry) { + SyncLeaderTransfer* pSyncLeaderTransfer; + if (syncUtilSameId(&(pSyncLeaderTransfer->newLeaderId), &(ths->myRaftId))) { + } + + return 0; +} + +static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* pEntry) { + SSyncCfg oldSyncCfg = ths->pRaftCfg->cfg; + + SSyncCfg newSyncCfg; + int32_t ret = syncCfgFromStr(pRpcMsg->pCont, &newSyncCfg); + ASSERT(ret == 0); + + // update new config myIndex + bool IamInNew = false; + for (int i = 0; i < newSyncCfg.replicaNum; ++i) { + if (strcmp(ths->myNodeInfo.nodeFqdn, (newSyncCfg.nodeInfo)[i].nodeFqdn) == 0 && + ths->myNodeInfo.nodePort == (newSyncCfg.nodeInfo)[i].nodePort) { + newSyncCfg.myIndex = i; + IamInNew = true; + break; + } + } + + bool isDrop; + + if (IamInNew || (!IamInNew && ths->state != TAOS_SYNC_STATE_LEADER)) { + syncNodeUpdateConfig(ths, &newSyncCfg, pEntry->index, &isDrop); + + // change isStandBy to normal + if (!isDrop) { + if (ths->state == TAOS_SYNC_STATE_LEADER) { + syncNodeBecomeLeader(ths, "config change"); + } else { + syncNodeBecomeFollower(ths, "config change"); + } + } + + if (gRaftDetailLog) { + char* sOld = syncCfg2Str(&oldSyncCfg); + char* sNew = syncCfg2Str(&newSyncCfg); + sInfo("==config change== 0x11 old:%s new:%s isDrop:%d \n", sOld, sNew, isDrop); + taosMemoryFree(sOld); + taosMemoryFree(sNew); + } + } + + // always call FpReConfigCb + if (ths->pFsm->FpReConfigCb != NULL) { + SReConfigCbMeta cbMeta = {0}; + cbMeta.code = 0; + cbMeta.currentTerm = ths->pRaftStore->currentTerm; + cbMeta.index = pEntry->index; + cbMeta.term = pEntry->term; + cbMeta.newCfg = newSyncCfg; + cbMeta.oldCfg = oldSyncCfg; + cbMeta.seqNum = pEntry->seqNum; + cbMeta.flag = 0x11; + cbMeta.isDrop = isDrop; + ths->pFsm->FpReConfigCb(ths->pFsm, pRpcMsg, cbMeta); + } + + return 0; +} + int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) { int32_t code = 0; ESyncState state = flag; - sInfo("sync event vgId:%d commit by wal from index:%" PRId64 " to index:%" PRId64 ", %s", ths->vgId, beginIndex, + sDebug("vgId:%d sync event commit by wal from index:%" PRId64 " to index:%" PRId64 ", %s", ths->vgId, beginIndex, endIndex, syncUtilState2String(state)); - /* - // maybe execute by leader, skip snapshot - SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; - if (ths->pFsm->FpGetSnapshot != NULL) { - ths->pFsm->FpGetSnapshot(ths->pFsm, &snapshot); - } - if (beginIndex <= snapshot.lastApplyIndex) { - beginIndex = snapshot.lastApplyIndex + 1; - } - */ - // execute fsm if (ths->pFsm != NULL) { for (SyncIndex i = beginIndex; i <= endIndex; ++i) { @@ -1764,6 +1899,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); + // user commit if (ths->pFsm->FpCommitCb != NULL && syncUtilUserCommit(pEntry->originalRpcType)) { SFsmCbMeta cbMeta; cbMeta.index = pEntry->index; @@ -1780,61 +1916,14 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, // config change if (pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE) { - SSyncCfg oldSyncCfg = ths->pRaftCfg->cfg; + code = syncNodeConfigChange(ths, &rpcMsg, pEntry); + ASSERT(code == 0); + } - SSyncCfg newSyncCfg; - int32_t ret = syncCfgFromStr(rpcMsg.pCont, &newSyncCfg); - ASSERT(ret == 0); - - // update new config myIndex - bool hit = false; - for (int i = 0; i < newSyncCfg.replicaNum; ++i) { - if (strcmp(ths->myNodeInfo.nodeFqdn, (newSyncCfg.nodeInfo)[i].nodeFqdn) == 0 && - ths->myNodeInfo.nodePort == (newSyncCfg.nodeInfo)[i].nodePort) { - newSyncCfg.myIndex = i; - hit = true; - break; - } - } - - SReConfigCbMeta cbMeta = {0}; - bool isDrop; - - // I am in newConfig - if (hit) { - syncNodeUpdateConfig(ths, &newSyncCfg, &isDrop); - - // change isStandBy to normal - if (!isDrop) { - if (ths->state == TAOS_SYNC_STATE_LEADER) { - syncNodeBecomeLeader(ths, "config change"); - } else { - syncNodeBecomeFollower(ths, "config change"); - } - } - - if (gRaftDetailLog) { - char* sOld = syncCfg2Str(&oldSyncCfg); - char* sNew = syncCfg2Str(&newSyncCfg); - sInfo("==config change== 0x11 old:%s new:%s isDrop:%d \n", sOld, sNew, isDrop); - taosMemoryFree(sOld); - taosMemoryFree(sNew); - } - } - - // always call FpReConfigCb - if (ths->pFsm->FpReConfigCb != NULL) { - cbMeta.code = 0; - cbMeta.currentTerm = ths->pRaftStore->currentTerm; - cbMeta.index = pEntry->index; - cbMeta.term = pEntry->term; - cbMeta.newCfg = newSyncCfg; - cbMeta.oldCfg = oldSyncCfg; - cbMeta.seqNum = pEntry->seqNum; - cbMeta.flag = 0x11; - cbMeta.isDrop = isDrop; - ths->pFsm->FpReConfigCb(ths->pFsm, &rpcMsg, cbMeta); - } + // config change + if (pEntry->originalRpcType == TDMT_SYNC_LEADER_TRANSFER) { + code = syncDoLeaderTransfer(ths, &rpcMsg, pEntry); + ASSERT(code == 0); } // restore finish @@ -1844,7 +1933,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, ths->pFsm->FpRestoreFinishCb(ths->pFsm); } ths->restoreFinish = true; - sInfo("sync event vgId:%d restore finish", ths->vgId); + sDebug("vgId:%d sync event restore finish", ths->vgId); } } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index af04a0f649..23165f6790 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -14,6 +14,7 @@ */ #include "syncMessage.h" +#include "syncRaftCfg.h" #include "syncUtil.h" #include "tcoding.h" @@ -75,6 +76,11 @@ cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg) { pRoot = syncSnapshotRsp2Json(pSyncMsg); syncSnapshotRspDestroy(pSyncMsg); + } else if (pRpcMsg->msgType == TDMT_SYNC_LEADER_TRANSFER) { + SyncLeaderTransfer* pSyncMsg = syncLeaderTransferDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen); + pRoot = syncLeaderTransfer2Json(pSyncMsg); + syncLeaderTransferDestroy(pSyncMsg); + } else if (pRpcMsg->msgType == TDMT_SYNC_COMMON_RESPONSE) { pRoot = cJSON_CreateObject(); char* s; @@ -1841,6 +1847,10 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) { snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastIndex); cJSON_AddStringToObject(pRoot, "lastIndex", u64buf); + snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastConfigIndex); + cJSON_AddStringToObject(pRoot, "lastConfigIndex", u64buf); + cJSON_AddItemToObject(pRoot, "lastConfig", syncCfg2Json((SSyncCfg*)&(pMsg->lastConfig))); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastTerm); cJSON_AddStringToObject(pRoot, "lastTerm", u64buf); @@ -2055,4 +2065,166 @@ void syncSnapshotRspLog2(char* s, const SyncSnapshotRsp* pMsg) { sTrace("syncSnapshotRspLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } +} + +// --------------------------------------------- +SyncLeaderTransfer* syncLeaderTransferBuild(int32_t vgId) { + uint32_t bytes = sizeof(SyncLeaderTransfer); + SyncLeaderTransfer* pMsg = taosMemoryMalloc(bytes); + memset(pMsg, 0, bytes); + pMsg->bytes = bytes; + pMsg->vgId = vgId; + pMsg->msgType = TDMT_SYNC_LEADER_TRANSFER; + return pMsg; +} + +void syncLeaderTransferDestroy(SyncLeaderTransfer* pMsg) { + if (pMsg != NULL) { + taosMemoryFree(pMsg); + } +} + +void syncLeaderTransferSerialize(const SyncLeaderTransfer* pMsg, char* buf, uint32_t bufLen) { + assert(pMsg->bytes <= bufLen); + memcpy(buf, pMsg, pMsg->bytes); +} + +void syncLeaderTransferDeserialize(const char* buf, uint32_t len, SyncLeaderTransfer* pMsg) { + memcpy(pMsg, buf, len); + assert(len == pMsg->bytes); +} + +char* syncLeaderTransferSerialize2(const SyncLeaderTransfer* pMsg, uint32_t* len) { + char* buf = taosMemoryMalloc(pMsg->bytes); + assert(buf != NULL); + syncLeaderTransferSerialize(pMsg, buf, pMsg->bytes); + if (len != NULL) { + *len = pMsg->bytes; + } + return buf; +} + +SyncLeaderTransfer* syncLeaderTransferDeserialize2(const char* buf, uint32_t len) { + uint32_t bytes = *((uint32_t*)buf); + SyncLeaderTransfer* pMsg = taosMemoryMalloc(bytes); + assert(pMsg != NULL); + syncLeaderTransferDeserialize(buf, len, pMsg); + assert(len == pMsg->bytes); + return pMsg; +} + +void syncLeaderTransfer2RpcMsg(const SyncLeaderTransfer* pMsg, SRpcMsg* pRpcMsg) { + memset(pRpcMsg, 0, sizeof(*pRpcMsg)); + pRpcMsg->msgType = pMsg->msgType; + pRpcMsg->contLen = pMsg->bytes; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + syncLeaderTransferSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen); +} + +void syncLeaderTransferFromRpcMsg(const SRpcMsg* pRpcMsg, SyncLeaderTransfer* pMsg) { + syncLeaderTransferDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg); +} + +SyncLeaderTransfer* syncLeaderTransferFromRpcMsg2(const SRpcMsg* pRpcMsg) { + SyncLeaderTransfer* pMsg = syncLeaderTransferDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen); + assert(pMsg != NULL); + return pMsg; +} + +cJSON* syncLeaderTransfer2Json(const SyncLeaderTransfer* pMsg) { + char u64buf[128]; + cJSON* pRoot = cJSON_CreateObject(); + + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + /* + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + */ + + cJSON* pNewerId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->newLeaderId.addr); + cJSON_AddStringToObject(pNewerId, "addr", u64buf); + { + uint64_t u64 = pMsg->newLeaderId.addr; + cJSON* pTmp = pNewerId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pNewerId, "vgId", pMsg->newLeaderId.vgId); + cJSON_AddItemToObject(pRoot, "newLeaderId", pNewerId); + } + + cJSON* pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SyncLeaderTransfer", pRoot); + return pJson; +} + +char* syncLeaderTransfer2Str(const SyncLeaderTransfer* pMsg) { + cJSON* pJson = syncLeaderTransfer2Json(pMsg); + char* serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + +// for debug ---------------------- +void syncLeaderTransferPrint(const SyncLeaderTransfer* pMsg) { + char* serialized = syncLeaderTransfer2Str(pMsg); + printf("syncLeaderTransferPrint | len:%lu | %s \n", strlen(serialized), serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg) { + char* serialized = syncLeaderTransfer2Str(pMsg); + printf("syncLeaderTransferPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void syncLeaderTransferLog(const SyncLeaderTransfer* pMsg) { + char* serialized = syncLeaderTransfer2Str(pMsg); + sTrace("syncLeaderTransferLog | len:%lu | %s", strlen(serialized), serialized); + taosMemoryFree(serialized); +} + +void syncLeaderTransferLog2(char* s, const SyncLeaderTransfer* pMsg) { + if (gRaftDetailLog) { + char* serialized = syncLeaderTransfer2Str(pMsg); + sTrace("syncLeaderTransferLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + taosMemoryFree(serialized); + } } \ No newline at end of file diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index 95eec5d98f..45e00aca2c 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -150,6 +150,10 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { cJSON_AddNumberToObject(pRoot, "isStandBy", pRaftCfg->isStandBy); cJSON_AddNumberToObject(pRoot, "snapshotEnable", pRaftCfg->snapshotEnable); + char buf64[128]; + snprintf(buf64, sizeof(buf64), "%ld", pRaftCfg->lastConfigIndex); + cJSON_AddStringToObject(pRoot, "lastConfigIndex", buf64); + cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "RaftCfg", pRoot); return pJson; @@ -172,6 +176,7 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path) { raftCfg.cfg = *pCfg; raftCfg.isStandBy = meta.isStandBy; raftCfg.snapshotEnable = meta.snapshotEnable; + raftCfg.lastConfigIndex = meta.lastConfigIndex; char *s = raftCfg2Str(&raftCfg); char buf[CONFIG_FILE_LEN] = {0}; @@ -199,6 +204,9 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) { cJSON *pJsonSnapshotEnable = cJSON_GetObjectItem(pJson, "snapshotEnable"); pRaftCfg->snapshotEnable = cJSON_GetNumberValue(pJsonSnapshotEnable); + cJSON *pJsonLastConfigIndex = cJSON_GetObjectItem(pJson, "lastConfigIndex"); + pRaftCfg->lastConfigIndex = atoll(cJSON_GetStringValue(pJsonLastConfigIndex)); + cJSON * pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); int32_t code = syncCfgFromJson(pJsonSyncCfg, &(pRaftCfg->cfg)); ASSERT(code == 0); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index c53e5916ae..996cd12e4a 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -162,7 +162,7 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr walFsync(pWal, true); - sTrace("sync event vgId:%d write index:%ld, %s, isStandBy:%d, msgType:%s, originalRpcType:%s", pData->pSyncNode->vgId, + sDebug("vgId:%d sync event write index:%ld, %s, isStandBy:%d, msgType:%s, originalRpcType:%s", pData->pSyncNode->vgId, pEntry->index, syncUtilState2String(pData->pSyncNode->state), pData->pSyncNode->pRaftCfg->isStandBy, TMSG_INFO(pEntry->msgType), TMSG_INFO(pEntry->originalRpcType)); @@ -320,7 +320,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { walFsync(pWal, true); - sTrace("sync event old write wal: %ld", pEntry->index); + sDebug("sync event old write wal: %ld", pEntry->index); return code; } @@ -553,15 +553,19 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore) { } void logStoreLog(SSyncLogStore* pLogStore) { - char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog | len:%lu | %s", strlen(serialized), serialized); - taosMemoryFree(serialized); + if (gRaftDetailLog) { + char* serialized = logStore2Str(pLogStore); + sTraceLong("logStoreLog | len:%lu | %s", strlen(serialized), serialized); + taosMemoryFree(serialized); + } } void logStoreLog2(char* s, SSyncLogStore* pLogStore) { - char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); - taosMemoryFree(serialized); + if (gRaftDetailLog) { + char* serialized = logStore2Str(pLogStore); + sTraceLong("logStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + taosMemoryFree(serialized); + } } // for debug ----------------- diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index a23fe2c38a..38742220fe 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -15,6 +15,7 @@ #include "syncSnapshot.h" #include "syncIndexMgr.h" +#include "syncRaftCfg.h" #include "syncRaftLog.h" #include "syncRaftStore.h" #include "syncUtil.h" @@ -83,6 +84,32 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) { // get current snapshot info pSender->pSyncNode->pFsm->FpGetSnapshot(pSender->pSyncNode->pFsm, &(pSender->snapshot)); + if (pSender->snapshot.lastConfigIndex != SYNC_INDEX_INVALID) { + /* + SSyncRaftEntry *pEntry = NULL; + int32_t code = pSender->pSyncNode->pLogStore->syncLogGetEntry(pSender->pSyncNode->pLogStore, + pSender->snapshot.lastConfigIndex, &pEntry); + ASSERT(code == 0); + ASSERT(pEntry != NULL); + */ + + SSyncRaftEntry *pEntry = + pSender->pSyncNode->pLogStore->getEntry(pSender->pSyncNode->pLogStore, pSender->snapshot.lastConfigIndex); + ASSERT(pEntry != NULL); + + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + SSyncCfg lastConfig; + int32_t ret = syncCfgFromStr(rpcMsg.pCont, &lastConfig); + ASSERT(ret == 0); + pSender->lastConfig = lastConfig; + + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pEntry); + + } else { + memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg)); + } pSender->sendingMS = SYNC_SNAPSHOT_RETRY_MS; pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; @@ -97,6 +124,8 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) { pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; pMsg->lastTerm = pSender->snapshot.lastApplyTerm; + pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; + pMsg->lastConfig = pSender->lastConfig; pMsg->seq = pSender->seq; // SYNC_SNAPSHOT_SEQ_BEGIN pMsg->privateTerm = pSender->privateTerm; @@ -111,16 +140,19 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace( - "sync event vgId:%d snapshot send to %s:%d begin seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu send " + sDebug( + "vgId:%d sync event snapshot send to %s:%d begin seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld send " "msg:%s", pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm, msgStr); + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot send to %s:%d begin seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu", - pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm); + sDebug( + "vgId:%d sync event snapshot send to %s:%d begin seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld", + pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex); } syncSnapshotSendDestroy(pMsg); @@ -228,6 +260,8 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; pMsg->lastTerm = pSender->snapshot.lastApplyTerm; + pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; + pMsg->lastConfig = pSender->lastConfig; pMsg->seq = pSender->seq; pMsg->privateTerm = pSender->privateTerm; memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); @@ -244,21 +278,26 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace( - "sync event vgId:%d snapshot send to %s:%d finish seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu send " + sDebug( + "vgId:%d sync event snapshot send to %s:%d finish seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld send " "msg:%s", pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm, msgStr); + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot send to %s:%d finish seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu", - pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm); + sDebug( + "vgId:%d sync event snapshot send to %s:%d finish seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld", + pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex); } } else { - sTrace("sync event vgId:%d snapshot send to %s:%d sending seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu", - pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm); + sDebug( + "vgId:%d sync event snapshot send to %s:%d sending seq:%d ack:%d lastApplyIndex:%ld lastApplyTerm:%lu " + "lastConfigIndex:%ld", + pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, pSender->snapshot.lastApplyIndex, + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex); } syncSnapshotSendDestroy(pMsg); @@ -274,6 +313,8 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; pMsg->lastTerm = pSender->snapshot.lastApplyTerm; + pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; + pMsg->lastConfig = pSender->lastConfig; pMsg->seq = pSender->seq; memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); @@ -287,11 +328,11 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace("sync event vgId:%d snapshot send to %s:%d resend seq:%d ack:%d send msg:%s", pSender->pSyncNode->vgId, + sDebug("vgId:%d sync event snapshot send to %s:%d resend seq:%d ack:%d send msg:%s", pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack, msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot send to %s:%d resend seq:%d ack:%d", pSender->pSyncNode->vgId, host, port, + sDebug("vgId:%d sync event snapshot send to %s:%d resend seq:%d ack:%d", pSender->pSyncNode->vgId, host, port, pSender->seq, pSender->ack); } @@ -352,7 +393,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { char *snapshotSender2Str(SSyncSnapshotSender *pSender) { cJSON *pJson = snapshotSender2Json(pSender); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -473,7 +514,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; - cJSON *pTmp = pFromId; + cJSON * pTmp = pFromId; char host[128] = {0}; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); @@ -497,7 +538,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) { cJSON *pJson = snapshotReceiver2Json(pReceiver); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -524,12 +565,17 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace("sync event vgId:%d snapshot recv from %s:%d begin ack:%d, lastIndex:%ld, lastTerm:%lu, recv msg:%s", - pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, msgStr); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d begin ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld, recv msg:%s", + pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex, + msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot recv from %s:%d begin ack:%d, lastIndex:%ld, lastTerm:%lu", - pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d begin ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld", + pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex); } } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { @@ -540,6 +586,42 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { pSyncNode->pFsm->FpSnapshotStopWrite(pSyncNode->pFsm, pReceiver->pWriter, true); pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1); + // maybe update lastconfig + if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) { + // update new config myIndex + bool IamInNew = false; + SSyncCfg newSyncCfg = pMsg->lastConfig; + for (int i = 0; i < newSyncCfg.replicaNum; ++i) { + if (strcmp(pSyncNode->myNodeInfo.nodeFqdn, (newSyncCfg.nodeInfo)[i].nodeFqdn) == 0 && + pSyncNode->myNodeInfo.nodePort == (newSyncCfg.nodeInfo)[i].nodePort) { + newSyncCfg.myIndex = i; + IamInNew = true; + break; + } + } + + bool isDrop; + if (IamInNew) { + sDebug("vgId:%d sync event update config by snapshot, lastIndex:%ld, lastTerm:%lu, lastConfigIndex:%ld ", + pSyncNode->vgId, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex); + syncNodeUpdateConfig(pSyncNode, &newSyncCfg, pMsg->lastConfigIndex, &isDrop); + } else { + sDebug( + "vgId:%d sync event do not update config by snapshot, I am not in newCfg, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld ", + pSyncNode->vgId, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex); + } + + // change isStandBy to normal + if (!isDrop) { + if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + syncNodeBecomeLeader(pSyncNode, "config change"); + } else { + syncNodeBecomeFollower(pSyncNode, "config change"); + } + } + } + SSnapshot snapshot; pSyncNode->pFsm->FpGetSnapshot(pSyncNode->pFsm, &snapshot); @@ -549,19 +631,20 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { if (gRaftDetailLog) { char *logSimpleStr = logStoreSimple2Str(pSyncNode->pLogStore); - sInfo( - "sync event vgId:%d snapshot recv from %s:%d finish, update log begin index:%ld, " + sDebug( + "vgId:%d sync event snapshot recv from %s:%d finish, update log begin index:%ld, " "snapshot.lastApplyIndex:%ld, " - "snapshot.lastApplyTerm:%lu, raft log:%s", + "snapshot.lastApplyTerm:%lu, snapshot.lastConfigIndex:%ld, raft log:%s", pSyncNode->vgId, host, port, pMsg->lastIndex + 1, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - logSimpleStr); + snapshot.lastConfigIndex, logSimpleStr); taosMemoryFree(logSimpleStr); } else { - sInfo( - "sync event vgId:%d snapshot recv from %s:%d finish, update log begin index:%ld, " + sDebug( + "vgId:%d sync event snapshot recv from %s:%d finish, update log begin index:%ld, " "snapshot.lastApplyIndex:%ld, " - "snapshot.lastApplyTerm:%lu", - pSyncNode->vgId, host, port, pMsg->lastIndex + 1, snapshot.lastApplyIndex, snapshot.lastApplyTerm); + "snapshot.lastApplyTerm:%lu, snapshot.lastConfigIndex:%ld", + pSyncNode->vgId, host, port, pMsg->lastIndex + 1, snapshot.lastApplyIndex, snapshot.lastApplyTerm, + snapshot.lastConfigIndex); } pReceiver->pWriter = NULL; @@ -571,12 +654,18 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace("sync event vgId:%d snapshot recv from %s:%d end ack:%d, lastIndex:%ld, lastTerm:%lu, recv msg:%s", - pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, msgStr); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d end ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld, recv msg:%s", + pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, + pMsg->lastConfigIndex, msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot recv from %s:%d end ack:%d, lastIndex:%ld, lastTerm:%lu", - pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d end ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld", + pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, + pMsg->lastConfigIndex); } } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { @@ -590,14 +679,19 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace( - "sync event vgId:%d snapshot recv from %s:%d force close ack:%d, lastIndex:%ld, lastTerm:%lu, recv " + sDebug( + "vgId:%d sync event snapshot recv from %s:%d force close ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld, recv " "msg:%s", - pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, msgStr); + pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, + pMsg->lastConfigIndex, msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot recv from %s:%d force close ack:%d, lastIndex:%ld, lastTerm:%lu", - pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d force close ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld", + pReceiver->pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, + pMsg->lastConfigIndex); } } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { @@ -616,13 +710,17 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { if (gRaftDetailLog) { char *msgStr = syncSnapshotSend2Str(pMsg); - sTrace( - "sync event vgId:%d snapshot recv from %s:%d receiving ack:%d, lastIndex:%ld, lastTerm:%lu, recv msg:%s", - pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, msgStr); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d receiving ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld, recv msg:%s", + pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex, + msgStr); taosMemoryFree(msgStr); } else { - sTrace("sync event vgId:%d snapshot recv from %s:%d receiving ack:%d, lastIndex:%ld, lastTerm:%lu", - pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm); + sDebug( + "vgId:%d sync event snapshot recv from %s:%d receiving ack:%d, lastIndex:%ld, lastTerm:%lu, " + "lastConfigIndex:%ld", + pSyncNode->vgId, host, port, pReceiver->ack, pMsg->lastIndex, pMsg->lastTerm, pMsg->lastConfigIndex); } } else { diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index f6ff521e01..d12c5058cc 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -214,29 +214,31 @@ void syncUtilMsgNtoH(void* msg) { pHead->vgId = ntohl(pHead->vgId); } +#if 0 bool syncUtilIsData(tmsg_t msgType) { if (msgType == TDMT_SYNC_NOOP || msgType == TDMT_SYNC_CONFIG_CHANGE) { return false; } return true; } +#endif bool syncUtilUserPreCommit(tmsg_t msgType) { - if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) { + if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE && msgType != TDMT_SYNC_LEADER_TRANSFER) { return true; } return false; } bool syncUtilUserCommit(tmsg_t msgType) { - if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) { + if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE && msgType != TDMT_SYNC_LEADER_TRANSFER) { return true; } return false; } bool syncUtilUserRollback(tmsg_t msgType) { - if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) { + if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE && msgType != TDMT_SYNC_LEADER_TRANSFER) { return true; } return false; diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index c68c6349fb..d39035ba53 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -47,6 +47,7 @@ add_executable(syncTestTool "") add_executable(syncRaftLogTest "") add_executable(syncRaftLogTest2 "") add_executable(syncRaftLogTest3 "") +add_executable(syncLeaderTransferTest "") target_sources(syncTest @@ -245,6 +246,10 @@ target_sources(syncRaftLogTest3 PRIVATE "syncRaftLogTest3.cpp" ) +target_sources(syncLeaderTransferTest + PRIVATE + "syncLeaderTransferTest.cpp" +) target_include_directories(syncTest @@ -492,6 +497,11 @@ target_include_directories(syncRaftLogTest3 "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncLeaderTransferTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -690,6 +700,10 @@ target_link_libraries(syncRaftLogTest3 sync gtest_main ) +target_link_libraries(syncLeaderTransferTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncLeaderTransferTest.cpp b/source/libs/sync/test/syncLeaderTransferTest.cpp new file mode 100644 index 0000000000..1c3891d492 --- /dev/null +++ b/source/libs/sync/test/syncLeaderTransferTest.cpp @@ -0,0 +1,101 @@ +#include +#include +#include "syncIO.h" +#include "syncInt.h" +#include "syncMessage.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +SyncLeaderTransfer *createMsg() { + SyncLeaderTransfer *pMsg = syncLeaderTransferBuild(1000); + /* + pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234); + pMsg->srcId.vgId = 100; + pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678); + pMsg->destId.vgId = 100; + */ + pMsg->newLeaderId.addr = syncUtilAddr2U64("127.0.0.1", 9999); + pMsg->newLeaderId.vgId = 100; + return pMsg; +} + +void test1() { + SyncLeaderTransfer *pMsg = createMsg(); + syncLeaderTransferLog2((char *)"test1:", pMsg); + syncLeaderTransferDestroy(pMsg); +} + +void test2() { + SyncLeaderTransfer *pMsg = createMsg(); + uint32_t len = pMsg->bytes; + char * serialized = (char *)taosMemoryMalloc(len); + syncLeaderTransferSerialize(pMsg, serialized, len); + SyncLeaderTransfer *pMsg2 = syncLeaderTransferBuild(1000); + syncLeaderTransferDeserialize(serialized, len, pMsg2); + syncLeaderTransferLog2((char *)"test2: syncLeaderTransferSerialize -> syncLeaderTransferDeserialize ", pMsg2); + + taosMemoryFree(serialized); + syncLeaderTransferDestroy(pMsg); + syncLeaderTransferDestroy(pMsg2); +} + +void test3() { + SyncLeaderTransfer *pMsg = createMsg(); + uint32_t len; + char * serialized = syncLeaderTransferSerialize2(pMsg, &len); + SyncLeaderTransfer *pMsg2 = syncLeaderTransferDeserialize2(serialized, len); + syncLeaderTransferLog2((char *)"test3: syncLeaderTransferSerialize2 -> syncLeaderTransferDeserialize2 ", pMsg2); + + taosMemoryFree(serialized); + syncLeaderTransferDestroy(pMsg); + syncLeaderTransferDestroy(pMsg2); +} + +void test4() { + SyncLeaderTransfer *pMsg = createMsg(); + SRpcMsg rpcMsg; + syncLeaderTransfer2RpcMsg(pMsg, &rpcMsg); + SyncLeaderTransfer *pMsg2 = (SyncLeaderTransfer *)taosMemoryMalloc(rpcMsg.contLen); + syncLeaderTransferFromRpcMsg(&rpcMsg, pMsg2); + syncLeaderTransferLog2((char *)"test4: syncLeaderTransfer2RpcMsg -> syncLeaderTransferFromRpcMsg ", pMsg2); + + rpcFreeCont(rpcMsg.pCont); + syncLeaderTransferDestroy(pMsg); + syncLeaderTransferDestroy(pMsg2); +} + +void test5() { + SyncLeaderTransfer *pMsg = createMsg(); + SRpcMsg rpcMsg; + syncLeaderTransfer2RpcMsg(pMsg, &rpcMsg); + SyncLeaderTransfer *pMsg2 = syncLeaderTransferFromRpcMsg2(&rpcMsg); + syncLeaderTransferLog2((char *)"test5: syncLeaderTransfer2RpcMsg -> syncLeaderTransferFromRpcMsg2 ", pMsg2); + + rpcFreeCont(rpcMsg.pCont); + syncLeaderTransferDestroy(pMsg); + syncLeaderTransferDestroy(pMsg2); +} + +int main() { + gRaftDetailLog = true; + + tsAsyncLog = 0; + sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE; + logTest(); + + test1(); + test2(); + test3(); + test4(); + test5(); + + return 0; +} diff --git a/source/libs/sync/test/syncRaftCfgTest.cpp b/source/libs/sync/test/syncRaftCfgTest.cpp index 564cbdb69a..8c6a704e2d 100644 --- a/source/libs/sync/test/syncRaftCfgTest.cpp +++ b/source/libs/sync/test/syncRaftCfgTest.cpp @@ -74,6 +74,7 @@ void test3() { SRaftCfgMeta meta; meta.isStandBy = 7; meta.snapshotEnable = 9; + meta.lastConfigIndex = 789; raftCfgCreateFile(pCfg, meta, s); printf("%s create json file: %s \n", (char*)__FUNCTION__, s); } @@ -98,6 +99,7 @@ void test5() { pCfg->cfg.myIndex = taosGetTimestampSec(); pCfg->isStandBy += 2; pCfg->snapshotEnable += 3; + pCfg->lastConfigIndex += 1000; raftCfgPersist(pCfg); printf("%s update json file: %s myIndex->%d \n", (char*)__FUNCTION__, "./test3_raft_cfg.json", pCfg->cfg.myIndex); diff --git a/source/libs/sync/test/syncSnapshotSendTest.cpp b/source/libs/sync/test/syncSnapshotSendTest.cpp index 01d3264693..ca7916359e 100644 --- a/source/libs/sync/test/syncSnapshotSendTest.cpp +++ b/source/libs/sync/test/syncSnapshotSendTest.cpp @@ -24,6 +24,16 @@ SyncSnapshotSend *createMsg() { pMsg->privateTerm = 99; pMsg->lastIndex = 22; pMsg->lastTerm = 33; + + pMsg->lastConfigIndex = 99; + pMsg->lastConfig.replicaNum = 3; + pMsg->lastConfig.myIndex = 1; + for (int i = 0; i < pMsg->lastConfig.replicaNum; ++i) { + ((pMsg->lastConfig.nodeInfo)[i]).nodePort = i * 100; + snprintf(((pMsg->lastConfig.nodeInfo)[i]).nodeFqdn, sizeof(((pMsg->lastConfig.nodeInfo)[i]).nodeFqdn), + "100.200.300.%d", i); + } + pMsg->seq = 44; strcpy(pMsg->data, "hello world"); return pMsg; @@ -87,6 +97,8 @@ void test5() { } int main() { + gRaftDetailLog = true; + tsAsyncLog = 0; sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE; logTest(); diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index 3b68073c7e..11f62455fd 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -81,24 +81,24 @@ int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) { rel.tv_nsec = nanosecs; GetSystemTimeAsFileTime(&ft_before); - errno = 0; - rc = sem_timedwait(&sem, pthread_win32_getabstime_np(&ts, &rel)); + // errno = 0; + rc = sem_timedwait(sem, pthread_win32_getabstime_np(&ts, &rel)); /* This should have timed out */ - assert(errno == ETIMEDOUT); - assert(rc != 0); - GetSystemTimeAsFileTime(&ft_after); - // We specified a non-zero wait. Time must advance. - if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime) - { - printf("nanoseconds: %d, rc: %d, errno: %d. before filetime: %d, %d; after filetime: %d, %d\n", - nanosecs, rc, errno, - (int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime, - (int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime); - printf("time must advance during sem_timedwait."); - return 1; - } - return 0; + // assert(errno == ETIMEDOUT); + // assert(rc != 0); + // GetSystemTimeAsFileTime(&ft_after); + // // We specified a non-zero wait. Time must advance. + // if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime) + // { + // printf("nanoseconds: %d, rc: %d, errno: %d. before filetime: %d, %d; after filetime: %d, %d\n", + // nanosecs, rc, errno, + // (int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime, + // (int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime); + // printf("time must advance during sem_timedwait."); + // return 1; + // } + return rc; } #elif defined(_TD_DARWIN_64) diff --git a/source/util/src/terror.c b/source/util/src/terror.c index b5c54b780d..e122ad0ab6 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -353,9 +353,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag valu TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_RECREATED, "Table re-created") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_SMA_INDEX_IN_META, "No sma index in meta") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_SMA_STAT, "Invalid sma state") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TSMA_ALREADY_EXIST, "TSMA already exists") // query @@ -537,25 +534,38 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_DELETE_WHERE, "The DELETE statemen TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG, "The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes") //planner -TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error") +TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error") //udf -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_READ_ERR, "udf pipe read error") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_CONNECT_ERR, "udf pipe connect error") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_NO_PIPE, "udf no pipe") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_LOAD_UDF_FAILURE, "udf load failure") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_STATE, "udf invalid state") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_INPUT, "udf invalid function input") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_NO_FUNC_HANDLE, "udf no function handle") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_BUFSIZE, "udf invalid bufsize") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_OUTPUT_TYPE, "udf invalid output type") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_READ_ERR, "udf pipe read error") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_CONNECT_ERR, "udf pipe connect error") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_PIPE_NO_PIPE, "udf no pipe") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_LOAD_UDF_FAILURE, "udf load failure") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_STATE, "udf invalid state") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_INPUT, "udf invalid function input") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_NO_FUNC_HANDLE, "udf no function handle") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_BUFSIZE, "udf invalid bufsize") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_OUTPUT_TYPE, "udf invalid output type") //schemaless -TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") -TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PRECISION_TYPE, "Invalid timestamp precision type") -TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DATA, "Invalid data type") -TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DB_CONF, "Invalid schemaless db config") +TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") +TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PRECISION_TYPE, "Invalid timestamp precision type") +TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DATA, "Invalid data type") +TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DB_CONF, "Invalid schemaless db config") + +//tsma +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_ALREADY_EXIST, "Tsma already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_META, "No tsma index in meta") +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_NO_INDEX_IN_CACHE, "No tsma index in cache") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_RM_SKEY_IN_HASH, "Rm tsma skey in cache") + +//rsma +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env") +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_STAT, "Invalid rsma state") + #ifdef TAOS_ERROR_C }; diff --git a/source/util/src/thash.c b/source/util/src/thash.c index f564ae45b6..8bda59bba7 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -33,9 +33,9 @@ #define FREE_HASH_NODE(_fp, _n) \ do { \ - /* if (_fp != NULL) { \ - (_fp)(_n); \ - }*/ \ + if (_fp != NULL) { \ + (_fp)(_n); \ + } \ taosMemoryFreeClear(_n); \ } while (0); diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c new file mode 100644 index 0000000000..b034a6e73e --- /dev/null +++ b/source/util/src/tlrucache.c @@ -0,0 +1,794 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "tlrucache.h" +#include "os.h" +#include "tdef.h" +#include "taoserror.h" +#include "tlog.h" +#include "tarray.h" + +typedef struct SLRUEntry SLRUEntry; +typedef struct SLRUEntryTable SLRUEntryTable; +typedef struct SLRUCacheShard SLRUCacheShard; +typedef struct SShardedCache SShardedCache; + +enum { + TAOS_LRU_IN_CACHE = (1 << 0), // Whether this entry is referenced by the hash table. + + TAOS_LRU_IS_HIGH_PRI = (1 << 1), // Whether this entry is high priority entry. + + TAOS_LRU_IN_HIGH_PRI_POOL = (1 << 2), // Whether this entry is in high-pri pool. + + TAOS_LRU_HAS_HIT = (1 << 3), // Whether this entry has had any lookups (hits). +}; + +struct SLRUEntry { + void *value; + _taos_lru_deleter_t deleter; + SLRUEntry *nextHash; + SLRUEntry *next; + SLRUEntry *prev; + size_t totalCharge; + size_t keyLength; + uint32_t hash; + uint32_t refs; + uint8_t flags; + char keyData[1]; +}; + +#define TAOS_LRU_ENTRY_IN_CACHE(h) ((h)->flags & TAOS_LRU_IN_CACHE) +#define TAOS_LRU_ENTRY_IN_HIGH_POOL(h) ((h)->flags & TAOS_LRU_IN_HIGH_PRI_POOL) +#define TAOS_LRU_ENTRY_IS_HIGH_PRI(h) ((h)->flags & TAOS_LRU_IS_HIGH_PRI) +#define TAOS_LRU_ENTRY_HAS_HIT(h) ((h)->flags & TAOS_LRU_HAS_HIT) + +#define TAOS_LRU_ENTRY_SET_IN_CACHE(h, inCache) do { if(inCache) {(h)->flags |= TAOS_LRU_IN_CACHE;} else {(h)->flags &= ~TAOS_LRU_IN_CACHE;} } while(0) +#define TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(h, inHigh) do { if(inHigh) {(h)->flags |= TAOS_LRU_IN_HIGH_PRI_POOL;} else {(h)->flags &= ~TAOS_LRU_IN_HIGH_PRI_POOL;} } while(0) +#define TAOS_LRU_ENTRY_SET_PRIORITY(h, priority) do { if(priority == TAOS_LRU_PRIORITY_HIGH) {(h)->flags |= TAOS_LRU_IS_HIGH_PRI;} else {(h)->flags &= ~TAOS_LRU_IS_HIGH_PRI;} } while(0) +#define TAOS_LRU_ENTRY_SET_HIT(h) ((h)->flags |= TAOS_LRU_HAS_HIT) + +#define TAOS_LRU_ENTRY_HAS_REFS(h) ((h)->refs > 0) +#define TAOS_LRU_ENTRY_REF(h) (++(h)->refs) + +static bool taosLRUEntryUnref(SLRUEntry *entry) { + assert(entry->refs > 0); + --entry->refs; + return entry->refs == 0; +} + +static void taosLRUEntryFree(SLRUEntry *entry) { + assert(entry->refs == 0); + + if (entry->deleter) { + (*entry->deleter)(entry->keyData, entry->keyLength, entry->value); + } + + taosMemoryFree(entry); +} + +typedef void (*_taos_lru_table_func_t)(SLRUEntry *entry); + +struct SLRUEntryTable { + int lengthBits; + SLRUEntry **list; + uint32_t elems; + int maxLengthBits; +}; + +static int taosLRUEntryTableInit(SLRUEntryTable *table, int maxUpperHashBits) { + table->lengthBits = 4; + table->list = taosMemoryCalloc(1 << table->lengthBits, sizeof(SLRUEntry*)); + if (!table->list) { + return -1; + } + + table->elems = 0; + table->maxLengthBits = maxUpperHashBits; + + return 0; +} + +static void taosLRUEntryTableApply(SLRUEntryTable *table, _taos_lru_table_func_t func, uint32_t begin, uint32_t end) { + for (uint32_t i = begin; i < end; ++i) { + SLRUEntry *h = table->list[i]; + while (h) { + SLRUEntry *n = h->nextHash; + assert(TAOS_LRU_ENTRY_IN_CACHE(h)); + func(h); + h = n; + } + } +} + +static void taosLRUEntryTableFree(SLRUEntry *entry) { + if (!TAOS_LRU_ENTRY_HAS_REFS(entry)) { + taosLRUEntryFree(entry); + } +} + +static void taosLRUEntryTableCleanup(SLRUEntryTable *table) { + taosLRUEntryTableApply(table, taosLRUEntryTableFree, 0, 1 << table->lengthBits); + + taosMemoryFree(table->list); +} + +static SLRUEntry **taosLRUEntryTableFindPtr(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { + SLRUEntry **entry = &table->list[hash >> (32 - table->lengthBits)]; + while (*entry && ((*entry)->hash != hash || memcmp(key, (*entry)->keyData, keyLen) != 0)) { + entry = &(*entry)->nextHash; + } + + return entry; +} + +static void taosLRUEntryTableResize(SLRUEntryTable * table) { + int lengthBits = table->lengthBits; + if (lengthBits >= table->maxLengthBits) { + return; + } + + if (lengthBits >= 31) { + return; + } + + uint32_t oldLength = 1 << lengthBits; + int newLengthBits = lengthBits + 1; + SLRUEntry **newList = taosMemoryCalloc(1 << newLengthBits, sizeof(SLRUEntry*)); + if (!newList) { + return; + } + uint32_t count = 0; + for (uint32_t i = 0; i < oldLength; ++i) { + SLRUEntry *entry = table->list[i]; + while (entry) { + SLRUEntry *next = entry->nextHash; + uint32_t hash = entry->hash; + SLRUEntry **ptr = &newList[hash >> (32 - newLengthBits)]; + entry->nextHash = *ptr; + *ptr = entry; + entry = next; + ++count; + } + } + assert(table->elems == count); + + taosMemoryFree(table->list); + table->list = newList; + table->lengthBits = newLengthBits; +} + +static SLRUEntry *taosLRUEntryTableLookup(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { + return *taosLRUEntryTableFindPtr(table, key, keyLen, hash); +} + +static SLRUEntry *taosLRUEntryTableInsert(SLRUEntryTable * table, SLRUEntry *entry) { + SLRUEntry **ptr = taosLRUEntryTableFindPtr(table, entry->keyData, entry->keyLength, entry->hash); + SLRUEntry *old = *ptr; + entry->nextHash = (old == NULL) ? NULL : old->nextHash; + *ptr = entry; + if (old == NULL) { + ++table->elems; + if ((table->elems >> table->lengthBits) > 0) { + taosLRUEntryTableResize(table); + } + } + + return old; +} + +static SLRUEntry *taosLRUEntryTableRemove(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { + SLRUEntry **entry = taosLRUEntryTableFindPtr(table, key, keyLen, hash); + SLRUEntry *result = *entry; + if (result) { + *entry = result->nextHash; + --table->elems; + } + + return result; +} + +struct SLRUCacheShard { + size_t capacity; + size_t highPriPoolUsage; + bool strictCapacity; + double highPriPoolRatio; + double highPriPoolCapacity; + SLRUEntry lru; + SLRUEntry *lruLowPri; + SLRUEntryTable table; + size_t usage; // Memory size for entries residing in the cache. + size_t lruUsage; // Memory size for entries residing only in the LRU list. + TdThreadMutex mutex; +}; + +#define TAOS_LRU_CACHE_SHARD_HASH32(key, len) (MurmurHash3_32((key), (len))) + +static void taosLRUCacheShardMaintainPoolSize(SLRUCacheShard *shard) { + while (shard->highPriPoolUsage > shard->highPriPoolCapacity) { + shard->lruLowPri = shard->lruLowPri->next; + assert(shard->lruLowPri != &shard->lru); + TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(shard->lruLowPri, false); + + assert(shard->highPriPoolUsage >= shard->lruLowPri->totalCharge); + shard->highPriPoolUsage -= shard->lruLowPri->totalCharge; + } +} + +static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) { + assert(e->next == NULL); + assert(e->prev == NULL); + + if (shard->highPriPoolRatio > 0 + && (TAOS_LRU_ENTRY_IS_HIGH_PRI(e) || TAOS_LRU_ENTRY_HAS_HIT(e))) { + e->next = &shard->lru; + e->prev = shard->lru.prev; + + e->prev->next = e; + e->next->prev = e; + + TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(e, true); + shard->highPriPoolUsage += e->totalCharge; + taosLRUCacheShardMaintainPoolSize(shard); + } else { + e->next = shard->lruLowPri->next; + e->prev = shard->lruLowPri; + + e->prev->next = e; + e->next->prev = e; + + TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(e, false); + shard->lruLowPri = e; + } + + shard->lruUsage += e->totalCharge; +} + +static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) { + assert(e->next); + assert(e->prev); + + if (shard->lruLowPri == e) { + shard->lruLowPri = e->prev; + } + e->next->prev = e->prev; + e->prev->next = e->next; + e->prev = e->next = NULL; + + assert(shard->lruUsage >= e->totalCharge); + shard->lruUsage -= e->totalCharge; + if (TAOS_LRU_ENTRY_IN_HIGH_POOL(e)) { + assert(shard->highPriPoolUsage >= e->totalCharge); + shard->highPriPoolUsage -= e->totalCharge; + } +} + +static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArray *deleted) { + while (shard->usage + charge > shard->capacity && shard->lru.next != &shard->lru) { + SLRUEntry *old = shard->lru.next; + assert(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); + + taosLRUCacheShardLRURemove(shard, old); + taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + + TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); + assert(shard->usage >= old->totalCharge); + shard->usage -= old->totalCharge; + + taosArrayPush(deleted, &old); + } +} + +static void taosLRUCacheShardSetCapacity(SLRUCacheShard *shard, size_t capacity) { + SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES); + + taosThreadMutexLock(&shard->mutex); + + shard->capacity = capacity; + shard->highPriPoolCapacity = capacity * shard->highPriPoolRatio; + taosLRUCacheShardEvictLRU(shard, 0, lastReferenceList); + + taosThreadMutexUnlock(&shard->mutex); + + for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { + SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); + taosLRUEntryFree(entry); + } + taosArrayDestroy(lastReferenceList); +} + +static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool strict, + double highPriPoolRatio, int maxUpperHashBits) { + if (taosLRUEntryTableInit(&shard->table, maxUpperHashBits) < 0) { + return -1; + } + + taosThreadMutexInit(&shard->mutex, NULL); + + shard->capacity = 0; + shard->highPriPoolUsage = 0; + shard->strictCapacity = strict; + shard->highPriPoolRatio = highPriPoolRatio; + shard->highPriPoolCapacity = 0; + + shard->usage = 0; + shard->lruUsage = 0; + + shard->lru.next = &shard->lru; + shard->lru.prev = &shard->lru; + shard->lruLowPri = &shard->lru; + + taosLRUCacheShardSetCapacity(shard, capacity); + + return 0; +} + +static void taosLRUCacheShardCleanup(SLRUCacheShard *shard) { + taosThreadMutexDestroy(&shard->mutex); + + taosLRUEntryTableCleanup(&shard->table); +} + +static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *e, LRUHandle **handle, bool freeOnFail) { + LRUStatus status = TAOS_LRU_STATUS_OK; + SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES); + + taosThreadMutexLock(&shard->mutex); + + taosLRUCacheShardEvictLRU(shard, e->totalCharge, lastReferenceList); + + if (shard->usage + e->totalCharge > shard->capacity && (shard->strictCapacity || handle == NULL)) { + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + if (handle == NULL) { + taosArrayPush(lastReferenceList, &e); + } else { + if (freeOnFail) { + taosMemoryFree(e); + + *handle = NULL; + } + + status = TAOS_LRU_STATUS_INCOMPLETE; + } + } else { + SLRUEntry *old = taosLRUEntryTableInsert(&shard->table, e); + shard->usage += e->totalCharge; + if (old != NULL) { + status = TAOS_LRU_STATUS_OK_OVERWRITTEN; + + assert(TAOS_LRU_ENTRY_IN_CACHE(old)); + TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, old); + assert(shard->usage >= old->totalCharge); + shard->usage -= old->totalCharge; + + taosArrayPush(lastReferenceList, &old); + } + } + if (handle == NULL) { + taosLRUCacheShardLRUInsert(shard, e); + } else { + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + TAOS_LRU_ENTRY_REF(e); + } + + *handle = (LRUHandle*) e; + } + } + + taosThreadMutexUnlock(&shard->mutex); + + for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { + SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); + + taosLRUEntryFree(entry); + } + taosArrayDestroy(lastReferenceList); + + return status; +} + +static LRUStatus taosLRUCacheShardInsert(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash, + void *value, size_t charge, _taos_lru_deleter_t deleter, + LRUHandle **handle, LRUPriority priority) { + SLRUEntry *e = taosMemoryCalloc(1, sizeof(SLRUEntry) - 1 + keyLen); + if (!e) { + return TAOS_LRU_STATUS_FAIL; + } + + e->value = value; + e->flags = 0; + e->deleter = deleter; + e->keyLength = keyLen; + e->hash = hash; + e->refs = 0; + e->next = e->prev = NULL; + TAOS_LRU_ENTRY_SET_IN_CACHE(e, true); + + TAOS_LRU_ENTRY_SET_PRIORITY(e, priority); + memcpy(e->keyData, key, keyLen); + // TODO: e->CalcTotalCharge(charge, metadataChargePolicy); + e->totalCharge = charge; + + return taosLRUCacheShardInsertEntry(shard, e, handle, true); +} + +static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash) { + SLRUEntry *e = NULL; + + taosThreadMutexLock(&shard->mutex); + e = taosLRUEntryTableLookup(&shard->table, key, keyLen, hash); + if (e != NULL) { + assert(TAOS_LRU_ENTRY_IN_CACHE(e)); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, e); + } + TAOS_LRU_ENTRY_REF(e); + TAOS_LRU_ENTRY_SET_HIT(e); + } + + taosThreadMutexUnlock(&shard->mutex); + + return (LRUHandle *) e; +} + +static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash) { + bool lastReference = false; + taosThreadMutexLock(&shard->mutex); + + SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, key, keyLen, hash); + if (e != NULL) { + assert(TAOS_LRU_ENTRY_IN_CACHE(e)); + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, e); + + assert(shard->usage >= e->totalCharge); + shard->usage -= e->totalCharge; + lastReference = true; + } + } + + taosThreadMutexUnlock(&shard->mutex); + + if (lastReference) { + taosLRUEntryFree(e); + } +} + +static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { + SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES); + + taosThreadMutexLock(&shard->mutex); + + while (shard->lru.next != &shard->lru) { + SLRUEntry *old = shard->lru.next; + assert(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); + taosLRUCacheShardLRURemove(shard, old); + taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); + assert(shard->usage >= old->totalCharge); + shard->usage -= old->totalCharge; + + taosArrayPush(lastReferenceList, &old); + } + + taosThreadMutexUnlock(&shard->mutex); + + for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { + SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); + + taosLRUEntryFree(entry); + } + + taosArrayDestroy(lastReferenceList); +} + +static bool taosLRUCacheShardRef(SLRUCacheShard *shard, LRUHandle *handle) { + SLRUEntry *e = (SLRUEntry *) handle; + taosThreadMutexLock(&shard->mutex); + + assert(TAOS_LRU_ENTRY_HAS_REFS(e)); + TAOS_LRU_ENTRY_REF(e); + + taosThreadMutexUnlock(&shard->mutex); + + return true; +} + +static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, bool eraseIfLastRef) { + if (handle == NULL) { + return false; + } + + SLRUEntry *e = (SLRUEntry *) handle; + bool lastReference = false; + + taosThreadMutexLock(&shard->mutex); + + lastReference = taosLRUEntryUnref(e); + if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) { + if (shard->usage > shard->capacity || eraseIfLastRef) { + assert(shard->lru.next == &shard->lru || eraseIfLastRef); + + taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + } else { + taosLRUCacheShardLRUInsert(shard, e); + + lastReference = false; + } + } + + if (lastReference && e->value) { + assert(shard->usage >= e->totalCharge); + shard->usage -= e->totalCharge; + } + + taosThreadMutexUnlock(&shard->mutex); + + if (lastReference) { + taosLRUEntryFree(e); + } + + return lastReference; +} + +static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) { + size_t usage = 0; + + taosThreadMutexLock(&shard->mutex); + usage = shard->usage; + taosThreadMutexUnlock(&shard->mutex); + + return usage; +} + +static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) { + size_t usage = 0; + + taosThreadMutexLock(&shard->mutex); + + assert(shard->usage >= shard->lruUsage); + usage = shard->usage - shard->lruUsage; + + taosThreadMutexUnlock(&shard->mutex); + + return usage; +} + +static void taosLRUCacheShardSetStrictCapacity(SLRUCacheShard *shard, bool strict) { + taosThreadMutexLock(&shard->mutex); + + shard->strictCapacity = strict; + + taosThreadMutexUnlock(&shard->mutex); +} + +struct SShardedCache { + uint32_t shardMask; + TdThreadMutex capacityMutex; + size_t capacity; + bool strictCapacity; + uint64_t lastId; // atomic var for last id +}; + +struct SLRUCache { + SShardedCache shardedCache; + SLRUCacheShard *shards; + int numShards; +}; + +static int getDefaultCacheShardBits(size_t capacity) { + int numShardBits = 0; + size_t minShardSize = 512 * 1024; + size_t numShards = capacity / minShardSize; + while (numShards >>= 1) { + if (++numShardBits >= 6) { + return numShardBits; + } + } + + return numShardBits; +} + +SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoolRatio) { + if (numShardBits >= 20) { + return NULL; + } + if (highPriPoolRatio < 0.0 || highPriPoolRatio > 1.0) { + return NULL; + } + SLRUCache *cache = taosMemoryCalloc(1, sizeof(SLRUCache)); + if (!cache) { + return NULL; + } + + if (numShardBits < 0) { + numShardBits = getDefaultCacheShardBits(capacity); + } + + int numShards = 1 << numShardBits; + cache->shards = taosMemoryCalloc(numShards, sizeof(SLRUCacheShard)); + if (!cache->shards) { + taosMemoryFree(cache); + + return NULL; + } + + bool strictCapacity = 1; + size_t perShard = (capacity + (numShards - 1)) / numShards; + for (int i = 0; i < numShards; ++i) { + taosLRUCacheShardInit(&cache->shards[i], perShard, strictCapacity, highPriPoolRatio, 32 - numShardBits); + } + + cache->numShards = numShards; + + cache->shardedCache.shardMask = (1 << numShardBits) - 1; + cache->shardedCache.strictCapacity = strictCapacity; + cache->shardedCache.capacity = capacity; + cache->shardedCache.lastId = 1; + + taosThreadMutexInit(&cache->shardedCache.capacityMutex, NULL); + + return cache; +} + +void taosLRUCacheCleanup(SLRUCache *cache) { + if (cache) { + if (cache->shards) { + int numShards = cache->numShards; + assert(numShards > 0); + for (int i = 0; i < numShards; ++i) { + taosLRUCacheShardCleanup(&cache->shards[i]); + } + taosMemoryFree(cache->shards); + cache->shards = 0; + } + + taosThreadMutexDestroy(&cache->shardedCache.capacityMutex); + + taosMemoryFree(cache); + } +} + +LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, + _taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority) { + uint32_t hash = TAOS_LRU_CACHE_SHARD_HASH32(key, keyLen); + uint32_t shardIndex = hash & cache->shardedCache.shardMask; + + return taosLRUCacheShardInsert(&cache->shards[shardIndex], key, keyLen, hash, value, charge, deleter, handle, priority); +} + +LRUHandle *taosLRUCacheLookup(SLRUCache *cache, const void *key, size_t keyLen) { + uint32_t hash = TAOS_LRU_CACHE_SHARD_HASH32(key, keyLen); + uint32_t shardIndex = hash & cache->shardedCache.shardMask; + + return taosLRUCacheShardLookup(&cache->shards[shardIndex], key, keyLen, hash); +} + +void taosLRUCacheErase(SLRUCache *cache, const void *key, size_t keyLen) { + uint32_t hash = TAOS_LRU_CACHE_SHARD_HASH32(key, keyLen); + uint32_t shardIndex = hash & cache->shardedCache.shardMask; + + return taosLRUCacheShardErase(&cache->shards[shardIndex], key, keyLen, hash); +} + +void taosLRUCacheEraseUnrefEntries(SLRUCache *cache) { + int numShards = cache->numShards; + for (int i = 0; i < numShards; ++i) { + taosLRUCacheShardEraseUnrefEntries(&cache->shards[i]); + } +} + +bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle) { + if (handle == NULL) { + return false; + } + + uint32_t hash = ((SLRUEntry *) handle)->hash; + uint32_t shardIndex = hash & cache->shardedCache.shardMask; + + return taosLRUCacheShardRef(&cache->shards[shardIndex], handle); +} + +bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef) { + if (handle == NULL) { + return false; + } + + uint32_t hash = ((SLRUEntry *) handle)->hash; + uint32_t shardIndex = hash & cache->shardedCache.shardMask; + + return taosLRUCacheShardRelease(&cache->shards[shardIndex], handle, eraseIfLastRef); +} + +void* taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle) { + return ((SLRUEntry*) handle)->value; +} + +size_t taosLRUCacheGetUsage(SLRUCache *cache) { + size_t usage = 0; + + for (int i = 0; i < cache->numShards; ++i) { + usage += taosLRUCacheShardGetUsage(&cache->shards[i]); + } + + return usage; +} + +size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache) { + size_t usage = 0; + + for (int i = 0; i < cache->numShards; ++i) { + usage += taosLRUCacheShardGetPinnedUsage(&cache->shards[i]); + } + + return usage; +} + +void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity) { + uint32_t numShards = cache->numShards; + size_t perShard = (capacity + (numShards = 1)) / numShards; + + taosThreadMutexLock(&cache->shardedCache.capacityMutex); + + for (int i = 0; i < numShards; ++i) { + taosLRUCacheShardSetCapacity(&cache->shards[i], perShard); + } + + cache->shardedCache.capacity = capacity; + + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); +} + +size_t taosLRUCacheGetCapacity(SLRUCache *cache) { + size_t capacity = 0; + + taosThreadMutexLock(&cache->shardedCache.capacityMutex); + + capacity = cache->shardedCache.capacity; + + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); + + return capacity; +} + +void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict) { + uint32_t numShards = cache->numShards; + + taosThreadMutexLock(&cache->shardedCache.capacityMutex); + + for (int i = 0; i < numShards; ++i) { + taosLRUCacheShardSetStrictCapacity(&cache->shards[i], strict); + } + + cache->shardedCache.strictCapacity = strict; + + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); +} + +bool taosLRUCacheIsStrictCapacity(SLRUCache *cache) { + bool strict = false; + + taosThreadMutexLock(&cache->shardedCache.capacityMutex); + + strict = cache->shardedCache.strictCapacity; + + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); + + return strict; +} diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 0d70ab82c0..b5916e2d76 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -589,7 +589,10 @@ class TDDnodes: psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'" processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") while(processID): - killCmd = "kill -9 %s > /dev/null 2>&1" % processID + if platform.system().lower() == 'windows': + killCmd = "kill -9 %s > nul 2>&1" % processID + else: + killCmd = "kill -9 %s > /dev/null 2>&1" % processID os.system(killCmd) time.sleep(1) processID = subprocess.check_output( @@ -599,7 +602,10 @@ class TDDnodes: psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") while(processID): - killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + if platform.system().lower() == 'windows': + killCmd = "kill -TERM %s > nul 2>&1" % processID + else: + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID os.system(killCmd) time.sleep(1) processID = subprocess.check_output( diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 57c3c01bb0..db8a055362 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -22,7 +22,7 @@ # ---- dnode ./test.sh -f tsim/dnode/create_dnode.sim -./test.sh -f tsim/dnode/drop_dnode_mnode.sim +./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim # ---- insert ./test.sh -f tsim/insert/basic0.sim @@ -57,9 +57,10 @@ # ---- mnode ./test.sh -f tsim/mnode/basic1.sim -#./test.sh -f tsim/mnode/basic2.sim +./test.sh -f tsim/mnode/basic2.sim ./test.sh -f tsim/mnode/basic3.sim ./test.sh -f tsim/mnode/basic4.sim +./test.sh -f tsim/mnode/basic5.sim # ---- show ./test.sh -f tsim/show/basic.sim @@ -71,6 +72,7 @@ ./test.sh -f tsim/stream/basic0.sim ./test.sh -f tsim/stream/basic1.sim ./test.sh -f tsim/stream/basic2.sim +# ./test.sh -f tsim/stream/distributeInterval0.sim # ./test.sh -f tsim/stream/session0.sim # ./test.sh -f tsim/stream/session1.sim # ./test.sh -f tsim/stream/state0.sim diff --git a/tests/script/tsim/dnode/create_dnode.sim b/tests/script/tsim/dnode/create_dnode.sim index 8a28897d5a..730b80b866 100644 --- a/tests/script/tsim/dnode/create_dnode.sim +++ b/tests/script/tsim/dnode/create_dnode.sim @@ -182,16 +182,5 @@ if $rows != 15 then return -1 endi -print =============== drop dnode -#sql drop dnode 2; -#sql show dnodes; -#if $rows != 1 then -# return -1 -#endi - -#if $data00 != 1 then -# return -1 -#endi - system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_mnode.sim b/tests/script/tsim/dnode/drop_dnode_has_mnode.sim new file mode 100644 index 0000000000..1dbec2c04d --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_mnode.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != offline then + goto step1 +endi + +print =============== step2 drop dnode 3 +sql_error drop dnode 1 +sql drop dnode 3 + +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print =============== step3: create mnode on dnode 2 +sql create mnode on dnode 2 +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes -x step3 +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $data(1)[2] != leader then + goto step3 +endi +if $data(2)[2] != follower then + goto step3 +endi + +print =============== step4: drop dnode 2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi + +print show dnodes; +sql show mnodes +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 1 then + return -1 +endi +if $data(1)[2] != leader then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_mnode.sim b/tests/script/tsim/dnode/drop_dnode_mnode.sim deleted file mode 100644 index e0a85b9803..0000000000 --- a/tests/script/tsim/dnode/drop_dnode_mnode.sim +++ /dev/null @@ -1,52 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start -sql connect - -print =============== step1 create dnode2 -sql create dnode $hostname port 7200 - -$x = 0 -step1: - $ = $x + 1 - sleep 1000 - if $x == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $data00 $data01 $data02 $data03 $data04 $data05 -print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 2 then - return -1 -endi -if $data(1)[4] != ready then - goto step1 -endi -if $data(2)[4] != ready then - goto step1 -endi - -sql create dnode $hostname port 7300 -sql drop dnode 3 -sql_error drop dnode 1 - -print =============== step2: create mnode -sql create mnode on dnode 2 - -print =============== step3: drop dnode 3 -sql drop dnode 2 -sql show dnodes; -if $rows != 1 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -return -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim similarity index 90% rename from tests/script/tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim rename to tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim index cb9f4173ac..c5cc765b88 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim @@ -21,7 +21,7 @@ sql create dnode $hostname port 7500 $x = 0 step1: - $ = $x + 1 + $x = $x + 1 sleep 1000 if $x == 10 then print ====> dnode not ready! @@ -69,11 +69,12 @@ sql_error redistribute vgroup 2 dnode 5 dnode 3 sql_error redistribute vgroup 2 dnode 2 dnode 3 sql_error redistribute vgroup 2 dnode 2 dnode 2 sql_error redistribute vgroup 3 dnode 2 dnode 2 +sql_error redistribute vgroup 2 dnode 2 dnode 2 dnode 3 system sh/exec.sh -n dnode5 -s start $x = 0 step2: - $ = $x + 1 + $x = $x + 1 sleep 1000 if $x == 10 then print ====> dnode not ready! @@ -112,9 +113,9 @@ $follower2 = 0 $x = 0 step3: - $ = $x + 1 + $x = $x + 1 sleep 1000 - if $x == 10 then + if $x == 60 then print ====> db not ready! return -1 endi @@ -149,31 +150,51 @@ print leader $leaderVnode print follower1 $follower1 print follower2 $follower2 +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + print =============== step32: move follower2 print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 -return +sql show d1.tables +if $rows != 1 then + return -1 +endi + print =============== step33: move follower1 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 +sql show d1.tables +if $rows != 1 then + return -1 +endi print =============== step34: move follower2 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +sql show d1.tables +if $rows != 1 then + return -1 +endi print =============== step35: move follower1 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 +sql show d1.tables +if $rows != 1 then + return -1 +endi print =============== step4: move leader -return - -print =============== step3: drop dnode 3 -return system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/mnode/basic2.sim b/tests/script/tsim/mnode/basic2.sim index 78558263d6..ff0101dd8e 100644 --- a/tests/script/tsim/mnode/basic2.sim +++ b/tests/script/tsim/mnode/basic2.sim @@ -92,6 +92,8 @@ sql show mnodes if $rows != 2 then return -1 endi +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 sql show users if $rows != 2 then @@ -111,6 +113,8 @@ step3: return -1 endi sql show dnodes -x step3 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 if $data(1)[4] != ready then goto step3 endi diff --git a/tests/script/tsim/mnode/basic3.sim b/tests/script/tsim/mnode/basic3.sim index dec036faaf..695e23f3ac 100644 --- a/tests/script/tsim/mnode/basic3.sim +++ b/tests/script/tsim/mnode/basic3.sim @@ -39,11 +39,9 @@ endi print =============== step2: create mnode 2 sql create mnode on dnode 2 sql create mnode on dnode 3 -return -system sh/exec.sh -n dnode1 -s stop -x SIGKILL sql_error create mnode on dnode 4 - +$leaderExist = 0 $x = 0 step2: $x = $x + 1 @@ -52,13 +50,20 @@ step2: return -1 endi sql show mnodes -x step2 -if $data(1)[2] != leader then - goto step2 + +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $data(1)[2] == leader then + $leaderExist = 1 endi -if $data(2)[2] != follower then - goto step2 +if $data(2)[2] == leader then + $leaderExist = 1 endi -if $data(3)[2] != follower then +if $data(3)[2] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then goto step2 endi @@ -70,10 +75,10 @@ if $rows != 2 then endi # wait mnode2 mnode3 recv data finish -sleep 10000 +sleep 1000 print =============== step4: stop dnode1 -system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop -x SIGKILL $x = 0 step4: @@ -92,13 +97,22 @@ if $rows != 2 then return -1 endi -sleep 1000 -sql show dnodes +$x = 0 +step41: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes -x step41 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 if $data(2)[4] != ready then - return -1 + goto step41 endi if $data(3)[4] != ready then - return -1 + goto step41 endi print =============== step5: stop dnode1 @@ -117,15 +131,29 @@ print $data(1)[0] $data(1)[1] $data(1)[2] print $data(2)[0] $data(2)[1] $data(2)[2] print $data(3)[0] $data(3)[1] $data(3)[2] -if $data(2)[2] != offline then - goto step5 -endi - sql show users if $rows != 2 then return -1 endi +$x = 0 +step51: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes -x step51 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $data(1)[4] != ready then + goto step51 +endi +if $data(3)[4] != ready then + goto step51 +endi + print =============== step6: stop dnode1 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s stop @@ -147,6 +175,24 @@ if $rows != 2 then return -1 endi +$x = 0 +step61: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes -x step61 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $data(1)[4] != ready then + goto step61 +endi +if $data(2)[4] != ready then + goto step61 +endi + system sh/exec.sh -n dnode1 -s stop system sh/exec.sh -n dnode2 -s stop system sh/exec.sh -n dnode3 -s stop diff --git a/tests/script/tsim/mnode/basic4.sim b/tests/script/tsim/mnode/basic4.sim index 88deb5af89..41524946be 100644 --- a/tests/script/tsim/mnode/basic4.sim +++ b/tests/script/tsim/mnode/basic4.sim @@ -117,7 +117,7 @@ if $data(3)[3] != ready then endi print =============== step5: drop mnode 3 and stop dnode3 -system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop -x SIGKILL sql_error drop mnode on dnode 3 $x = 0 diff --git a/tests/script/tsim/mnode/basic5.sim b/tests/script/tsim/mnode/basic5.sim new file mode 100644 index 0000000000..399dced169 --- /dev/null +++ b/tests/script/tsim/mnode/basic5.sim @@ -0,0 +1,349 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== step1: create dnodes +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 5 then + return -1 + endi +sql show dnodes +if $data(1)[4] != ready then + goto step1 +endi + +print =============== step2: create dnodes - with error +sql_error create mnode on dnode 1; +sql_error create mnode on dnode 2; +sql_error create mnode on dnode 3; +sql_error create mnode on dnode 4; +sql_error create mnode on dnode 5; +sql_error create mnode on dnode 6; + +print =============== step3: create mnode 2 and 3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 5 then + return -1 + endi +sql show dnodes +if $data(2)[4] != ready then + goto step3 +endi +if $data(3)[4] != ready then + goto step3 +endi +if $data(4)[4] != ready then + goto step3 +endi + +sql create mnode on dnode 2 +sql create mnode on dnode 3 + +$x = 0 +step31: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show mnodes +if $data(1)[2] != leader then + goto step31 +endi +if $data(2)[2] != follower then + goto step31 +endi +if $data(3)[2] != follower then + goto step31 +endi + +print =============== step4: create dnodes - with error +sql_error create mnode on dnode 1 +sql_error create mnode on dnode 2; +sql_error create mnode on dnode 3; +sql_error create mnode on dnode 4; +sql_error create mnode on dnode 5; +sql_error create mnode on dnode 6; + +print =============== step5: drop mnodes - with error +sql_error drop mnode on dnode 1 +sql_error drop mnode on dnode 4 +sql_error drop mnode on dnode 5 +sql_error drop mnode on dnode 6 + +system sh/exec.sh -n dnode2 -s stop -x SIGKILL +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $data(1)[4] != ready then + goto step5 +endi +if $data(2)[4] != offline then + goto step5 +endi +if $data(3)[4] != ready then + goto step5 +endi +if $data(4)[4] != ready then + goto step5 +endi + +sql_error drop mnode on dnode 2 + +system sh/exec.sh -n dnode2 -s start +$x = 0 +step51: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $data(1)[4] != ready then + goto step51 +endi +if $data(2)[4] != ready then + goto step51 +endi +if $data(3)[4] != ready then + goto step51 +endi +if $data(4)[4] != ready then + goto step51 +endi + +print =============== step6: stop mnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sql_error drop mnode on dnode 1 + +$x = 0 +step61: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +$leaderNum = 0 +if $data(2)[2] == leader then + $leaderNum = 1 +endi +if $data(3)[2] == leader then + $leaderNum = 1 +endi +if $leaderNum != 1 then + goto step61 +endi + +print =============== step7: start mnode1 and wait it online +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step71: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $data(1)[4] != ready then + goto step71 +endi +if $data(2)[4] != ready then + goto step71 +endi +if $data(3)[4] != ready then + goto step71 +endi +if $data(4)[4] != ready then + goto step71 +endi + +print =============== step8: stop mnode1 and drop it +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sql_error drop mnode on dnode 1 + +$x = 0 +step81: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +$leaderNum = 0 +if $data(1)[2] == leader then + $leaderNum = 1 +endi +if $data(2)[2] == leader then + $leaderNum = 1 +endi +if $data(3)[2] == leader then + $leaderNum = 1 +endi +if $leaderNum != 1 then + goto step81 +endi +if $data(1)[3] != dropping then + goto step81 +endi + +print =============== step9: start mnode1 and wait it dropped +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step91: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $data(1)[4] != ready then + goto step91 +endi +if $data(2)[4] != ready then + goto step91 +endi +if $data(3)[4] != ready then + goto step91 +endi +if $data(4)[4] != ready then + goto step91 +endi + +$x = 0 +step92: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +$leaderNum = 0 +if $data(1)[2] == leader then + $leaderNum = 1 +endi +if $data(2)[2] == leader then + $leaderNum = 1 +endi +if $data(3)[2] == leader then + $leaderNum = 1 +endi +if $leaderNum != 1 then + goto step92 +endi +if $rows != 2 then + goto step92 +endi + +print =============== stepa: create mnode1 again +sql create mnode on dnode 1 +$x = 0 +stepa: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +$leaderNum = 0 +if $data(2)[2] == leader then + $leaderNum = 1 +endi +if $data(3)[2] == leader then + $leaderNum = 1 +endi +if $data(3)[2] == leader then + $leaderNum = 1 +endi +if $leaderNum == 0 then + goto stepa +endi +if $leaderNum != 1 then + return -1 +endi + +$x = 0 +stepb: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto stepb +endi +if $data(2)[4] != ready then + goto stepb +endi +if $data(3)[4] != ready then + goto stepb +endi +if $data(4)[4] != ready then + goto stepb +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim new file mode 100644 index 0000000000..f4f3e04f0a --- /dev/null +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +sql create dnode $hostname2 port 7200 + +system sh/exec.sh -n dnode2 -s start + +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); +sql create table ts3 using st tags(3,2,2); +sql create table ts4 using st tags(4,2,2); +sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); + +sleep 1000 + +sql insert into ts1 values(1648791213001,1,12,3,1.0); +sql insert into ts2 values(1648791213001,1,12,3,1.0); + +sql insert into ts3 values(1648791213001,1,12,3,1.0); +sql insert into ts4 values(1648791213001,1,12,3,1.0); + +sql insert into ts1 values(1648791213002,NULL,NULL,NULL,NULL); +sql insert into ts2 values(1648791213002,NULL,NULL,NULL,NULL); + +sql insert into ts3 values(1648791213002,NULL,NULL,NULL,NULL); +sql insert into ts4 values(1648791213002,NULL,NULL,NULL,NULL); + +sql insert into ts1 values(1648791223002,2,2,3,1.1); +sql insert into ts1 values(1648791233003,3,2,3,2.1); +sql insert into ts2 values(1648791243004,4,2,43,73.1); +sql insert into ts1 values(1648791213002,24,22,23,4.1); +sql insert into ts1 values(1648791243005,4,20,3,3.1); +sql insert into ts2 values(1648791243006,4,2,3,3.1) (1648791243007,4,2,3,3.1) ; +sql insert into ts1 values(1648791243008,4,2,30,3.1) (1648791243009,4,2,3,3.1) (1648791243010,4,2,3,3.1) ; +sql insert into ts2 values(1648791243011,4,2,3,3.1) (1648791243012,34,32,33,3.1) (1648791243013,4,2,3,3.1) (1648791243014,4,2,13,3.1); +sql insert into ts1 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ; +sql insert into ts2 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) (1648791233004,13,12,13,2.1) ; +sql insert into ts1 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ; + +sql insert into ts3 values(1648791223002,2,2,3,1.1); +sql insert into ts4 values(1648791233003,3,2,3,2.1); +sql insert into ts3 values(1648791243004,4,2,43,73.1); +sql insert into ts4 values(1648791213002,24,22,23,4.1); +sql insert into ts3 values(1648791243005,4,20,3,3.1); +sql insert into ts4 values(1648791243006,4,2,3,3.1) (1648791243007,4,2,3,3.1) ; +sql insert into ts3 values(1648791243008,4,2,30,3.1) (1648791243009,4,2,3,3.1) (1648791243010,4,2,3,3.1) ; +sql insert into ts4 values(1648791243011,4,2,3,3.1) (1648791243012,34,32,33,3.1) (1648791243013,4,2,3,3.1) (1648791243014,4,2,13,3.1); +sql insert into ts3 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ; +sql insert into ts4 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) (1648791233004,13,12,13,2.1) ; +sql insert into ts3 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ; + +$loop_count = 0 +loop1: +sql select * from streamtST1; + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 8 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 4 then + print =====data02=$data02 + goto loop1 +endi + +if $data03 != 4 then + print ======$data03 + return -1 +endi + +if $data04 != 52 then + print ======$data04 + return -1 +endi + +if $data05 != 13 then + print ======$data05 + return -1 +endi + +# row 1 +if $data11 != 6 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 6 then + print =====data12=$data12 + goto loop1 +endi + +if $data13 != 92 then + print ======$data13 + return -1 +endi + +if $data14 != 22 then + print ======$data14 + return -1 +endi + +if $data15 != 3 then + print ======$data15 + return -1 +endi + +# row 2 +if $data21 != 4 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 4 then + print =====data22=$data22 + goto loop1 +endi + +if $data23 != 32 then + print ======$data23 + return -1 +endi + +if $data24 != 12 then + print ======$data24 + return -1 +endi + +if $data25 != 3 then + print ======$data25 + return -1 +endi + +# row 3 +if $data31 != 30 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 30 then + print =====data32=$data32 + goto loop1 +endi + +if $data33 != 180 then + print ======$data33 + return -1 +endi + +if $data34 != 42 then + print ======$data34 + return -1 +endi + +if $data35 != 3 then + print ======$data35 + return -1 +endi + +sql select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/stream/session0.sim b/tests/script/tsim/stream/session0.sim index c021e14de7..2a737578bc 100644 --- a/tests/script/tsim/stream/session0.sim +++ b/tests/script/tsim/stream/session0.sim @@ -231,8 +231,10 @@ sql use test3; sql create table t1(ts timestamp, a int, b int , c int, d double); sql create stream streams3 trigger at_once watermark 1d into streamt3 as select _wstartts, min(b), a,c from t1 session(ts,10s); sql create stream streams4 trigger at_once watermark 1d into streamt4 as select _wstartts, max(b), a,c from t1 session(ts,10s); -sql create stream streams5 trigger at_once watermark 1d into streamt5 as select _wstartts, max(b), a,c from t1 session(ts,10s); -sql create stream streams6 trigger at_once watermark 1d into streamt6 as select _wstartts, max(b), a,c from t1 session(ts,10s); +sql create stream streams5 trigger at_once watermark 1d into streamt5 as select _wstartts, top(b,3), a,c from t1 session(ts,10s); +sql create stream streams6 trigger at_once watermark 1d into streamt6 as select _wstartts, bottom(b,3), a,c from t1 session(ts,10s); +sql create stream streams7 trigger at_once watermark 1d into streamt7 as select _wstartts, spread(a), elapsed(ts), hyperloglog(a) from t1 session(ts,10s); +sql create stream streams8 trigger at_once watermark 1d into streamt8 as select _wstartts, histogram(a,"user_input", "[1,3,5,7]", 1), histogram(a,"user_input", "[1,3,5,7]", 0) from t1 session(ts,10s); sql insert into t1 values(1648791213001,1,1,1,1.0); sql insert into t1 values(1648791213002,2,3,2,3.4); sql insert into t1 values(1648791213003,4,9,3,4.8); @@ -279,4 +281,16 @@ if $rows == 0 then goto loop3 endi +sql select * from streamt7; +if $rows == 0 then + print ======$rows + goto loop3 +endi + +sql select * from streamt8; +if $rows == 0 then + print ======$rows + goto loop3 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/1-insert/alter_stable.py b/tests/system-test/1-insert/alter_stable.py index e8c3544152..c92efb403c 100644 --- a/tests/system-test/1-insert/alter_stable.py +++ b/tests/system-test/1-insert/alter_stable.py @@ -122,10 +122,10 @@ class TDTestCase: for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']: for j in [1,2,3]: - tdSql.error(f'alter table {stbname} modify tag t{j} {i}') + tdSql.error(f'alter stable {stbname} modify tag t{j} {i}') for i in ['int','unsigned int','float','binary(10)','nchar(10)']: - tdSql.error(f'alter table {stbname} modify tag t8 {i}') - tdSql.error(f'alter table {stbname} modify tag t4 int') + tdSql.error(f'alter stable {stbname} modify tag t8 {i}') + tdSql.error(f'alter stable {stbname} modify tag t4 int') tdSql.execute(f'drop database {dbname}') def run(self): diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index 53e3793dcf..3c0def86e4 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -145,10 +145,17 @@ class TDTestCase: tdSql.execute(f'alter table {dbname}.{tbname} rename column c1 c21') tdSql.query(f'describe {dbname}.{tbname}') tdSql.checkData(1,0,'c21') + # !bug TD-16423 + # tdSql.error(f'select c1 from {dbname}.{tbname}') + # tdSql.query(f'select c21 from {dbname}.{tbname}') + # tdSql.checkData(0,1,1) tdSql.execute(f'alter table {dbname}.{tbname} rename column `c21` c1') tdSql.query(f'describe {dbname}.{tbname}') tdSql.checkData(1,0,'c1') - + # !bug TD-16423 + # tdSql.error(f'select c1 from {dbname}.{tbname}') + # tdSql.query(f'select c1 from {dbname}.{tbname}') + # tdSql.checkData(0,1,1) tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bigint') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 double') tdSql.error(f'alter table {dbname}.{tbname} modify column c4 int') @@ -158,9 +165,109 @@ class TDTestCase: tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') tdSql.execute(f'drop database {dbname}') + def alter_stb_column_check(self): + dbname = self.get_long_name(length=10, mode="letters") + tdSql.execute(f'create database if not exists {dbname}') + stbname = self.get_long_name(length=3, mode="letters") + tbname = self.get_long_name(length=3, mode="letters") + tdSql.execute(f'create database if not exists {dbname}') + tdSql.execute(f'use {dbname}') + tdSql.execute( + f'create table {stbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \ + c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) ') + tdSql.execute(f'create table {tbname} using {stbname} tags(1)') + tdSql.execute(f'insert into {tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') + tdSql.execute(f'alter table {stbname} add column c14 int') + tdSql.query(f'select c14 from {stbname}') + tdSql.checkRows(1) + tdSql.execute(f'alter table {stbname} add column `c15` int') + tdSql.query(f'select c15 from {stbname}') + tdSql.checkRows(1) + tdSql.query(f'describe {stbname}') + tdSql.checkRows(17) + tdSql.execute(f'alter table {stbname} drop column c14') + tdSql.query(f'describe {stbname}') + tdSql.checkRows(16) + tdSql.execute(f'alter table {stbname} drop column `c15`') + tdSql.query(f'describe {stbname}') + tdSql.checkRows(15) + tdSql.execute(f'alter table {stbname} modify column c12 binary(30)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(12,2,30) + tdSql.execute(f'alter table {stbname} modify column `c12` binary(35)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(12,2,35) + tdSql.error(f'alter table {stbname} modify column `c12` binary(34)') + tdSql.execute(f'alter table {stbname} modify column c13 nchar(30)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(13,2,30) + tdSql.error(f'alter table {stbname} modify column c13 nchar(29)') + tdSql.error(f'alter table {stbname} rename column c1 c21') + tdSql.error(f'alter table {stbname} modify column c1 int') + tdSql.error(f'alter table {stbname} modify column c4 int') + tdSql.error(f'alter table {stbname} modify column c8 int') + tdSql.error(f'alter table {stbname} modify column c1 unsigned int') + tdSql.error(f'alter table {stbname} modify column c9 double') + tdSql.error(f'alter table {stbname} modify column c10 float') + tdSql.error(f'alter table {stbname} modify column c11 int') + tdSql.execute(f'drop database {dbname}') + def alter_stb_tag_check(self): + dbname = self.get_long_name(length=10, mode="letters") + tdSql.execute(f'create database if not exists {dbname}') + stbname = self.get_long_name(length=3, mode="letters") + tbname = self.get_long_name(length=3, mode="letters") + tdSql.execute(f'create database if not exists {dbname}') + tdSql.execute(f'use {dbname}') + tdSql.execute( + f'create table {stbname} (ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int, \ + t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) ') + tdSql.execute(f'create table {tbname} using {stbname} tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') + tdSql.execute(f'insert into {tbname} values(now,1)') + + tdSql.execute(f'alter table {stbname} add tag t14 int') + tdSql.query(f'select t14 from {stbname}') + tdSql.checkRows(1) + tdSql.execute(f'alter table {stbname} add tag `t15` int') + tdSql.query(f'select t14 from {stbname}') + tdSql.checkRows(1) + tdSql.query(f'describe {stbname}') + tdSql.checkRows(18) + tdSql.execute(f'alter table {stbname} drop tag t14') + tdSql.query(f'describe {stbname}') + tdSql.checkRows(17) + tdSql.execute(f'alter table {stbname} drop tag `t15`') + tdSql.query(f'describe {stbname}') + tdSql.checkRows(16) + tdSql.execute(f'alter table {stbname} modify tag t12 binary(30)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(14,2,30) + tdSql.execute(f'alter table {stbname} modify tag `t12` binary(35)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(14,2,35) + tdSql.error(f'alter table {stbname} modify tag `t12` binary(34)') + tdSql.execute(f'alter table {stbname} modify tag t13 nchar(30)') + tdSql.query(f'describe {stbname}') + tdSql.checkData(15,2,30) + tdSql.error(f'alter table {stbname} modify tag t13 nchar(29)') + tdSql.execute(f'alter table {stbname} rename tag t1 t21') + tdSql.query(f'describe {stbname}') + tdSql.checkData(3,0,'t21') + tdSql.execute(f'alter table {stbname} rename tag `t21` t1') + tdSql.query(f'describe {stbname}') + tdSql.checkData(3,0,'t1') + + for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']: + for j in [1,2,3]: + tdSql.error(f'alter table {stbname} modify tag t{j} {i}') + for i in ['int','unsigned int','float','binary(10)','nchar(10)']: + tdSql.error(f'alter table {stbname} modify tag t8 {i}') + tdSql.error(f'alter table {stbname} modify tag t4 int') + tdSql.execute(f'drop database {dbname}') def run(self): self.alter_tb_tag_check() self.alter_ntb_column_check() + self.alter_stb_column_check() + self.alter_stb_tag_check() def stop(self): tdSql.close() diff --git a/tests/system-test/1-insert/influxdb_line_taosc_insert.py b/tests/system-test/1-insert/influxdb_line_taosc_insert.py index 0ddeba4665..10e81892ef 100644 --- a/tests/system-test/1-insert/influxdb_line_taosc_insert.py +++ b/tests/system-test/1-insert/influxdb_line_taosc_insert.py @@ -23,6 +23,10 @@ from util.sql import * import threading from util.types import TDSmlProtocolType, TDSmlTimestampType from util.common import tdCom +import platform +import io +if platform.system().lower() == 'windows': + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): diff --git a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py index 23404330ed..649f0101af 100644 --- a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py @@ -22,6 +22,10 @@ from util.sql import * from util.common import tdCom from util.types import TDSmlProtocolType, TDSmlTimestampType import threading +import platform +import io +if platform.system().lower() == 'windows': + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): diff --git a/tests/system-test/2-query/To_iso8601.py b/tests/system-test/2-query/To_iso8601.py index 57bcca638c..da7b7e272f 100644 --- a/tests/system-test/2-query/To_iso8601.py +++ b/tests/system-test/2-query/To_iso8601.py @@ -1,9 +1,10 @@ +import time from time import sleep from util.log import * from util.sql import * from util.cases import * - +import os @@ -12,28 +13,47 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - - def run(self): # sourcery skip: extract-duplicate-method - tdSql.prepare() - # get system timezone - today_date = datetime.datetime.strptime( - datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d") + self.rowNum = 10 + self.ts = 1640966400000 # 2022-1-1 00:00:00.000 + def check_customize_param_ms(self): + time_zone = time.strftime('%z') + tdSql.execute('create database db1 precision "ms"') + tdSql.execute('use db1') + tdSql.execute('create table if not exists ntb(ts timestamp, c1 int, c2 timestamp)') + for i in range(self.rowNum): + tdSql.execute("insert into ntb values(%d, %d, %d)" + % (self.ts + i, i + 1, self.ts + i)) + tdSql.query('select to_iso8601(ts) from ntb') + for i in range(self.rowNum): + tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{time_zone}') + + timezone_list = ['+0000','+0100','+0200','+0300','+0330','+0400','+0500','+0530','+0600','+0700','+0800','+0900','+1000','+1100','+1200',\ + '+00','+01','+02','+03','+04','+05','+06','+07','+08','+09','+10','+11','+12',\ + '+00:00','+01:00','+02:00','+03:00','+03:30','+04:00','+05:00','+05:30','+06:00','+07:00','+08:00','+09:00','+10:00','+11:00','+12:00',\ + '-0000','-0100','-0200','-0300','-0400','-0500','-0600','-0700','-0800','-0900','-1000','-1100','-1200',\ + '-00','-01','-02','-03','-04','-05','-06','-07','-08','-09','-10','-11','-12',\ + '-00:00','-01:00','-02:00','-03:00','-04:00','-05:00','-06:00','-07:00','-08:00','-09:00','-10:00','-11:00','-12:00',\ + 'z','Z'] + for j in timezone_list: + tdSql.query(f'select to_iso8601(ts,"{j}") from ntb') + for i in range(self.rowNum): + tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{j}') + + error_param_list = [0,100.5,'a','!'] + for i in error_param_list: + tdSql.error(f'select to_iso8601(ts,"{i}") from ntb') + #! bug TD-16372:对于错误的时区,缺少校验 + error_timezone_param = ['+13','-13','+1300','-1300','+0001','-0001','-0330','-0530'] + for i in error_timezone_param: + tdSql.error(f'select to_iso8601(ts,"{i}") from ntb') + + def check_base_function(self): + tdSql.prepare() tdLog.printNoPrefix("==========step1:create tables==========") - tdSql.execute( - '''create table if not exists ntb - (ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) - ''' - ) - tdSql.execute( - '''create table if not exists stb - (ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int) - ''' - ) - tdSql.execute( - '''create table if not exists stb_1 using stb tags(100) - ''' - ) + tdSql.execute('create table if not exists ntb(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp)') + tdSql.execute('create table if not exists stb(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int)') + tdSql.execute('create table if not exists stb_1 using stb tags(100)') tdLog.printNoPrefix("==========step2:insert data==========") tdSql.execute('insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())') @@ -48,12 +68,9 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select to_iso8601(ts) from ntb where ts=today()") tdSql.checkRows(1) - # tdSql.checkData(0,0,10) - for i in range(1,10): + for i in range(0,3): tdSql.query("select to_iso8601(1) from ntb") - tdSql.checkData(0,0,"1970-01-01T08:00:01+0800") - i+=1 - sleep(0.2) + tdSql.checkData(i,0,"1970-01-01T08:00:01+0800") tdSql.checkRows(3) tdSql.query("select to_iso8601(ts) from ntb") tdSql.checkRows(3) @@ -67,53 +84,34 @@ class TDTestCase: tdSql.error("select to_iso8601(timezone()) from ntb") tdSql.error("select to_iso8601('abc') from ntb") - tdSql.query("select to_iso8601(today()) *null from ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) +null from ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) -null from ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) /null from ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - - tdSql.query("select to_iso8601(today()) *null from db.ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) +null from db.ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) -null from db.ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) /null from db.ntb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - # tdSql.query("select to_iso8601(-1) from ntb") + for i in ['+','-','*','/']: + tdSql.query(f"select to_iso8601(today()) {i}null from ntb") + tdSql.checkRows(3) + tdSql.checkData(0,0,None) + tdSql.query(f"select to_iso8601(today()) {i}null from db.ntb") + tdSql.checkRows(3) + tdSql.checkData(0,0,None) tdSql.query("select to_iso8601(9223372036854775807) from ntb") tdSql.checkRows(3) - # bug TD-14896 + # bug TD-15207 # tdSql.query("select to_iso8601(10000000000) from ntb") # tdSql.checkData(0,0,None) # tdSql.query("select to_iso8601(-1) from ntb") # tdSql.checkRows(3) # tdSql.query("select to_iso8601(-10000000000) from ntb") # tdSql.checkData(0,0,None) - tdSql.error("select to_iso8601(1.5) from ntb") - tdSql.error("select to_iso8601(1.5) from db.ntb") - tdSql.error("select to_iso8601('a') from ntb") - tdSql.error("select to_iso8601(c2) from ntb") + err_param = [1.5,'a','c2'] + for i in err_param: + tdSql.error(f"select to_iso8601({i}) from ntb") + tdSql.error(f"select to_iso8601({i}) from db.ntb") + tdSql.query("select to_iso8601(now) from stb") + tdSql.checkRows(3) tdSql.query("select to_iso8601(now()) from stb") tdSql.checkRows(3) - for i in range(1,10): - tdSql.query("select to_iso8601(1) from stb") - tdSql.checkData(0,0,"1970-01-01T08:00:01+0800") - i+=1 - sleep(0.2) + tdSql.query("select to_iso8601(1) from stb") + for i in range(0,3): + tdSql.checkData(i,0,"1970-01-01T08:00:01+0800") tdSql.checkRows(3) tdSql.query("select to_iso8601(ts) from stb") tdSql.checkRows(3) @@ -121,37 +119,17 @@ class TDTestCase: tdSql.checkRows(3) tdSql.query("select to_iso8601(ts)+'a' from stb ") tdSql.checkRows(3) + for i in ['+','-','*','/']: + tdSql.query(f"select to_iso8601(today()) {i}null from stb") + tdSql.checkRows(3) + tdSql.checkData(0,0,None) + tdSql.query(f"select to_iso8601(today()) {i}null from db.stb") + tdSql.checkRows(3) + tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) *null from stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) +null from stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) -null from stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) /null from stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) *null from db.stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) +null from db.stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) -null from db.stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - tdSql.query("select to_iso8601(today()) /null from db.stb") - tdSql.checkRows(3) - tdSql.checkData(0,0,None) - - # bug TD-14896 - # tdSql.query("select to_iso8601(-1) from ntb") - # tdSql.checkRows(3) - - + def run(self): # sourcery skip: extract-duplicate-method + self.check_base_function() + self.check_customize_param_ms() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index a3e976b490..d9c37be996 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -65,6 +65,60 @@ class TDTestCase: ''' ) + + def prepare_tag_datas(self): + # prepare datas + tdSql.execute("create database if not exists testdb keep 3650 days 1000") + tdSql.execute(" use testdb ") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) + ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + def check_result_auto(self ,origin_query , abs_query): abs_result = tdSql.getResult(abs_query) origin_result = tdSql.getResult(origin_query) @@ -95,6 +149,7 @@ class TDTestCase: tdLog.info("abs value check pass , it work as expected ,sql is \"%s\" "%abs_query ) def test_errors(self): + tdSql.execute("use testdb") error_sql_lists = [ "select abs from t1", # "select abs(-+--+c1) from t1", @@ -129,11 +184,16 @@ class TDTestCase: tdSql.error(error_sql) def support_types(self): + tdSql.execute("use testdb") type_error_sql_lists = [ "select abs(ts) from t1" , + "select abs(t0) from t1" , "select abs(c7) from t1", "select abs(c8) from t1", "select abs(c9) from t1", + "select abs(t7) from t1", + "select abs(t8) from t1", + "select abs(t9) from t1", "select abs(ts) from ct1" , "select abs(c7) from ct1", "select abs(c8) from ct1", @@ -171,6 +231,13 @@ class TDTestCase: "select abs(c5) from t1", "select abs(c6) from t1", + "select abs(t1) from ct1", + "select abs(t2) from ct1", + "select abs(t3) from ct1", + "select abs(t4) from ct1", + "select abs(t5) from ct1", + "select abs(t6) from ct1", + "select abs(c1) from ct1", "select abs(c2) from ct1", "select abs(c3) from ct1", @@ -447,6 +514,38 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ") + def test_tag_compute_for_scalar_function(self): + + tdSql.execute("use testdb") + + self.check_result_auto( "select c1, t2, t3 , t4, t5 from ct4 ", "select (c1), abs(t2) ,abs(t3), abs(t4), abs(t5) from ct4") + self.check_result_auto( "select c1+2, t2+2, t3 , t4, t5 from ct4 ", "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from ct4") + self.check_result_auto( "select c1+2, t2+2, t3 , t4, t5 from stb1 order by t1 ", "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from stb1 order by t1") + + # bug need fix + + # tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash + tdSql.query("select c1 ,t1 from stb1 where t1 =0 ") + tdSql.checkRows(13) + # tdSql.query("select t1 from stb1 where t1 >0 ") + # tdSql.checkRows(3) + # tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)") + # tdSql.checkData(0,0,61) + # tdSql.query("select distinct(c1) ,t1 from stb1") + # tdSql.checkRows(11) + # tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") + # tdSql.checkData(0,3,33333) + + # tag filter with abs function + # tdSql.query("select t1 from stb1 where abs(t1)=1") + # tdSql.checkRows(1) + tdSql.query("select t1 from stb1 where abs(c1+t1)=1") + tdSql.checkRows(1) + # tdSql.query("select t1 from stb1 where abs(t1+c1)=1") + # tdSql.checkRows(1) + tdSql.query("select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -454,6 +553,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:create table ==============") self.prepare_datas() + self.prepare_tag_datas() tdLog.printNoPrefix("==========step2:test errors ==============") @@ -475,6 +575,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step6: tag coumpute query ============") + + self.test_tag_compute_for_scalar_function() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/csum.py b/tests/system-test/2-query/csum.py index 5c2de5ea14..b7fa9a0cbb 100644 --- a/tests/system-test/2-query/csum.py +++ b/tests/system-test/2-query/csum.py @@ -83,6 +83,8 @@ class TDTestCase: tdSql.query(f"select {col} {alias} from {table_expr} {pre_condition}") pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') print("data is ", pre_data) pre_csum = np.cumsum(pre_data) tdSql.query(self.csum_query_form( @@ -124,6 +126,8 @@ class TDTestCase: tdSql.query(f"select {col} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") offset_val = condition.split("offset")[1].split(" ")[1] if "offset" in condition else 0 pre_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_result.dtype == 'int32'): + pre_result = np.array(pre_result, dtype = 'int64') pre_csum = np.cumsum(pre_result)[offset_val:] tdSql.query(self.csum_query_form( col=col, alias=alias, table_expr=table_expr, condition=condition diff --git a/tests/system-test/2-query/function_diff.py b/tests/system-test/2-query/function_diff.py index 325bd2bc8e..8edc96ed81 100644 --- a/tests/system-test/2-query/function_diff.py +++ b/tests/system-test/2-query/function_diff.py @@ -83,6 +83,8 @@ class TDTestCase: tdSql.query(f"select {col} {alias} from {table_expr} {pre_condition}") pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') pre_diff = np.diff(pre_data) # trans precision for data tdSql.query(self.diff_query_form( @@ -127,6 +129,8 @@ class TDTestCase: tdSql.query(f"select {col} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") offset_val = condition.split("offset")[1].split(" ")[1] if "offset" in condition else 0 pre_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_result.dtype == 'int32'): + pre_result = np.array(pre_result, dtype = 'int64') pre_diff = np.diff(pre_result)[offset_val:] tdSql.query(self.diff_query_form( col=col, alias=alias, table_expr=table_expr, condition=condition diff --git a/tests/system-test/2-query/mavg.py b/tests/system-test/2-query/mavg.py index 13d2b4d420..fa2d0f47a4 100644 --- a/tests/system-test/2-query/mavg.py +++ b/tests/system-test/2-query/mavg.py @@ -245,6 +245,8 @@ class TDTestCase: tdSql.query(f"select {col} {alias} from {table_expr} {pre_condition}") pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') pre_mavg = np.convolve(pre_data, np.ones(k), "valid")/k tdSql.query(self.mavg_query_form( sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr, @@ -291,6 +293,8 @@ class TDTestCase: # print(f"select {col} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") if not tdSql.queryResult: pre_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_result.dtype == 'int32'): + pre_result = np.array(pre_result, dtype = 'int64') pre_mavg = pre_mavg = np.convolve(pre_result, np.ones(k), "valid")[offset_val:]/k tdSql.query(self.mavg_query_form( diff --git a/tests/system-test/7-tmq/basic5.py b/tests/system-test/7-tmq/basic5.py index d6ac4d4208..3d9efea938 100644 --- a/tests/system-test/7-tmq/basic5.py +++ b/tests/system-test/7-tmq/basic5.py @@ -196,11 +196,13 @@ class TDTestCase: showMsg = 1 showRow = 1 - shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) shellCmd += "> nul 2>&1 &" else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -312,12 +314,13 @@ class TDTestCase: pollDelay = 100 showMsg = 1 showRow = 1 - - shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) if (platform.system().lower() == 'windows'): - shellCmd += "> nul 2>&1 &" + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -448,11 +451,13 @@ class TDTestCase: showMsg = 1 showRow = 1 - shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) shellCmd += "> nul 2>&1 &" else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/db.py b/tests/system-test/7-tmq/db.py index 70d02c4e29..fd793fd841 100644 --- a/tests/system-test/7-tmq/db.py +++ b/tests/system-test/7-tmq/db.py @@ -98,15 +98,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index 279518d283..b2c569e31e 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -81,15 +81,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeDb0.py b/tests/system-test/7-tmq/subscribeDb0.py index b0b8b06076..c9f256ed74 100644 --- a/tests/system-test/7-tmq/subscribeDb0.py +++ b/tests/system-test/7-tmq/subscribeDb0.py @@ -81,15 +81,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index 9af78ce6c3..44c24eb616 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -81,15 +81,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -291,8 +295,12 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] + tdSql.query("select count(*) from %s.%s" %(parameterDict['dbName'], parameterDict['stbName'])) + countOfStb = tdSql.getData(0,0) + print ("====total rows of stb: %d"%countOfStb) + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - if totalConsumeRows != expectrowcnt: + if totalConsumeRows < expectrowcnt: tdLog.exit("tmq consume rows error!") tdLog.info("again start consume processer") @@ -361,7 +369,10 @@ class TDTestCase: time.sleep(2) tdLog.info("pkill consume processor") - os.system('pkill tmq_sim') + if (platform.system().lower() == 'windows'): + os.system("TASKKILL /F /IM tmq_sim.exe") + else: + os.system('pkill tmq_sim') expectRows = 0 resultList = self.selectConsumeResult(expectRows) @@ -433,7 +444,10 @@ class TDTestCase: time.sleep(5) tdLog.info("pkill consume processor") - os.system('pkill tmq_sim') + if (platform.system().lower() == 'windows'): + os.system("TASKKILL /F /IM tmq_sim.exe") + else: + os.system('pkill tmq_sim') expectRows = 0 resultList = self.selectConsumeResult(expectRows) diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 9f308abd7c..4f70340b5a 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeStb0.py b/tests/system-test/7-tmq/subscribeStb0.py index f7e56b4550..65eaab897d 100644 --- a/tests/system-test/7-tmq/subscribeStb0.py +++ b/tests/system-test/7-tmq/subscribeStb0.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py index 4098d151d1..90d77dba0d 100644 --- a/tests/system-test/7-tmq/subscribeStb1.py +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeStb2.py b/tests/system-test/7-tmq/subscribeStb2.py index 45feb21019..74caa139f1 100644 --- a/tests/system-test/7-tmq/subscribeStb2.py +++ b/tests/system-test/7-tmq/subscribeStb2.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeStb3.py b/tests/system-test/7-tmq/subscribeStb3.py index 81105f5352..e6eaa17564 100644 --- a/tests/system-test/7-tmq/subscribeStb3.py +++ b/tests/system-test/7-tmq/subscribeStb3.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/subscribeStb4.py b/tests/system-test/7-tmq/subscribeStb4.py index a6f1cab4a4..d8a9ca95b0 100644 --- a/tests/system-test/7-tmq/subscribeStb4.py +++ b/tests/system-test/7-tmq/subscribeStb4.py @@ -93,15 +93,19 @@ class TDTestCase: return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): - shellCmd = 'nohup ' if valgrind == 1: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/fulltest.bat b/tests/system-test/fulltest.bat index c8084c3ad5..8a11ad42d4 100644 --- a/tests/system-test/fulltest.bat +++ b/tests/system-test/fulltest.bat @@ -1,103 +1,102 @@ -@REM python3 .\test.py -f 0-others\taosShell.py -@REM python3 .\test.py -f 0-others\taosShellError.py +python3 .\test.py -f 0-others\taosShell.py +python3 .\test.py -f 0-others\taosShellError.py python3 .\test.py -f 0-others\taosShellNetChk.py python3 .\test.py -f 0-others\telemetry.py python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\udfTest.py python3 .\test.py -f 0-others\udf_create.py -@REM python3 .\test.py -f 0-others\udf_restart_taosd.py -@REM python3 .\test.py -f 0-others\cachelast.py +python3 .\test.py -f 0-others\udf_restart_taosd.py +python3 .\test.py -f 0-others\cachelast.py -@REM python3 .\test.py -f 0-others\user_control.py -@REM python3 .\test.py -f 0-others\fsync.py +python3 .\test.py -f 0-others\user_control.py +python3 .\test.py -f 0-others\fsync.py -@REM python3 .\test.py -f 1-insert\influxdb_line_taosc_insert.py -@REM python3 .\test.py -f 1-insert\opentsdb_telnet_line_taosc_insert.py -@REM python3 .\test.py -f 1-insert\opentsdb_json_taosc_insert.py +python3 .\test.py -f 1-insert\influxdb_line_taosc_insert.py +python3 .\test.py -f 1-insert\opentsdb_telnet_line_taosc_insert.py +python3 .\test.py -f 1-insert\opentsdb_json_taosc_insert.py @REM #python3 .\test.py -f 1-insert\test_stmt_muti_insert_query.py -@REM python3 .\test.py -f 1-insert\alter_stable.py -@REM python3 .\test.py -f 1-insert\alter_table.py -@REM python3 .\test.py -f 2-query\between.py -@REM python3 .\test.py -f 2-query\distinct.py -@REM python3 .\test.py -f 2-query\varchar.py -@REM python3 .\test.py -f 2-query\ltrim.py -@REM python3 .\test.py -f 2-query\rtrim.py -@REM python3 .\test.py -f 2-query\length.py -@REM python3 .\test.py -f 2-query\char_length.py -@REM python3 .\test.py -f 2-query\upper.py -@REM python3 .\test.py -f 2-query\lower.py -@REM python3 .\test.py -f 2-query\join.py -@REM python3 .\test.py -f 2-query\join2.py -@REM python3 .\test.py -f 2-query\cast.py -@REM python3 .\test.py -f 2-query\union.py -@REM python3 .\test.py -f 2-query\union1.py -@REM python3 .\test.py -f 2-query\concat.py -@REM python3 .\test.py -f 2-query\concat2.py -@REM python3 .\test.py -f 2-query\concat_ws.py -@REM python3 .\test.py -f 2-query\concat_ws2.py -@REM python3 .\test.py -f 2-query\check_tsdb.py -@REM python3 .\test.py -f 2-query\spread.py +python3 .\test.py -f 1-insert\alter_stable.py +python3 .\test.py -f 1-insert\alter_table.py +python3 .\test.py -f 2-query\between.py +python3 .\test.py -f 2-query\distinct.py +python3 .\test.py -f 2-query\varchar.py +python3 .\test.py -f 2-query\ltrim.py +python3 .\test.py -f 2-query\rtrim.py +python3 .\test.py -f 2-query\length.py +python3 .\test.py -f 2-query\char_length.py +python3 .\test.py -f 2-query\upper.py +python3 .\test.py -f 2-query\lower.py +python3 .\test.py -f 2-query\join.py +python3 .\test.py -f 2-query\join2.py +python3 .\test.py -f 2-query\cast.py +python3 .\test.py -f 2-query\union.py +python3 .\test.py -f 2-query\union1.py +python3 .\test.py -f 2-query\concat.py +python3 .\test.py -f 2-query\concat2.py +python3 .\test.py -f 2-query\concat_ws.py +python3 .\test.py -f 2-query\concat_ws2.py +python3 .\test.py -f 2-query\check_tsdb.py +python3 .\test.py -f 2-query\spread.py @REM python3 .\test.py -f 2-query\hyperloglog.py +python3 .\test.py -f 2-query\timezone.py +python3 .\test.py -f 2-query\Now.py +python3 .\test.py -f 2-query\Today.py +python3 .\test.py -f 2-query\max.py +python3 .\test.py -f 2-query\min.py +python3 .\test.py -f 2-query\count.py +python3 .\test.py -f 2-query\last.py +python3 .\test.py -f 2-query\first.py +python3 .\test.py -f 2-query\To_iso8601.py +python3 .\test.py -f 2-query\To_unixtimestamp.py +python3 .\test.py -f 2-query\timetruncate.py +python3 .\test.py -f 2-query\diff.py +python3 .\test.py -f 2-query\Timediff.py -@REM python3 .\test.py -f 2-query\timezone.py -@REM python3 .\test.py -f 2-query\Now.py -@REM python3 .\test.py -f 2-query\Today.py -@REM python3 .\test.py -f 2-query\max.py -@REM python3 .\test.py -f 2-query\min.py -@REM python3 .\test.py -f 2-query\count.py -@REM python3 .\test.py -f 2-query\last.py -@REM python3 .\test.py -f 2-query\first.py -@REM python3 .\test.py -f 2-query\To_iso8601.py -@REM python3 .\test.py -f 2-query\To_unixtimestamp.py -@REM python3 .\test.py -f 2-query\timetruncate.py -@REM python3 .\test.py -f 2-query\diff.py -@REM python3 .\test.py -f 2-query\Timediff.py - -@REM python3 .\test.py -f 2-query\top.py -@REM python3 .\test.py -f 2-query\bottom.py -@REM python3 .\test.py -f 2-query\percentile.py -@REM python3 .\test.py -f 2-query\apercentile.py -@REM python3 .\test.py -f 2-query\abs.py -@REM python3 .\test.py -f 2-query\ceil.py -@REM python3 .\test.py -f 2-query\floor.py -@REM python3 .\test.py -f 2-query\round.py -@REM python3 .\test.py -f 2-query\log.py -@REM python3 .\test.py -f 2-query\pow.py -@REM python3 .\test.py -f 2-query\sqrt.py -@REM python3 .\test.py -f 2-query\sin.py -@REM python3 .\test.py -f 2-query\cos.py -@REM python3 .\test.py -f 2-query\tan.py -@REM python3 .\test.py -f 2-query\arcsin.py -@REM python3 .\test.py -f 2-query\arccos.py -@REM python3 .\test.py -f 2-query\arctan.py -@REM python3 .\test.py -f 2-query\query_cols_tags_and_or.py +python3 .\test.py -f 2-query\top.py +python3 .\test.py -f 2-query\bottom.py +python3 .\test.py -f 2-query\percentile.py +python3 .\test.py -f 2-query\apercentile.py +python3 .\test.py -f 2-query\abs.py +python3 .\test.py -f 2-query\ceil.py +python3 .\test.py -f 2-query\floor.py +python3 .\test.py -f 2-query\round.py +python3 .\test.py -f 2-query\log.py +python3 .\test.py -f 2-query\pow.py +python3 .\test.py -f 2-query\sqrt.py +python3 .\test.py -f 2-query\sin.py +python3 .\test.py -f 2-query\cos.py +python3 .\test.py -f 2-query\tan.py +python3 .\test.py -f 2-query\arcsin.py +python3 .\test.py -f 2-query\arccos.py +python3 .\test.py -f 2-query\arctan.py +python3 .\test.py -f 2-query\query_cols_tags_and_or.py @REM # python3 .\test.py -f 2-query\nestedQuery.py @REM # TD-15983 subquery output duplicate name column. @REM # Please Xiangyang Guo modify the following script @REM # python3 .\test.py -f 2-query\nestedQuery_str.py -@REM python3 .\test.py -f 2-query\avg.py -@REM python3 .\test.py -f 2-query\elapsed.py -@REM python3 .\test.py -f 2-query\csum.py -@REM python3 .\test.py -f 2-query\mavg.py -@REM python3 .\test.py -f 2-query\diff.py -@REM python3 .\test.py -f 2-query\sample.py -@REM python3 .\test.py -f 2-query\function_diff.py -@REM python3 .\test.py -f 2-query\unique.py -@REM python3 .\test.py -f 2-query\stateduration.py -@REM python3 .\test.py -f 2-query\function_stateduration.py -@REM python3 .\test.py -f 2-query\statecount.py +python3 .\test.py -f 2-query\avg.py +python3 .\test.py -f 2-query\elapsed.py +python3 .\test.py -f 2-query\csum.py +python3 .\test.py -f 2-query\mavg.py +python3 .\test.py -f 2-query\diff.py +python3 .\test.py -f 2-query\sample.py +python3 .\test.py -f 2-query\function_diff.py +python3 .\test.py -f 2-query\unique.py +python3 .\test.py -f 2-query\stateduration.py +python3 .\test.py -f 2-query\function_stateduration.py +python3 .\test.py -f 2-query\statecount.py -@REM python3 .\test.py -f 7-tmq\basic5.py -@REM python3 .\test.py -f 7-tmq\subscribeDb.py -@REM python3 .\test.py -f 7-tmq\subscribeDb0.py -@REM python3 .\test.py -f 7-tmq\subscribeDb1.py -@REM python3 .\test.py -f 7-tmq\subscribeStb.py -@REM python3 .\test.py -f 7-tmq\subscribeStb0.py -@REM python3 .\test.py -f 7-tmq\subscribeStb1.py -@REM python3 .\test.py -f 7-tmq\subscribeStb2.py -@REM python3 .\test.py -f 7-tmq\subscribeStb3.py -@REM python3 .\test.py -f 7-tmq\subscribeStb4.py -@REM python3 .\test.py -f 7-tmq\db.py +python3 .\test.py -f 7-tmq\basic5.py +python3 .\test.py -f 7-tmq\subscribeDb.py +python3 .\test.py -f 7-tmq\subscribeDb0.py +python3 .\test.py -f 7-tmq\subscribeDb1.py +python3 .\test.py -f 7-tmq\subscribeStb.py +python3 .\test.py -f 7-tmq\subscribeStb0.py +python3 .\test.py -f 7-tmq\subscribeStb1.py +python3 .\test.py -f 7-tmq\subscribeStb2.py +python3 .\test.py -f 7-tmq\subscribeStb3.py +python3 .\test.py -f 7-tmq\subscribeStb4.py +python3 .\test.py -f 7-tmq\db.py \ No newline at end of file diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index abc8a81248..022b81224a 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -98,7 +98,7 @@ python3 ./test.py -f 2-query/statecount.py python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb0.py -python3 ./test.py -f 7-tmq/subscribeDb1.py +# python3 ./test.py -f 7-tmq/subscribeDb1.py python3 ./test.py -f 7-tmq/subscribeStb.py python3 ./test.py -f 7-tmq/subscribeStb0.py python3 ./test.py -f 7-tmq/subscribeStb1.py diff --git a/tests/system-test/simpletest.bat b/tests/system-test/simpletest.bat new file mode 100644 index 0000000000..c8084c3ad5 --- /dev/null +++ b/tests/system-test/simpletest.bat @@ -0,0 +1,103 @@ + +@REM python3 .\test.py -f 0-others\taosShell.py +@REM python3 .\test.py -f 0-others\taosShellError.py +python3 .\test.py -f 0-others\taosShellNetChk.py +python3 .\test.py -f 0-others\telemetry.py +python3 .\test.py -f 0-others\taosdMonitor.py +python3 .\test.py -f 0-others\udfTest.py +python3 .\test.py -f 0-others\udf_create.py +@REM python3 .\test.py -f 0-others\udf_restart_taosd.py +@REM python3 .\test.py -f 0-others\cachelast.py + +@REM python3 .\test.py -f 0-others\user_control.py +@REM python3 .\test.py -f 0-others\fsync.py + +@REM python3 .\test.py -f 1-insert\influxdb_line_taosc_insert.py +@REM python3 .\test.py -f 1-insert\opentsdb_telnet_line_taosc_insert.py +@REM python3 .\test.py -f 1-insert\opentsdb_json_taosc_insert.py +@REM #python3 .\test.py -f 1-insert\test_stmt_muti_insert_query.py +@REM python3 .\test.py -f 1-insert\alter_stable.py +@REM python3 .\test.py -f 1-insert\alter_table.py +@REM python3 .\test.py -f 2-query\between.py +@REM python3 .\test.py -f 2-query\distinct.py +@REM python3 .\test.py -f 2-query\varchar.py +@REM python3 .\test.py -f 2-query\ltrim.py +@REM python3 .\test.py -f 2-query\rtrim.py +@REM python3 .\test.py -f 2-query\length.py +@REM python3 .\test.py -f 2-query\char_length.py +@REM python3 .\test.py -f 2-query\upper.py +@REM python3 .\test.py -f 2-query\lower.py +@REM python3 .\test.py -f 2-query\join.py +@REM python3 .\test.py -f 2-query\join2.py +@REM python3 .\test.py -f 2-query\cast.py +@REM python3 .\test.py -f 2-query\union.py +@REM python3 .\test.py -f 2-query\union1.py +@REM python3 .\test.py -f 2-query\concat.py +@REM python3 .\test.py -f 2-query\concat2.py +@REM python3 .\test.py -f 2-query\concat_ws.py +@REM python3 .\test.py -f 2-query\concat_ws2.py +@REM python3 .\test.py -f 2-query\check_tsdb.py +@REM python3 .\test.py -f 2-query\spread.py +@REM python3 .\test.py -f 2-query\hyperloglog.py + + +@REM python3 .\test.py -f 2-query\timezone.py +@REM python3 .\test.py -f 2-query\Now.py +@REM python3 .\test.py -f 2-query\Today.py +@REM python3 .\test.py -f 2-query\max.py +@REM python3 .\test.py -f 2-query\min.py +@REM python3 .\test.py -f 2-query\count.py +@REM python3 .\test.py -f 2-query\last.py +@REM python3 .\test.py -f 2-query\first.py +@REM python3 .\test.py -f 2-query\To_iso8601.py +@REM python3 .\test.py -f 2-query\To_unixtimestamp.py +@REM python3 .\test.py -f 2-query\timetruncate.py +@REM python3 .\test.py -f 2-query\diff.py +@REM python3 .\test.py -f 2-query\Timediff.py + +@REM python3 .\test.py -f 2-query\top.py +@REM python3 .\test.py -f 2-query\bottom.py +@REM python3 .\test.py -f 2-query\percentile.py +@REM python3 .\test.py -f 2-query\apercentile.py +@REM python3 .\test.py -f 2-query\abs.py +@REM python3 .\test.py -f 2-query\ceil.py +@REM python3 .\test.py -f 2-query\floor.py +@REM python3 .\test.py -f 2-query\round.py +@REM python3 .\test.py -f 2-query\log.py +@REM python3 .\test.py -f 2-query\pow.py +@REM python3 .\test.py -f 2-query\sqrt.py +@REM python3 .\test.py -f 2-query\sin.py +@REM python3 .\test.py -f 2-query\cos.py +@REM python3 .\test.py -f 2-query\tan.py +@REM python3 .\test.py -f 2-query\arcsin.py +@REM python3 .\test.py -f 2-query\arccos.py +@REM python3 .\test.py -f 2-query\arctan.py +@REM python3 .\test.py -f 2-query\query_cols_tags_and_or.py +@REM # python3 .\test.py -f 2-query\nestedQuery.py +@REM # TD-15983 subquery output duplicate name column. +@REM # Please Xiangyang Guo modify the following script +@REM # python3 .\test.py -f 2-query\nestedQuery_str.py + +@REM python3 .\test.py -f 2-query\avg.py +@REM python3 .\test.py -f 2-query\elapsed.py +@REM python3 .\test.py -f 2-query\csum.py +@REM python3 .\test.py -f 2-query\mavg.py +@REM python3 .\test.py -f 2-query\diff.py +@REM python3 .\test.py -f 2-query\sample.py +@REM python3 .\test.py -f 2-query\function_diff.py +@REM python3 .\test.py -f 2-query\unique.py +@REM python3 .\test.py -f 2-query\stateduration.py +@REM python3 .\test.py -f 2-query\function_stateduration.py +@REM python3 .\test.py -f 2-query\statecount.py + +@REM python3 .\test.py -f 7-tmq\basic5.py +@REM python3 .\test.py -f 7-tmq\subscribeDb.py +@REM python3 .\test.py -f 7-tmq\subscribeDb0.py +@REM python3 .\test.py -f 7-tmq\subscribeDb1.py +@REM python3 .\test.py -f 7-tmq\subscribeStb.py +@REM python3 .\test.py -f 7-tmq\subscribeStb0.py +@REM python3 .\test.py -f 7-tmq\subscribeStb1.py +@REM python3 .\test.py -f 7-tmq\subscribeStb2.py +@REM python3 .\test.py -f 7-tmq\subscribeStb3.py +@REM python3 .\test.py -f 7-tmq\subscribeStb4.py +@REM python3 .\test.py -f 7-tmq\db.py diff --git a/tests/system-test/test-all.bat b/tests/system-test/test-all.bat index 4c67404e01..076be6563a 100644 --- a/tests/system-test/test-all.bat +++ b/tests/system-test/test-all.bat @@ -2,26 +2,43 @@ SETLOCAL EnableDelayedExpansion for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a") set /a a=0 +if %1 == full ( + echo Windows Taosd Full Test + set /a exitNum=0 + for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( + for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" ( + set /a a+=1 + echo !a! Processing %%i + call :GetTimeSeconds !time! + set time1=!_timeTemp! + echo Start at !time! + call %%i ARG1 > result_!a!.txt 2>error_!a!.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 ) else ( call :colorEcho 0a "Success" &echo. ) + ) + ) + exit !exitNum! +) echo Windows Taosd Test -for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( +for /F "usebackq tokens=*" %%i in (simpletest.bat) do ( for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" ( - echo Processing %%i - call :GetTimeSeconds %time% - set time1=!_timeTemp! - echo Start at %time% set /a a+=1 + set timeNow=!time! + echo !a! Processing %%i + call :GetTimeSeconds !timeNow! + set time1=!_timeTemp! + echo Start at !timeNow! call %%i ARG1 > result_!a!.txt 2>error_!a!.txt if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && echo result: && cat result_!a!.txt && echo error: && cat error_!a!.txt && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) ) ) @REM echo Linux Taosd Test -@REM for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( +@REM for /F "usebackq tokens=*" %%i in (simpletest.bat) do ( @REM for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" ( -@REM echo Processing %%i -@REM call :GetTimeSeconds %time% -@REM set time1=!_timeTemp! -@REM echo Start at %time% @REM set /a a+=1 +@REM echo !a! Processing %%i +@REM call :GetTimeSeconds !time! +@REM set time1=!_timeTemp! +@REM echo Start at !time! @REM call %%i ARG1 -m %1 > result_!a!.txt 2>error_!a!.txt @REM if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && echo result: && cat result_!a!.txt && echo error: && cat error_!a!.txt && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) @REM ) @@ -29,10 +46,11 @@ for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( exit :colorEcho -call :GetTimeSeconds %time% +set timeNow=%time% +call :GetTimeSeconds %timeNow% set time2=%_timeTemp% set /a interTime=%time2% - %time1% -echo End at %time% , cast %interTime%s +echo End at %timeNow% , cast %interTime%s echo off "%~2" findstr /v /a:%1 /R "^$" "%~2" nul @@ -46,16 +64,16 @@ set tt=%tt::= % set index=1 for %%a in (%tt%) do ( if !index! EQU 1 ( - set hh=%%a + set /a hh=%%a )^ else if !index! EQU 2 ( - set mm=%%a + set /a mm=%%a )^ else if !index! EQU 3 ( - set ss=%%a + set /a ss=%%a ) set /a index=index+1 ) -set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% +set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% || echo hh:%hh% mm:%mm% ss:%ss% goto :eof \ No newline at end of file diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 4d9e2275f4..2710a00a72 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -128,7 +128,12 @@ void initLogFile() { sprintf(filename,"%s/../log/tmqlog_%s.txt", configDir, getCurrentTimeString(tmpString)); //sprintf(filename, "%s/../log/tmqlog.txt", configDir); - +#ifdef WINDOWS + for (int i = 2; i < sizeof(filename); i++) { + if (filename[i] == ':') filename[i] = '-'; + if (filename[i] == '\0') break; + } +#endif TdFilePtr pFile = taosOpenFile(filename, TD_FILE_TEXT | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); if (NULL == pFile) { fprintf(stderr, "Failed to open %s for save result\n", filename); @@ -308,8 +313,10 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex) taos_print_row(buf, row, fields, numOfFields); + const char* tbName = tmq_get_table_name(msg); + if (0 != g_stConfInfo.showRowFlag) { - taosFprintfFile(g_fp, "rows[%d]: %s\n", totalRows, buf); + taosFprintfFile(g_fp, "tbname:%s, rows[%d]: %s\n", (tbName != NULL ? tbName:"null table"), totalRows, buf); if (0 != g_stConfInfo.saveRowFlag) { saveConsumeContentToTbl(pInfo, buf); } @@ -356,6 +363,8 @@ void build_consumer(SThreadInfo* pInfo) { tmq_conf_set(conf, pInfo->key[i], pInfo->value[i]); } + tmq_conf_set(conf, "msg.with.table.name", "true"); + // tmq_conf_set(conf, "client.id", "c-001"); // tmq_conf_set(conf, "enable.auto.commit", "true"); @@ -528,6 +537,12 @@ void* consumeThreadFunc(void* param) { // save consume result into consumeresult table saveConsumeResult(pInfo); + // save rows from per vgroup + taosFprintfFile(g_fp, "======== consumerId: %d, consume rows from per vgroups ========\n", pInfo->consumerId); + for (int32_t i = 0; i < pInfo->numOfVgroups; i++) { + taosFprintfFile(g_fp, "vgroups: %04d, rows: %d\n", pInfo->rowsOfPerVgroups[i][0], pInfo->rowsOfPerVgroups[i][1]); + } + return NULL; }