diff --git a/Jenkinsfile2 b/Jenkinsfile2 index f618912295..920eb0c01d 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -130,6 +130,9 @@ def pre_test(){ def pre_test_win(){ bat ''' hostname + taskkill /f /t /im python.exe + taskkill /f /t /im bash.exe + taskkill /f /t /im taosd.exe ipconfig set date /t diff --git a/cmake/cmake.options b/cmake/cmake.options index 62816a80d5..86096c18fe 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -52,12 +52,22 @@ IF(${TD_WINDOWS}) ON ) ELSE () - - option( - BUILD_TEST - "If build unit tests using googletest" - ON - ) + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++13" COMPILER_SUPPORTS_CXX13) + IF(${COMPILER_SUPPORTS_CXX13}) + add_definitions(-DCOMPILER_SUPPORTS_CXX13) + option( + BUILD_TEST + "If build unit tests using googletest" + ON + ) + ELSE () + option( + BUILD_TEST + "If build unit tests using googletest" + OFF + ) + ENDIF () ENDIF () option( diff --git a/docs/en/14-reference/04-taosadapter.md b/docs/en/14-reference/04-taosadapter.md index 3264124655..cad229c32d 100644 --- a/docs/en/14-reference/04-taosadapter.md +++ b/docs/en/14-reference/04-taosadapter.md @@ -206,8 +206,8 @@ Note: InfluxDB token authorization is not supported at present. Only Basic autho You can use any client that supports the http protocol to access the RESTful interface address `http://:6041/` to write data in OpenTSDB compatible format to TDengine. ```text -/opentsdb/v1/put/json/:db -/opentsdb/v1/put/telnet/:db +/opentsdb/v1/put/json/ +/opentsdb/v1/put/telnet/ ``` ### collectd diff --git a/docs/zh/14-reference/04-taosadapter.md b/docs/zh/14-reference/04-taosadapter.md index 6e259391d4..42bc51a6d3 100644 --- a/docs/zh/14-reference/04-taosadapter.md +++ b/docs/zh/14-reference/04-taosadapter.md @@ -207,8 +207,8 @@ AllowWebSockets 您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://:6041/` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下: ```text -/opentsdb/v1/put/json/:db -/opentsdb/v1/put/telnet/:db +/opentsdb/v1/put/json/ +/opentsdb/v1/put/telnet/ ``` ### collectd diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 4226587d56..697a53e570 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -199,7 +199,7 @@ tmq_t* build_consumer() { tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "experiment.use.snapshot", "false"); + tmq_conf_set(conf, "experimental.snapshot.enable", "true"); tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 72e0af657c..8b64287033 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -222,6 +222,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock); size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize); int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n); +int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n); int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src); int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); @@ -235,6 +236,7 @@ SColumnInfoData* bdGetColumnInfoData(SSDataBlock* pBlock, int32_t index); void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress); const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData); +void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag); void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag); // for debug char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf); diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 8f7f22a6a0..e70008e4ef 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -78,6 +78,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf); // STRUCT ================= struct STColumn { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 71867d9741..454b940862 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -436,15 +436,16 @@ typedef struct { int32_t ttl; int32_t numOfColumns; int32_t numOfTags; + int32_t numOfFuncs; int32_t commentLen; int32_t ast1Len; int32_t ast2Len; SArray* pColumns; // array of SField SArray* pTags; // array of SField - char* comment; + SArray* pFuncs; + char* pComment; char* pAst1; char* pAst2; - SArray* pFuncs; } SMCreateStbReq; int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); @@ -1495,6 +1496,7 @@ typedef struct SSubQueryMsg { uint64_t queryId; uint64_t taskId; int64_t refId; + int32_t execId; int8_t taskType; int8_t explain; uint32_t sqlLen; // the query sql, @@ -1514,6 +1516,7 @@ typedef struct { uint64_t sId; uint64_t queryId; uint64_t taskId; + int32_t execId; } SQueryContinueReq; typedef struct { @@ -1535,6 +1538,7 @@ typedef struct { uint64_t sId; uint64_t queryId; uint64_t taskId; + int32_t execId; } SResFetchReq; typedef struct { @@ -1546,6 +1550,7 @@ typedef struct { uint64_t queryId; uint64_t taskId; int64_t refId; + int32_t execId; int8_t status; } STaskStatus; @@ -1591,6 +1596,7 @@ typedef struct { uint64_t queryId; uint64_t taskId; int64_t refId; + int32_t execId; } STaskCancelReq; typedef struct { @@ -1603,6 +1609,7 @@ typedef struct { uint64_t queryId; uint64_t taskId; int64_t refId; + int32_t execId; } STaskDropReq; typedef struct { @@ -1623,6 +1630,7 @@ typedef struct { int8_t triggerType; int64_t maxDelay; int64_t watermark; + int8_t igExpired; } SCMCreateStreamReq; typedef struct { diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index acf08bd47e..371e079913 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -167,10 +167,6 @@ enum { TD_NEW_MSG_SEG(TDMT_VND_MSG) TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp) - TD_DEF_MSG_TYPE(TDMT_VND_QUERY, "query", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_QUERY_CONTINUE, "query-continue", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_QUERY_HEARTBEAT, "query-heartbeat", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_FETCH, "fetch", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TABLE, "create-table", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TABLE, "alter-table", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TABLE, "drop-table", NULL, NULL) @@ -184,12 +180,9 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp) TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp) TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset) - TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_EXPLAIN, "vnode-explain", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_SUBSCRIBE, "vnode-subscribe", SMVSubscribeReq, SMVSubscribeRsp) TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL) @@ -206,6 +199,17 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "drop-ttl-stb", NULL, NULL) + TD_NEW_MSG_SEG(TDMT_SCH_MSG) + TD_DEF_MSG_TYPE(TDMT_SCH_QUERY, "query", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_MERGE_QUERY, "merge-query", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_QUERY_CONTINUE, "query-continue", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_QUERY_HEARTBEAT, "query-heartbeat", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_FETCH, "fetch", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_CANCEL_TASK, "cancel-task", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_DROP_TASK, "drop-task", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_EXPLAIN, "explain", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL) + TD_NEW_MSG_SEG(TDMT_STREAM_MSG) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DROP, "stream-task-drop", NULL, NULL) @@ -214,9 +218,6 @@ enum { TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL) - TD_NEW_MSG_SEG(TDMT_SCH_MSG) - TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL) - TD_NEW_MSG_SEG(TDMT_MON_MSG) TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL) @@ -232,10 +233,12 @@ enum { TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE, "sync-request-vote", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE_REPLY, "sync-request-vote-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES, "sync-append-entries", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_BATCH, "sync-append-entries-batch", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_REPLY, "sync-append-entries-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_NOOP, "sync-noop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_UNKNOWN, "sync-unknown", NULL, NULL) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index f5e068693e..bd73e04746 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -192,79 +192,81 @@ #define TK_TRIGGER 174 #define TK_AT_ONCE 175 #define TK_WINDOW_CLOSE 176 -#define TK_KILL 177 -#define TK_CONNECTION 178 -#define TK_TRANSACTION 179 -#define TK_BALANCE 180 -#define TK_VGROUP 181 -#define TK_MERGE 182 -#define TK_REDISTRIBUTE 183 -#define TK_SPLIT 184 -#define TK_SYNCDB 185 -#define TK_DELETE 186 -#define TK_NULL 187 -#define TK_NK_QUESTION 188 -#define TK_NK_ARROW 189 -#define TK_ROWTS 190 -#define TK_TBNAME 191 -#define TK_QSTARTTS 192 -#define TK_QENDTS 193 -#define TK_WSTARTTS 194 -#define TK_WENDTS 195 -#define TK_WDURATION 196 -#define TK_CAST 197 -#define TK_NOW 198 -#define TK_TODAY 199 -#define TK_TIMEZONE 200 -#define TK_CLIENT_VERSION 201 -#define TK_SERVER_VERSION 202 -#define TK_SERVER_STATUS 203 -#define TK_CURRENT_USER 204 -#define TK_COUNT 205 -#define TK_LAST_ROW 206 -#define TK_BETWEEN 207 -#define TK_IS 208 -#define TK_NK_LT 209 -#define TK_NK_GT 210 -#define TK_NK_LE 211 -#define TK_NK_GE 212 -#define TK_NK_NE 213 -#define TK_MATCH 214 -#define TK_NMATCH 215 -#define TK_CONTAINS 216 -#define TK_JOIN 217 -#define TK_INNER 218 -#define TK_SELECT 219 -#define TK_DISTINCT 220 -#define TK_WHERE 221 -#define TK_PARTITION 222 -#define TK_BY 223 -#define TK_SESSION 224 -#define TK_STATE_WINDOW 225 -#define TK_SLIDING 226 -#define TK_FILL 227 -#define TK_VALUE 228 -#define TK_NONE 229 -#define TK_PREV 230 -#define TK_LINEAR 231 -#define TK_NEXT 232 -#define TK_HAVING 233 -#define TK_RANGE 234 -#define TK_EVERY 235 -#define TK_ORDER 236 -#define TK_SLIMIT 237 -#define TK_SOFFSET 238 -#define TK_LIMIT 239 -#define TK_OFFSET 240 -#define TK_ASC 241 -#define TK_NULLS 242 -#define TK_ID 243 -#define TK_NK_BITNOT 244 -#define TK_INSERT 245 -#define TK_VALUES 246 -#define TK_IMPORT 247 -#define TK_NK_SEMI 248 -#define TK_FILE 249 +#define TK_IGNORE 177 +#define TK_EXPIRED 178 +#define TK_KILL 179 +#define TK_CONNECTION 180 +#define TK_TRANSACTION 181 +#define TK_BALANCE 182 +#define TK_VGROUP 183 +#define TK_MERGE 184 +#define TK_REDISTRIBUTE 185 +#define TK_SPLIT 186 +#define TK_SYNCDB 187 +#define TK_DELETE 188 +#define TK_NULL 189 +#define TK_NK_QUESTION 190 +#define TK_NK_ARROW 191 +#define TK_ROWTS 192 +#define TK_TBNAME 193 +#define TK_QSTARTTS 194 +#define TK_QENDTS 195 +#define TK_WSTARTTS 196 +#define TK_WENDTS 197 +#define TK_WDURATION 198 +#define TK_CAST 199 +#define TK_NOW 200 +#define TK_TODAY 201 +#define TK_TIMEZONE 202 +#define TK_CLIENT_VERSION 203 +#define TK_SERVER_VERSION 204 +#define TK_SERVER_STATUS 205 +#define TK_CURRENT_USER 206 +#define TK_COUNT 207 +#define TK_LAST_ROW 208 +#define TK_BETWEEN 209 +#define TK_IS 210 +#define TK_NK_LT 211 +#define TK_NK_GT 212 +#define TK_NK_LE 213 +#define TK_NK_GE 214 +#define TK_NK_NE 215 +#define TK_MATCH 216 +#define TK_NMATCH 217 +#define TK_CONTAINS 218 +#define TK_JOIN 219 +#define TK_INNER 220 +#define TK_SELECT 221 +#define TK_DISTINCT 222 +#define TK_WHERE 223 +#define TK_PARTITION 224 +#define TK_BY 225 +#define TK_SESSION 226 +#define TK_STATE_WINDOW 227 +#define TK_SLIDING 228 +#define TK_FILL 229 +#define TK_VALUE 230 +#define TK_NONE 231 +#define TK_PREV 232 +#define TK_LINEAR 233 +#define TK_NEXT 234 +#define TK_HAVING 235 +#define TK_RANGE 236 +#define TK_EVERY 237 +#define TK_ORDER 238 +#define TK_SLIMIT 239 +#define TK_SOFFSET 240 +#define TK_LIMIT 241 +#define TK_OFFSET 242 +#define TK_ASC 243 +#define TK_NULLS 244 +#define TK_ID 245 +#define TK_NK_BITNOT 246 +#define TK_INSERT 247 +#define TK_VALUES 248 +#define TK_IMPORT 249 +#define TK_NK_SEMI 250 +#define TK_FILE 251 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 6b4772dc2e..45fa94b3bf 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -36,6 +36,7 @@ typedef struct SReadHandle { void* vnode; void* mnd; SMsgCb* pMsgCb; + bool tqReader; } SReadHandle; typedef enum { @@ -133,7 +134,6 @@ int32_t qKillTask(qTaskInfo_t tinfo); */ int32_t qAsyncKillTask(qTaskInfo_t tinfo); - /** * destroy query info structure * @param qHandle @@ -172,6 +172,8 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le */ int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts); +int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts); + #ifdef __cplusplus } #endif diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index f03422672d..1012161d0e 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -34,6 +34,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_ELAPSED, FUNCTION_TYPE_IRATE, FUNCTION_TYPE_LAST_ROW, + FUNCTION_TYPE_LAST_ROWT, //TODO: removed FUNCTION_TYPE_MAX, FUNCTION_TYPE_MIN, FUNCTION_TYPE_MODE, @@ -195,6 +196,7 @@ bool fmIsIntervalInterpoFunc(int32_t funcId); bool fmIsInterpFunc(int32_t funcId); bool fmIsLastRowFunc(int32_t funcId); bool fmIsSystemInfoFunc(int32_t funcId); +bool fmIsImplicitTsFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index e473daad8d..134cd80487 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -338,6 +338,7 @@ typedef struct SStreamOptions { int8_t triggerType; SNode* pDelay; SNode* pWatermark; + bool ignoreExpired; } SStreamOptions; typedef struct SCreateStreamStmt { diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index f8d79a863f..3558e04bbf 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -73,8 +73,7 @@ typedef struct SScanLogicNode { SNode* pTagIndexCond; int8_t triggerType; int64_t watermark; - int16_t tsColId; - double filesFactor; + int8_t igExpired; SArray* pSmaIndexes; SNodeList* pGroupTags; bool groupSort; @@ -105,6 +104,7 @@ typedef struct SIndefRowsFuncLogicNode { SNodeList* pFuncs; bool isTailFunc; bool isUniqueFunc; + bool isTimeLineFunc; } SIndefRowsFuncLogicNode; typedef struct SInterpFuncLogicNode { @@ -175,7 +175,7 @@ typedef struct SWindowLogicNode { SNode* pStateExpr; int8_t triggerType; int64_t watermark; - double filesFactor; + int8_t igExpired; EWindowAlgorithm windowAlgo; } SWindowLogicNode; @@ -296,8 +296,7 @@ typedef struct STableScanPhysiNode { int8_t slidingUnit; int8_t triggerType; int64_t watermark; - int16_t tsColId; - double filesFactor; + int8_t igExpired; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; @@ -347,6 +346,7 @@ typedef struct SDownstreamSourceNode { SQueryNodeAddr addr; uint64_t taskId; uint64_t schedId; + int32_t execId; } SDownstreamSourceNode; typedef struct SExchangePhysiNode { @@ -373,7 +373,7 @@ typedef struct SWinodwPhysiNode { SNode* pTsEnd; // window end timestamp int8_t triggerType; int64_t watermark; - double filesFactor; + int8_t igExpired; } SWinodwPhysiNode; typedef struct SIntervalPhysiNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 9d84f2c32f..3478926fef 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -251,7 +251,7 @@ typedef struct SSelectStmt { char stmtName[TSDB_TABLE_NAME_LEN]; uint8_t precision; bool isEmptyResult; - bool isTimeOrderQuery; + bool isTimeLineResult; bool hasAggFuncs; bool hasRepeatScanFuncs; bool hasIndefiniteRowsFunc; @@ -261,6 +261,7 @@ typedef struct SSelectStmt { bool hasTailFunc; bool hasInterpFunc; bool hasLastRowFunc; + bool hasTimeLineFunc; bool groupSort; } SSelectStmt; diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index b4c75da131..d1a5c5db10 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -34,6 +34,7 @@ typedef struct SPlanContext { bool showRewrite; int8_t triggerType; int64_t watermark; + int8_t igExpired; char* pMsg; int32_t msgLen; const char* pUser; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 9e8ce3ffb6..7f7fe76139 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -135,9 +135,11 @@ typedef struct STableMetaOutput { } STableMetaOutput; typedef struct SDataBuf { + int32_t msgType; void* pData; uint32_t len; void* handle; + SEpSet* pEpSet; } SDataBuf; typedef struct STargetInfo { @@ -146,7 +148,7 @@ typedef struct STargetInfo { int32_t vgId; } STargetInfo; -typedef int32_t (*__async_send_cb_fn_t)(void* param, const SDataBuf* pMsg, int32_t code); +typedef int32_t (*__async_send_cb_fn_t)(void* param, SDataBuf* pMsg, int32_t code); typedef int32_t (*__async_exec_fn_t)(void* param); typedef struct SRequestConnInfo { @@ -234,13 +236,18 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define NEED_CLIENT_HANDLE_ERROR(_code) \ (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \ NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code)) +#define NEED_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ + (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || (_code) == TSDB_CODE_SYN_NOT_LEADER || \ + (_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK) + #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_VND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ (_type) == TDMT_VND_DROP_STB) -#define NEED_SCHEDULER_RETRY_ERROR(_code) \ - ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ - (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) +#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \ + (_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_APP_NOT_READY) #define REQUEST_TOTAL_EXEC_TIMES 2 diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 5fa7eed40c..d07cf0adf1 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -26,6 +26,7 @@ extern "C" { extern bool gRaftDetailLog; +#define SYNC_MAX_BATCH_SIZE 100 #define SYNC_INDEX_BEGIN 0 #define SYNC_INDEX_INVALID -1 #define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF @@ -120,7 +121,7 @@ typedef struct SSyncFSM { int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader); int32_t (*FpGetSnapshotInfo)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot); - int32_t (*FpSnapshotStartRead)(struct SSyncFSM* pFsm, void** ppReader); + int32_t (*FpSnapshotStartRead)(struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader); int32_t (*FpSnapshotStopRead)(struct SSyncFSM* pFsm, void* pReader); int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len); @@ -164,6 +165,7 @@ typedef struct SSyncLogStore { bool (*syncLogIsEmpty)(struct SSyncLogStore* pLogStore); int32_t (*syncLogEntryCount)(struct SSyncLogStore* pLogStore); int32_t (*syncLogRestoreFromSnapshot)(struct SSyncLogStore* pLogStore, SyncIndex index); + bool (*syncLogExist)(struct SSyncLogStore* pLogStore, SyncIndex index); SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore); SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore); @@ -179,6 +181,7 @@ typedef struct SSyncInfo { bool isStandBy; bool snapshotEnable; SyncGroupId vgId; + int32_t batchSize; SSyncCfg syncCfg; char path[TSDB_FILENAME_LEN]; SWal* pWal; @@ -202,6 +205,7 @@ SyncGroupId syncGetVgId(int64_t rid); void syncGetEpSet(int64_t rid, SEpSet* pEpSet); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); +// int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); bool syncEnvIsStart(); const char* syncStr(ESyncState state); bool syncIsRestoreFinish(int64_t rid); diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 46f279ed85..745c63d5b3 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -219,6 +219,34 @@ void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg); void syncClientRequestLog(const SyncClientRequest* pMsg); void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg); +// --------------------------------------------- +typedef struct SOffsetAndContLen { + int32_t offset; + int32_t contLen; +} SOffsetAndContLen; + +typedef struct SRaftMeta { + uint64_t seqNum; + bool isWeak; +} SRaftMeta; + +// block1: +// block2: SRaftMeta array +// block3: rpc msg array (with pCont) + +typedef struct SyncClientRequestBatch { + uint32_t bytes; + int32_t vgId; + uint32_t msgType; // SyncClientRequestBatch msgType + uint32_t dataCount; + uint32_t dataLen; // user RpcMsg.contLen + char data[]; // user RpcMsg.pCont +} SyncClientRequestBatch; + +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, + int32_t vgId); +void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg); + // --------------------------------------------- typedef struct SyncClientRequestReply { uint32_t bytes; @@ -325,22 +353,58 @@ void syncAppendEntriesLog(const SyncAppendEntries* pMsg); void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg); // --------------------------------------------- + +// define ahead +/* +typedef struct SOffsetAndContLen { + int32_t offset; + int32_t contLen; +} SOffsetAndContLen; +*/ + +// block1: SOffsetAndContLen +// block2: SOffsetAndContLen Array +// block3: SRpcMsg Array +// block4: SRpcMsg pCont Array + typedef struct SyncAppendEntriesBatch { uint32_t bytes; int32_t vgId; uint32_t msgType; SRaftId srcId; SRaftId destId; + // private data SyncTerm term; SyncIndex prevLogIndex; SyncTerm prevLogTerm; SyncIndex commitIndex; SyncTerm privateTerm; + int32_t dataCount; uint32_t dataLen; char data[]; } SyncAppendEntriesBatch; +SyncAppendEntriesBatch* syncAppendEntriesBatchBuild(SRpcMsg* rpcMsgArr, int32_t arrSize, int32_t vgId); +void syncAppendEntriesBatchDestroy(SyncAppendEntriesBatch* pMsg); +void syncAppendEntriesBatchSerialize(const SyncAppendEntriesBatch* pMsg, char* buf, uint32_t bufLen); +void syncAppendEntriesBatchDeserialize(const char* buf, uint32_t len, SyncAppendEntriesBatch* pMsg); +char* syncAppendEntriesBatchSerialize2(const SyncAppendEntriesBatch* pMsg, uint32_t* len); +SyncAppendEntriesBatch* syncAppendEntriesBatchDeserialize2(const char* buf, uint32_t len); +void syncAppendEntriesBatch2RpcMsg(const SyncAppendEntriesBatch* pMsg, SRpcMsg* pRpcMsg); +void syncAppendEntriesBatchFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntriesBatch* pMsg); +SyncAppendEntriesBatch* syncAppendEntriesBatchFromRpcMsg2(const SRpcMsg* pRpcMsg); +cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg); +char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg); +void syncAppendEntriesBatch2RpcMsgArray(SyncAppendEntriesBatch* pSyncMsg, SRpcMsg* rpcMsgArr, int32_t maxArrSize, + int32_t* pRetArrSize); + +// for debug ---------------------- +void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg); +void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg); +void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg); +void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg); + // --------------------------------------------- typedef struct SyncAppendEntriesReply { uint32_t bytes; @@ -542,6 +606,7 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg); int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex); +int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* pMsg); int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg); int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg); int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 92701db2ad..c11651970c 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -61,45 +61,23 @@ extern "C" { } \ } -#define WAL_HEAD_VER 0 +#define WAL_PROTO_VER 0 #define WAL_NOSUFFIX_LEN 20 #define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1) #define WAL_LOG_SUFFIX "log" #define WAL_INDEX_SUFFIX "idx" #define WAL_REFRESH_MS 1000 -#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead)) +#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalCkHead)) #define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12) #define WAL_FILE_LEN (WAL_PATH_LEN + 32) #define WAL_MAGIC 0xFAFBFCFDULL -#pragma pack(push, 1) typedef enum { TAOS_WAL_NOLOG = 0, TAOS_WAL_WRITE = 1, TAOS_WAL_FSYNC = 2, } EWalType; -// used by sync module -typedef struct { - int8_t isWeek; - uint64_t seqNum; - uint64_t term; -} SSyncLogMeta; - -typedef struct SWalReadHead { - int8_t headVer; - int8_t reserved; - int16_t msgType; - int32_t bodyLen; - int64_t ingestTs; // not implemented - int64_t version; - - // sync meta - SSyncLogMeta syncMeta; - - char body[]; -} SWalReadHead; - typedef struct { int32_t vgId; int32_t fsyncPeriod; // millisecond @@ -110,13 +88,6 @@ typedef struct { EWalType level; // wal level } SWalCfg; -typedef struct { - uint64_t magic; - uint32_t cksumHead; - uint32_t cksumBody; - SWalReadHead head; -} SWalHead; - typedef struct SWalVer { int64_t firstVer; int64_t verInSnapshotting; @@ -125,6 +96,35 @@ typedef struct SWalVer { int64_t lastVer; } SWalVer; +#pragma pack(push, 1) +// used by sync module +typedef struct { + int8_t isWeek; + uint64_t seqNum; + uint64_t term; +} SSyncLogMeta; + +typedef struct { + int8_t protoVer; + int64_t version; + int16_t msgType; + int32_t bodyLen; + int64_t ingestTs; // not implemented + + // sync meta + SSyncLogMeta syncMeta; + + char body[]; +} SWalCont; + +typedef struct { + uint64_t magic; + uint32_t cksumHead; + uint32_t cksumBody; + SWalCont head; +} SWalCkHead; +#pragma pack(pop) + typedef struct SWal { // cfg SWalCfg cfg; @@ -134,7 +134,7 @@ typedef struct SWal { TdFilePtr pWriteLogTFile; TdFilePtr pWriteIdxTFile; int32_t writeCur; - SArray *fileInfoSet; + SArray *fileInfoSet; // SArray // status int64_t totSize; int64_t lastRollSeq; @@ -146,7 +146,7 @@ typedef struct SWal { // path char path[WAL_PATH_LEN]; // reusable write head - SWalHead writeHead; + SWalCkHead writeHead; } SWal; // WAL HANDLE typedef struct SWalReadHandle { @@ -158,11 +158,8 @@ typedef struct SWalReadHandle { int64_t capacity; int64_t status; // if cursor valid TdThreadMutex mutex; - SWalHead *pHead; + SWalCkHead *pHead; } SWalReadHandle; -#pragma pack(pop) - -// typedef int32_t (*FWalWrite)(void *ahandle, void *pHead); // module initialization int32_t walInit(); @@ -174,9 +171,9 @@ int32_t walAlter(SWal *, SWalCfg *pCfg); void walClose(SWal *); // write -int64_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, +int32_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, int32_t bodyLen); -int64_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen); +int32_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen); void walFsync(SWal *, bool force); // apis for lifecycle management @@ -196,9 +193,9 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver); // only for tq usage void walSetReaderCapacity(SWalReadHandle *pRead, int32_t capacity); -int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead); -int32_t walFetchBody(SWalReadHandle *pRead, SWalHead **ppHead); -int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalHead *pHead); +int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalCkHead *pHead); +int32_t walFetchBody(SWalReadHandle *pRead, SWalCkHead **ppHead); +int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalCkHead *pHead); typedef struct { int64_t refId; @@ -210,6 +207,8 @@ void walCloseRef(SWalRef *); int32_t walRefVer(SWalRef *, int64_t ver); int32_t walUnrefVer(SWal *); +bool walLogExist(SWal *, int64_t ver); + // lifecycle check bool walIsEmpty(SWal *); int64_t walGetFirstVer(SWal *); diff --git a/include/os/osFile.h b/include/os/osFile.h index 8751e175a5..2f6a6ba480 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -25,17 +25,17 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following sectio #ifndef ALLOW_FORBID_FUNC - #define open OPEN_FUNC_TAOS_FORBID - #define fopen FOPEN_FUNC_TAOS_FORBID - #define access ACCESS_FUNC_TAOS_FORBID - #define stat STAT_FUNC_TAOS_FORBID - #define lstat LSTAT_FUNC_TAOS_FORBID - #define fstat FSTAT_FUNC_TAOS_FORBID - #define close CLOSE_FUNC_TAOS_FORBID - #define fclose FCLOSE_FUNC_TAOS_FORBID - #define fsync FSYNC_FUNC_TAOS_FORBID - #define getline GETLINE_FUNC_TAOS_FORBID - // #define fflush FFLUSH_FUNC_TAOS_FORBID +#define open OPEN_FUNC_TAOS_FORBID +#define fopen FOPEN_FUNC_TAOS_FORBID +#define access ACCESS_FUNC_TAOS_FORBID +#define stat STAT_FUNC_TAOS_FORBID +#define lstat LSTAT_FUNC_TAOS_FORBID +#define fstat FSTAT_FUNC_TAOS_FORBID +#define close CLOSE_FUNC_TAOS_FORBID +#define fclose FCLOSE_FUNC_TAOS_FORBID +#define fsync FSYNC_FUNC_TAOS_FORBID +#define getline GETLINE_FUNC_TAOS_FORBID +// #define fflush FFLUSH_FUNC_TAOS_FORBID #endif #ifndef PATH_MAX @@ -43,54 +43,54 @@ extern "C" { #endif typedef struct TdFile *TdFilePtr; - -#define TD_FILE_CREATE 0x0001 -#define TD_FILE_WRITE 0x0002 -#define TD_FILE_READ 0x0004 -#define TD_FILE_TRUNC 0x0008 -#define TD_FILE_APPEND 0x0010 -#define TD_FILE_TEXT 0x0020 -#define TD_FILE_AUTO_DEL 0x0040 -#define TD_FILE_EXCL 0x0080 -#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile -TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions); + +#define TD_FILE_CREATE 0x0001 +#define TD_FILE_WRITE 0x0002 +#define TD_FILE_READ 0x0004 +#define TD_FILE_TRUNC 0x0008 +#define TD_FILE_APPEND 0x0010 +#define TD_FILE_TEXT 0x0020 +#define TD_FILE_AUTO_DEL 0x0040 +#define TD_FILE_EXCL 0x0080 +#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile +TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions); #define TD_FILE_ACCESS_EXIST_OK 0x1 #define TD_FILE_ACCESS_READ_OK 0x2 #define TD_FILE_ACCESS_WRITE_OK 0x4 -bool taosCheckAccessFile(const char *pathname, int mode); - +bool taosCheckAccessFile(const char *pathname, int mode); + int32_t taosLockFile(TdFilePtr pFile); int32_t taosUnLockFile(TdFilePtr pFile); - + int32_t taosUmaskFile(int32_t maskVal); - + int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime); int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno); int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime); bool taosCheckExistFile(const char *pathname); - + int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence); int32_t taosFtruncateFile(TdFilePtr pFile, int64_t length); int32_t taosFsyncFile(TdFilePtr pFile); - + int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count); int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset); int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count); void taosFprintfFile(TdFilePtr pFile, const char *format, ...); -int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict ptrBuf); +int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf); int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf); int32_t taosEOFFile(TdFilePtr pFile); - -int64_t taosCloseFile(TdFilePtr *ppFile); - + +int32_t taosCloseFile(TdFilePtr *ppFile); + int32_t taosRenameFile(const char *oldName, const char *newName); int64_t taosCopyFile(const char *from, const char *to); int32_t taosRemoveFile(const char *path); - -void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); + +void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size); diff --git a/include/os/osMath.h b/include/os/osMath.h index e13c32422e..b0c75f4dd7 100644 --- a/include/os/osMath.h +++ b/include/os/osMath.h @@ -60,6 +60,13 @@ extern "C" { }) #endif +#ifndef __COMPAR_FN_T +#define __COMPAR_FN_T +typedef int32_t (*__compar_fn_t)(const void *, const void *); +#endif + +void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar); + #ifdef __cplusplus } #endif diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 08e09dca2f..33313e0400 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -86,6 +86,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102) #define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103) #define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104) +#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0105) //client #define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) @@ -387,6 +388,10 @@ int32_t* taosGetErrno(); #define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0719) #define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x071A) #define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x071B) +//json +#define TSDB_CODE_QRY_JSON_IN_ERROR TAOS_DEF_ERROR_CODE(0, 0x071C) +#define TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR TAOS_DEF_ERROR_CODE(0, 0x071D) +#define TSDB_CODE_QRY_JSON_IN_GROUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x071E) // grant #define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) @@ -422,6 +427,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SYN_RECONFIG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0910) #define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911) #define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912) +#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913) #define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF) // tq @@ -571,6 +577,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B) #define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C) #define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D) +#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E) //planner #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) @@ -616,6 +623,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150) #define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151) #define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152) +#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153) //index #define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200) diff --git a/include/util/tutil.h b/include/util/tutil.h index b29e1f7cfa..6a1a40f14c 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -44,6 +44,8 @@ uint32_t ip2uint(const char *const ip_addr); void taosIp2String(uint32_t ip, char *str); void taosIpPort2String(uint32_t ip, uint16_t port, char *str); +void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen); + static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { T_MD5_CTX context; tMD5Init(&context); @@ -59,10 +61,10 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar tMD5Final(&context); char buf[TSDB_PASSWORD_LEN + 1]; - sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], - context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], - context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10], - context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1], + context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); memcpy(target, buf, TSDB_PASSWORD_LEN); } diff --git a/packaging/cfg/tarbitratord.service b/packaging/cfg/tarbitratord.service deleted file mode 100644 index d60cb536b0..0000000000 --- a/packaging/cfg/tarbitratord.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=TDengine arbitrator service -After=network-online.target -Wants=network-online.target - -[Service] -Type=simple -ExecStart=/usr/bin/tarbitrator -TimeoutStopSec=1000000s -LimitNOFILE=infinity -LimitNPROC=infinity -LimitCORE=infinity -TimeoutStartSec=0 -StandardOutput=null -Restart=always -StartLimitBurst=3 -StartLimitInterval=60s - -[Install] -WantedBy=multi-user.target diff --git a/packaging/deb/tarbitratord b/packaging/deb/tarbitratord deleted file mode 100644 index 3f97c3c0c2..0000000000 --- a/packaging/deb/tarbitratord +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# Modified from original source: Elastic Search -# https://github.com/elasticsearch/elasticsearch -# Thank you to the Elastic Search authors -# -# chkconfig: 2345 99 01 -# -### BEGIN INIT INFO -# Provides: taoscluster -# Required-Start: $local_fs $network $syslog -# Required-Stop: $local_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Starts taoscluster tarbitrator -# Description: Starts taoscluster tarbitrator, a arbitrator -### END INIT INFO - -set -e - -PATH="/bin:/usr/bin:/sbin:/usr/sbin" -NAME="taoscluster" -USER="root" -GROUP="root" -DAEMON="/usr/local/taos/bin/tarbitrator" -DAEMON_OPTS="" -PID_FILE="/var/run/$NAME.pid" -APPARGS="" - -# Maximum number of open files -MAX_OPEN_FILES=65535 - -. /lib/lsb/init-functions - -case "$1" in - start) - - log_action_begin_msg "Starting tarbitrator..." - if start-stop-daemon --test --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile "$PID_FILE" --exec "$DAEMON" -- $APPARGS &> /dev/null; then - - touch "$PID_FILE" && chown "$USER":"$GROUP" "$PID_FILE" - - if [ -n "$MAX_OPEN_FILES" ]; then - ulimit -n $MAX_OPEN_FILES - fi - - start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile "$PID_FILE" --exec "$DAEMON" -- $APPARGS - - log_end_msg $? - fi - ;; - - stop) - log_action_begin_msg "Stopping tarbitrator..." - set +e - if [ -f "$PID_FILE" ]; then - start-stop-daemon --stop --pidfile "$PID_FILE" --user "$USER" --retry=TERM/120/KILL/5 > /dev/null - if [ $? -eq 1 ]; then - log_action_cont_msg "TSD is not running but pid file exists, cleaning up" - elif [ $? -eq 3 ]; then - PID="`cat $PID_FILE`" - log_failure_msg "Failed to stop tarbitrator (pid $PID)" - exit 1 - fi - rm -f "$PID_FILE" - else - log_action_cont_msg "tarbitrator was not running" - fi - log_action_end_msg 0 - set -e - ;; - - restart|force-reload) - if [ -f "$PID_FILE" ]; then - $0 stop - sleep 1 - fi - $0 start - ;; - status) - status_of_proc -p "$PID_FILE" "$DAEMON" "$NAME" - ;; - *) - exit 1 - ;; -esac - -exit 0 diff --git a/packaging/release.sh b/packaging/release.sh index 2ac52a0df9..3426c2856d 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -302,7 +302,6 @@ if [ "$osType" != "Darwin" ]; then ${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName} ${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} else # only make client for Darwin diff --git a/packaging/rpm/tarbitratord b/packaging/rpm/tarbitratord deleted file mode 100644 index 68138f5c1d..0000000000 --- a/packaging/rpm/tarbitratord +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# -# tarbitratord This shell script takes care of starting and stopping tarbitrator. -# -# chkconfig: 2345 99 01 -# description: tarbitrator is a arbitrator used in TDengine cluster. -# -# -### BEGIN INIT INFO -# Provides: taoscluster -# Required-Start: $network $local_fs $remote_fs -# Required-Stop: $network $local_fs $remote_fs -# Short-Description: start and stop tarbitrator -# Description: tarbitrator is a arbitrator used in TDengine cluster. -### END INIT INFO - -# Source init functions -. /etc/init.d/functions - -# Maximum number of open files -MAX_OPEN_FILES=65535 - -# Default program options -NAME=tarbitrator -PROG=/usr/local/taos/bin/tarbitrator -USER=root -GROUP=root - -# Default directories -LOCK_DIR=/var/lock/subsys -PID_DIR=/var/run/$NAME - -# Set file names -LOCK_FILE=$LOCK_DIR/$NAME -PID_FILE=$PID_DIR/$NAME.pid - -[ -e $PID_DIR ] || mkdir -p $PID_DIR - -PROG_OPTS="" - -start() { - echo -n "Starting ${NAME}: " - # check identity - curid="`id -u -n`" - if [ "$curid" != root ] && [ "$curid" != "$USER" ] ; then - echo "Must be run as root or $USER, but was run as $curid" - return 1 - fi - # Sets the maximum number of open file descriptors allowed. - ulimit -n $MAX_OPEN_FILES - curulimit="`ulimit -n`" - if [ "$curulimit" -lt $MAX_OPEN_FILES ] ; then - echo "'ulimit -n' must be greater than or equal to $MAX_OPEN_FILES, is $curulimit" - return 1 - fi - - if [ "`id -u -n`" == root ] ; then - # Changes the owner of the lock, and the pid files to allow - # non-root OpenTSDB daemons to run /usr/share/opentsdb/bin/opentsdb_restart.py. - touch $LOCK_FILE && chown $USER:$GROUP $LOCK_FILE - touch $PID_FILE && chown $USER:$GROUP $PID_FILE - daemon --user $USER --pidfile $PID_FILE "$PROG $PROG_OPTS &> /dev/null &" - else - # Don't have to change user. - daemon --pidfile $PID_FILE "$PROG $PROG_OPTS &> /dev/null &" - fi - retval=$? - sleep 2 - echo - [ $retval -eq 0 ] && (findproc > $PID_FILE && touch $LOCK_FILE) - return $retval -} - -stop() { - echo -n "Stopping ${NAME}: " - killproc -p $PID_FILE $NAME - retval=$? - echo - # Non-root users don't have enough permission to remove pid and lock files. - # So, the opentsdb_restart.py cannot get rid of the files, and the command - # "service opentsdb status" will complain about the existing pid file. - # Makes the pid file empty. - echo > $PID_FILE - [ $retval -eq 0 ] && (rm -f $PID_FILE && rm -f $LOCK_FILE) - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status -p $PID_FILE -l $LOCK_FILE $NAME -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac - -exit $? diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 7c7d5477cf..2d17ef4812 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -194,7 +194,6 @@ function install_bin() { ${csudo}rm -f ${bin_link_dir}/${serverName} || : ${csudo}rm -f ${bin_link_dir}/${adapterName} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : - ${csudo}rm -f ${bin_link_dir}/tarbitrator || : ${csudo}rm -f ${bin_link_dir}/set_core || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : @@ -210,7 +209,6 @@ function install_bin() { [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* @@ -606,28 +604,19 @@ function install_service_on_sysvinit() { if ((${os_type} == 1)); then # ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.deb ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} - # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type} == 2)); then # ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.rpm ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} - # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod} == 1)); then ${csudo}chkconfig --add ${serverName} || : ${csudo}chkconfig --level 2345 ${serverName} on || : - ${csudo}chkconfig --add tarbitratord || : - ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod} == 2)); then ${csudo}insserv ${serverName} || : ${csudo}insserv -d ${serverName} || : - ${csudo}insserv tarbitratord || : - ${csudo}insserv -d tarbitratord || : elif ((${initd_mod} == 3)); then ${csudo}update-rc.d ${serverName} defaults || : - ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -669,9 +658,6 @@ function install_service_on_systemd() { ${csudo}systemctl enable ${serverName} - [ -f ${script_dir}/cfg/tarbitratord.service ] && - ${csudo}cp ${script_dir}/cfg/tarbitratord.service \ - ${service_config_dir}/ || : ${csudo}systemctl daemon-reload if [ "$verMode" == "cluster" ]; then diff --git a/packaging/tools/install_arbi.sh b/packaging/tools/install_arbi.sh deleted file mode 100755 index 2863640153..0000000000 --- a/packaging/tools/install_arbi.sh +++ /dev/null @@ -1,340 +0,0 @@ -#!/bin/bash -# -# This file is used to install database on linux systems. The operating system -# is required to use systemd to manage services at boot - -set -e -#set -x - -# -----------------------Variables definition--------------------- -script_dir=$(dirname $(readlink -f "$0")) - -bin_link_dir="/usr/bin" -#inc_link_dir="/usr/include" - -#install main path -install_main_dir="/usr/local/tarbitrator" - -# old bin dir -bin_dir="/usr/local/tarbitrator/bin" - -service_config_dir="/etc/systemd/system" - -# Color setting -RED='\033[0;31m' -GREEN='\033[1;32m' -GREEN_DARK='\033[0;32m' -GREEN_UNDERLINE='\033[4;32m' -NC='\033[0m' - -csudo="" -if command -v sudo >/dev/null; then - csudo="sudo " -fi - -update_flag=0 - -initd_mod=0 -service_mod=2 -if pidof systemd &>/dev/null; then - service_mod=0 -elif $(which service &>/dev/null); then - service_mod=1 - service_config_dir="/etc/init.d" - if $(which chkconfig &>/dev/null); then - initd_mod=1 - elif $(which insserv &>/dev/null); then - initd_mod=2 - elif $(which update-rc.d &>/dev/null); then - initd_mod=3 - else - service_mod=2 - fi -else - service_mod=2 -fi - -# get the operating system type for using the corresponding init file -# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification -#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) -if [[ -e /etc/os-release ]]; then - osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) || : -else - osinfo="" -fi -#echo "osinfo: ${osinfo}" -os_type=0 -if echo $osinfo | grep -qwi "ubuntu"; then - # echo "This is ubuntu system" - os_type=1 -elif echo $osinfo | grep -qwi "debian"; then - # echo "This is debian system" - os_type=1 -elif echo $osinfo | grep -qwi "Kylin"; then - # echo "This is Kylin system" - os_type=1 -elif echo $osinfo | grep -qwi "centos"; then - # echo "This is centos system" - os_type=2 -elif echo $osinfo | grep -qwi "fedora"; then - # echo "This is fedora system" - os_type=2 -else - echo " osinfo: ${osinfo}" - echo " This is an officially unverified linux system," - echo " if there are any problems with the installation and operation, " - echo " please feel free to contact taosdata.com for support." - os_type=1 -fi - -function kill_tarbitrator() { - pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') - if [ -n "$pid" ]; then - ${csudo}kill -9 $pid || : - fi -} - -function install_main_path() { - #create install main dir and all sub dir - ${csudo}rm -rf ${install_main_dir} || : - ${csudo}mkdir -p ${install_main_dir} - ${csudo}mkdir -p ${install_main_dir}/bin - #${csudo}mkdir -p ${install_main_dir}/include - ${csudo}mkdir -p ${install_main_dir}/init.d -} - -function install_bin() { - # Remove links - ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo}rm -f ${bin_link_dir}/tarbitrator || : - ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* - - #Make link - [ -x ${install_main_dir}/bin/remove_arbi.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : -} - -function install_header() { - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : - ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* - ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h - ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h -} - -function install_jemalloc() { - jemalloc_dir=${script_dir}/jemalloc - - if [ -d ${jemalloc_dir} ]; then - ${csudo}/usr/bin/install -c -d /usr/local/bin - - if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin - fi - if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin - fi - if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin - fi - if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc - fi - if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo}/usr/bin/install -c -d /usr/local/lib - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo}/usr/bin/install -c -d /usr/local/lib - if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib - fi - if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib - fi - if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig - fi - fi - if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc - fi - if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 - fi - - if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo}ldconfig - else - echo "/etc/ld.so.conf.d not found!" - fi - fi -} - -function clean_service_on_sysvinit() { - if pidof tarbitrator &>/dev/null; then - ${csudo}service tarbitratord stop || : - fi - - if ((${initd_mod} == 1)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}chkconfig --del tarbitratord || : - fi - elif ((${initd_mod} == 2)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}insserv -r tarbitratord || : - fi - elif ((${initd_mod} == 3)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}update-rc.d -f tarbitratord remove || : - fi - fi - - ${csudo}rm -f ${service_config_dir}/tarbitratord || : - - if $(which init &>/dev/null); then - ${csudo}init q || : - fi -} - -function install_service_on_sysvinit() { - clean_service_on_sysvinit - sleep 1 - - if ((${os_type} == 1)); then - ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord - elif ((${os_type} == 2)); then - ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord - fi - - if ((${initd_mod} == 1)); then - ${csudo}chkconfig --add tarbitratord || : - ${csudo}chkconfig --level 2345 tarbitratord on || : - elif ((${initd_mod} == 2)); then - ${csudo}insserv tarbitratord || : - ${csudo}insserv -d tarbitratord || : - elif ((${initd_mod} == 3)); then - ${csudo}update-rc.d tarbitratord defaults || : - fi -} - -function clean_service_on_systemd() { - tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - if systemctl is-active --quiet tarbitratord; then - echo "tarbitrator is running, stopping it..." - ${csudo}systemctl stop tarbitratord &>/dev/null || echo &>/dev/null - fi - ${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null - - ${csudo}rm -f ${tarbitratord_service_config} -} - -function install_service_on_systemd() { - clean_service_on_systemd - - tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - - ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo}systemctl enable tarbitratord -} - -function install_service() { - if ((${service_mod} == 0)); then - install_service_on_systemd - elif ((${service_mod} == 1)); then - install_service_on_sysvinit - else - kill_tarbitrator - fi -} - -function update_TDengine() { - # Start to update - echo -e "${GREEN}Start to update TDengine's arbitrator ...${NC}" - # Stop the service if running - if pidof tarbitrator &>/dev/null; then - if ((${service_mod} == 0)); then - ${csudo}systemctl stop tarbitratord || : - elif ((${service_mod} == 1)); then - ${csudo}service tarbitratord stop || : - else - kill_tarbitrator - fi - sleep 1 - fi - - install_main_path - #install_header - install_bin - install_service - install_jemalloc - - echo - if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" - elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" - else - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" - fi - echo - echo -e "\033[44;32;1mTDengine's arbitrator is updated successfully!${NC}" -} - -function install_TDengine() { - # Start to install - echo -e "${GREEN}Start to install TDengine's arbitrator ...${NC}" - - install_main_path - #install_header - install_bin - install_service - install_jemalloc - - echo - if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" - elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" - else - echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" - fi - - echo -e "\033[44;32;1mTDengine's arbitrator is installed successfully!${NC}" - echo -} - -## ==============================Main program starts from here============================ -# Install server and client -if [ -x ${bin_dir}/tarbitrator ]; then - update_flag=1 - update_TDengine -else - install_TDengine -fi diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 59be60f8fc..4e4ebb72c0 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -185,7 +185,6 @@ function install_bin() { [ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || : [ -f ${binary_dir}/build/bin/udfd ] && ${csudo}cp -r ${binary_dir}/build/bin/udfd ${install_main_dir}/bin || : ${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || : - # ${csudo}cp -r ${binary_dir}/build/bin/tarbitrator ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin || : diff --git a/packaging/tools/makearbi.sh b/packaging/tools/makearbi.sh deleted file mode 100755 index cfae2b4a46..0000000000 --- a/packaging/tools/makearbi.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# Generate arbitrator's tar.gz setup package for all os system - -set -e -#set -x - -curr_dir=$(pwd) -compile_dir=$1 -version=$2 -build_time=$3 -cpuType=$4 -osType=$5 -verMode=$6 -verType=$7 -pagMode=$8 - -script_dir="$(dirname $(readlink -f $0))" -top_dir="$(readlink -f ${script_dir}/../..)" - -productName="TDengine" - -# create compressed install file. -build_dir="${compile_dir}/build" -code_dir="${top_dir}" -release_dir="${top_dir}/release" - -#package_name='linux' -if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/${productName}-enterprise-arbitrator-${version}" -else - install_dir="${release_dir}/${productName}-arbitrator-${version}" -fi - -# Directories and files. -bin_files="${build_dir}/bin/tarbitrator ${script_dir}/remove_arbi.sh" -install_files="${script_dir}/install_arbi.sh" - -#header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h" -init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord -init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord - -# make directories. -mkdir -p ${install_dir} && cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install_arbi.sh || : -#mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc || : -mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : -mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || : -mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || : - -cd ${release_dir} - -# install_dir has been distinguishes cluster from edege, so comments this code -pkg_name=${install_dir}-${osType}-${cpuType} - -if [[ "$verType" == "beta" ]] || [[ "$verType" == "preRelease" ]]; then - pkg_name=${install_dir}-${verType}-${osType}-${cpuType} -elif [ "$verType" == "stable" ]; then - pkg_name=${pkg_name} -else - echo "unknow verType, nor stabel or beta" - exit 1 -fi - -tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : -exitcode=$? -if [ "$exitcode" != "0" ]; then - echo "tar ${pkg_name}.tar.gz error !!!" - exit $exitcode -fi - -cd ${curr_dir} diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 0bc11b99b3..cd656fe6f2 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -85,7 +85,6 @@ else ${build_dir}/bin/${clientName} \ ${taostools_bin_files} \ ${build_dir}/bin/taosadapter \ - ${build_dir}/bin/tarbitrator\ ${script_dir}/remove.sh \ ${script_dir}/set_core.sh \ ${script_dir}/startPre.sh \ @@ -106,8 +105,6 @@ nginx_dir="${top_dir}/../enterprise/src/plugins/web" init_file_deb=${script_dir}/../deb/taosd init_file_rpm=${script_dir}/../rpm/taosd -init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord -init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord # make directories. mkdir -p ${install_dir} @@ -126,10 +123,6 @@ if [ -f "${cfg_dir}/${serverName}.service" ]; then cp ${cfg_dir}/${serverName}.service ${install_dir}/cfg || : fi -if [ -f "${top_dir}/packaging/cfg/tarbitratord.service" ]; then - cp ${top_dir}/packaging/cfg/tarbitratord.service ${install_dir}/cfg || : -fi - if [ -f "${top_dir}/packaging/cfg/nginxd.service" ]; then cp ${top_dir}/packaging/cfg/nginxd.service ${install_dir}/cfg || : fi @@ -137,8 +130,6 @@ fi mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/${serverName}.deb mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/${serverName}.rpm -mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || : -mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || : if [ $adapterName != "taosadapter" ]; then mv ${install_dir}/cfg/taosadapter.toml ${install_dir}/cfg/$adapterName.toml diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 413de17ee6..d34c81a4f5 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Script to stop the service and uninstall TDengine, but retain the config, data and log files. +# Script to stop and uninstall the service, but retain the config, data and log files. set -e #set -x @@ -11,121 +11,216 @@ RED='\033[0;31m' GREEN='\033[1;32m' NC='\033[0m' +installDir="/usr/local/taos" +serverName="taosd" +clientName="taos" +uninstallScript="rmtaos" +productName="TDengine" + #install main path -install_main_dir="/usr/local/taos" -data_link_dir="/usr/local/taos/data" -log_link_dir="/usr/local/taos/log" -cfg_link_dir="/usr/local/taos/cfg" +install_main_dir=${installDir} +data_link_dir=${installDir}/data +log_link_dir=${installDir}/log +cfg_link_dir=${installDir}/cfg bin_link_dir="/usr/bin" +local_bin_link_dir="/usr/local/bin" lib_link_dir="/usr/lib" lib64_link_dir="/usr/lib64" inc_link_dir="/usr/include" +install_nginxd_dir="/usr/local/nginxd" service_config_dir="/etc/systemd/system" -taos_service_name="taosd" - +taos_service_name=${serverName} +taosadapter_service_name="taosadapter" +tarbitrator_service_name="tarbitratord" +nginx_service_name="nginxd" csudo="" -if command -v sudo > /dev/null; then - csudo="sudo" +if command -v sudo >/dev/null; then + csudo="sudo " fi initd_mod=0 service_mod=2 -if pidof systemd &> /dev/null; then - service_mod=0 -elif $(which service &> /dev/null); then - service_mod=1 - service_config_dir="/etc/init.d" - if $(which chkconfig &> /dev/null); then - initd_mod=1 - elif $(which insserv &> /dev/null); then - initd_mod=2 - elif $(which update-rc.d &> /dev/null); then - initd_mod=3 - else - service_mod=2 - fi -else +if pidof systemd &>/dev/null; then + service_mod=0 +elif $(which service &>/dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &>/dev/null); then + initd_mod=1 + elif $(which insserv &>/dev/null); then + initd_mod=2 + elif $(which update-rc.d &>/dev/null); then + initd_mod=3 + else service_mod=2 + fi +else + service_mod=2 fi - -function kill_taosd() { - pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') +function kill_taosadapter() { + pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } +function kill_taosd() { + pid=$(ps -ef | grep ${serverName} | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo}kill -9 $pid || : + fi +} + +function kill_tarbitrator() { + pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo}kill -9 $pid || : + fi +} function clean_bin() { - # Remove link - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/create_table || : - ${csudo} rm -f ${bin_link_dir}/tmq_sim || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - #${csudo} rm -f ${bin_link_dir}/set_core || : + # Remove link + ${csudo}rm -f ${bin_link_dir}/${clientName} || : + ${csudo}rm -f ${bin_link_dir}/${serverName} || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosBenchmark || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : +} + +function clean_local_bin() { + ${csudo}rm -f ${local_bin_link_dir}/taosBenchmark || : + ${csudo}rm -f ${local_bin_link_dir}/taosdemo || : } function clean_lib() { - # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - - ${csudo} rm -f ${lib_link_dir}/libtdb.* || : - ${csudo} rm -f ${lib64_link_dir}/libtdb.* || : + # Remove link + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { - # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : - ${csudo} rm -f ${inc_link_dir}/taosudf.h || : + # Remove link + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { - # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + # Remove link + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { - # Remove link - ${csudo} rm -rf ${log_link_dir} || : + # Remove link + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { - taosd_service_config="${service_config_dir}/${taos_service_name}.service" - if systemctl is-active --quiet ${taos_service_name}; then - echo "TDengine taosd is running, stopping it..." - ${csudo} systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null + taosd_service_config="${service_config_dir}/${taos_service_name}.service" + if systemctl is-active --quiet ${taos_service_name}; then + echo "${productName} ${serverName} is running, stopping it..." + ${csudo}systemctl stop ${taos_service_name} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${taosd_service_config} + + taosadapter_service_config="${service_config_dir}/taosadapter.service" + if systemctl is-active --quiet ${taosadapter_service_name}; then + echo "${productName} taosAdapter is running, stopping it..." + ${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${taosadapter_service_name} &>/dev/null || echo &>/dev/null + [ -f ${taosadapter_service_config} ] && ${csudo}rm -f ${taosadapter_service_config} + + tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" + if systemctl is-active --quiet ${tarbitrator_service_name}; then + echo "${productName} tarbitrator is running, stopping it..." + ${csudo}systemctl stop ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${tarbitratord_service_config} + + if [ "$verMode" == "cluster" ]; then + nginx_service_config="${service_config_dir}/${nginx_service_name}.service" + if [ -d ${install_nginxd_dir} ]; then + if systemctl is-active --quiet ${nginx_service_name}; then + echo "Nginx for ${productName} is running, stopping it..." + ${csudo}systemctl stop ${nginx_service_name} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${nginx_service_name} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${nginx_service_config} fi - ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + fi } function clean_service_on_sysvinit() { - echo " " + if pidof ${serverName} &>/dev/null; then + echo "${productName} ${serverName} is running, stopping it..." + ${csudo}service ${serverName} stop || : + fi + + if pidof tarbitrator &>/dev/null; then + echo "${productName} tarbitrator is running, stopping it..." + ${csudo}service tarbitratord stop || : + fi + + if ((${initd_mod} == 1)); then + if [ -e ${service_config_dir}/${serverName} ]; then + ${csudo}chkconfig --del ${serverName} || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo}chkconfig --del tarbitratord || : + fi + elif ((${initd_mod} == 2)); then + if [ -e ${service_config_dir}/${serverName} ]; then + ${csudo}insserv -r ${serverName} || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo}insserv -r tarbitratord || : + fi + elif ((${initd_mod} == 3)); then + if [ -e ${service_config_dir}/${serverName} ]; then + ${csudo}update-rc.d -f ${serverName} remove || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo}update-rc.d -f tarbitratord remove || : + fi + fi + + ${csudo}rm -f ${service_config_dir}/${serverName} || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : + + if $(which init &>/dev/null); then + ${csudo}init q || : + fi } function clean_service() { - if ((${service_mod}==0)); then - clean_service_on_systemd - elif ((${service_mod}==1)); then - clean_service_on_sysvinit - else - # must manual stop taosd - kill_taosd - fi + if ((${service_mod} == 0)); then + clean_service_on_systemd + elif ((${service_mod} == 1)); then + clean_service_on_sysvinit + else + kill_taosadapter + kill_taosd + kill_tarbitrator + fi } # Stop service and disable booting start. clean_service # Remove binary file and links clean_bin +# Remove links of local bin +clean_local_bin # Remove header file. clean_header # Remove lib file @@ -135,15 +230,26 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : - -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${data_link_dir} || : +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else osinfo="" fi -echo -e "${GREEN}TDengine is removed successfully!${NC}" +if echo $osinfo | grep -qwi "ubuntu"; then + # echo "this is ubuntu system" + ${csudo}dpkg --force-all -P tdengine >/dev/null 2>&1 || : +elif echo $osinfo | grep -qwi "debian"; then + # echo "this is debian system" + ${csudo}dpkg --force-all -P tdengine >/dev/null 2>&1 || : +elif echo $osinfo | grep -qwi "centos"; then + # echo "this is centos system" + ${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || : +fi + +echo -e "${GREEN}${productName} is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_arbi.sh b/packaging/tools/remove_arbi.sh deleted file mode 100755 index c95c579d30..0000000000 --- a/packaging/tools/remove_arbi.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# -# Script to stop the service and uninstall TDengine's arbitrator - -set -e -#set -x - -verMode=edge - -RED='\033[0;31m' -GREEN='\033[1;32m' -NC='\033[0m' - -#install main path -install_main_dir="/usr/local/tarbitrator" -bin_link_dir="/usr/bin" -#inc_link_dir="/usr/include" - -service_config_dir="/etc/systemd/system" -tarbitrator_service_name="tarbitratord" -csudo="" -if command -v sudo > /dev/null; then - csudo="sudo " -fi - -initd_mod=0 -service_mod=2 -if pidof systemd &> /dev/null; then - service_mod=0 -elif $(which service &> /dev/null); then - service_mod=1 - service_config_dir="/etc/init.d" - if $(which chkconfig &> /dev/null); then - initd_mod=1 - elif $(which insserv &> /dev/null); then - initd_mod=2 - elif $(which update-rc.d &> /dev/null); then - initd_mod=3 - else - service_mod=2 - fi -else - service_mod=2 -fi - -function kill_tarbitrator() { - pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') - if [ -n "$pid" ]; then - ${csudo}kill -9 $pid || : - fi -} -function clean_bin() { - # Remove link - ${csudo}rm -f ${bin_link_dir}/tarbitrator || : -} - -function clean_header() { - # Remove link - ${csudo}rm -f ${inc_link_dir}/taos.h || : - ${csudo}rm -f ${inc_link_dir}/taosdef.h || : - ${csudo}rm -f ${inc_link_dir}/taoserror.h || : - ${csudo}rm -f ${inc_link_dir}/taosudf.h || : - -} - -function clean_log() { - # Remove link - ${csudo}rm -rf /arbitrator.log || : -} - -function clean_service_on_systemd() { - tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" - - if systemctl is-active --quiet ${tarbitrator_service_name}; then - echo "TDengine tarbitrator is running, stopping it..." - ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - fi - ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - - ${csudo}rm -f ${tarbitratord_service_config} -} - -function clean_service_on_sysvinit() { - if pidof tarbitrator &> /dev/null; then - echo "TDengine's tarbitrator is running, stopping it..." - ${csudo}service tarbitratord stop || : - fi - - if ((${initd_mod}==1)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}chkconfig --del tarbitratord || : - fi - elif ((${initd_mod}==2)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}insserv -r tarbitratord || : - fi - elif ((${initd_mod}==3)); then - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}update-rc.d -f tarbitratord remove || : - fi - fi - - ${csudo}rm -f ${service_config_dir}/tarbitratord || : - - if $(which init &> /dev/null); then - ${csudo}init q || : - fi -} - -function clean_service() { - if ((${service_mod}==0)); then - clean_service_on_systemd - elif ((${service_mod}==1)); then - clean_service_on_sysvinit - else - # must manual stop - kill_tarbitrator - fi -} - -# Stop service and disable booting start. -clean_service -# Remove binary file and links -clean_bin -# Remove header file. -##clean_header -# Remove log file -clean_log - -${csudo}rm -rf ${install_main_dir} - -echo -e "${GREEN}TDengine's arbitrator is removed successfully!${NC}" diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index d150d68c8d..a234311569 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -89,8 +89,10 @@ void closeTransporter(SAppInstInfo *pAppInfo) { } static bool clientRpcRfp(int32_t code, tmsg_t msgType) { - if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || - code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (NEED_REDIRECT_ERROR(code)) { + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 2de630e181..48fa2d7938 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -262,7 +262,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { return TSDB_CODE_SUCCESS; } -static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) { +static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) { static int32_t emptyRspNum = 0; if (code != 0) { taosMemoryFreeClear(param); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 09fb73cfba..7d42bbdad9 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -769,7 +769,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { code = handleSubmitExecRes(pRequest, pRes->res, pCatalog, &epset); break; } - case TDMT_VND_QUERY: { + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: { code = handleQueryExecRes(pRequest, pRes->res, pCatalog, &epset); break; } @@ -785,6 +786,7 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { SRequestObj* pRequest = (SRequestObj*)param; pRequest->code = code; + pRequest->body.resInfo.execRes = pResult->res; if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) { @@ -796,6 +798,8 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { } } + taosMemoryFree(pResult); + tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId); @@ -1255,10 +1259,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { */ int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start; if (pMsg->code == TSDB_CODE_SUCCESS) { - tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self, + tscDebug("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId); } else { - tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self, + tscError("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId); } @@ -1268,7 +1272,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { updateTargetEpSet(pSendInfo, pTscObj, pMsg, pEpSet); - SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->info.handle}; + SDataBuf buf = {.msgType = pMsg->msgType, .len = pMsg->contLen, .pData = NULL, .handle = pMsg->info.handle, .pEpSet = pEpSet}; if (pMsg->contLen > 0) { buf.pData = taosMemoryCalloc(1, pMsg->contLen); @@ -1407,7 +1411,11 @@ void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertU } SSyncQueryParam* pParam = pRequest->body.param; - + if (NULL == pParam) { + pParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + tsem_init(&pParam->sem, 0, 0); + } + // convert ucs4 to native multi-bytes string pResultInfo->convertUcs4 = convertUcs4; diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index e2b558e61f..761eebee42 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -26,7 +26,7 @@ static void setErrno(SRequestObj* pRequest, int32_t code) { terrno = code; } -int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; setErrno(pRequest, code); @@ -39,7 +39,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { return code; } -int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(pMsg->pData); @@ -116,7 +116,7 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) { return pMsgSendInfo; } -int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) { // todo rsp with the vnode id list SRequestObj* pRequest = param; taosMemoryFree(pMsg->pData); @@ -132,7 +132,7 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { return code; } -int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (TSDB_CODE_MND_DB_NOT_EXIST == code) { @@ -211,7 +211,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { return 0; } -int32_t processCreateSTableRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { assert(pMsg != NULL && param != NULL); SRequestObj* pRequest = param; @@ -229,7 +229,7 @@ int32_t processCreateSTableRsp(void* param, const SDataBuf* pMsg, int32_t code) return code; } -int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); @@ -250,7 +250,7 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { return code; } -int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); @@ -356,7 +356,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { return TSDB_CODE_SUCCESS; } -int32_t processShowVariablesRsp(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 1cb0e2d54b..5039f8bbaf 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2456,10 +2456,10 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr return NULL; } + int batchs = 0; pTscObj->schemalessType = 1; SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf}; - int cnt = ceil(((double)numLines) / LINE_BATCH); Params params; params.request = request; tsem_init(¶ms.sem, 0, 0); @@ -2496,7 +2496,16 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr goto end; } - for (int i = 0; i < cnt; ++i) { + if(protocol == TSDB_SML_JSON_PROTOCOL){ + numLines = 1; + }else if(numLines <= 0){ + request->code = TSDB_CODE_SML_INVALID_DATA; + smlBuildInvalidDataMsg(&msg, "line num is invalid", NULL); + goto end; + } + + batchs = ceil(((double)numLines) / LINE_BATCH); + for (int i = 0; i < batchs; ++i) { SRequestObj* req = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT); if(!req){ request->code = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 5493628e74..667f5b1dbc 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -54,7 +54,8 @@ struct tmq_conf_t { int8_t autoCommit; int8_t resetOffset; int8_t withTbName; - int8_t useSnapshot; + int8_t spEnable; + int32_t spBatchSize; uint16_t port; int32_t autoCommitInterval; char* ip; @@ -288,18 +289,23 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value } } - if (strcmp(key, "experiment.use.snapshot") == 0) { + if (strcmp(key, "experimental.snapshot.enable") == 0) { if (strcmp(value, "true") == 0) { - conf->useSnapshot = true; + conf->spEnable = true; return TMQ_CONF_OK; } else if (strcmp(value, "false") == 0) { - conf->useSnapshot = false; + conf->spEnable = false; return TMQ_CONF_OK; } else { return TMQ_CONF_INVALID; } } + if (strcmp(key, "experimental.snapshot.batch.size") == 0) { + conf->spBatchSize = atoi(value); + return TMQ_CONF_OK; + } + if (strcmp(key, "td.connect.ip") == 0) { conf->ip = strdup(value); return TMQ_CONF_OK; @@ -378,7 +384,7 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) { } #endif -int32_t tmqCommitCb2(void* param, const SDataBuf* pBuf, int32_t code) { +int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) { SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param; SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params; // push into array @@ -813,7 +819,7 @@ void tmqClearUnhandleMsg(tmq_t* tmq) { } } -int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) { SMqSubscribeCbParam* pParam = (SMqSubscribeCbParam*)param; pParam->rspErr = code; /*tmq_t* tmq = pParam->tmq;*/ @@ -918,7 +924,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { strcpy(pTmq->clientId, conf->clientId); strcpy(pTmq->groupId, conf->groupId); pTmq->withTbName = conf->withTbName; - pTmq->useSnapshot = conf->useSnapshot; + pTmq->useSnapshot = conf->spEnable; pTmq->autoCommit = conf->autoCommit; pTmq->autoCommitInterval = conf->autoCommitInterval; pTmq->commitCb = conf->commitCb; @@ -1067,7 +1073,7 @@ int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) { } #endif -int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SMqPollCbParam* pParam = (SMqPollCbParam*)param; SMqClientVg* pVg = pParam->pVg; SMqClientTopic* pTopic = pParam->pTopic; @@ -1324,7 +1330,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { } #endif -int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param; tmq_t* tmq = pParam->tmq; int8_t async = pParam->async; @@ -1541,7 +1547,7 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { } int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { - /*printf("call poll\n");*/ + /*tscDebug("call poll");*/ for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { @@ -1603,8 +1609,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { int64_t transporterId = 0; /*printf("send poll\n");*/ - char offsetFormatBuf[50]; - tFormatOffset(offsetFormatBuf, 50, &pVg->currentOffsetNew); + char offsetFormatBuf[80]; + tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffsetNew); tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %s, reqId %lu", tmq->consumerId, pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId); /*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/ @@ -1702,6 +1708,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { } TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { + /*tscDebug("call poll1");*/ void* rspObj; int64_t startTime = taosGetTimestampMs(); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 7b142e3053..4881dd88aa 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -716,7 +716,12 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) { void* left1 = colDataGetData(pColInfoData, left); void* right1 = colDataGetData(pColInfoData, right); - + if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) { + if (tTagIsJson(left1) || tTagIsJson(right1)) { + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return 0; + } + } __compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order); int ret = fn(left1, right1); @@ -890,9 +895,9 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { SBlockOrderInfo* pOrder = taosArrayGet(pOrderInfo, 0); int64_t p0 = taosGetTimestampUs(); - + __compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order); - qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); + taosSort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); uDebug("blockDataSort easy cost:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); @@ -919,6 +924,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { } taosqsort(index, rows, sizeof(int32_t), &helper, dataBlockCompar); + if(terrno) return terrno; int64_t p1 = taosGetTimestampUs(); @@ -1218,7 +1224,7 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) { for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pDst = taosArrayGet(dst->pDataBlock, i); SColumnInfoData* pSrc = taosArrayGet(src->pDataBlock, i); - if (pSrc->pData == NULL) { + if (pSrc->pData == NULL && (!IS_VAR_DATA_TYPE(pSrc->info.type))) { continue; } @@ -1431,9 +1437,39 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) { } } +static int32_t colDataMoveVarData(SColumnInfoData* pColInfoData, size_t start, size_t end){ + int32_t dataOffset = -1; + int32_t dataLen = 0; + int32_t beigin = start; + while(beigin < end){ + int32_t offset = pColInfoData->varmeta.offset[beigin]; + if(offset == -1) { + beigin++; + continue; + } + if(start != 0) { + pColInfoData->varmeta.offset[beigin] = dataLen; + } + char *data = pColInfoData->pData + offset; + if(dataOffset == -1) dataOffset = offset; // mark the begin of data + int32_t type = pColInfoData->info.type; + if (type == TSDB_DATA_TYPE_JSON) { + dataLen += getJsonValueLen(data); + } else { + dataLen += varDataTLen(data); + } + beigin++; + } + if(dataOffset > 0){ + memmove(pColInfoData->pData, pColInfoData->pData + dataOffset, dataLen); + memmove(pColInfoData->varmeta.offset, &pColInfoData->varmeta.offset[start], (end - start) * sizeof(int32_t)); + } + return dataLen; +} + static void colDataTrimFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_t total) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { - memmove(pColInfoData->varmeta.offset, &pColInfoData->varmeta.offset[n], (total - n) * sizeof(int32_t)); + pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, n, total); memset(&pColInfoData->varmeta.offset[total - n], 0, n); } else { int32_t bytes = pColInfoData->info.bytes; @@ -1461,6 +1497,33 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n) { return TSDB_CODE_SUCCESS; } +static void colDataKeepFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_t total) { + if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { + pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, 0, n); + memset(&pColInfoData->varmeta.offset[n], 0, total - n); + } +} + +int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n) { + if (n == 0) { + blockDataCleanup(pBlock); + return TSDB_CODE_SUCCESS; + } + + if (pBlock->info.rows <= n) { + return TSDB_CODE_SUCCESS; + } else { + size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); + colDataKeepFirstNRows(pColInfoData, n, pBlock->info.rows); + } + + pBlock->info.rows = n; + } + return TSDB_CODE_SUCCESS; +} + int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { int64_t tbUid = pBlock->info.uid; int16_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -1605,6 +1668,13 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { return buf; } +void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag) { + SArray* dataBlocks = taosArrayInit(1, sizeof(SSDataBlock)); + taosArrayPush(dataBlocks, pBlock); + blockDebugShowDataBlocks(dataBlocks, flag); + taosArrayDestroy(dataBlocks); +} + void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { char pBuf[128] = {0}; int32_t sz = taosArrayGetSize(dataBlocks); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 7c1b31b6e4..83ae442ae7 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -931,9 +931,9 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) { // sort if (isJson) { - qsort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn); + taosSort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn); } else { - qsort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn); + taosSort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn); } // get size diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 78eccdf0cd..aaf1e5414c 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -503,6 +503,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfFuncs) < 0) return -1; if (tEncodeI32(&encoder, pReq->commentLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->ast1Len) < 0) return -1; if (tEncodeI32(&encoder, pReq->ast2Len) < 0) return -1; @@ -510,21 +511,26 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq for (int32_t i = 0; i < pReq->numOfColumns; ++i) { SField *pField = taosArrayGet(pReq->pColumns, i); if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI8(&encoder, pField->flags) < 0) return -1; if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; if (tEncodeCStr(&encoder, pField->name) < 0) return -1; - if (tEncodeI8(&encoder, pField->flags) < 0) return -1; } for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField *pField = taosArrayGet(pReq->pTags, i); if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI8(&encoder, pField->flags) < 0) return -1; if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; if (tEncodeCStr(&encoder, pField->name) < 0) return -1; - if (tEncodeI8(&encoder, pField->flags) < 0) return -1; + } + + for (int32_t i = 0; i < pReq->numOfFuncs; ++i) { + const char *pFunc = taosArrayGet(pReq->pFuncs, i); + if (tEncodeCStr(&encoder, pFunc) < 0) return -1; } if (pReq->commentLen > 0) { - if (tEncodeCStr(&encoder, pReq->comment) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1; } if (pReq->ast1Len > 0) { if (tEncodeBinary(&encoder, pReq->pAst1, pReq->ast1Len) < 0) return -1; @@ -533,13 +539,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1; } - int32_t numOfFuncs = taosArrayGetSize(pReq->pFuncs); - if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1; - for (int32_t i = 0; i < numOfFuncs; ++i) { - const char *pFunc = taosArrayGet(pReq->pFuncs, i); - if (tEncodeCStr(&encoder, pFunc) < 0) return -1; - } - tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -561,13 +560,15 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numOfFuncs) < 0) return -1; if (tDecodeI32(&decoder, &pReq->commentLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->ast1Len) < 0) return -1; if (tDecodeI32(&decoder, &pReq->ast2Len) < 0) return -1; pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField)); pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField)); - if (pReq->pColumns == NULL || pReq->pTags == NULL) { + pReq->pFuncs = taosArrayInit(pReq->numOfFuncs, TSDB_FUNC_NAME_LEN); + if (pReq->pColumns == NULL || pReq->pTags == NULL || pReq->pFuncs == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } @@ -575,9 +576,9 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR for (int32_t i = 0; i < pReq->numOfColumns; ++i) { SField field = {0}; if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI8(&decoder, &field.flags) < 0) return -1; if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; - if (tDecodeI8(&decoder, &field.flags) < 0) return -1; if (taosArrayPush(pReq->pColumns, &field) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -587,19 +588,28 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField field = {0}; if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI8(&decoder, &field.flags) < 0) return -1; if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; - if (tDecodeI8(&decoder, &field.flags) < 0) return -1; if (taosArrayPush(pReq->pTags, &field) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } } + for (int32_t i = 0; i < pReq->numOfFuncs; ++i) { + char pFunc[TSDB_FUNC_NAME_LEN] = {0}; + if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1; + if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + if (pReq->commentLen > 0) { - pReq->comment = taosMemoryMalloc(pReq->commentLen + 1); - if (pReq->comment == NULL) return -1; - if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1; + pReq->pComment = taosMemoryMalloc(pReq->commentLen + 1); + if (pReq->pComment == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1; } if (pReq->ast1Len > 0) { @@ -614,23 +624,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1; } - int32_t numOfFuncs = 0; - if (tDecodeI32(&decoder, &numOfFuncs) < 0) return -1; - if (numOfFuncs > 0) { - pReq->pFuncs = taosArrayInit(numOfFuncs, TSDB_FUNC_NAME_LEN); - if (NULL == pReq->pFuncs) return -1; - } - for (int32_t i = 0; i < numOfFuncs; ++i) { - char pFunc[TSDB_FUNC_NAME_LEN] = {0}; - if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1; - if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - } - tEndDecode(&decoder); - tDecoderClear(&decoder); return 0; } @@ -638,10 +632,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR void tFreeSMCreateStbReq(SMCreateStbReq *pReq) { taosArrayDestroy(pReq->pColumns); taosArrayDestroy(pReq->pTags); - taosMemoryFreeClear(pReq->comment); + taosArrayDestroy(pReq->pFuncs); + taosMemoryFreeClear(pReq->pComment); taosMemoryFreeClear(pReq->pAst1); taosMemoryFreeClear(pReq->pAst2); - taosArrayDestroy(pReq->pFuncs); } int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) { @@ -4309,6 +4303,7 @@ int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pR if (tEncodeU64(&encoder, status->queryId) < 0) return -1; if (tEncodeU64(&encoder, status->taskId) < 0) return -1; if (tEncodeI64(&encoder, status->refId) < 0) return -1; + if (tEncodeI32(&encoder, status->execId) < 0) return -1; if (tEncodeI8(&encoder, status->status) < 0) return -1; } } else { @@ -4339,6 +4334,7 @@ int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp * if (tDecodeU64(&decoder, &status.queryId) < 0) return -1; if (tDecodeU64(&decoder, &status.taskId) < 0) return -1; if (tDecodeI64(&decoder, &status.refId) < 0) return -1; + if (tDecodeI32(&decoder, &status.execId) < 0) return -1; if (tDecodeI8(&decoder, &status.status) < 0) return -1; taosArrayPush(pRsp->taskStatus, &status); } @@ -4641,6 +4637,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS 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 (tEncodeI8(&encoder, pReq->igExpired) < 0) return -1; if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; @@ -4668,6 +4665,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea 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 (tDecodeI8(&decoder, &pReq->igExpired) < 0) return -1; if (sqlLen > 0) { pReq->sql = taosMemoryCalloc(1, sqlLen + 1); @@ -5398,9 +5396,9 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { } else if (pVal->type == TMQ_OFFSET__LOG) { snprintf(buf, maxLen, "offset(log) ver:%ld", pVal->version); } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA) { - snprintf(buf, maxLen, "offset(snapshot data) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + snprintf(buf, maxLen, "offset(ss data) uid:%ld, ts:%ld", pVal->uid, pVal->ts); } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_META) { - snprintf(buf, maxLen, "offset(snapshot meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + snprintf(buf, maxLen, "offset(ss meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts); } else { ASSERT(0); } @@ -5502,4 +5500,3 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { } return 0; } - diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 7b0bef4918..0810be1497 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -155,7 +155,8 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin void taosVariantDestroy(SVariant *pVar) { if (pVar == NULL) return; - if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { + if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR + || pVar->nType == TSDB_DATA_TYPE_JSON) { taosMemoryFreeClear(pVar->pz); pVar->nLen = 0; } @@ -184,7 +185,8 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; pDst->nType = pSrc->nType; - if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) { + if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR + || pSrc->nType == TSDB_DATA_TYPE_JSON) { int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; char *p = taosMemoryRealloc(pDst->pz, len); assert(p); @@ -976,6 +978,7 @@ char *taosVariantGet(SVariant *pVar, int32_t type) { case TSDB_DATA_TYPE_FLOAT: return (char *)&pVar->d; case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_JSON: return (char *)pVar->pz; case TSDB_DATA_TYPE_NCHAR: return (char *)pVar->ucs4; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 3bf6d9b04f..59d68b2110 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -209,10 +209,11 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; @@ -220,7 +221,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c index 864f5b485a..1f22eefddf 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c @@ -107,14 +107,15 @@ SArray *qmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MON_QM_INFO, qmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER; // Requests handled by VNODE - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_RSP, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH_RSP, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER; code = 0; _OVER: diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 00d83f0ad4..5bc9582527 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -324,16 +324,17 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MON_VM_LOAD, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; @@ -349,7 +350,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 1c5d74bb94..35d478177a 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -41,6 +41,7 @@ static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { } static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) { + pMsg->info.hasEpSet = 1; SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet); @@ -86,7 +87,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { return; case TDMT_MND_SYSTABLE_RETRIEVE_RSP: case TDMT_DND_SYSTABLE_RETRIEVE_RSP: - case TDMT_VND_FETCH_RSP: + case TDMT_SCH_FETCH_RSP: qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0); return; case TDMT_MND_STATUS_RSP: @@ -250,7 +251,10 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { static bool rpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || - code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) { + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 0605e3a69e..21002f5f9c 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -341,11 +341,12 @@ typedef struct { int32_t colVer; int32_t smaVer; int32_t nextColId; - int64_t watermark[2]; int64_t maxdelay[2]; + int64_t watermark[2]; int32_t ttl; int32_t numOfColumns; int32_t numOfTags; + int32_t numOfFuncs; int32_t commentLen; int32_t ast1Len; int32_t ast2Len; @@ -555,7 +556,7 @@ typedef struct { int64_t uid; int8_t status; // config - int8_t dropPolicy; + int8_t igExpired; int8_t trigger; int64_t triggerParam; int64_t watermark; diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index e0ff7a70d7..6622b89b1d 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -47,6 +47,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *cntlen, bool standby); void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen); void *mndBuildAlterVnodeReq(SMnode *, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen); +bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index abd1492d5e..dabb938705 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -645,7 +645,7 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid == pNew->uid) { + if (mndVgroupInDb(pVgroup, pNew->uid)) { if (mndBuildAlterVgroupAction(pMnode, pTrans, pNew, pVgroup, pArray) != 0) { sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pVgroup); @@ -1006,7 +1006,7 @@ static int32_t mndGetDBTableNum(SDbObj *pDb, SMnode *pMnode) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid == pDb->uid) { + if (mndVgroupInDb(pVgroup, pDb->uid)) { numOfTables += pVgroup->numOfTables / TSDB_TABLE_NUM_UNIT; vindex++; } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index dc7f08ebc2..727b20ef8a 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -28,7 +28,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) { if (tEncodeI64(pEncoder, pObj->uid) < 0) return -1; if (tEncodeI8(pEncoder, pObj->status) < 0) return -1; - if (tEncodeI8(pEncoder, pObj->dropPolicy) < 0) return -1; + if (tEncodeI8(pEncoder, pObj->igExpired) < 0) return -1; if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1; if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1; if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1; @@ -73,7 +73,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) { if (tDecodeI64(pDecoder, &pObj->uid) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1; - if (tDecodeI8(pDecoder, &pObj->dropPolicy) < 0) return -1; + if (tDecodeI8(pDecoder, &pObj->igExpired) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1; if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1; if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index fa9c8606bb..c39c9847a9 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -58,7 +58,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) { static void mndPullupTrans(SMnode *pMnode) { int32_t contLen = 0; - void *pReq = mndBuildTimerMsg(&contLen); + void * pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen}; tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); @@ -67,14 +67,14 @@ static void mndPullupTrans(SMnode *pMnode) { static void mndTtlTimer(SMnode *pMnode) { int32_t contLen = 0; - void *pReq = mndBuildTimerMsg(&contLen); + void * pReq = mndBuildTimerMsg(&contLen); SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen}; tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } static void mndCalMqRebalance(SMnode *pMnode) { int32_t contLen = 0; - void *pReq = mndBuildTimerMsg(&contLen); + void * pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen}; tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); @@ -83,7 +83,7 @@ static void mndCalMqRebalance(SMnode *pMnode) { static void mndPullupTelem(SMnode *pMnode) { int32_t contLen = 0; - void *pReq = mndBuildTimerMsg(&contLen); + void * pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen}; tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); @@ -395,7 +395,7 @@ void mndStop(SMnode *pMnode) { } int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { - SMnode *pMnode = pMsg->info.node; + SMnode * pMnode = pMsg->info.node; SSyncMgmt *pMgmt = &pMnode->syncMgmt; int32_t code = 0; @@ -413,7 +413,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { } do { - char *syncNodeStr = sync2SimpleStr(pMgmt->sync); + char * syncNodeStr = sync2SimpleStr(pMgmt->sync); static int64_t mndTick = 0; if (++mndTick % 10 == 1) { mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); @@ -527,9 +527,9 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; - if (pMsg->msgType == TDMT_VND_QUERY || pMsg->msgType == TDMT_VND_QUERY_CONTINUE || - pMsg->msgType == TDMT_VND_QUERY_HEARTBEAT || pMsg->msgType == TDMT_VND_FETCH || - pMsg->msgType == TDMT_VND_DROP_TASK) { + if (pMsg->msgType == TDMT_SCH_QUERY || pMsg->msgType == TDMT_SCH_MERGE_QUERY || + pMsg->msgType == TDMT_SCH_QUERY_CONTINUE || pMsg->msgType == TDMT_SCH_QUERY_HEARTBEAT || + pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_SCH_DROP_TASK) { return 0; } if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0; @@ -552,6 +552,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); pMsg->info.rsp = rpcMallocCont(contLen); + pMsg->info.hasEpSet = 1; if (pMsg->info.rsp != NULL) { tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); pMsg->info.rspLen = contLen; @@ -578,7 +579,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) { } int32_t mndProcessRpcMsg(SRpcMsg *pMsg) { - SMnode *pMnode = pMsg->info.node; + SMnode * pMnode = pMsg->info.node; const STraceId *trace = &pMsg->info.traceId; MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)]; @@ -631,7 +632,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo) { if (mndAcquireRpcRef(pMnode) != 0) return -1; - SSdb *pSdb = pMnode->pSdb; + SSdb * pSdb = pMnode->pSdb; int64_t ms = taosGetTimestampMs(); pClusterInfo->dnodes = taosArrayInit(sdbGetSize(pSdb, SDB_DNODE), sizeof(SMonDnodeDesc)); @@ -712,7 +713,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pGrantInfo->timeseries_used += pVgroup->numOfTimeSeries; tstrncpy(desc.status, "unsynced", sizeof(desc.status)); for (int32_t i = 0; i < pVgroup->replica; ++i) { - SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; + SVnodeGid * pVgid = &pVgroup->vnodeGid[i]; SMonVnodeDesc *pVnDesc = &desc.vnodes[i]; pVnDesc->dnode_id = pVgid->dnodeId; tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->role), sizeof(pVnDesc->vnode_role)); diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index 671152f9c6..aec99fa3b7 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -19,13 +19,13 @@ #include "qworker.h" int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg) { - if (TDMT_VND_QUERY != pMsg->msgType) return 0; + if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) return 0; SMnode *pMnode = pMsg->info.node; return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg); } void mndPostProcessQueryMsg(SRpcMsg *pMsg) { - if (TDMT_VND_QUERY != pMsg->msgType) return; + if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) return; SMnode *pMnode = pMsg->info.node; qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg); } @@ -37,19 +37,20 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) { mTrace("msg:%p, in query queue is processing", pMsg); switch (pMsg->msgType) { - case TDMT_VND_QUERY: + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: code = qWorkerProcessQueryMsg(&handle, pMnode->pQuery, pMsg, 0); break; - case TDMT_VND_QUERY_CONTINUE: + case TDMT_SCH_QUERY_CONTINUE: code = qWorkerProcessCQueryMsg(&handle, pMnode->pQuery, pMsg, 0); break; - case TDMT_VND_FETCH: + case TDMT_SCH_FETCH: code = qWorkerProcessFetchMsg(pMnode, pMnode->pQuery, pMsg, 0); break; - case TDMT_VND_DROP_TASK: + case TDMT_SCH_DROP_TASK: code = qWorkerProcessDropMsg(pMnode, pMnode->pQuery, pMsg, 0); break; - case TDMT_VND_QUERY_HEARTBEAT: + case TDMT_SCH_QUERY_HEARTBEAT: code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0); break; default: @@ -67,11 +68,12 @@ int32_t mndInitQuery(SMnode *pMnode) { return -1; } - mndSetMsgHandle(pMnode, TDMT_VND_QUERY, mndProcessQueryMsg); - mndSetMsgHandle(pMnode, TDMT_VND_QUERY_CONTINUE, mndProcessQueryMsg); - mndSetMsgHandle(pMnode, TDMT_VND_FETCH, mndProcessQueryMsg); - mndSetMsgHandle(pMnode, TDMT_VND_DROP_TASK, mndProcessQueryMsg); - mndSetMsgHandle(pMnode, TDMT_VND_QUERY_HEARTBEAT, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_QUERY, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_QUERY, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_CONTINUE, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_FETCH, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg); return 0; } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index eb0ccbb5f7..aa6e7192fc 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -225,10 +225,11 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) { SVgObj* pVgroup; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); if (pIter == NULL) break; - if (strcmp(pVgroup->dbName, pStream->targetDb) != 0) { + if (!mndVgroupInDb(pVgroup, pStream->targetDbUid)) { sdbRelease(pSdb, pVgroup); continue; } + SStreamTask* pTask = tNewSStreamTask(pStream->uid); if (pTask == NULL) { sdbRelease(pSdb, pVgroup); @@ -420,10 +421,11 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { SVgObj* pVgroup; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pStream->sourceDbUid) { + if (!mndVgroupInDb(pVgroup, pStream->sourceDbUid)) { sdbRelease(pSdb, pVgroup); continue; } + SStreamTask* pTask = tNewSStreamTask(pStream->uid); if (pInnerTask == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -483,10 +485,11 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { SVgObj* pVgroup; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pStream->sourceDbUid) { + if (!mndVgroupInDb(pVgroup, pStream->sourceDbUid)) { sdbRelease(pSdb, pVgroup); continue; } + SStreamTask* pTask = tNewSStreamTask(pStream->uid); if (pTask == NULL) { sdbRelease(pSdb, pVgroup); @@ -559,7 +562,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pTopic->dbUid) { + if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) { sdbRelease(pSdb, pVgroup); continue; } diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 10eeaba982..530cc57390 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -396,6 +396,8 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb stbObj.pColumns = NULL; stbObj.numOfTags = 0; stbObj.pTags = NULL; + stbObj.numOfFuncs = 0; + stbObj.pFuncs = NULL; stbObj.updateTime = taosGetTimestampMs(); stbObj.lock = 0; stbObj.smaVer++; @@ -408,47 +410,6 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb return 0; } -#if 0 -static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) { - SSdb *pSdb = pMnode->pSdb; - SVgObj *pVgroup = NULL; - void *pIter = NULL; - int32_t contLen; - - while (1) { - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { - sdbRelease(pSdb, pVgroup); - continue; - } - - void *pReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &contLen); - if (pReq == NULL) { - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_VND_CREATE_SMA; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(pReq); - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - return -1; - } - sdbRelease(pSdb, pVgroup); - } - - return 0; -} -#endif - static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SSmaObj *pSma) { SVnodeGid *pVgid = pVgroup->vnodeGid + 0; @@ -621,7 +582,6 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER; if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; - // if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER; if (mndScheduleStream(pMnode, &streamObj) != 0) goto _OVER; if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER; @@ -770,49 +730,6 @@ static int32_t mndSetDropSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, SVg return 0; } -#if 0 -static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) { - SSdb *pSdb = pMnode->pSdb; - SVgObj *pVgroup = NULL; - void *pIter = NULL; - int32_t contLen; - - while (1) { - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { - sdbRelease(pSdb, pVgroup); - continue; - } - - int32_t contLen = 0; - void *pReq = mndBuildVDropSmaReq(pMnode, pVgroup, pSma, &contLen); - if (pReq == NULL) { - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_VND_DROP_SMA; - action.acceptableCode = TSDB_CODE_VND_SMA_NOT_EXIST; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(pReq); - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - return -1; - } - sdbRelease(pSdb, pVgroup); - } - - return 0; -} -#endif - static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) { SVnodeGid *pVgid = pVgroup->vnodeGid + 0; SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); @@ -879,7 +796,6 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; - // if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; @@ -906,10 +822,20 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p if (pSma->stbUid == pStb->uid) { pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId); if (pVgroup == NULL) goto _OVER; + + SStreamObj *pStream = mndAcquireStream(pMnode, pSma->name); + if (pStream != NULL && pStream->smaId == pSma->uid) { + if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { + mError("stream:%s, failed to drop task since %s", pStream->name, terrstr()); + goto _OVER; + } + if (mndPersistDropStreamLog(pMnode, pTrans, pStream) < 0) { + goto _OVER; + } + } if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; - // if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; mndReleaseVgroup(pMnode, pVgroup); pVgroup = NULL; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index dd01a0fa16..c7a89945f8 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -78,7 +78,7 @@ void mndCleanupStb(SMnode *pMnode) {} SSdbRaw *mndStbActionEncode(SStbObj *pStb) { terrno = TSDB_CODE_OUT_OF_MEMORY; - int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + +pStb->commentLen + + int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + pStb->commentLen + pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE + taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN; SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size); if (pRaw == NULL) goto _OVER; @@ -92,6 +92,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->tagVer, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->colVer, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->smaVer, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER) SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[0], _OVER) SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[1], _OVER) @@ -100,17 +101,11 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { SDB_SET_INT32(pRaw, dataPos, pStb->ttl, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfFuncs, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->ast1Len, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->ast2Len, _OVER) - int32_t funcNum = taosArrayGetSize(pStb->pFuncs); - SDB_SET_INT32(pRaw, dataPos, funcNum, _OVER) - for (int32_t i = 0; i < funcNum; ++i) { - char *func = taosArrayGet(pStb->pFuncs, i); - SDB_SET_BINARY(pRaw, dataPos, func, TSDB_FUNC_NAME_LEN, _OVER) - } - for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) @@ -129,15 +124,23 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } + for (int32_t i = 0; i < pStb->numOfFuncs; ++i) { + char *func = taosArrayGet(pStb->pFuncs, i); + SDB_SET_BINARY(pRaw, dataPos, func, TSDB_FUNC_NAME_LEN, _OVER) + } + if (pStb->commentLen > 0) { SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER) } + if (pStb->ast1Len > 0) { SDB_SET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER) } + if (pStb->ast2Len > 0) { SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER) } + SDB_SET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -180,6 +183,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->tagVer, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->colVer, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->smaVer, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER) SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[0], _OVER) SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[1], _OVER) @@ -188,27 +192,15 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfFuncs, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->ast1Len, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->ast2Len, _OVER) - int32_t funcNum = 0; - SDB_GET_INT32(pRaw, dataPos, &funcNum, _OVER) - if (funcNum > 0) { - pStb->pFuncs = taosArrayInit(funcNum, TSDB_FUNC_NAME_LEN); - if (NULL == pStb->pFuncs) { - goto _OVER; - } - char funcName[TSDB_FUNC_NAME_LEN]; - for (int32_t i = 0; i < funcNum; ++i) { - SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER) - taosArrayPush(pStb->pFuncs, funcName); - } - } - pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema)); pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema)); - if (pStb->pColumns == NULL || pStb->pTags == NULL) { + pStb->pFuncs = taosArrayInit(pStb->numOfFuncs, TSDB_FUNC_NAME_LEN); + if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pFuncs == NULL) { goto _OVER; } @@ -230,16 +222,24 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } + for (int32_t i = 0; i < pStb->numOfFuncs; ++i) { + char funcName[TSDB_FUNC_NAME_LEN] = {0}; + SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER) + taosArrayPush(pStb->pFuncs, funcName); + } + if (pStb->commentLen > 0) { pStb->comment = taosMemoryCalloc(pStb->commentLen + 1, 1); if (pStb->comment == NULL) goto _OVER; SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER) } + if (pStb->ast1Len > 0) { pStb->pAst1 = taosMemoryCalloc(pStb->ast1Len, 1); if (pStb->pAst1 == NULL) goto _OVER; SDB_GET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER) } + if (pStb->ast2Len > 0) { pStb->pAst2 = taosMemoryCalloc(pStb->ast2Len, 1); if (pStb->pAst2 == NULL) goto _OVER; @@ -273,6 +273,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) { taosMemoryFreeClear(pStb->pColumns); taosMemoryFreeClear(pStb->pTags); taosMemoryFreeClear(pStb->comment); + taosMemoryFreeClear(pStb->pFuncs); taosMemoryFreeClear(pStb->pAst1); taosMemoryFreeClear(pStb->pAst2); taosArrayDestroy(pStb->pFuncs); @@ -322,7 +323,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { pOld->commentLen = pNew->commentLen; if (pOld->ast1Len < pNew->ast1Len) { - void *pAst1 = taosMemoryMalloc(pNew->ast1Len); + void *pAst1 = taosMemoryMalloc(pNew->ast1Len + 1); if (pAst1 != NULL) { taosMemoryFree(pOld->pAst1); pOld->pAst1 = pAst1; @@ -334,7 +335,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { } if (pOld->ast2Len < pNew->ast2Len) { - void *pAst2 = taosMemoryMalloc(pNew->ast2Len); + void *pAst2 = taosMemoryMalloc(pNew->ast2Len + 1); if (pAst2 != NULL) { taosMemoryFree(pOld->pAst2); pOld->pAst2 = pAst2; @@ -361,12 +362,15 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { } if (pNew->commentLen > 0) { memcpy(pOld->comment, pNew->comment, pNew->commentLen + 1); + pOld->commentLen = pNew->commentLen; } if (pNew->ast1Len != 0) { memcpy(pOld->pAst1, pNew->pAst1, pNew->ast1Len); + pOld->ast1Len = pNew->ast1Len; } if (pNew->ast2Len != 0) { memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len); + pOld->ast2Len = pNew->ast2Len; } taosWUnLockLatch(&pOld->lock); return 0; @@ -575,7 +579,10 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) { static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { SSdbRaw *pRedoRaw = mndStbActionEncode(pStb); if (pRedoRaw == NULL) return -1; - if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { + sdbFreeRaw(pRedoRaw); + return -1; + } if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) return -1; return 0; @@ -584,7 +591,10 @@ static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { SSdbRaw *pUndoRaw = mndStbActionEncode(pStb); if (pUndoRaw == NULL) return -1; - if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) return -1; + if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) { + sdbFreeRaw(pUndoRaw); + return -1; + } if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1; return 0; @@ -593,7 +603,10 @@ static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p static int32_t mndSetCreateStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { SSdbRaw *pCommitRaw = mndStbActionEncode(pStb); if (pCommitRaw == NULL) return -1; - if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + sdbFreeRaw(pCommitRaw); + return -1; + } if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1; return 0; @@ -608,7 +621,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { + if (!mndVgroupInDb(pVgroup, pDb->uid)) { sdbRelease(pSdb, pVgroup); continue; } @@ -646,7 +659,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { + if (!mndVgroupInDb(pVgroup, pDb->uid)) { sdbRelease(pSdb, pVgroup); continue; } @@ -697,6 +710,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat pDst->dbUid = pDb->uid; pDst->tagVer = 1; pDst->colVer = 1; + pDst->smaVer = 1; pDst->nextColId = 1; pDst->maxdelay[0] = pCreate->delay1; pDst->maxdelay[1] = pCreate->delay2; @@ -705,6 +719,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat pDst->ttl = pCreate->ttl; pDst->numOfColumns = pCreate->numOfColumns; pDst->numOfTags = pCreate->numOfTags; + pDst->numOfFuncs = pCreate->numOfFuncs; pDst->commentLen = pCreate->commentLen; pDst->pFuncs = pCreate->pFuncs; pCreate->pFuncs = NULL; @@ -715,7 +730,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - memcpy(pDst->comment, pCreate->comment, pDst->commentLen + 1); + memcpy(pDst->comment, pCreate->pComment, pDst->commentLen + 1); } pDst->ast1Len = pCreate->ast1Len; @@ -770,20 +785,15 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCreate, SDbObj *pDb) { SStbObj stbObj = {0}; - int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name); - if (mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb) != 0) goto _OVER; - if (mndAddStbToTrans(pMnode, pTrans, pDb, &stbObj) < 0) goto _OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; - code = 0; _OVER: @@ -906,7 +916,8 @@ _OVER: } static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) { - if (pAlter->commentLen >= 0 || pAlter->ttl != 0) return 0; + if (pAlter->commentLen >= 0) return 0; + if (pAlter->ttl != 0) return 0; if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) { terrno = TSDB_CODE_MND_INVALID_STB_OPTION; @@ -969,6 +980,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha memcpy(pNew->comment, pComment, commentLen + 1); } else if (commentLen == 0) { pNew->commentLen = 0; + } else { } if (ttl >= 0) { @@ -1245,7 +1257,10 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { SSdbRaw *pRedoRaw = mndStbActionEncode(pStb); if (pRedoRaw == NULL) return -1; - if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { + sdbFreeRaw(pRedoRaw); + return -1; + } if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) return -1; return 0; @@ -1254,7 +1269,10 @@ static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { SSdbRaw *pCommitRaw = mndStbActionEncode(pStb); if (pCommitRaw == NULL) return -1; - if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + sdbFreeRaw(pCommitRaw); + return -1; + } if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1; return 0; @@ -1269,7 +1287,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { + if (!mndVgroupInDb(pVgroup, pDb->uid)) { sdbRelease(pSdb, pVgroup); continue; } @@ -1388,7 +1406,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName, pSchema->bytes = pSrcSchema->bytes; } - if (pStb->pFuncs) { + if (pStb->numOfFuncs > 0) { pRsp->pFuncs = taosArrayDup(pStb->pFuncs); } @@ -1626,7 +1644,10 @@ _OVER: static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) { SSdbRaw *pRedoRaw = mndStbActionEncode(pStb); if (pRedoRaw == NULL) return -1; - if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { + sdbFreeRaw(pRedoRaw); + return -1; + } if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1; return 0; @@ -1635,7 +1656,10 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS static int32_t mndSetDropStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) { SSdbRaw *pCommitRaw = mndStbActionEncode(pStb); if (pCommitRaw == NULL) return -1; - if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + sdbFreeRaw(pCommitRaw); + return -1; + } if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1; return 0; @@ -1649,7 +1673,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != pDb->uid) { + if (!mndVgroupInDb(pVgroup, pDb->uid)) { sdbRelease(pSdb, pVgroup); continue; } @@ -1683,7 +1707,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index cabbac14f1..c27d007fbd 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -248,7 +248,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->status = 0; // TODO - pObj->dropPolicy = 0; + pObj->igExpired = pCreate->igExpired; pObj->trigger = pCreate->triggerType; pObj->triggerParam = pCreate->maxDelay; pObj->watermark = pCreate->watermark; @@ -301,6 +301,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, .streamQuery = true, .triggerType = pObj->trigger == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : pObj->trigger, .watermark = pObj->watermark, + .igExpired = pObj->igExpired, }; // using ast and param to build physical plan diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index c58ce97588..693eed5222 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -117,7 +117,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM } } -int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { +int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) { mDebug("start to read snapshot from sdb"); SMnode *pMnode = pFsm->data; return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index b09ee5f608..534cba73c7 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1146,13 +1146,13 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) } else { code = TSDB_CODE_ACTION_IN_PROGRESS; } - } - if (pAction->rawWritten) { + } else if (pAction->rawWritten) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { code = pAction->errCode; } else { mDebug("trans:%d, %s:%d write successfully", pTrans->id, mndTransStr(pAction->stage), action); } + } else { } } diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index d42016e6a0..5ca945624d 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -426,7 +426,15 @@ static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) { float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes; float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes; +#if 0 + if (d1Score == d2Score) { + return pDnode2->id - pDnode1->id; + } else { + return d1Score >= d2Score ? 1 : 0; + } +#else return d1Score >= d2Score ? 1 : 0; +#endif } void mndSortVnodeGid(SVgObj *pVgroup) { @@ -1751,4 +1759,6 @@ _OVER: taosArrayDestroy(pArray); return code; -} \ No newline at end of file +} + +bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid) { return !pVgroup->isTsma && pVgroup->dbUid == dbUid; } \ No newline at end of file diff --git a/source/dnode/qnode/src/qnode.c b/source/dnode/qnode/src/qnode.c index ebaf73a952..cfc63b083d 100644 --- a/source/dnode/qnode/src/qnode.c +++ b/source/dnode/qnode/src/qnode.c @@ -65,7 +65,7 @@ int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { } int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) { - if (TDMT_VND_QUERY != pMsg->msgType) { + if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) { return 0; } @@ -78,28 +78,29 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) { qTrace("message in qnode queue is processing"); switch (pMsg->msgType) { - case TDMT_VND_QUERY: + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts); break; - case TDMT_VND_QUERY_CONTINUE: + case TDMT_SCH_QUERY_CONTINUE: code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts); break; - case TDMT_VND_FETCH: + case TDMT_SCH_FETCH: code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts); break; - case TDMT_VND_FETCH_RSP: + case TDMT_SCH_FETCH_RSP: code = qWorkerProcessFetchRsp(pQnode, pQnode->pQuery, pMsg, ts); break; - case TDMT_VND_CANCEL_TASK: + case TDMT_SCH_CANCEL_TASK: code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts); break; - case TDMT_VND_DROP_TASK: + case TDMT_SCH_DROP_TASK: code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts); break; case TDMT_VND_CONSUME: // code = tqProcessConsumeReq(pQnode->pTq, pMsg); // break; - case TDMT_VND_QUERY_HEARTBEAT: + case TDMT_SCH_QUERY_HEARTBEAT: code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts); break; default: diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index b09ab34224..174fe6dab5 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -31,6 +31,8 @@ target_sources( "src/sma/smaEnv.c" "src/sma/smaUtil.c" "src/sma/smaOpen.c" + "src/sma/smaCommit.c" + "src/sma/smaSnapshot.c" "src/sma/smaRollup.c" "src/sma/smaTimeRange.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index cef0bbbc01..4dc11a4815 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -116,6 +116,7 @@ typedef void *tsdbReaderT; #define BLOCK_LOAD_TABLE_SEQ_ORDER 2 #define BLOCK_LOAD_TABLE_RR_ORDER 3 +int32_t tsdbSetTableId(tsdbReaderT reader, int64_t uid); int32_t tsdbSetTableList(tsdbReaderT reader, SArray *tableList); tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableList, uint64_t qId, uint64_t taskId); diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index b455d779c1..a95eb395c2 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -92,8 +92,9 @@ enum { TASK_TRIGGER_STAT_INIT = 0, TASK_TRIGGER_STAT_ACTIVE = 1, TASK_TRIGGER_STAT_INACTIVE = 2, - TASK_TRIGGER_STAT_CANCELLED = 3, - TASK_TRIGGER_STAT_FINISHED = 4, + TASK_TRIGGER_STAT_PAUSED = 3, + TASK_TRIGGER_STAT_CANCELLED = 4, + TASK_TRIGGER_STAT_FINISHED = 5, }; void tdDestroySmaEnv(SSmaEnv *pSmaEnv); void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); @@ -214,25 +215,22 @@ struct STFInfo { }; struct STFile { - STFInfo info; - STfsFile f; - TdFilePtr pFile; uint8_t state; + STFInfo info; + char *fname; + TdFilePtr pFile; }; -#define TD_TFILE_F(tf) (&((tf)->f)) #define TD_TFILE_PFILE(tf) ((tf)->pFile) #define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL) -#define TD_TFILE_FULL_NAME(tf) (TD_TFILE_F(tf)->aname) -#define TD_TFILE_REL_NAME(tf) (TD_TFILE_F(tf)->rname) +#define TD_TFILE_FULL_NAME(tf) ((tf)->fname) #define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL) #define TD_TFILE_CLOSED(tf) (!TD_TFILE_OPENED(tf)) #define TD_TFILE_SET_CLOSED(f) (TD_TFILE_PFILE(f) = NULL) #define TD_TFILE_SET_STATE(tf, s) ((tf)->state = (s)) -#define TD_TFILE_DID(tf) (TD_TFILE_F(tf)->did) -int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname); -int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fType); +int32_t tdInitTFile(STFile *pTFile, const char *dname, const char *fname); +int32_t tdCreateTFile(STFile *pTFile, bool updateHeader, int8_t fType); int32_t tdOpenTFile(STFile *pTFile, int flags); int64_t tdReadTFile(STFile *pTFile, void *buf, int64_t nbyte); int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence); @@ -244,8 +242,10 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo); int32_t tdUpdateTFileHeader(STFile *pTFile); void tdUpdateTFileMagic(STFile *pTFile, void *pCksm); void tdCloseTFile(STFile *pTFile); +void tdDestroyTFile(STFile *pTFile); -void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, char *outputName); +void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, int64_t version, char *outputName); +void tdGetVndDirName(int32_t vgId, const char *dname, char *outputName); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 38a4f28041..d10935c022 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -157,11 +157,11 @@ typedef struct { static STqMgmt tqMgmt = {0}; // tqRead -int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead** pHeadWithCkSum); +int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum); // tqExec int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId); -int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId); +int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId); int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); // tqMeta @@ -178,11 +178,23 @@ STqOffsetStore* tqOffsetOpen(); void tqOffsetClose(STqOffsetStore*); STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey); int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset); +int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey); int32_t tqOffsetSnapshot(STqOffsetStore* pStore); // tqSink void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data); +static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) { + pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA; + pOffsetVal->uid = uid; + pOffsetVal->ts = ts; +} + +static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) { + pOffsetVal->type = TMQ_OFFSET__LOG; + pOffsetVal->version = ver; +} + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 6bd7d4edd1..c52884d6ad 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -165,6 +165,9 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool int32_t smaOpen(SVnode* pVnode); int32_t smaCloseEnv(SSma* pSma); int32_t smaCloseEx(SSma* pSma); +int32_t smaPreCommit(SSma* pSma); +int32_t smaCommit(SSma* pSma); +int32_t smaPostCommit(SSma* pSma); int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg); int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c new file mode 100644 index 0000000000..b98f9bc866 --- /dev/null +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -0,0 +1,150 @@ +/* + * 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" + +static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma); +static int32_t tdProcessRSmaCommitImpl(SSma *pSma); +static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma); + +/** + * @brief Only applicable to Rollup SMA + * + * @param pSma + * @return int32_t + */ +int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaPreCommitImpl(pSma); } + +/** + * @brief Only applicable to Rollup SMA + * + * @param pSma + * @return int32_t + */ +int32_t smaCommit(SSma *pSma) { return tdProcessRSmaCommitImpl(pSma); } + +/** + * @brief Only applicable to Rollup SMA + * + * @param pSma + * @return int32_t + */ +int32_t smaPostCommit(SSma *pSma) { return tdProcessRSmaPostCommitImpl(pSma); } + +/** + * @brief pre-commit for rollup sma. + * 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED. + * 2) perform persist task for qTaskInfo + * 3) wait all triggered fetch tasks finished + * 4) set trigger stat of rsma timer TASK_TRIGGER_STAT_ACTIVE. + * 5) finish + * + * @param pSma + * @return int32_t + */ +static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) { + SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma); + if (!pSmaEnv) { + return TSDB_CODE_SUCCESS; + } + + SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv); + SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat); + + // step 1 + atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED); + + // step 2 + + return TSDB_CODE_SUCCESS; +} + +/** + * @brief commit for rollup sma + * + * @param pSma + * @return int32_t + */ +static int32_t tdProcessRSmaCommitImpl(SSma *pSma) { + SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma); + if (!pSmaEnv) { + return TSDB_CODE_SUCCESS; + } + return TSDB_CODE_SUCCESS; +} + +/** + * @brief post-commit for rollup sma + * 1) clean up the outdated qtaskinfo files + * + * @param pSma + * @return int32_t + */ +static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) { + SVnode *pVnode = pSma->pVnode; + + if (!VND_IS_RSMA(pVnode)) { + return TSDB_CODE_SUCCESS; + } + + int64_t committed = pVnode->state.committed; + TdDirPtr pDir = NULL; + TdDirEntryPtr pDirEntry = NULL; + char dir[TSDB_FILENAME_LEN]; + char bname[TSDB_FILENAME_LEN]; + const char *pattern = "^v[0-9]+qtaskinfo\\.ver([0-9]+)?$"; + regex_t regex; + + tdGetVndDirName(TD_VID(pVnode), VNODE_RSMA_DIR, dir); + + // Resource allocation and init + regcomp(®ex, pattern, REG_EXTENDED); + + if ((pDir = taosOpenDir(dir)) == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + smaWarn("rsma post-commit open dir %s failed since %s", dir, terrstr()); + return TSDB_CODE_FAILED; + } + + regmatch_t regMatch[2]; + while ((pDirEntry = taosReadDir(pDir)) != NULL) { + char *entryName = taosGetDirEntryName(pDirEntry); + if (!entryName) { + continue; + } + char *fileName = taosDirEntryBaseName(entryName); + int code = regexec(®ex, bname, 2, regMatch, 0); + + if (code == 0) { + // match + printf("match 0 = %s\n", (char *)POINTER_SHIFT(fileName, regMatch[0].rm_so)); + printf("match 1 = %s\n", (char *)POINTER_SHIFT(fileName, regMatch[1].rm_so)); + } else if (code == REG_NOMATCH) { + // not match + smaInfo("rsma post-commit not match %s", fileName); + continue; + } else { + // has other error + terrno = TAOS_SYSTEM_ERROR(code); + smaWarn("rsma post-commit regexec failed since %s", terrstr()); + + taosCloseDir(&pDir); + regfree(®ex); + return TSDB_CODE_FAILED; + } + } + taosCloseDir(&pDir); + return TSDB_CODE_SUCCESS; +} diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 41af641e9e..ff9b17bf6e 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -23,8 +23,7 @@ SSmaMgmt smaMgmt = { .smaRef = -1, }; -typedef enum { TD_QTASK_TMP_F = 0, TD_QTASK_CUR_F } TD_QTASK_FILE_T; -static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; +#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver" typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; @@ -37,7 +36,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType static void tdRSmaFetchTrigger(void *param, void *tmrId); static void tdRSmaPersistTrigger(void *param, void *tmrId); static void *tdRSmaPersistExec(void *param); -static void tdRSmaQTaskInfoGetFName(int32_t vid, int8_t ftype, char *outputName); +static void tdRSmaQTaskInfoGetFName(int32_t vid, int64_t version, char *outputName); static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile); static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish); @@ -88,8 +87,8 @@ struct SRSmaQTaskInfoIter { int32_t nBufPos; }; -static void tdRSmaQTaskInfoGetFName(int32_t vgId, int8_t ftype, char *outputName) { - tdGetVndFileName(vgId, VNODE_RSMA_DIR, tdQTaskInfoFname[ftype], outputName); +static void tdRSmaQTaskInfoGetFName(int32_t vgId, int64_t version, char *outputName) { + tdGetVndFileName(vgId, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, version, outputName); } static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { @@ -493,7 +492,6 @@ static int32_t tdProcessSubmitReq(STsdb *pTsdb, int64_t version, void *pReq) { } static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) { - ASSERT(pMsg != NULL); SSubmitMsgIter msgIter = {0}; SSubmitBlk *pBlock = NULL; SSubmitBlkIter blkIter = {0}; @@ -501,19 +499,26 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) { terrno = TSDB_CODE_SUCCESS; - if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1; + if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) { + return -1; + } while (true) { - if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1; + if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) { + return -1; + } if (!pBlock) break; tdUidStorePut(pStore, msgIter.suid, NULL); } - if (terrno != TSDB_CODE_SUCCESS) return -1; + if (terrno != TSDB_CODE_SUCCESS) { + return -1; + } return 0; } static void tdDestroySDataBlockArray(SArray *pArray) { + // TODO #if 0 for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { SSDataBlock *pDataBlock = taosArrayGet(pArray, i); @@ -598,33 +603,54 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { pSma = RSMA_INFO_SMA(pItem->pRsmaInfo); - // if rsma trigger stat in cancelled or finished, not start fetch task anymore + // if rsma trigger stat in paused, cancelled or finished, not start fetch task int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); - if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) { - taosReleaseRef(smaMgmt.smaRef, pItem->refId); - smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is cancelled", - SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); - return; + switch (rsmaTriggerStat) { + case TASK_TRIGGER_STAT_PAUSED: + case TASK_TRIGGER_STAT_CANCELLED: + case TASK_TRIGGER_STAT_FINISHED: { + taosReleaseRef(smaMgmt.smaRef, pItem->refId); + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is cancelled", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); + return; + } + default: + break; } int8_t fetchTriggerStat = atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); - if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) { - smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma), - pItem->level, pItem->pRsmaInfo->suid); + switch (fetchTriggerStat) { + case TASK_TRIGGER_STAT_ACTIVE: { + smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma), + pItem->level, pItem->pRsmaInfo->suid); - tdRefSmaStat(pSma, (SSmaStat *)pStat); + tdRefSmaStat(pSma, (SSmaStat *)pStat); - SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; - qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); - tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_BLOCK); + SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; + qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); + tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_BLOCK); - tdUnRefSmaStat(pSma, (SSmaStat *)pStat); - - } else { - smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is inactive", - SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); + tdUnRefSmaStat(pSma, (SSmaStat *)pStat); + } break; + case TASK_TRIGGER_STAT_PAUSED: { + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); + } break; + case TASK_TRIGGER_STAT_INACTIVE: { + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is inactive", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); + } break; + case TASK_TRIGGER_STAT_INIT: { + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is init", SMA_VID(pSma), + pItem->level, pItem->pRsmaInfo->suid); + } break; + default: { + smaWarn("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is unknown", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); + } break; } + _end: taosReleaseRef(smaMgmt.smaRef, pItem->refId); } @@ -780,10 +806,10 @@ _err: static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) { SVnode *pVnode = pSma->pVnode; STFile tFile = {0}; - char qTaskInfoFName[TSDB_FILENAME_LEN]; + char qTaskInfoFName[TSDB_FILENAME_LEN] = {0}; - tdRSmaQTaskInfoGetFName(TD_VID(pVnode), TD_QTASK_TMP_F, qTaskInfoFName); - if (tdInitTFile(&tFile, pVnode->pTfs, qTaskInfoFName) < 0) { + tdRSmaQTaskInfoGetFName(TD_VID(pVnode), pVnode->state.committed, qTaskInfoFName); + if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) { goto _err; } @@ -799,17 +825,20 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) { if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) { tdRSmaQTaskInfoIterDestroy(&fIter); tdCloseTFile(&tFile); + tdDestroyTFile(&tFile); goto _err; } if (tdRSmaQTaskInfoRestore(pSma, &fIter) < 0) { tdRSmaQTaskInfoIterDestroy(&fIter); tdCloseTFile(&tFile); + tdDestroyTFile(&tFile); goto _err; } tdRSmaQTaskInfoIterDestroy(&fIter); tdCloseTFile(&tFile); + tdDestroyTFile(&tFile); return TSDB_CODE_SUCCESS; _err: smaError("rsma restore, qtaskinfo reload failed since %s", terrstr()); @@ -931,19 +960,21 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF } if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) { - ASSERT(0); return TSDB_CODE_FAILED; } if (tdReadTFile(pTFile, pIter->qBuf, nBytes) != nBytes) { - ASSERT(0); return TSDB_CODE_FAILED; } int32_t infoLen = 0; taosDecodeFixedI32(pIter->qBuf, &infoLen); if (infoLen > nBytes) { - ASSERT(infoLen > RSMA_QTASKINFO_BUFSIZE); + if (infoLen <= RSMA_QTASKINFO_BUFSIZE) { + terrno = TSDB_CODE_RSMA_FILE_CORRUPTED; + smaError("iterate rsma qtaskinfo file %s failed since %s", TD_TFILE_FULL_NAME(pIter->pTFile), terrstr()); + return TSDB_CODE_FAILED; + } pIter->nAlloc = infoLen; void *pBuf = taosMemoryRealloc(pIter->pBuf, infoLen); if (!pBuf) { @@ -955,12 +986,10 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF nBytes = infoLen; if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET)) { - ASSERT(0); return TSDB_CODE_FAILED; } if (tdReadTFile(pTFile, pIter->pBuf, nBytes) != nBytes) { - ASSERT(0); return TSDB_CODE_FAILED; } } @@ -977,7 +1006,6 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) { // block iter bool isFinish = false; if (tdRSmaQTaskInfoIterNextBlock(pIter, &isFinish) < 0) { - ASSERT(0); return TSDB_CODE_FAILED; } if (isFinish) { @@ -989,6 +1017,7 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) { pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead); if (qTaskInfoLenWithHead < RSMA_QTASKINFO_HEAD_LEN) { terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + smaError("restore rsma qtaskinfo file %s failed since %s", TD_TFILE_FULL_NAME(pIter->pTFile), terrstr()); return TSDB_CODE_FAILED; } @@ -1025,22 +1054,16 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) { return TSDB_CODE_SUCCESS; } -static void *tdRSmaPersistExec(void *param) { - setThreadName("rsma-task-persist"); - SRSmaStat *pRSmaStat = param; - SSma *pSma = pRSmaStat->pSma; - STfs *pTfs = pSma->pVnode->pTfs; - int32_t vid = SMA_VID(pSma); - int64_t toffset = 0; - bool isFileCreated = false; - - if (TASK_TRIGGER_STAT_CANCELLED == atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))) { - goto _end; - } +static int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) { + SSma *pSma = pRSmaStat->pSma; + SVnode *pVnode = pSma->pVnode; + int32_t vid = SMA_VID(pSma); + int64_t toffset = 0; + bool isFileCreated = false; void *infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL); if (!infoHash) { - goto _end; + return TSDB_CODE_SUCCESS; } STFile tFile = {0}; @@ -1074,9 +1097,13 @@ static void *tdRSmaPersistExec(void *param) { if (!isFileCreated) { char qTaskInfoFName[TSDB_FILENAME_LEN]; - tdRSmaQTaskInfoGetFName(vid, TD_QTASK_TMP_F, qTaskInfoFName); - tdInitTFile(&tFile, pTfs, qTaskInfoFName); - tdCreateTFile(&tFile, pTfs, true, -1); + tdRSmaQTaskInfoGetFName(vid, pSma->pVnode->state.applied, qTaskInfoFName); + if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) { + goto _err; + } + if (tdCreateTFile(&tFile, true, -1) < 0) { + goto _err; + } isFileCreated = true; } @@ -1101,49 +1128,55 @@ static void *tdRSmaPersistExec(void *param) { infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), infoHash); } -_normal: + if (isFileCreated) { if (tdUpdateTFileHeader(&tFile) < 0) { smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile), tstrerror(terrno)); - tdCloseTFile(&tFile); - tdRemoveTFile(&tFile); goto _err; } else { smaDebug("vgId:%d, rsma, succeed to update tfile %s header", vid, TD_TFILE_FULL_NAME(&tFile)); } tdCloseTFile(&tFile); - - char newFName[TSDB_FILENAME_LEN]; - strncpy(newFName, TD_TFILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); - char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_F]); - strncpy(pos, tdQTaskInfoFname[TD_QTASK_TMP_F], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); - if (taosRenameFile(TD_TFILE_FULL_NAME(&tFile), newFName) != 0) { - smaError("vgId:%d, rsma, failed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); - goto _err; - } else { - smaDebug("vgId:%d, rsma, succeed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); - } + tdDestroyTFile(&tFile); } - goto _end; + return TSDB_CODE_SUCCESS; _err: if (isFileCreated) { tdRemoveTFile(&tFile); + tdDestroyTFile(&tFile); } + return TSDB_CODE_FAILED; +} + +static void *tdRSmaPersistExec(void *param) { + setThreadName("rsma-task-persist"); + SRSmaStat *pRSmaStat = param; + SSma *pSma = pRSmaStat->pSma; + + int8_t triggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)); + + if (TASK_TRIGGER_STAT_CANCELLED == triggerStat || TASK_TRIGGER_STAT_PAUSED == triggerStat) { + goto _end; + } + + // execution + tdRSmaPersistExecImpl(pRSmaStat); + _end: if (TASK_TRIGGER_STAT_INACTIVE == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INACTIVE, TASK_TRIGGER_STAT_ACTIVE)) { - smaDebug("vgId:%d, rsma persist task is active again", vid); + smaDebug("vgId:%d, rsma persist task is active again", SMA_VID(pSma)); } else if (TASK_TRIGGER_STAT_CANCELLED == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { - smaDebug("vgId:%d, rsma persist task is cancelled", vid); + smaDebug("vgId:%d, rsma persist task is cancelled", SMA_VID(pSma)); } else { - smaWarn("vgId:%d, rsma persist task in abnormal stat %" PRIi8, vid, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); - ASSERT(0); + smaWarn("vgId:%d, rsma persist task in stat %" PRIi8, SMA_VID(pSma), atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); } + atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); taosReleaseRef(smaMgmt.smaRef, pRSmaStat->refId); taosThreadExit(NULL); @@ -1166,8 +1199,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { TASK_TRIGGER_STAT_FINISHED)) { smaDebug("vgId:%d, persist task is cancelled and set finished", SMA_VID(pRSmaStat->pSma)); } else { - smaWarn("vgId:%d, persist task in abnormal stat %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)), - SMA_VID(pRSmaStat->pSma)); + smaWarn("vgId:%d, persist task in abnormal stat %" PRIi8, SMA_VID(pRSmaStat->pSma), + atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); ASSERT(0); } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); @@ -1216,6 +1249,9 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED); smaDebug("rsma persistence not start since cancelled and finished"); } break; + case TASK_TRIGGER_STAT_PAUSED: { + smaDebug("rsma persistence not start since paused"); + } break; case TASK_TRIGGER_STAT_INACTIVE: { smaDebug("rsma persistence not start since inactive"); } break; diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c new file mode 100644 index 0000000000..b2c85642b9 --- /dev/null +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -0,0 +1,16 @@ +/* + * 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" \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 2244b91c28..ecd8db8ea9 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -113,7 +113,7 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { if (!pDataBlocks) { terrno = TSDB_CODE_TSMA_INVALID_PTR; smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); - return terrno; + return TSDB_CODE_FAILED; } if (taosArrayGetSize(pDataBlocks) <= 0) { @@ -127,9 +127,9 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { return TSDB_CODE_FAILED; } - SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); - SSmaStat *pStat = NULL; - STSmaStat *pItem = NULL; + SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); + SSmaStat *pStat = NULL; + STSmaStat *pTsmaStat = NULL; if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) { terrno = TSDB_CODE_TSMA_INVALID_STAT; @@ -137,32 +137,43 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { } tdRefSmaStat(pSma, pStat); - pItem = &pStat->tsmaStat; + pTsmaStat = SMA_TSMA_STAT(pStat); - ASSERT(pItem); - - if (!pItem->pTSma) { + if (!pTsmaStat->pTSma) { STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid); if (!pTSma) { - terrno = TSDB_CODE_TSMA_NO_INDEX_IN_META; - smaWarn("vgId:%d, tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), indexUid, tstrerror(terrno)); - return TSDB_CODE_FAILED; + smaError("vgId:%d, failed to get STSma while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), + indexUid, tstrerror(terrno)); + goto _err; + } + pTsmaStat->pTSma = pTSma; + pTsmaStat->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1); + if (!pTsmaStat->pTSchema) { + smaError("vgId:%d, failed to get STSchema while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), + indexUid, tstrerror(terrno)); + goto _err; } - pItem->pTSma = pTSma; - pItem->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1); - ASSERT(pItem->pTSchema); // TODO } - ASSERT(pItem->pTSma->indexUid == indexUid); + if (pTsmaStat->pTSma->indexUid != indexUid) { + terrno = TSDB_CODE_VND_APP_ERROR; + smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 "(!=%" PRIi64 ") failed since %s", SMA_VID(pSma), indexUid, + pTsmaStat->pTSma->indexUid, tstrerror(terrno)); + goto _err; + } - SSubmitReq *pSubmitReq = NULL; + SSubmitReq *pSubmitReq = tdBlockToSubmit((const SArray *)msg, pTsmaStat->pTSchema, true, pTsmaStat->pTSma->dstTbUid, + pTsmaStat->pTSma->dstTbName, pTsmaStat->pTSma->dstVgId); - pSubmitReq = tdBlockToSubmit((const SArray *)msg, pItem->pTSchema, true, pItem->pTSma->dstTbUid, - pItem->pTSma->dstTbName, pItem->pTSma->dstVgId); + if (!pSubmitReq) { + smaError("vgId:%d, failed to gen submit blk while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), + indexUid, tstrerror(terrno)); + goto _err; + } - ASSERT(pSubmitReq); // TODO - - ASSERT(!strncasecmp("td.tsma.rst.tb", pItem->pTSma->dstTbName, 14)); +#if 0 + ASSERT(!strncasecmp("td.tsma.rst.tb", pTsmaStat->pTSma->dstTbName, 14)); +#endif SRpcMsg submitReqMsg = { .msgType = TDMT_VND_SUBMIT, @@ -170,9 +181,15 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { .contLen = ntohl(pSubmitReq->length), }; - ASSERT(tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) == 0); + if (tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) < 0) { + smaError("vgId:%d, failed to put SubmitReq msg while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), + indexUid, tstrerror(terrno)); + goto _err; + } tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_SUCCESS; +_err: + tdUnRefSmaStat(pSma, pStat); + return TSDB_CODE_FAILED; } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 17bc2cdaca..9bea3ff468 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -179,72 +179,83 @@ void tdCloseTFile(STFile *pTFile) { } } -void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, char *outputName) { - snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/%s", vgId, dname, fname); +void tdDestroyTFile(STFile *pTFile) { taosMemoryFreeClear(TD_TFILE_FULL_NAME(pTFile)); } + +void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, int64_t version, char *outputName) { + if (version < 0) { + snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/v%d%s", vgId, dname, vgId, fname); + } else { + snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/v%d%s%" PRIi64, vgId, dname, vgId, fname, version); + } } -int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) { - char fullname[TSDB_FILENAME_LEN]; - SDiskID did = {0}; +void tdGetVndDirName(int32_t vgId, const char *dname, char *outputName) { + snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s", vgId, dname); +} +int32_t tdInitTFile(STFile *pTFile, const char *dname, const char *fname) { TD_TFILE_SET_STATE(pTFile, TD_FILE_STATE_OK); TD_TFILE_SET_CLOSED(pTFile); memset(&(pTFile->info), 0, sizeof(pTFile->info)); pTFile->info.magic = TD_FILE_INIT_MAGIC; - if (tfsAllocDisk(pTfs, 0, &did) < 0) { - terrno = TSDB_CODE_NO_AVAIL_DISK; + char tmpName[TSDB_FILENAME_LEN * 2 + 32] = {0}; + snprintf(tmpName, TSDB_FILENAME_LEN * 2 + 32, "%s%s%s", dname, TD_DIRSEP, fname); + int32_t tmpNameLen = strlen(tmpName) + 1; + pTFile->fname = taosMemoryMalloc(tmpNameLen); + if (!pTFile->fname) { + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - - tfsInitFile(pTfs, &(pTFile->f), did, fname); + tstrncpy(pTFile->fname, tmpName, tmpNameLen); return 0; } -int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fType) { +int32_t tdCreateTFile(STFile *pTFile, bool updateHeader, int8_t fType) { ASSERT(pTFile->info.fsize == 0 && pTFile->info.magic == TD_FILE_INIT_MAGIC); pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pTFile->pFile == NULL) { if (errno == ENOENT) { // Try to create directory recursively - char *s = strdup(TD_TFILE_REL_NAME(pTFile)); - if (tfsMkdirRecurAt(pTfs, taosDirName(s), TD_TFILE_DID(pTFile)) < 0) { - taosMemoryFreeClear(s); - return -1; - } - taosMemoryFreeClear(s); - - pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pTFile->pFile == NULL) { + if (taosMulMkDir(taosDirName(TD_TFILE_FULL_NAME(pTFile))) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; + } else { + pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pTFile->pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } } - } else { - terrno = TAOS_SYSTEM_ERROR(errno); + } + + if (!updateHeader) { + return 0; + } + + pTFile->info.fsize += TD_FILE_HEAD_SIZE; + pTFile->info.fver = 0; + + if (tdUpdateTFileHeader(pTFile) < 0) { + tdCloseTFile(pTFile); + tdRemoveTFile(pTFile); return -1; } } - if (!updateHeader) { - return 0; - } - - pTFile->info.fsize += TD_FILE_HEAD_SIZE; - pTFile->info.fver = 0; - - if (tdUpdateTFileHeader(pTFile) < 0) { - tdCloseTFile(pTFile); - tdRemoveTFile(pTFile); - return -1; - } - return 0; } -int32_t tdRemoveTFile(STFile *pTFile) { return tfsRemoveFile(TD_TFILE_F(pTFile)); } +int32_t tdRemoveTFile(STFile *pTFile) { + if (taosRemoveFile(TD_TFILE_FULL_NAME(pTFile)) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + }; + return 0; +} // smaXXXUtil ================ // ... \ 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 a08515ed5c..7c4a7d520d 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -154,10 +154,10 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con }; tmsgSendRsp(&rsp); - char buf1[50]; - char buf2[50]; - tFormatOffset(buf1, 50, &pRsp->reqOffset); - tFormatOffset(buf2, 50, &pRsp->rspOffset); + char buf1[80]; + char buf2[80]; + tFormatOffset(buf1, 80, &pRsp->reqOffset); + tFormatOffset(buf2, 80, &pRsp->rspOffset); tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset: %s", TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); @@ -183,13 +183,15 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) { } else { ASSERT(0); } - STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, offset.subKey); - if (pOffset == NULL || pOffset->val.version < offset.val.version) { - if (tqOffsetWrite(pTq->pOffsetStore, &offset) < 0) { - ASSERT(0); - return -1; - } + /*STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, offset.subKey);*/ + /*if (pOffset != NULL) {*/ + /*if (pOffset->val.type == TMQ_OFFSET__LOG && pOffset->val.version < offset.val.version) {*/ + if (tqOffsetWrite(pTq->pOffsetStore, &offset) < 0) { + ASSERT(0); + return -1; } + /*}*/ + /*}*/ return 0; } @@ -228,17 +230,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; } -static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) { - pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA; - pOffsetVal->uid = uid; - pOffsetVal->ts = ts; -} - -static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) { - pOffsetVal->type = TMQ_OFFSET__LOG; - pOffsetVal->version = ver; -} - int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { SMqPollReq* pReq = pMsg->pCont; int64_t consumerId = pReq->consumerId; @@ -249,8 +240,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { STqOffsetVal fetchOffsetNew; // 1.find handle - char buf[50]; - tFormatOffset(buf, 50, &reqOffset); + char buf[80]; + tFormatOffset(buf, 80, &reqOffset); tqDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s", consumerId, pReq->epoch, TD_VID(pTq->pVnode), buf); @@ -282,12 +273,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey); if (pOffset != NULL) { fetchOffsetNew = pOffset->val; - char formatBuf[50]; - tFormatOffset(formatBuf, 50, &fetchOffsetNew); + char formatBuf[80]; + tFormatOffset(formatBuf, 80, &fetchOffsetNew); tqDebug("tmq poll: consumer %ld, offset reset to %s", consumerId, formatBuf); } else { if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { - if (pReq->useSnapshot) { + if (pReq->useSnapshot && pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (!pHandle->fetchMeta) { tqOffsetResetToData(&fetchOffsetNew, 0, 0); } else { @@ -313,9 +304,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); if (fetchOffsetNew.type == TMQ_OFFSET__LOG) { - int64_t fetchVer = fetchOffsetNew.version + 1; - SWalHead* pHeadWithCkSum = taosMemoryMalloc(sizeof(SWalHead) + 2048); - if (pHeadWithCkSum == NULL) { + int64_t fetchVer = fetchOffsetNew.version + 1; + SWalCkHead* pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); + if (pCkHead == NULL) { return -1; } @@ -329,7 +320,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { break; } - if (tqFetchLog(pTq, pHandle, &fetchVer, &pHeadWithCkSum) < 0) { + if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead) < 0) { // TODO add push mgr tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer); @@ -340,7 +331,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { goto OVER; } - SWalReadHead* pHead = &pHeadWithCkSum->head; + SWalCont* pHead = &pCkHead->head; tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType); @@ -371,7 +362,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType); SMqMetaRsp metaRsp = {0}; metaRsp.reqOffset = pReq->reqOffset.version; - /*tqOffsetResetToLog(&metaR)*/ metaRsp.rspOffset = fetchVer; metaRsp.resMsgType = pHead->msgType; metaRsp.metaRspLen = pHead->bodyLen; @@ -385,25 +375,16 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } } - taosMemoryFree(pHeadWithCkSum); + taosMemoryFree(pCkHead); } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) { - // 1. set uid and ts - // 2. get data (rebuild reader if needed) - // 3. get new uid and ts - - char formatBuf[50]; - tFormatOffset(formatBuf, 50, &dataRsp.reqOffset); - tqInfo("retrieve using snapshot req offset %s", formatBuf); - if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, workerId) < 0) { + tqInfo("retrieve using snapshot actual offset: uid %ld ts %ld", fetchOffsetNew.uid, fetchOffsetNew.ts); + if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) { ASSERT(0); } // 4. send rsp - if (dataRsp.blockNum != 0) { - tqOffsetResetToData(&dataRsp.rspOffset, 0, 0); - if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { - code = -1; - } + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; } } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) { ASSERT(0); @@ -543,7 +524,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { break; } - SWalReadHead* pHead = &pHeadWithCkSum->head; + SWalCont* pHead = &pHeadWithCkSum->head; tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, pHead->msgType); @@ -618,6 +599,8 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) { int32_t code = taosHashRemove(pTq->handles, pReq->subKey, strlen(pReq->subKey)); ASSERT(code == 0); + tqOffsetDelete(pTq->pOffsetStore, pReq->subKey); + if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) { ASSERT(0); } @@ -655,6 +638,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { .reader = pHandle->execHandle.pExecReader[i], .meta = pTq->pVnode->pMeta, .vnode = pTq->pVnode, + .tqReader = true, }; pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle); ASSERT(pHandle->execHandle.execCol.task[i]); diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index eb09199c70..9dd2a0258f 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -59,13 +59,19 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, i return 0; } -int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId) { +int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) { ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); qTaskInfo_t task = pExec->execCol.task[workerId]; - // TODO set uid and ts - if (qStreamScanSnapshot(task) < 0) { + + /*if (qStreamScanSnapshot(task) < 0) {*/ + /*ASSERT(0);*/ + /*}*/ + + if (qStreamPrepareScan(task, offset.uid, offset.ts) < 0) { ASSERT(0); } + + int32_t rowCnt = 0; while (1) { SSDataBlock* pDataBlock = NULL; uint64_t ts = 0; @@ -80,13 +86,27 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, i tqAddBlockDataToRsp(pDataBlock, pRsp); if (pRsp->withTbName) { - // TODO pRsp->withTbName = 0; - /*int64_t uid = 0;*/ - /*tqAddTbNameToRsp(pTq, uid, pRsp, workerId);*/ +#if 0 + int64_t uid; + int64_t ts; + if (qGetStreamScanStatus(task, &uid, &ts) < 0) { + ASSERT(0); + } + tqAddTbNameToRsp(pTq, uid, pRsp, workerId); +#endif } pRsp->blockNum++; + + rowCnt += pDataBlock->info.rows; + if (rowCnt >= 4096) break; } + int64_t uid; + int64_t ts; + if (qGetStreamScanStatus(task, &uid, &ts) < 0) { + ASSERT(0); + } + tqOffsetResetToData(&pRsp->rspOffset, uid, ts); return 0; } diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 16b8872098..ef61897f91 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -97,6 +97,10 @@ int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset) { return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset)); } +int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey) { + return taosHashRemove(pStore->pHash, subscribeKey, strlen(subscribeKey)); +} + int32_t tqOffsetSnapshot(STqOffsetStore* pStore) { // open file // TODO file name should be with a version diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 7d7b9636df..bc992b2211 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -15,13 +15,13 @@ #include "tq.h" -int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead** ppHeadWithCkSum) { +int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) { int32_t code = 0; taosThreadMutexLock(&pHandle->pWalReader->mutex); int64_t offset = *fetchOffset; while (1) { - if (walFetchHead(pHandle->pWalReader, offset, *ppHeadWithCkSum) < 0) { + if (walFetchHead(pHandle->pWalReader, offset, *ppCkHead) < 0) { tqDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", pHandle->consumerId, pHandle->epoch, TD_VID(pTq->pVnode), offset); *fetchOffset = offset - 1; @@ -29,8 +29,8 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead* goto END; } - if ((*ppHeadWithCkSum)->head.msgType == TDMT_VND_SUBMIT) { - code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum); + if ((*ppCkHead)->head.msgType == TDMT_VND_SUBMIT) { + code = walFetchBody(pHandle->pWalReader, ppCkHead); if (code < 0) { ASSERT(0); @@ -43,9 +43,9 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead* goto END; } else { if (pHandle->fetchMeta) { - SWalReadHead* pHead = &((*ppHeadWithCkSum)->head); + SWalCont* pHead = &((*ppCkHead)->head); if (IS_META_MSG(pHead->msgType)) { - code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum); + code = walFetchBody(pHandle->pWalReader, ppCkHead); if (code < 0) { ASSERT(0); @@ -58,7 +58,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead* goto END; } } - code = walSkipFetchBody(pHandle->pWalReader, *ppHeadWithCkSum); + code = walSkipFetchBody(pHandle->pWalReader, *ppCkHead); if (code < 0) { ASSERT(0); *fetchOffset = offset; @@ -120,7 +120,9 @@ bool tqNextDataBlock(SStreamReader* pHandle) { return true; } void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->msgIter.uid, sizeof(int64_t)); + /*tqDebug("search uid %ld", pHandle->msgIter.uid);*/ if (ret != NULL) { + /*tqDebug("find uid %ld", pHandle->msgIter.uid);*/ return true; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 03f18cc766..4604e3699f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -112,9 +112,9 @@ typedef struct STsdbReadHandle { STimeWindow window; // the primary query time window that applies to all queries // SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time // SColumnDataAgg** pstatis;// the ptr array list to return to caller - int32_t numOfBlocks; + int32_t numOfBlocks; SSDataBlock* pResBlock; -// SArray* pColumns; // column list, SColumnInfoData array list + // SArray* pColumns; // column list, SColumnInfoData array list bool locateStart; int32_t outputCapacity; int32_t realNumOfRows; @@ -223,6 +223,22 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) { return rows; } +static SArray* createCheckInfoFromUid(STsdbReadHandle* pTsdbReadHandle, int64_t uid) { + SArray* pTableCheckInfo = taosArrayInit(1, sizeof(STableCheckInfo)); + if (pTableCheckInfo == NULL) { + return NULL; + } + STableCheckInfo info = { + .tableId = uid, + }; + info.suid = pTsdbReadHandle->suid; + + taosArrayPush(pTableCheckInfo, &info); + tsdbDebug("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReadHandle, info.tableId, info.lastKey, + pTsdbReadHandle->idStr); + return pTableCheckInfo; +} + static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) { size_t tableSize = taosArrayGetSize(pTableList); @@ -428,8 +444,8 @@ static STsdbReadHandle* tsdbQueryTablesImpl(SVnode* pVnode, SQueryTableDataCond* for (int32_t i = 0; i < pCond->numOfCols; ++i) { SColumnInfoData colInfo = {.info = pCond->colList[i], 0}; - int32_t code = blockDataAppendColInfo(pReadHandle->pResBlock, &colInfo); - if (code != TSDB_CODE_SUCCESS){ + int32_t code = blockDataAppendColInfo(pReadHandle->pResBlock, &colInfo); + if (code != TSDB_CODE_SUCCESS) { goto _end; } } @@ -494,9 +510,19 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle return TSDB_CODE_SUCCESS; } -int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){ +int32_t tsdbSetTableId(tsdbReaderT reader, int64_t uid) { STsdbReadHandle* pTsdbReadHandle = reader; - if(pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo); + if (pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo); + pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromUid(pTsdbReadHandle, uid); + if (pTsdbReadHandle->pTableCheckInfo == NULL) { + return TSDB_CODE_TDB_OUT_OF_MEMORY; + } + return TDB_CODE_SUCCESS; +} + +int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList) { + STsdbReadHandle* pTsdbReadHandle = reader; + if (pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo); pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, tableList); if (pTsdbReadHandle->pTableCheckInfo == NULL) { return TSDB_CODE_TDB_OUT_OF_MEMORY; @@ -505,8 +531,8 @@ int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){ } tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId, - uint64_t taskId) { - if(taosArrayGetSize(tableList) == 0){ + uint64_t taskId) { + if (taosArrayGetSize(tableList) == 0) { return NULL; } STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId); @@ -553,8 +579,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* t } tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle, - taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList), - pTsdbReadHandle->idStr); + taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList), pTsdbReadHandle->idStr); return (tsdbReaderT)pTsdbReadHandle; } @@ -1073,7 +1098,7 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio } int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerMin[precision])); // set the starting fileId - if (fid < 0LL && llabs(fid) > INT32_MAX) { // data value overflow for INT32 + if (fid < 0LL && llabs(fid) > INT32_MAX) { // data value overflow for INT32 fid = INT32_MIN; } @@ -2612,7 +2637,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files - if ((win.skey > pTsdbReadHandle->window.ekey)/* || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)*/) { + if ((win.skey > pTsdbReadHandle->window.ekey) /* || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)*/) { tsdbUnLockFS(REPO_FS(pTsdbReadHandle->pTsdb)); tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %s", pTsdbReadHandle, pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr); @@ -2886,7 +2911,7 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) { */ int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) { SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid); - if(!pCur) { + if (!pCur) { return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 79e63d5abc..0b28d6bf10 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -28,12 +28,12 @@ const SVnodeCfg vnodeCfgDefault = { .update = 1, .compression = 2, .slLevel = 5, - .days = 10, + .days = 14400, .minRows = 100, .maxRows = 4096, - .keep2 = 3650, - .keep0 = 3650, - .keep1 = 3650}, + .keep2 = 5256000, + .keep0 = 5256000, + .keep1 = 5256000}, .walCfg = {.vgId = -1, .fsyncPeriod = 0, .retentionPeriod = 0, .rollPeriod = 0, .segSize = 0, .level = TAOS_WAL_WRITE}, .hashBegin = 0, diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index dbbe3d3750..a12e11b398 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -229,6 +229,9 @@ int vnodeCommit(SVnode *pVnode) { return -1; } + // preCommit + // TODO + // commit each sub-system if (metaCommit(pVnode->pMeta) < 0) { ASSERT(0); @@ -266,6 +269,11 @@ int vnodeCommit(SVnode *pVnode) { ASSERT(0); return -1; } + + pVnode->state.committed = info.state.committed; + + // postCommit + smaPostCommit(pVnode->pSma); // apply the commit (TODO) vnodeBufPoolReset(pVnode->onCommit); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 2ddeb8ba2b..649e8299f4 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -216,7 +216,7 @@ _err: } int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { - if (TDMT_VND_QUERY != pMsg->msgType) { + if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) { return 0; } @@ -227,9 +227,10 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { vTrace("message in vnode query queue is processing"); SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode, .pMsgCb = &pVnode->msgCb}; switch (pMsg->msgType) { - case TDMT_VND_QUERY: + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0); - case TDMT_VND_QUERY_CONTINUE: + case TDMT_SCH_QUERY_CONTINUE: return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0); default: vError("unknown msg type:%d in query queue", pMsg->msgType); @@ -243,15 +244,15 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); switch (pMsg->msgType) { - case TDMT_VND_FETCH: + case TDMT_SCH_FETCH: return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg, 0); - case TDMT_VND_FETCH_RSP: + case TDMT_SCH_FETCH_RSP: return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg, 0); - case TDMT_VND_CANCEL_TASK: + case TDMT_SCH_CANCEL_TASK: return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg, 0); - case TDMT_VND_DROP_TASK: + case TDMT_SCH_DROP_TASK: return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg, 0); - case TDMT_VND_QUERY_HEARTBEAT: + case TDMT_SCH_QUERY_HEARTBEAT: return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_VND_TABLE_META: return vnodeGetTableMeta(pVnode, pMsg); @@ -778,6 +779,7 @@ _exit: taosArrayDestroy(submitRsp.pArray); // TODO: the partial success scenario and the error case + // => If partial success, extract the success submitted rows and reconstruct a new submit msg, and push to level 1/level 2. // TODO: refactor if ((terrno == TSDB_CODE_SUCCESS) && (pRsp->code == TSDB_CODE_SUCCESS)) { tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index e9b64389aa..80ba80e61a 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -178,7 +178,7 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { for (int32_t i = 0; i < newEpSet.numOfEps; ++i) { vGTrace("vgId:%d, msg:%p redirect:%d ep:%s:%u", vgId, pMsg, i, newEpSet.eps[i].fqdn, newEpSet.eps[i].port); } - + pMsg->info.hasEpSet = 1; SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; tmsgSendRedirectRsp(&rsp, &newEpSet); } else { @@ -409,7 +409,7 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } -static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { return 0; } +static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) { return 0; } static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; } diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 304da88888..59ad009527 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -241,7 +241,7 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, } -int32_t ctgHandleMsgCallback(void *param, const SDataBuf *pMsg, int32_t rspCode) { +int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param; int32_t code = 0; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 377df8f8ac..cd454c075b 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -297,7 +297,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { SArray* pTagVals = NULL; STag* pTag = (STag*)pCfg->pTags; - if (pCfg->pTags && pTag->flags & TD_TAG_JSON) { + if (pCfg->pTags && tTagIsJson(pTag)) { char* pJson = parseTagDatatoJson(pTag); if (pJson) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 6b5826bf88..cfe144e7d7 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -248,6 +248,11 @@ typedef struct SSampleExecInfo { uint32_t seed; // random seed value } SSampleExecInfo; +enum { + TABLE_SCAN__TABLE_ORDER = 1, + TABLE_SCAN__BLOCK_ORDER = 2, +}; + typedef struct STableScanInfo { void* dataReader; SReadHandle readHandle; @@ -272,13 +277,17 @@ typedef struct STableScanInfo { int32_t curTWinIdx; int32_t currentGroupId; + int32_t currentTable; uint64_t queryId; // todo remove it uint64_t taskId; // todo remove it struct { uint64_t uid; - int64_t t; - } scanStatus; + int64_t ts; + } lastStatus; + + int8_t scanMode; + int8_t noTable; } STableScanInfo; typedef struct STagScanInfo { @@ -347,6 +356,7 @@ typedef struct SStreamBlockScanInfo { SUpdateInfo* pUpdateInfo; EStreamScanMode scanMode; + SOperatorInfo* pStreamScanOp; SOperatorInfo* pSnapshotReadOp; SArray* childIds; SessionWindowSupporter sessionSup; @@ -713,6 +723,7 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput); void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle); void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId); +int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts); int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts); SSDataBlock* loadNextDataBlock(void* param); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 2561516f6a..24eae225bf 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -63,6 +63,7 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { rowSize += pCtx[i].resDataInfo.interBufSize; } + rowSize += (numOfOutput * sizeof(bool)); // expand rowSize to mark if col is null for top/bottom result(saveTupleData) return rowSize; } @@ -112,13 +113,15 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int p->groupId = *(uint64_t*)key; p->pos = *(SResultRowPosition*)pData; memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t)); - +#ifdef BUF_PAGE_DEBUG + qDebug("page_groupRes, groupId:%"PRIu64",pageId:%d,offset:%d\n", p->groupId, p->pos.pageId, p->pos.offset); +#endif taosArrayPush(pGroupResInfo->pRows, &p); } if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) { __compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc; - qsort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), POINTER_BYTES, fn); + taosSort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), POINTER_BYTES, fn); } pGroupResInfo->index = 0; @@ -271,6 +274,7 @@ static bool isTableOk(STableKeyInfo* info, SNode* pTagCond, SMeta* metaHandle) { SNode* pNew = NULL; int32_t code = scalarCalculateConstants(pTagCondTmp, &pNew); if (TSDB_CODE_SUCCESS != code) { + terrno = code; nodesDestroyNode(pTagCondTmp); return false; } @@ -323,12 +327,19 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo code = tsdbGetAllTableList(metaHandle, tableUid, pListInfo->pTableList); } - if (pTagCond) { + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid); + terrno = code; + return code; + } + + if(pTagCond){ int32_t i = 0; while (i < taosArrayGetSize(pListInfo->pTableList)) { STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i); - bool isOk = isTableOk(info, pTagCond, metaHandle); - if (!isOk) { + bool isOk = isTableOk(info, pTagCond, metaHandle); + if(terrno) return terrno; + if(!isOk){ taosArrayRemove(pListInfo->pTableList, i); continue; } @@ -586,13 +597,16 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu } for (int32_t i = 0; i < numOfOutput; ++i) { - if (strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_select_value") == 0) { + if (strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_select_value") == 0 || + strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_group_key") == 0) { pValCtx[num++] = &pCtx[i]; } else if (fmIsSelectFunc(pCtx[i].functionId)) { p = &pCtx[i]; } } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_setSelect num:%d", num); +#endif if (p != NULL) { p->subsidiaries.pCtx = pValCtx; p->subsidiaries.num = num; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 31edc46b4d..0e76607c8f 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -145,10 +145,12 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo, continue; } + // TODO handle ntb case if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != pScanInfo->tableUid) { continue; } - // TODO handle ntb case + /*pScanInfo->pStreamScanOp->pTaskInfo->tableqinfoList.*/ + // handle multiple partition taosArrayPush(qa, id); } diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index 0871575d95..2d5ccf8568 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -222,7 +222,7 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) { } int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len) { - SExecTaskInfo* pTaskInfo = (struct SExecTaskInfo*) tinfo; + SExecTaskInfo* pTaskInfo = (struct SExecTaskInfo*)tinfo; if (pTaskInfo == NULL || pInput == NULL || len == 0) { return TSDB_CODE_INVALID_PARA; @@ -231,11 +231,22 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le return decodeOperator(pTaskInfo->pRoot, pInput, len); } +int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; -int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo; + if (uid == 0) { + if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) { + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0); + uid = pTableInfo->uid; + ts = INT64_MIN; + } + } - return TSDB_CODE_SUCCESS; + return doPrepareScan(pTaskInfo->pRoot, uid, ts); } +int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + return doGetScanStatus(pTaskInfo->pRoot, uid, ts); +} diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 95782ce001..a485d265b9 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -274,6 +274,9 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // 1. close current opened time window if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) { +#ifdef BUF_PAGE_DEBUG + qDebug("page_1"); +#endif SResultRowPosition pos = pResultRowInfo->cur; SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); releaseBufPage(pResultBuf, pPage); @@ -281,6 +284,9 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // allocate a new buffer page if (pResult == NULL) { +#ifdef BUF_PAGE_DEBUG + qDebug("page_2"); +#endif ASSERT(pSup->resultRowSize > 0); pResult = getNewResultRow(pResultBuf, groupId, pSup->resultRowSize); @@ -538,7 +544,9 @@ static int32_t doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunct if (pCtx[k].fpSet.process == NULL) { continue; } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_process"); +#endif int32_t code = pCtx[k].fpSet.process(&pCtx[k]); if (code != TSDB_CODE_SUCCESS) { qError("%s aggregate function error happens, code: %s", GET_TASKID(pOperator->pTaskInfo), tstrerror(code)); @@ -1033,7 +1041,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData SqlFunctionCtx* pCtx = pTableScanInfo->pCtx; uint32_t status = BLK_DATA_NOT_LOAD; - int32_t numOfOutput = 0;//pTableScanInfo->numOfOutput; + int32_t numOfOutput = 0; // pTableScanInfo->numOfOutput; for (int32_t i = 0; i < numOfOutput; ++i) { int32_t functionId = pCtx[i].functionId; int32_t colId = pTableScanInfo->pExpr[i].base.pParam[0].pCol->colId; @@ -1348,7 +1356,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR 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 (pDst->pData == NULL) { + if (pDst->pData == NULL || pSrc->pData == NULL) { continue; } @@ -1413,7 +1421,9 @@ void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == groupId) { return; } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_setbuf, groupId:%"PRIu64, groupId); +#endif doSetTableGroupOutputBuf(pOperator, pAggInfo, numOfOutput, groupId); // record the current active group id @@ -1489,11 +1499,15 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI int32_t numOfExprs) { int32_t numOfRows = getNumOfTotalRes(pGroupResInfo); int32_t start = pGroupResInfo->index; - +#ifdef BUF_PAGE_DEBUG + qDebug("\npage_copytoblock rows:%d", numOfRows); +#endif for (int32_t i = start; i < numOfRows; i += 1) { SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i); SFilePage* page = getBufPage(pBuf, pPos->pos.pageId); - +#ifdef BUF_PAGE_DEBUG + qDebug("page_copytoblock pos pageId:%d, offset:%d", pPos->pos.pageId, pPos->pos.offset); +#endif SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset); doUpdateNumOfRows(pRow, numOfExprs, rowCellOffset); @@ -1525,6 +1539,9 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowCellOffset); if (pCtx[j].fpSet.finalize) { +#ifdef BUF_PAGE_DEBUG + qDebug("\npage_finalize %d", numOfExprs); +#endif int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock); if (TAOS_FAILED(code)) { qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code)); @@ -1553,9 +1570,9 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI releaseBufPage(pBuf, page); pBlock->info.rows += pRow->numOfRows; - if (pBlock->info.rows >= pBlock->info.capacity) { // output buffer is full - break; - } +// if (pBlock->info.rows >= pBlock->info.capacity) { // output buffer is full +// break; +// } } qDebug("%s result generated, rows:%d, groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, @@ -1933,7 +1950,7 @@ typedef struct SFetchRspHandleWrapper { int32_t sourceIndex; } SFetchRspHandleWrapper; -int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param; SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId); @@ -2010,13 +2027,15 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY); - qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", %d/%" PRIzu, GET_TASKID(pTaskInfo), - pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources); + qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu, + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, pSource->execId, + sourceIndex, totalSources); pMsg->header.vgId = htonl(pSource->addr.nodeId); pMsg->sId = htobe64(pSource->schedId); pMsg->taskId = htobe64(pSource->taskId); pMsg->queryId = htobe64(pTaskInfo->id.queryId); + pMsg->execId = htonl(pSource->execId); // send the fetch remote task result reques SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); @@ -2034,7 +2053,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf pMsgSendInfo->param = pWrapper; pMsgSendInfo->msgInfo.pData = pMsg; pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq); - pMsgSendInfo->msgType = TDMT_VND_FETCH; + pMsgSendInfo->msgType = TDMT_SCH_FETCH; pMsgSendInfo->fp = loadRemoteDataCallback; int64_t transporterId = 0; @@ -2145,9 +2164,9 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx SSDataBlock* pRes = pExchangeInfo->pResult; SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo; if (pRsp->numOfRows == 0) { - qDebug("%s vgId:%d, taskId:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 - ", completed:%d try next %d/%" PRIzu, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pDataInfo->totalRows, + qDebug("%s vgId:%d, taskId:0x%" PRIx64 " execId:%d index:%d completed, rowsOfSource:%" PRIu64 + ", totalRows:%" PRIu64 ", completed:%d try next %d/%" PRIzu, + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pDataInfo->totalRows, pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources); pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; completed += 1; @@ -2166,17 +2185,18 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx if (pRsp->completed == 1) { qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 + " execId:%d" " index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 ", completed:%d try next %d/%" PRIzu, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pRes->info.rows, pDataInfo->totalRows, - pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources); + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRes->info.rows, + pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources); completed += 1; pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; } else { - qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 + qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows, - pLoadInfo->totalSize); + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, + pLoadInfo->totalRows, pLoadInfo->totalSize); } taosMemoryFreeClear(pDataInfo->pRsp); @@ -2249,8 +2269,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) { SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); if (pDataInfo->code != TSDB_CODE_SUCCESS) { - qError("%s vgId:%d, taskID:0x%" PRIx64 " error happens, code:%s", GET_TASKID(pTaskInfo), pSource->addr.nodeId, - pSource->taskId, tstrerror(pDataInfo->code)); + qError("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d error happens, code:%s", GET_TASKID(pTaskInfo), + pSource->addr.nodeId, pSource->taskId, pSource->execId, tstrerror(pDataInfo->code)); pOperator->pTaskInfo->code = pDataInfo->code; return NULL; } @@ -2258,9 +2278,9 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) { SRetrieveTableRsp* pRsp = pDataInfo->pRsp; SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo; if (pRsp->numOfRows == 0) { - qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 - " try next", - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1, + qDebug("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d %d of total completed, rowsOfSource:%" PRIu64 + ", totalRows:%" PRIu64 " try next", + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pExchangeInfo->current + 1, pDataInfo->totalRows, pLoadInfo->totalRows); pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; @@ -2276,18 +2296,19 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) { pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL); if (pRsp->completed == 1) { - qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, rowsOfSource:%" PRIu64 + qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pDataInfo->totalRows, - pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, totalSources); + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, + pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, + totalSources); pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; pExchangeInfo->current += 1; } else { - qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 + qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows, - pLoadInfo->totalSize); + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, + pLoadInfo->totalRows, pLoadInfo->totalSize); } pOperator->resultInfo.totalRows += pRes->info.rows; @@ -2372,13 +2393,12 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* } pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode)); - pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo)); - if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) { + if (pInfo->pSources == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } for (int32_t i = 0; i < numOfSources; ++i) { - SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); + SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); taosArrayPush(pInfo->pSources, pNode); } @@ -2821,13 +2841,56 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } +int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) { + int32_t type = pOperator->operatorType; + if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + SStreamBlockScanInfo* pScanInfo = pOperator->info; + pScanInfo->blockType = STREAM_INPUT__DATA_SCAN; + + STableScanInfo* pInfo = pScanInfo->pSnapshotReadOp->info; + if (uid == 0) { + pInfo->noTable = 1; + return TSDB_CODE_SUCCESS; + } + + /*if (pSnapShotScanInfo->dataReader == NULL) {*/ + /*pSnapShotScanInfo->dataReader = tsdbReaderOpen(pHandle->vnode, &pSTInfo->cond, tableList, 0, 0);*/ + /*pSnapShotScanInfo->scanMode = TABLE_SCAN__TABLE_ORDER;*/ + /*}*/ + + pInfo->noTable = 0; + + if (pInfo->lastStatus.uid != uid || pInfo->lastStatus.ts != ts) { + tsdbSetTableId(pInfo->dataReader, uid); + int64_t oldSkey = pInfo->cond.twindows[0].skey; + pInfo->cond.twindows[0].skey = ts + 1; + tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0); + pInfo->cond.twindows[0].skey = oldSkey; + pInfo->scanTimes = 0; + pInfo->curTWinIdx = 0; + } + return TSDB_CODE_SUCCESS; + + } else { + if (pOperator->numOfDownstream == 1) { + return doPrepareScan(pOperator->pDownstream[0], uid, ts); + } else if (pOperator->numOfDownstream == 0) { + qError("failed to find stream scan operator to set the input data block"); + return TSDB_CODE_QRY_APP_ERROR; + } else { + qError("join not supported for stream block scan"); + return TSDB_CODE_QRY_APP_ERROR; + } + } +} + int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) { int32_t type = pOperator->operatorType; if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { SStreamBlockScanInfo* pScanInfo = pOperator->info; - STableScanInfo* pSnapShotScanInfo = pScanInfo->pSnapshotReadOp->info; - *uid = pSnapShotScanInfo->scanStatus.uid; - *ts = pSnapShotScanInfo->scanStatus.t; + STableScanInfo* pSnapShotScanInfo = pScanInfo->pSnapshotReadOp->info; + *uid = pSnapShotScanInfo->lastStatus.uid; + *ts = pSnapShotScanInfo->lastStatus.ts; } else { if (pOperator->pDownstream[0] == NULL) { return TSDB_CODE_INVALID_PARA; @@ -3121,8 +3184,9 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) } // check for the limitation in each group - if (pProjectInfo->limit.limit > 0 && pProjectInfo->curOutput + pRes->info.rows >= pProjectInfo->limit.limit) { - pRes->info.rows = (int32_t)(pProjectInfo->limit.limit - pProjectInfo->curOutput); + if (pProjectInfo->limit.limit >= 0 && pProjectInfo->curOutput + pRes->info.rows >= pProjectInfo->limit.limit) { + int32_t keepRows = (int32_t)(pProjectInfo->limit.limit - pProjectInfo->curOutput); + blockDataKeepFirstNRows(pRes, keepRows); if (pProjectInfo->slimit.limit > 0 && pProjectInfo->slimit.limit <= pProjectInfo->curGroupOutput) { pOperator->status = OP_EXEC_DONE; } @@ -3196,8 +3260,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { longjmp(pTaskInfo->env, code); } - doFilter(pProjectInfo->pFilterNode, pBlock); - setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false); blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows); @@ -3208,6 +3270,10 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { } int32_t status = handleLimitOffset(pOperator, pBlock); + + // filter shall be applied after apply functions and limit/offset on the result + doFilter(pProjectInfo->pFilterNode, pInfo->pRes); + if (status == PROJECT_RETRIEVE_CONTINUE) { continue; } else if (status == PROJECT_RETRIEVE_DONE) { @@ -3434,11 +3500,12 @@ int32_t initAggInfo(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInf } void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows) { + ASSERT(numOfRows != 0); pOperator->resultInfo.capacity = numOfRows; pOperator->resultInfo.threshold = numOfRows * 0.75; if (pOperator->resultInfo.threshold == 0) { - pOperator->resultInfo.capacity = numOfRows; + pOperator->resultInfo.threshold = numOfRows; } } @@ -3938,12 +4005,12 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) return TSDB_CODE_QRY_APP_ERROR; } if (p == NULL) { - if (taosArrayPush(sortSupport, groupId) != NULL) { + if (taosArrayPush(sortSupport, groupId) == NULL) { qError("taos push support array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } - if (taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL) { + if (taosArrayPush(pTableListInfo->pGroupList, &tGroup) == NULL) { qError("taos push group array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; @@ -4023,6 +4090,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } else { taosMemoryFree(keyBuf); nodesClearList(groupNew); + metaReaderClear(&mr); return code; } @@ -4035,7 +4103,14 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } else { isNull[index++] = 0; char* data = nodesGetValueFromNode(pValue); - if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON) { + if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON){ + if(tTagIsJson(data)){ + terrno = TSDB_CODE_QRY_JSON_IN_GROUP_ERROR; + taosMemoryFree(keyBuf); + nodesClearList(groupNew); + metaReaderClear(&mr); + return terrno; + } int32_t len = getJsonValueLen(data); memcpy(pStart, data, len); pStart += len; @@ -4094,7 +4169,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); - if (code) { + if(code){ + pTaskInfo->code = code; return NULL; } code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); @@ -4121,7 +4197,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .maxTs = INT64_MIN, }; if (pHandle) { - createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); + int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); + if(code){ + pTaskInfo->code = code; + return NULL; + } } SOperatorInfo* pOperator = diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 0a14993c21..3ce7b66ddf 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -141,6 +141,10 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData pkey->isNull = false; char* val = colDataGetData(pColInfoData, rowIndex); if (pkey->type == TSDB_DATA_TYPE_JSON) { + if(tTagIsJson(val)){ + terrno = TSDB_CODE_QRY_JSON_IN_GROUP_ERROR; + return; + } int32_t dataLen = getJsonValueLen(val); memcpy(pkey->pData, val, dataLen); } else if (IS_VAR_DATA_TYPE(pkey->type)) { @@ -227,11 +231,15 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { int32_t len = 0; STimeWindow w = TSWINDOW_INITIALIZER; + terrno = TSDB_CODE_SUCCESS; int32_t num = 0; for (int32_t j = 0; j < pBlock->info.rows; ++j) { // Compare with the previous row of this column, and do not set the output buffer again if they are identical. if (!pInfo->isInit) { recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j); + if (terrno != TSDB_CODE_SUCCESS) { // group by json error + longjmp(pTaskInfo->env, terrno); + } pInfo->isInit = true; num++; continue; @@ -247,6 +255,9 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { if (j == 0) { num++; recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j); + if (terrno != TSDB_CODE_SUCCESS) { // group by json error + longjmp(pTaskInfo->env, terrno); + } continue; } @@ -661,7 +672,11 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) { } } + terrno = TSDB_CODE_SUCCESS; doHashPartition(pOperator, pBlock); + if (terrno != TSDB_CODE_SUCCESS) { // group by json error + longjmp(pTaskInfo->env, terrno); + } } SArray* groupArray = taosArrayInit(taosHashGetSize(pInfo->pGroupSet), sizeof(SDataGroupInfo)); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index ca4afdeb7f..317f3db27e 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -392,6 +392,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { binfo.capacity = binfo.rows; blockDataEnsureCapacity(pBlock, binfo.rows); pBlock->info = binfo; + ASSERT(binfo.uid != 0); uint32_t status = 0; int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status); @@ -416,9 +417,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime; // todo refactor - pTableScanInfo->scanStatus.uid = pBlock->info.uid; - pTableScanInfo->scanStatus.t = pBlock->info.window.ekey; + pTableScanInfo->lastStatus.uid = pBlock->info.uid; + pTableScanInfo->lastStatus.ts = pBlock->info.window.ekey; + ASSERT(pBlock->info.uid != 0); return pBlock; } return NULL; @@ -438,6 +440,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) { SSDataBlock* p = doTableScanImpl(pOperator); if (p != NULL) { + ASSERT(p->info.uid != 0); return p; } pTableScanInfo->curTWinIdx += 1; @@ -513,6 +516,27 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { STableScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + // if scan table by table + if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) { + if (pInfo->noTable) return NULL; + while (1) { + SSDataBlock* result = doTableScanGroup(pOperator); + if (result) { + return result; + } + // if no data, switch to next table and continue scan + pInfo->currentTable++; + if (pInfo->currentTable >= taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList)) { + return NULL; + } + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable); + tsdbSetTableId(pInfo->dataReader, pTableInfo->uid); + tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0); + pInfo->scanTimes = 0; + pInfo->curTWinIdx = 0; + } + } + if (pInfo->currentGroupId == -1) { pInfo->currentGroupId++; if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) { @@ -1188,7 +1212,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys int16_t colId = id->colId; taosArrayPush(pColIds, &colId); - if (id->colId == pTableScanNode->tsColId) { + if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { pInfo->primaryTsIndex = id->targetSlotId; } } @@ -1207,6 +1231,13 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys if (pHandle) { SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId); STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info; + + SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0); + if (pHandle->tqReader) { + pSTInfo->scanMode = TABLE_SCAN__TABLE_ORDER; + pSTInfo->dataReader = tsdbReaderOpen(pHandle->vnode, &pSTInfo->cond, tableList, 0, 0); + } + if (pSTInfo->interval.interval > 0) { pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark); } else { @@ -1243,6 +1274,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->sessionSup = (SessionWindowSupporter){.pStreamAggSup = NULL, .gap = -1}; pInfo->groupId = 0; pInfo->pPullDataRes = createPullDataBlock(); + pInfo->pStreamScanOp = pOperator; pOperator->name = "StreamBlockScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN; @@ -1330,7 +1362,7 @@ static void getDBNameFromCondition(SNode* pCondition, const char* dbName) { nodesWalkExpr(pCondition, getDBNameFromConditionWalker, (char*)dbName); } -static int32_t loadSysTableCallback(void* param, const SDataBuf* pMsg, int32_t code) { +static int32_t loadSysTableCallback(void* param, SDataBuf* pMsg, int32_t code) { SOperatorInfo* operator=(SOperatorInfo*) param; SSysTableScanInfo* pScanResInfo = (SSysTableScanInfo*)operator->info; if (TSDB_CODE_SUCCESS == code) { @@ -2059,6 +2091,7 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId); return TSDB_CODE_SUCCESS; } + pTableListInfo->needSortTableByGroupId = pTableScanNode->groupSort; code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pGroupTags); if (code != TSDB_CODE_SUCCESS) { return code; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 95b16589ee..66900fb7aa 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1246,6 +1246,9 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprS pCtx[i].fpSet.init(&pCtx[i], pResInfo); } } + SFilePage* bufPage = getBufPage(pResultBuf, p1->pageId); + setBufPageDirty(bufPage, true); + releaseBufPage(pResultBuf, bufPage); } bool doClearWindow(SAggSupporter* pAggSup, SExprSupp* pSup, char* pData, int16_t bytes, uint64_t groupId, @@ -3171,6 +3174,10 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup, getSessionTimeWindow(pAggSup, tsCols[i], INT64_MIN, pBlock->info.groupId, gap, &winIndex); step = updateSessionWindowInfo(pCurWin, tsCols, NULL, pBlock->info.rows, i, gap, NULL); ASSERT(isInWindow(pCurWin, tsCols[i], gap)); + if (pCurWin->pos.pageId == -1) { + // window has been closed. + continue; + } doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pSup, numOfOutput); if (result) { taosArrayPush(result, pCurWin); @@ -3246,12 +3253,12 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput, pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo); compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo); - SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pChWin->pos.pageId); - setBufPageDirty(bufPage, true); - releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage); + SFilePage* bufPage = getBufPage(pChInfo->streamAggSup.pResultBuf, pChWin->pos.pageId); + releaseBufPage(pChInfo->streamAggSup.pResultBuf, bufPage); continue; + } else if (!pChWin->isClosed) { + break; } - break; } } SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId); @@ -3265,7 +3272,8 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*); SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo*)pData; } SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; } -int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn) { +int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, + SArray* pClosed, __get_win_info_ fn, bool delete) { // Todo(liuyao) save window to tdb void** pIte = NULL; size_t keyLen = 0; @@ -3279,10 +3287,18 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra if (isCloseWindow(&pSeWin->win, pTwSup)) { if (!pSeWin->isClosed) { pSeWin->isClosed = true; - if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE && pClosed) { int32_t code = saveResult(pSeWin->win.skey, pSeWin->pos.pageId, pSeWin->pos.offset, *pGroupId, pClosed); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pSeWin->isOutput = true; } + if (delete) { + taosArrayRemove(pWins, i); + i--; + size = taosArrayGetSize(pWins); + } } continue; } @@ -3292,6 +3308,16 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra return TSDB_CODE_SUCCESS; } +static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete) { + int32_t size = taosArrayGetSize(pChildren); + for (int32_t i = 0; i < size; i++) { + SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); + SStreamSessionAggOperatorInfo* pChInfo = pChildOp->info; + pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); + closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete); + } +} + int32_t getAllSessionWindow(SHashObj* pHashMap, SArray* pClosed, __get_win_info_ fn) { void** pIte = NULL; while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { @@ -3339,6 +3365,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { if (pBlock == NULL) { break; } + printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "Final Session Recv" : "Single Session Recv"); if (pBlock->info.type == STREAM_CLEAR) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); @@ -3385,7 +3412,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession); + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, + getResWinForSession, pInfo->ignoreCloseWindow); + closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreCloseWindow); copyUpdateResult(pStUpdated, pUpdated); taosHashCleanup(pStUpdated); @@ -3437,10 +3466,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { } else if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, "Semi Session"); return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - if (pInfo->binfo.pRes->info.rows == 0) { + if (pBInfo->pRes->info.rows == 0) { pOperator->status = OP_EXEC_DONE; if (pInfo->pUpdateRes->info.rows == 0) { // semi interval operator clear disk buffer @@ -3449,9 +3479,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { } // process the rest of the data pOperator->status = OP_OPENED; + printDataBlock(pInfo->pUpdateRes, "Semi Session"); return pInfo->pUpdateRes; } - return pInfo->binfo.pRes; + printDataBlock(pBInfo->pRes, "Semi Session"); + return pBInfo->pRes; } _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); @@ -3495,21 +3527,24 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); - blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); + blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity); doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, "Semi Session"); return pInfo->pDelRes; } - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - if (pInfo->binfo.pRes->info.rows == 0) { + doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); + if (pBInfo->pRes->info.rows == 0) { pOperator->status = OP_EXEC_DONE; if (pInfo->pUpdateRes->info.rows == 0) { return NULL; } // process the rest of the data pOperator->status = OP_OPENED; + printDataBlock(pInfo->pUpdateRes, "Semi Session"); return pInfo->pUpdateRes; } + printDataBlock(pBInfo->pRes, "Semi Session"); return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3867,7 +3902,9 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState); + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, + getResWinForState, pInfo->ignoreCloseWindow); + closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreCloseWindow); copyUpdateResult(pSeUpdated, pUpdated); taosHashCleanup(pSeUpdated); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 7d44d41b55..8ee6d18b98 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -593,7 +593,10 @@ static int32_t createInitialSources(SSortHandle* pHandle) { if (size > sortBufSize) { // Perform the in-memory sort and then flush data in the buffer into disk. int64_t p = taosGetTimestampUs(); - blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + if (code != 0) { + return code; + } int64_t el = taosGetTimestampUs() - p; pHandle->sortElapsed += el; @@ -608,7 +611,10 @@ static int32_t createInitialSources(SSortHandle* pHandle) { // Perform the in-memory sort and then flush data in the buffer into disk. int64_t p = taosGetTimestampUs(); - blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + int32_t code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + if (code != 0) { + return code; + } int64_t el = taosGetTimestampUs() - p; pHandle->sortElapsed += el; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index f7e22cb151..8eafb0703e 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -117,6 +117,9 @@ int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getFirstLastInfoSize(int32_t resBytes); +int32_t lastRowFunction(SqlFunctionCtx *pCtx); +int32_t lastRowFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); + bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); bool topBotFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index e1aca7ce00..2fcddce5eb 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -32,7 +32,7 @@ extern "C" { #define FUNC_MGT_STRING_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(3) #define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4) #define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5) -#define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) +#define FUNC_MGT_IMPLICIT_TS_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) #define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7) #define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) #define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 23d7185508..e01750a3ca 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -44,6 +44,7 @@ void static addDbPrecisonParam(SNodeList** pList, uint8_t precision) { pVal->literal = NULL; pVal->isDuration = false; pVal->translate = true; + pVal->notReserved = true; pVal->node.resType.type = TSDB_DATA_TYPE_TINYINT; pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TINYINT].bytes; pVal->node.resType.precision = precision; @@ -237,7 +238,7 @@ static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t l static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters - //add database precision as param + // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; addDbPrecisonParam(&pFunc->pParameterList, dbPrec); @@ -633,6 +634,12 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l } // param1 ~ param3 + if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY || + ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY || + ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + for (int32_t i = 1; i < numOfParams; ++i) { SNode* pParamNode = nodesListGetNode(pFunc->pParameterList, i); if (QUERY_NODE_VALUE != nodeType(pParamNode)) { @@ -642,12 +649,11 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l SValueNode* pValue = (SValueNode*)pParamNode; pValue->notReserved = true; - } - if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY || - ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY || - ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) { - return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + if (i == 3 && pValue->datum.i != 1 && pValue->datum.i != 0) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, + "HISTOGRAM function normalized parameter should be 0/1"); + } } pFunc->node.resType = (SDataType){.bytes = 512, .type = TSDB_DATA_TYPE_BINARY}; @@ -667,6 +673,12 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32 } // param1 ~ param3 + if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY || + ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY || + ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + for (int32_t i = 1; i < numOfParams; ++i) { SNode* pParamNode = nodesListGetNode(pFunc->pParameterList, i); if (QUERY_NODE_VALUE != nodeType(pParamNode)) { @@ -676,12 +688,11 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32 SValueNode* pValue = (SValueNode*)pParamNode; pValue->notReserved = true; - } - if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY || - ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY || - ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) { - return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + if (i == 3 && pValue->datum.i != 1 && pValue->datum.i != 0) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, + "HISTOGRAM function normalized parameter should be 0/1"); + } } pFunc->node.resType = @@ -1016,6 +1027,10 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } + // add database precision as param + uint8_t dbPrec = pFunc->node.resType.precision; + addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE}; return TSDB_CODE_SUCCESS; } @@ -1026,13 +1041,7 @@ static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t l return TSDB_CODE_SUCCESS; } - SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); - if (QUERY_NODE_COLUMN != nodeType(pPara)) { - return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, - "The parameters of first/last can only be columns"); - } - - pFunc->node.resType = ((SExprNode*)pPara)->resType; + pFunc->node.resType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType; return TSDB_CODE_SUCCESS; } @@ -1046,11 +1055,6 @@ static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32 uint8_t paraType = ((SExprNode*)pPara)->resType.type; int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes; if (isPartial) { - if (QUERY_NODE_COLUMN != nodeType(pPara)) { - return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, - "The parameters of first/last can only be columns"); - } - pFunc->node.resType = (SDataType){.bytes = getFirstLastInfoSize(paraBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; } else { @@ -1472,7 +1476,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - //add database precision as param + // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; addDbPrecisonParam(&pFunc->pParameterList, dbPrec); @@ -1492,7 +1496,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - //add database precision as param + // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; addDbPrecisonParam(&pFunc->pParameterList, dbPrec); @@ -1520,7 +1524,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le } } - //add database precision as param + // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; addDbPrecisonParam(&pFunc->pParameterList, dbPrec); @@ -1538,7 +1542,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BINARY].bytes, .type = TSDB_DATA_TYPE_BINARY}; + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_JSON].bytes, .type = TSDB_DATA_TYPE_JSON}; return TSDB_CODE_SUCCESS; } @@ -1919,7 +1923,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "interp", .type = FUNCTION_TYPE_INTERP, - .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC, + .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getSelectivityFuncEnv, .initFunc = functionSetup, @@ -1929,7 +1933,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "derivative", .type = FUNCTION_TYPE_DERIVATIVE, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateDerivative, .getEnvFunc = getDerivativeFuncEnv, .initFunc = derivativeFuncSetup, @@ -1939,7 +1943,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "irate", .type = FUNCTION_TYPE_IRATE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateIrate, .getEnvFunc = getIrateFuncEnv, .initFunc = irateFuncSetup, @@ -1949,20 +1953,17 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, - .processFunc = lastFunction, - .finalizeFunc = firstLastFinalize, - .pPartialFunc = "_last_partial", - .pMergeFunc = "_last_merge", - .combineFunc = lastCombine, + .processFunc = lastRowFunction, + .finalizeFunc = lastRowFinalize, }, { .name = "_cache_last_row", .type = FUNCTION_TYPE_CACHE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -1972,7 +1973,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "first", .type = FUNCTION_TYPE_FIRST, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1985,7 +1986,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_first_partial", .type = FUNCTION_TYPE_FIRST_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLastPartial, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1996,7 +1997,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_first_merge", .type = FUNCTION_TYPE_FIRST_MERGE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLastMerge, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2007,7 +2008,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last", .type = FUNCTION_TYPE_LAST, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2020,7 +2021,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_last_partial", .type = FUNCTION_TYPE_LAST_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLastPartial, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2031,7 +2032,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_last_merge", .type = FUNCTION_TYPE_LAST_MERGE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLastMerge, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2042,7 +2043,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "twa", .type = FUNCTION_TYPE_TWA, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateInNumOutDou, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getTwaFuncEnv, @@ -2139,7 +2140,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "statecount", .type = FUNCTION_TYPE_STATE_COUNT, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateCount, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2149,7 +2150,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "stateduration", .type = FUNCTION_TYPE_STATE_DURATION, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateDuration, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2189,7 +2190,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "tail", .type = FUNCTION_TYPE_TAIL, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC, + .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | + FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateTail, .getEnvFunc = getTailFuncEnv, .initFunc = tailFunctionSetup, @@ -2200,7 +2202,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "unique", .type = FUNCTION_TYPE_UNIQUE, .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | - FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC, + FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateUnique, .getEnvFunc = getUniqueFuncEnv, .initFunc = uniqueFunctionSetup, @@ -2618,7 +2620,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_group_key", .type = FUNCTION_TYPE_GROUP_KEY, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC, .translateFunc = translateGroupKey, .getEnvFunc = getGroupKeyFuncEnv, .initFunc = functionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index a75d5a2ecb..3f6afaf5fd 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -16,6 +16,7 @@ #include "builtinsimpl.h" #include "cJSON.h" #include "function.h" +#include "query.h" #include "querynodes.h" #include "taggfunction.h" #include "tcompare.h" @@ -80,6 +81,7 @@ typedef struct STopBotRes { typedef struct SFirstLastRes { bool hasResult; + bool isNull; // used for last_row function only int32_t bytes; char buf[]; } SFirstLastRes; @@ -208,13 +210,13 @@ typedef struct SMavgInfo { } SMavgInfo; typedef struct SSampleInfo { - int32_t samples; - int32_t totalPoints; - int32_t numSampled; - uint8_t colType; - int16_t colBytes; - char* data; - STuplePos* tuplePos; + int32_t samples; + int32_t totalPoints; + int32_t numSampled; + uint8_t colType; + int16_t colBytes; + char* data; + STuplePos* tuplePos; } SSampleInfo; typedef struct STailItem { @@ -269,20 +271,19 @@ typedef struct SDerivInfo { } SDerivInfo; typedef struct SRateInfo { - double firstValue; - TSKEY firstKey; - double lastValue; - TSKEY lastKey; - int8_t hasResult; // flag to denote has value + double firstValue; + TSKEY firstKey; + double lastValue; + TSKEY lastKey; + int8_t hasResult; // flag to denote has value } SRateInfo; -typedef struct SGroupKeyInfo{ - bool hasResult; - bool isNull; - char data[]; +typedef struct SGroupKeyInfo { + bool hasResult; + bool isNull; + char data[]; } SGroupKeyInfo; - #define SET_VAL(_info, numOfElem, res) \ do { \ if ((numOfElem) <= 0) { \ @@ -1471,8 +1472,8 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple int32_t pageId = pTuplePos->pageId; int32_t offset = pTuplePos->offset; - if (pTuplePos->pageId != -1) { - int32_t numOfCols = taosArrayGetSize(pCtx->pSrcBlock->pDataBlock); + if (pTuplePos->pageId != -1 && pCtx->subsidiaries.num > 0) { + int32_t numOfCols = pCtx->subsidiaries.num; SFilePage* pPage = getBufPage(pCtx->pBuf, pageId); bool* nullList = (bool*)((char*)pPage + offset); @@ -1483,22 +1484,21 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; - int32_t srcSlotId = pFuncParam->pCol->slotId; int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; int32_t ps = 0; - for (int32_t k = 0; k < srcSlotId; ++k) { - SColumnInfoData* pSrcCol = taosArrayGet(pCtx->pSrcBlock->pDataBlock, k); - ps += pSrcCol->info.bytes; - } SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); - if (nullList[srcSlotId]) { + ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); + if (nullList[j]) { colDataAppendNULL(pDstCol, rowIndex); } else { - colDataAppend(pDstCol, rowIndex, (pStart + ps), false); + colDataAppend(pDstCol, rowIndex, pStart, false); } + pStart += pDstCol->info.bytes; } + + releaseBufPage(pCtx->pBuf, pPage); } } @@ -2409,7 +2409,9 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) return TSDB_CODE_SUCCESS; } -int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes + sizeof(int64_t) + sizeof(STuplePos); } +int32_t getFirstLastInfoSize(int32_t resBytes) { + return sizeof(SFirstLastRes) + resBytes + sizeof(int64_t) + sizeof(STuplePos); +} bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); @@ -2491,7 +2493,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; - //handle selectivity + // handle selectivity if (pCtx->subsidiaries.num > 0) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (!pInfo->hasResult) { @@ -2501,7 +2503,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } } pInfo->hasResult = true; - //DO_UPDATE_TAG_COLUMNS(pCtx, ts); + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; break; } @@ -2533,7 +2535,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; - //handle selectivity + // handle selectivity if (pCtx->subsidiaries.num > 0) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (!pInfo->hasResult) { @@ -2543,7 +2545,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } } pInfo->hasResult = true; - //DO_UPDATE_TAG_COLUMNS(pCtx, ts); + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; break; } @@ -2597,7 +2599,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; - //handle selectivity + // handle selectivity if (pCtx->subsidiaries.num > 0) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (!pInfo->hasResult) { @@ -2607,7 +2609,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } } pInfo->hasResult = true; - //DO_UPDATE_TAG_COLUMNS(pCtx, ts); + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; } break; @@ -2629,7 +2631,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; - //handle selectivity + // handle selectivity if (pCtx->subsidiaries.num > 0) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (!pInfo->hasResult) { @@ -2640,7 +2642,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } pInfo->hasResult = true; pResInfo->numOfRes = 1; - //DO_UPDATE_TAG_COLUMNS(pCtx, ts); + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); } break; } @@ -2652,7 +2654,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) { SInputColumnInfoData* pColInfo = &pCtx->input; - int32_t start = pColInfo->startRowIndex; + int32_t start = pColInfo->startRowIndex; pOutput->bytes = pInput->bytes; TSKEY* tsIn = (TSKEY*)(pInput->buf + pInput->bytes); @@ -2670,7 +2672,7 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S } *tsOut = *tsIn; memcpy(pOutput->buf, pInput->buf, pOutput->bytes); - //handle selectivity + // handle selectivity STuplePos* pTuplePos = (STuplePos*)(pOutput->buf + pOutput->bytes + sizeof(TSKEY)); if (pCtx->subsidiaries.num > 0) { if (!pOutput->hasResult) { @@ -2717,7 +2719,7 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); colDataAppend(pCol, pBlock->info.rows, pRes->buf, pResInfo->isNullRes); - //handle selectivity + // handle selectivity STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows); @@ -2728,8 +2730,8 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getFirstLastInfoSize(pRes->bytes); - char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + int32_t resultBytes = getFirstLastInfoSize(pRes->bytes); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pRes, resultBytes); varDataSetLen(res, resultBytes); @@ -2738,7 +2740,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); colDataAppend(pCol, pBlock->info.rows, res, false); - //handle selectivity + // handle selectivity STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows); @@ -2763,6 +2765,111 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { return TSDB_CODE_SUCCESS; } +int32_t lastRowFunction(SqlFunctionCtx* pCtx) { + int32_t numOfElems = 0; + + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pInputCol = pInput->pData[0]; + + int32_t type = pInputCol->info.type; + int32_t bytes = pInputCol->info.bytes; + pInfo->bytes = bytes; + + SColumnDataAgg* pColAgg = (pInput->colDataAggIsSet) ? pInput->pColumnDataAgg[0] : NULL; + + TSKEY startKey = getRowPTs(pInput->pPTS, 0); + TSKEY endKey = getRowPTs(pInput->pPTS, pInput->totalRows - 1); + + int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; + + if (blockDataOrder == TSDB_ORDER_ASC) { + for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) { + char* data = colDataGetData(pInputCol, i); + TSKEY cts = getRowPTs(pInput->pPTS, i); + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf) < cts) { + if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { + pInfo->isNull = true; + } else { + pInfo->isNull = false; + if (IS_VAR_DATA_TYPE(type)) { + bytes = varDataTLen(data); + pInfo->bytes = bytes; + } + memcpy(pInfo->buf + sizeof(TSKEY), data, bytes); + } + *(TSKEY*)(pInfo->buf) = cts; + numOfElems++; + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } + pInfo->hasResult = true; + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + pResInfo->numOfRes = 1; + } + break; + } + } else { // descending order + for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) { + char* data = colDataGetData(pInputCol, i); + TSKEY cts = getRowPTs(pInput->pPTS, i); + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf) < cts) { + if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { + pInfo->isNull = true; + } else { + pInfo->isNull = false; + if (IS_VAR_DATA_TYPE(type)) { + bytes = varDataTLen(data); + pInfo->bytes = bytes; + } + memcpy(pInfo->buf + sizeof(TSKEY), data, bytes); + } + *(TSKEY*)(pInfo->buf) = cts; + numOfElems++; + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } + pInfo->hasResult = true; + pResInfo->numOfRes = 1; + // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + } + break; + } + } + + SET_VAL(pResInfo, numOfElems, 1); + return TSDB_CODE_SUCCESS; +} + +int32_t lastRowFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + + SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); + colDataAppend(pCol, pBlock->info.rows, pRes->buf + sizeof(TSKEY), pRes->isNull); + // handle selectivity + STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); + setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows); + + return pResInfo->numOfRes; +} + bool getDiffFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SDiffInfo); return true; @@ -2776,7 +2883,11 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { SDiffInfo* pDiffInfo = GET_ROWCELL_INTERBUF(pResInfo); pDiffInfo->hasPrev = false; pDiffInfo->prev.i64 = 0; - pDiffInfo->ignoreNegative = pCtx->param[1].param.i; // TODO set correct param + if (pCtx->numOfParams > 1) { + pDiffInfo->ignoreNegative = pCtx->param[1].param.i; // TODO set correct param + } else { + pDiffInfo->ignoreNegative = false; + } pDiffInfo->includeNull = false; pDiffInfo->firstOutput = false; return true; @@ -2891,10 +3002,8 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; - SColumnInfoData* pTsOutput = pCtx->pTsOutput; int32_t numOfElems = 0; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; int32_t startOffset = pCtx->offset; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; @@ -2906,9 +3015,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { if (pDiffInfo->includeNull) { colDataSetNull_f(pOutput->nullbitmap, pos); - if (tsList != NULL) { - colDataAppendInt64(pTsOutput, pos, &tsList[i]); - } numOfElems += 1; } @@ -2919,9 +3025,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (pDiffInfo->hasPrev) { doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order); - if (pTsOutput != NULL) { - colDataAppendInt64(pTsOutput, pos, &tsList[i]); - } numOfElems++; } else { @@ -2937,9 +3040,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { if (pDiffInfo->includeNull) { colDataSetNull_f(pOutput->nullbitmap, pos); - if (tsList != NULL) { - colDataAppendInt64(pTsOutput, pos, &tsList[i]); - } numOfElems += 1; } @@ -2951,9 +3051,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { // there is a row of previous data block to be handled in the first place. if (pDiffInfo->hasPrev) { doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order); - if (pTsOutput != NULL) { - colDataAppendInt64(pTsOutput, pos, &pDiffInfo->prevTs); - } numOfElems++; } else { @@ -2961,9 +3058,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { } pDiffInfo->hasPrev = true; - if (pTsOutput != NULL) { - pDiffInfo->prevTs = tsList[i]; - } } } @@ -3100,7 +3194,10 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData if (pCtx->subsidiaries.num > 0) { saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId, + pItem->tuplePos.offset); +#endif // allocate the buffer and keep the data of this row into the new allocated buffer pEntryInfo->numOfRes++; taosheapsort((void*)pItems, sizeof(STopBotResItem), pEntryInfo->numOfRes, (const void*)&type, topBotResComparFn, @@ -3121,7 +3218,9 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData if (pCtx->subsidiaries.num > 0) { copyTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_copyTuple pageId:%d, offset:%d", pItem->tuplePos.pageId, pItem->tuplePos.offset); +#endif taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type, topBotResComparFn, NULL, !isTopQuery); } @@ -3131,7 +3230,11 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) { SFilePage* pPage = NULL; - int32_t completeRowSize = pSrcBlock->info.rowSize + (int32_t) taosArrayGetSize(pSrcBlock->pDataBlock) * sizeof(bool); + int32_t completeRowSize = pCtx->subsidiaries.num * sizeof(bool); + for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) { + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; + completeRowSize += pc->pExpr->base.resSchema.bytes; + } if (pCtx->curBufPage == -1) { pPage = getNewBufPage(pCtx->pBuf, 0, &pCtx->curBufPage); @@ -3149,19 +3252,22 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS // keep the current row data, extract method int32_t offset = 0; bool* nullList = (bool*)((char*)pPage + pPage->num); - char* pStart = (char*)(nullList + sizeof(bool) * (int32_t) taosArrayGetSize(pSrcBlock->pDataBlock)); - for (int32_t i = 0; i < (int32_t) taosArrayGetSize(pSrcBlock->pDataBlock); ++i) { - SColumnInfoData* pCol = taosArrayGet(pSrcBlock->pDataBlock, i); - bool isNull = colDataIsNull_s(pCol, rowIndex); - if (isNull) { - nullList[i] = true; + char* pStart = (char*)(nullList + sizeof(bool) * pCtx->subsidiaries.num); + for (int32_t i = 0; i < pCtx->subsidiaries.num; ++i) { + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[i]; + + SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; + int32_t srcSlotId = pFuncParam->pCol->slotId; + + SColumnInfoData* pCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId); + if ((nullList[i] = colDataIsNull_s(pCol, rowIndex)) == true) { offset += pCol->info.bytes; continue; } char* p = colDataGetData(pCol, rowIndex); if (IS_VAR_DATA_TYPE(pCol->info.type)) { - memcpy(pStart + offset, p, varDataTLen(p)); + memcpy(pStart + offset, p, (pCol->info.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(p) : varDataTLen(p)); } else { memcpy(pStart + offset, p, pCol->info.bytes); } @@ -3179,14 +3285,18 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) { SFilePage* pPage = getBufPage(pCtx->pBuf, pPos->pageId); - int32_t numOfCols = taosArrayGetSize(pSrcBlock->pDataBlock); + int32_t numOfCols = pCtx->subsidiaries.num; bool* nullList = (bool*)((char*)pPage + pPos->offset); char* pStart = (char*)(nullList + numOfCols * sizeof(bool)); int32_t offset = 0; for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pCol = taosArrayGet(pSrcBlock->pDataBlock, i); + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[i]; + SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; + int32_t srcSlotId = pFuncParam->pCol->slotId; + + SColumnInfoData* pCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId); if ((nullList[i] = colDataIsNull_s(pCol, rowIndex)) == true) { offset += pCol->info.bytes; continue; @@ -3194,7 +3304,7 @@ void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS char* p = colDataGetData(pCol, rowIndex); if (IS_VAR_DATA_TYPE(pCol->info.type)) { - memcpy(pStart + offset, p, varDataTLen(p)); + memcpy(pStart + offset, p, (pCol->info.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(p) : varDataTLen(p)); } else { memcpy(pStart + offset, p, pCol->info.bytes); } @@ -3208,7 +3318,7 @@ void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); - STopBotRes* pRes = GET_ROWCELL_INTERBUF(pEntryInfo); + STopBotRes* pRes = getTopBotOutputInfo(pCtx); int16_t type = pCtx->input.pData[0]->info.type; int32_t slotId = pCtx->pExpr->base.resSchema.slotId; @@ -3225,7 +3335,10 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } else { colDataAppend(pCol, currentRow, (const char*)&pItem->v.i, false); } - +#ifdef BUF_PAGE_DEBUG + qDebug("page_finalize i:%d,item:%p,pageId:%d, offset:%d\n", i, pItem, pItem->tuplePos.pageId, + pItem->tuplePos.offset); +#endif setSelectivityValue(pCtx, pBlock, &pRes->pItems[i].tuplePos, currentRow); currentRow += 1; } @@ -3464,7 +3577,7 @@ bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo pInfo->min = MAX_TS_KEY; pInfo->max = 0; - if (pCtx->numOfParams > 2) { + if (pCtx->numOfParams > 1) { pInfo->timeUnit = pCtx->param[1].param.i; } else { pInfo->timeUnit = 1; @@ -4405,7 +4518,6 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { SMavgInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pTsOutput = pCtx->pTsOutput; @@ -4445,10 +4557,6 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { colDataAppend(pOutput, pos, (char*)&result, false); } - // TODO: remove this after pTsOutput is handled - if (pTsOutput != NULL) { - colDataAppendInt64(pTsOutput, pos, &tsList[i]); - } numOfElems++; } @@ -4795,11 +4903,11 @@ static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) { return; } - int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; - SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { - int32_t size = sizeof(SModeItem) + pInfo->colBytes; - SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); + int32_t size = sizeof(SModeItem) + pInfo->colBytes; + SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); memcpy(pItem->data, data, pInfo->colBytes); pItem->count += 1; @@ -4812,7 +4920,7 @@ static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) { int32_t modeFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; @@ -4860,7 +4968,6 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } - bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(STwaInfo); return true; @@ -5112,7 +5219,7 @@ int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return functionFinalize(pCtx, pBlock); } -bool blockDistSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { +bool blockDistSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } @@ -5144,7 +5251,7 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) { pDistInfo->defMinRows = p1.defMinRows; pDistInfo->defMaxRows = p1.defMaxRows; - pDistInfo->rowSize = p1.rowSize; + pDistInfo->rowSize = p1.rowSize; pDistInfo->numOfSmallBlocks = p1.numOfSmallBlocks; if (pDistInfo->minRows > p1.minRows) { @@ -5230,16 +5337,18 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t row = 0; char st[256] = {0}; double totalRawSize = pData->totalRows * pData->rowSize; - int32_t len = - sprintf(st + VARSTR_HEADER_SIZE, "Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]", - pData->numOfBlocks, pData->totalSize / 1024.0, ((double)pData->totalSize) / pData->numOfBlocks, - pData->totalSize * 100 / totalRawSize, '%'); + int32_t len = sprintf(st + VARSTR_HEADER_SIZE, + "Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]", + pData->numOfBlocks, pData->totalSize / 1024.0, ((double)pData->totalSize) / pData->numOfBlocks, + pData->totalSize * 100 / totalRawSize, '%'); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); - len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Rows=[%"PRId64"] Inmem_Rows=[%d] MinRows=[%d] MaxRows=[%d] Average_Rows=[%"PRId64"]", - pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows, pData->totalRows / pData->numOfBlocks); + len = sprintf(st + VARSTR_HEADER_SIZE, + "Total_Rows=[%" PRId64 "] Inmem_Rows=[%d] MinRows=[%d] MaxRows=[%d] Average_Rows=[%" PRId64 "]", + pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows, + pData->totalRows / pData->numOfBlocks); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); @@ -5415,25 +5524,25 @@ bool irateFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - pInfo->firstKey = INT64_MIN; - pInfo->lastKey = INT64_MIN; + pInfo->firstKey = INT64_MIN; + pInfo->lastKey = INT64_MIN; pInfo->firstValue = (double)INT64_MIN; - pInfo->lastValue = (double)INT64_MIN; + pInfo->lastValue = (double)INT64_MIN; - pInfo->hasResult = 0; + pInfo->hasResult = 0; return true; } int32_t irateFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SRateInfo* pRateInfo = GET_ROWCELL_INTERBUF(pResInfo); + SRateInfo* pRateInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; int32_t numOfElems = 0; int32_t type = pInputCol->info.type; @@ -5445,13 +5554,13 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) { numOfElems++; - char* data = colDataGetData(pInputCol, i); - double v = 0; + char* data = colDataGetData(pInputCol, i); + double v = 0; GET_TYPED_DATA(v, double, type, data); if (INT64_MIN == pRateInfo->lastKey) { pRateInfo->lastValue = v; - pRateInfo->lastKey = tsList[i]; + pRateInfo->lastKey = tsList[i]; continue; } @@ -5462,7 +5571,7 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) { } pRateInfo->lastValue = v; - pRateInfo->lastKey = tsList[i]; + pRateInfo->lastKey = tsList[i]; continue; } @@ -5471,7 +5580,6 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) { pRateInfo->firstValue = v; pRateInfo->firstKey = tsList[i]; } - } SET_VAL(pResInfo, numOfElems, 1); @@ -5497,7 +5605,7 @@ static double doCalcRate(const SRateInfo* pRateInfo, double tickPerSec) { return 0; } - return (duration > 0)? ((double)diff) / (duration/tickPerSec):0.0; + return (duration > 0) ? ((double)diff) / (duration / tickPerSec) : 0.0; } int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { @@ -5508,7 +5616,7 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0; SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - double result = doCalcRate(pInfo, 1000); + double result = doCalcRate(pInfo, (double)TSDB_TICK_PER_SECOND(pCtx->param[1].param.i)); colDataAppend(pCol, pBlock->info.rows, (const char*)&result, pResInfo->isNullRes); return pResInfo->numOfRes; @@ -5516,16 +5624,14 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pInputCol = pInput->pData[0]; - - int32_t bytes = pInputCol->info.bytes; + SColumnInfoData* pInputCol = pInput->pData[0]; int32_t startIndex = pInput->startRowIndex; - //escape rest of data blocks to avoid first entry to be overwritten. + // escape rest of data blocks to avoid first entry to be overwritten. if (pInfo->hasResult) { goto _group_key_over; } @@ -5537,7 +5643,12 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { } char* data = colDataGetData(pInputCol, startIndex); - memcpy(pInfo->data, data, bytes); + if (IS_VAR_DATA_TYPE(pInputCol->info.type)) { + memcpy(pInfo->data, data, + (pInputCol->info.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(data) : varDataTLen(data)); + } else { + memcpy(pInfo->data, data, pInputCol->info.bytes); + } pInfo->hasResult = true; _group_key_over: diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 52edf83232..7ad7612e7e 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -181,6 +181,8 @@ bool fmIsForbidGroupByFunc(int32_t funcId) { return isSpecificClassifyFunc(funcI bool fmIsSystemInfoFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SYSTEM_INFO_FUNC); } +bool fmIsImplicitTsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IMPLICIT_TS_FUNC); } + bool fmIsInterpFunc(int32_t funcId) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return false; diff --git a/source/libs/function/src/taggfunction.c b/source/libs/function/src/taggfunction.c index 47ae07f823..c8998b9d94 100644 --- a/source/libs/function/src/taggfunction.c +++ b/source/libs/function/src/taggfunction.c @@ -1887,10 +1887,10 @@ static void top_bottom_func_finalizer(SqlFunctionCtx *pCtx) { // user specify the order of output by sort the result according to timestamp if (pCtx->param[1].param.i == PRIMARYKEY_TIMESTAMP_COL_ID) { __compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn; - qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); + taosSort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); } else /*if (pCtx->param[1].param.i > PRIMARYKEY_TIMESTAMP_COL_ID)*/ { __compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn; - qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); + taosSort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); } GET_TRUE_DATA_TYPE(); diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index b40dd8b78d..057d2bc7dc 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -44,7 +44,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) offset += (int32_t)(pg->num * pMemBucket->bytes); } - qsort(buffer->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn); + taosSort(buffer->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn); return buffer; } diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 364ee0692f..708ea4bd38 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -548,8 +548,8 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { } static bool udfdRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || - code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { - if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) { + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) { return false; } return true; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index b372bf75fc..9c5cec07df 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -18,6 +18,7 @@ #include "querynodes.h" #include "taos.h" #include "taoserror.h" +#include "tdatablock.h" #define COPY_SCALAR_FIELD(fldname) \ do { \ @@ -164,7 +165,15 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { memcpy(pDst->datum.p, pSrc->datum.p, len); break; } - case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_JSON:{ + int32_t len = getJsonValueLen(pSrc->datum.p); + pDst->datum.p = taosMemoryCalloc(1, len); + if (NULL == pDst->datum.p) { + return TSDB_CODE_OUT_OF_MEMORY; + } + memcpy(pDst->datum.p, pSrc->datum.p, len); + break; + } case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: case TSDB_DATA_TYPE_MEDIUMBLOB: @@ -350,9 +359,9 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { CLONE_NODE_FIELD(pTagIndexCond); COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); - COPY_SCALAR_FIELD(tsColId); - COPY_SCALAR_FIELD(filesFactor); + COPY_SCALAR_FIELD(igExpired); CLONE_NODE_LIST_FIELD(pGroupTags); + COPY_SCALAR_FIELD(groupSort); return TSDB_CODE_SUCCESS; } @@ -421,7 +430,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p CLONE_NODE_FIELD(pStateExpr); COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); - COPY_SCALAR_FIELD(filesFactor); + COPY_SCALAR_FIELD(igExpired); COPY_SCALAR_FIELD(windowAlgo); return TSDB_CODE_SUCCESS; } @@ -511,8 +520,7 @@ static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhy COPY_SCALAR_FIELD(slidingUnit); COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); - COPY_SCALAR_FIELD(tsColId); - COPY_SCALAR_FIELD(filesFactor); + COPY_SCALAR_FIELD(igExpired); return TSDB_CODE_SUCCESS; } @@ -532,7 +540,7 @@ static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* p CLONE_NODE_FIELD(pTsEnd); COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); - COPY_SCALAR_FIELD(filesFactor); + COPY_SCALAR_FIELD(igExpired); return TSDB_CODE_SUCCESS; } @@ -582,6 +590,7 @@ static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstre COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr)); COPY_SCALAR_FIELD(taskId); COPY_SCALAR_FIELD(schedId); + COPY_SCALAR_FIELD(execId); return TSDB_CODE_SUCCESS; } @@ -600,7 +609,7 @@ static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_CHAR_ARRAY_FIELD(stmtName); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(isEmptyResult); - COPY_SCALAR_FIELD(isTimeOrderQuery); + COPY_SCALAR_FIELD(isTimeLineResult); COPY_SCALAR_FIELD(hasAggFuncs); COPY_SCALAR_FIELD(hasRepeatScanFuncs); return TSDB_CODE_SUCCESS; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index df7429bd88..4179930033 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -20,6 +20,7 @@ #include "querynodes.h" #include "taoserror.h" #include "tjson.h" +#include "tdatablock.h" static int32_t nodeToJson(const void* pObj, SJson* pJson); static int32_t jsonToNode(const SJson* pJson, void* pObj); @@ -1426,12 +1427,11 @@ static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs"; static const char* jkTableScanPhysiPlanInterval = "Interval"; static const char* jkTableScanPhysiPlanOffset = "Offset"; static const char* jkTableScanPhysiPlanSliding = "Sliding"; -static const char* jkTableScanPhysiPlanIntervalUnit = "intervalUnit"; -static const char* jkTableScanPhysiPlanSlidingUnit = "slidingUnit"; -static const char* jkTableScanPhysiPlanTriggerType = "triggerType"; -static const char* jkTableScanPhysiPlanWatermark = "watermark"; -static const char* jkTableScanPhysiPlanTsColId = "tsColId"; -static const char* jkTableScanPhysiPlanFilesFactor = "FilesFactor"; +static const char* jkTableScanPhysiPlanIntervalUnit = "IntervalUnit"; +static const char* jkTableScanPhysiPlanSlidingUnit = "SlidingUnit"; +static const char* jkTableScanPhysiPlanTriggerType = "TriggerType"; +static const char* jkTableScanPhysiPlanWatermark = "Watermark"; +static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired"; static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; @@ -1482,10 +1482,7 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanWatermark, pNode->watermark); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanTsColId, pNode->tsColId); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanFilesFactor, pNode->filesFactor); + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIgnoreExpired, pNode->igExpired); } if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkTableScanPhysiPlanGroupTags, pNode->pGroupTags); @@ -1517,37 +1514,34 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired, code); + code = tjsonGetIntValue(pJson, jkTableScanPhysiPlanDataRequired, &pNode->dataRequired); } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval, code); + code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanInterval, &pNode->interval); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset, code); + code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanOffset, &pNode->offset); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding, code); + code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanSliding, &pNode->sliding); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit, code); + code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIntervalUnit, &pNode->intervalUnit); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit, code); + code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanSlidingUnit, &pNode->slidingUnit); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTriggerType, pNode->triggerType, code); + code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanTriggerType, &pNode->triggerType); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanWatermark, pNode->watermark, code); + code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanWatermark, &pNode->watermark); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTsColId, pNode->tsColId, code); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanFilesFactor, &pNode->filesFactor); + code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIgnoreExpired, &pNode->igExpired); } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkTableScanPhysiPlanGroupTags, &pNode->pGroupTags); @@ -1826,7 +1820,7 @@ static const char* jkWindowPhysiPlanTsPk = "TsPk"; static const char* jkWindowPhysiPlanTsEnd = "TsEnd"; static const char* jkWindowPhysiPlanTriggerType = "TriggerType"; static const char* jkWindowPhysiPlanWatermark = "Watermark"; -static const char* jkWindowPhysiPlanFilesFactor = "FilesFactor"; +static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired"; static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj; @@ -1851,7 +1845,7 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanWatermark, pNode->watermark); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddDoubleToObject(pJson, jkWindowPhysiPlanFilesFactor, pNode->filesFactor); + code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired); } return code; @@ -1874,15 +1868,13 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) { code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsEnd, (SNode**)&pNode->pTsEnd); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkWindowPhysiPlanTriggerType, pNode->triggerType, code); - ; + code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanTriggerType, &pNode->triggerType); } if (TSDB_CODE_SUCCESS == code) { - tjsonGetNumberValue(pJson, jkWindowPhysiPlanWatermark, pNode->watermark, code); - ; + code = tjsonGetBigIntValue(pJson, jkWindowPhysiPlanWatermark, &pNode->watermark); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetDoubleValue(pJson, jkWindowPhysiPlanFilesFactor, &pNode->filesFactor); + code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired); } return code; @@ -2638,7 +2630,18 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) { case TSDB_DATA_TYPE_VARBINARY: code = tjsonAddStringToObject(pJson, jkValueDatum, varDataVal(pNode->datum.p)); break; - case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_JSON:{ + int32_t len = getJsonValueLen(pNode->datum.p); + char* buf = taosMemoryCalloc( len * 2 + 1, sizeof(char)); + code = taosHexEncode(pNode->datum.p, buf, len); + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(buf); + return TSDB_CODE_TSC_INVALID_VALUE; + } + code = tjsonAddStringToObject(pJson, jkValueDatum, buf); + taosMemoryFree(buf); + break; + } case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: // todo @@ -2761,7 +2764,30 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { } break; } - case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_JSON:{ + pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes); + if (NULL == pNode->datum.p) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + 1); + if (NULL == buf) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + code = tjsonGetStringValue(pJson, jkValueDatum, buf); + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(buf); + break; + } + code = taosHexDecode(buf, pNode->datum.p, pNode->node.resType.bytes); + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(buf); + break; + } + taosMemoryFree(buf); + break; + } case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: // todo @@ -3430,6 +3456,7 @@ static int32_t jsonToSlotDescNode(const SJson* pJson, void* pObj) { static const char* jkDownstreamSourceAddr = "Addr"; static const char* jkDownstreamSourceTaskId = "TaskId"; static const char* jkDownstreamSourceSchedId = "SchedId"; +static const char* jkDownstreamSourceExecId = "ExecId"; static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) { const SDownstreamSourceNode* pNode = (const SDownstreamSourceNode*)pObj; @@ -3441,6 +3468,9 @@ static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceSchedId, pNode->schedId); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceExecId, pNode->execId); + } return code; } @@ -3455,6 +3485,9 @@ static int32_t jsonToDownstreamSourceNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceSchedId, &pNode->schedId); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkDownstreamSourceExecId, &pNode->execId); + } return code; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index dc9d9b92ee..eb59bd7f6a 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -20,6 +20,7 @@ #include "taos.h" #include "taoserror.h" #include "thash.h" +#include "tdatablock.h" static SNode* makeNode(ENodeType type, size_t size) { SNode* p = taosMemoryCalloc(1, size); @@ -1675,6 +1676,10 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { pVal->pz[pVal->nLen + VARSTR_HEADER_SIZE] = 0; break; case TSDB_DATA_TYPE_JSON: + pVal->nLen = getJsonValueLen(pNode->datum.p); + pVal->pz = taosMemoryMalloc(pVal->nLen); + memcpy(pVal->pz, pNode->datum.p, pVal->nLen); + break; case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: // todo @@ -1728,7 +1733,6 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) { } else { pCxt->hasOtherCol = true; } - return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END; } return DEAL_RES_CONTINUE; } diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index d06d6ec527..e829c9266f 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -62,7 +62,6 @@ int32_t getNumOfColumns(const STableMeta* pTableMeta); int32_t getNumOfTags(const STableMeta* pTableMeta); STableComInfo getTableInfo(const STableMeta* pTableMeta); STableMeta* tableMetaDup(const STableMeta* pTableMeta); -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, SMsgBuf* pMsgBuf); int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index cb43bfef0e..2e58cc56b8 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -488,6 +488,7 @@ stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE. 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; } +stream_options(A) ::= stream_options(B) IGNORE EXPIRED. { ((SStreamOptions*)B)->ignoreExpired = true; A = B; } /************************************************ kill connection/query ***********************************************/ cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } @@ -848,14 +849,10 @@ set_quantifier_opt(A) ::= ALL. %type select_list { SNodeList* } %destructor select_list { nodesDestroyList($$); } -select_list(A) ::= NK_STAR. { A = NULL; } -select_list(A) ::= select_sublist(B). { A = B; } - -%type select_sublist { SNodeList* } -%destructor select_sublist { nodesDestroyList($$); } -select_sublist(A) ::= select_item(B). { A = createNodeList(pCxt, B); } -select_sublist(A) ::= select_sublist(B) NK_COMMA select_item(C). { A = addNodeToList(pCxt, B, C); } +select_list(A) ::= select_item(B). { A = createNodeList(pCxt, B); } +select_list(A) ::= select_list(B) NK_COMMA select_item(C). { A = addNodeToList(pCxt, B, C); } +select_item(A) ::= NK_STAR(B). { A = createColumnNode(pCxt, NULL, &B); } select_item(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); } select_item(A) ::= common_expression(B) column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); } select_item(A) ::= common_expression(B) AS column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 9709a8b1ea..59fbeded60 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -717,7 +717,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr select->pProjectionList = pProjectionList; select->pFromTable = pTable; sprintf(select->stmtName, "%p", select); - select->isTimeOrderQuery = true; + select->isTimeLineResult = true; return (SNode*)select; } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 044ec90a7f..a76640d0b5 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -790,11 +790,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* pColIdx[i].schemaColIdx = pColList->boundColumns[i]; pColIdx[i].boundIdx = i; } - qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); for (col_id_t i = 0; i < pColList->numOfBound; ++i) { pColIdx[i].finalIdx = i; } - qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); } if (pColList->numOfCols > pColList->numOfBound) { @@ -1302,6 +1302,74 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da return TSDB_CODE_SUCCESS; } +static int32_t parseCsvFile(SInsertParseContext* pCxt, TdFilePtr fp, STableDataBlocks* pDataBlock, int maxRows, + int32_t* numOfRows) { + STableComInfo tinfo = getTableInfo(pDataBlock->pTableMeta); + int32_t extendedRowSize = getExtendedRowSize(pDataBlock); + CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); + + (*numOfRows) = 0; + char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \" + char* pLine = NULL; + int64_t readLen = 0; + while ((readLen = taosGetLineFile(fp, &pLine)) != -1) { + if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) { + pLine[--readLen] = '\0'; + } + + if (readLen == 0) { + continue; + } + + if ((*numOfRows) >= maxRows || pDataBlock->size + extendedRowSize >= pDataBlock->nAllocSize) { + int32_t tSize; + CHECK_CODE(allocateMemIfNeed(pDataBlock, extendedRowSize, &tSize)); + ASSERT(tSize >= maxRows); + maxRows = tSize; + } + + strtolower(pLine, pLine); + char* pRawSql = pCxt->pSql; + pCxt->pSql = pLine; + bool gotRow = false; + CHECK_CODE(parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf)); + if (gotRow) { + pDataBlock->size += extendedRowSize; // len; + (*numOfRows)++; + } + pCxt->pSql = pRawSql; + } + + if (0 == (*numOfRows) && (!TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT))) { + return buildSyntaxErrMsg(&pCxt->msg, "no any data points", NULL); + } + return TSDB_CODE_SUCCESS; +} + +static int32_t parseDataFromFile(SInsertParseContext* pCxt, SToken filePath, STableDataBlocks* dataBuf) { + char filePathStr[TSDB_FILENAME_LEN] = {0}; + strncpy(filePathStr, filePath.z, filePath.n); + TdFilePtr fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM); + if (NULL == fp) { + return TAOS_SYSTEM_ERROR(errno); + } + + int32_t maxNumOfRows; + CHECK_CODE(allocateMemIfNeed(dataBuf, getExtendedRowSize(dataBuf), &maxNumOfRows)); + + int32_t numOfRows = 0; + CHECK_CODE(parseCsvFile(pCxt, fp, dataBuf, maxNumOfRows, &numOfRows)); + + SSubmitBlk* pBlocks = (SSubmitBlk*)(dataBuf->pData); + if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf, numOfRows)) { + return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than 32767"); + } + + dataBuf->numOfTables = 1; + pCxt->totalNum += numOfRows; + return TSDB_CODE_SUCCESS; +} + void destroyCreateSubTbReq(SVCreateTbReq* pReq) { taosMemoryFreeClear(pReq->name); taosMemoryFreeClear(pReq->ctb.pTag); @@ -1421,7 +1489,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { if (0 == sToken.n || (TK_NK_STRING != sToken.type && TK_NK_ID != sToken.type)) { return buildSyntaxErrMsg(&pCxt->msg, "file path is required following keyword FILE", sToken.z); } - // todo + CHECK_CODE(parseDataFromFile(pCxt, sToken, dataBuf)); pCxt->pOutput->insertType = TSDB_QUERY_TYPE_FILE_INSERT; tbNum++; @@ -2164,11 +2232,11 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS pColIdx[i].schemaColIdx = pColList->boundColumns[i]; pColIdx[i].boundIdx = i; } - qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); for (col_id_t i = 0; i < pColList->numOfBound; ++i) { pColIdx[i].finalIdx = i; } - qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); } if (pColList->numOfCols > pColList->numOfBound) { diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index 56301c072c..84bcef7185 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -295,7 +295,7 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) { char* pBlockData = pBlocks->data; // todo. qsort is unstable, if timestamp is same, should get the last one - qsort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar); + taosSort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar); int32_t i = 0; int32_t j = 1; @@ -365,7 +365,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; // todo. qsort is unstable, if timestamp is same, should get the last one - qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable); + taosSort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable); pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; int32_t i = 0; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 7f5d742dc7..6736fea635 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -84,8 +84,10 @@ static SKeyword keywordTable[] = { {"DURATION", TK_DURATION}, {"ENABLE", TK_ENABLE}, {"EXISTS", TK_EXISTS}, + {"EXPIRED", TK_EXPIRED}, {"EXPLAIN", TK_EXPLAIN}, {"EVERY", TK_EVERY}, + {"FILE", TK_FILE}, {"FILL", TK_FILL}, {"FIRST", TK_FIRST}, {"FLOAT", TK_FLOAT}, @@ -98,6 +100,7 @@ static SKeyword keywordTable[] = { {"GROUP", TK_GROUP}, {"HAVING", TK_HAVING}, {"IF", TK_IF}, + {"IGNORE", TK_IGNORE}, {"IMPORT", TK_IMPORT}, {"IN", TK_IN}, {"INDEX", TK_INDEX}, @@ -289,7 +292,6 @@ static SKeyword keywordTable[] = { // {"END", TK_END}, // {"FAIL", TK_FAIL}, // {"FOR", TK_FOR}, - // {"IGNORE", TK_IGNORE}, // {"IMMEDIATE", TK_IMMEDIATE}, // {"INITIALLY", TK_INITIALLY}, // {"INSTEAD", TK_INSTEAD}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 521c733ceb..2b5993b800 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -440,6 +440,10 @@ static bool isTimelineFunc(const SNode* pNode) { return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId)); } +static bool isImplicitTsFunc(const SNode* pNode) { + return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsImplicitTsFunc(((SFunctionNode*)pNode)->funcId)); +} + static bool isScanPseudoColumnFunc(const SNode* pNode) { return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsScanPseudoColumnFunc(((SFunctionNode*)pNode)->funcId)); } @@ -479,6 +483,35 @@ static SNodeList* getProjectList(const SNode* pNode) { return NULL; } +static bool isTimeLineQuery(SNode* pStmt) { + if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + return ((SSelectStmt*)pStmt)->isTimeLineResult; + } else { + return false; + } +} + +static bool isPrimaryKeyImpl(SNode* pExpr) { + if (QUERY_NODE_COLUMN == nodeType(pExpr)) { + return (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId); + } else if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { + SFunctionNode* pFunc = (SFunctionNode*)pExpr; + if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) { + return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0)); + } else if (FUNCTION_TYPE_WSTARTTS == pFunc->funcType || FUNCTION_TYPE_WENDTS == pFunc->funcType) { + return true; + } + } + return false; +} + +static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) { + if (!isTimeLineQuery(pTable->pSubquery)) { + return false; + } + return isPrimaryKeyImpl(pExpr); +} + static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, int32_t tagFlag, SColumnNode* pCol) { strcpy(pCol->dbName, pTable->table.dbName); @@ -500,7 +533,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p } } -static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef) { +static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef) { SColumnNode* pCol = *pColRef; // pCol->pProjectRef = (SNode*)pExpr; @@ -508,15 +541,8 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol pExpr->pAssociation = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); } taosArrayPush(pExpr->pAssociation, &pColRef); - if (NULL != pTable) { - strcpy(pCol->tableAlias, pTable->tableAlias); - } else if (QUERY_NODE_COLUMN == nodeType(pExpr)) { - SColumnNode* pProjCol = (SColumnNode*)pExpr; - strcpy(pCol->tableAlias, pProjCol->tableAlias); - pCol->tableId = pProjCol->tableId; - pCol->colId = pProjCol->colId; - pCol->colType = pProjCol->colType; - } + strcpy(pCol->tableAlias, pTable->table.tableAlias); + pCol->colId = isPrimaryKey(pTable, (SNode*)pExpr) ? PRIMARYKEY_TIMESTAMP_COL_ID : 0; strcpy(pCol->colName, pExpr->aliasName); if ('\0' == pCol->node.aliasName[0]) { strcpy(pCol->node.aliasName, pCol->colName); @@ -538,8 +564,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p nodesListAppend(pList, (SNode*)pCol); } } else { - SNodeList* pProjectList = getProjectList(((STempTableNode*)pTable)->pSubquery); - SNode* pNode; + STempTableNode* pTempTable = (STempTableNode*)pTable; + SNodeList* pProjectList = getProjectList(pTempTable->pSubquery); + SNode* pNode; FOREACH(pNode, pProjectList) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -547,7 +574,7 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p } nodesListAppend(pList, (SNode*)pCol); SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); - setColumnInfoByExpr(pTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); + setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); } } return TSDB_CODE_SUCCESS; @@ -557,35 +584,6 @@ static bool isInternalPrimaryKey(const SColumnNode* pCol) { return PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && 0 == strcmp(pCol->colName, PK_TS_COL_INTERNAL_NAME); } -static bool isTimeOrderQuery(SNode* pStmt) { - if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - return ((SSelectStmt*)pStmt)->isTimeOrderQuery; - } else { - return false; - } -} - -static bool isPrimaryKeyImpl(STempTableNode* pTable, SNode* pExpr) { - if (QUERY_NODE_COLUMN == nodeType(pExpr)) { - return (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId); - } else if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { - SFunctionNode* pFunc = (SFunctionNode*)pExpr; - if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) { - return isPrimaryKeyImpl(pTable, nodesListGetNode(pFunc->pParameterList, 0)); - } else if (FUNCTION_TYPE_WSTARTTS == pFunc->funcType || FUNCTION_TYPE_WENDTS == pFunc->funcType) { - return true; - } - } - return false; -} - -static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) { - if (!isTimeOrderQuery(pTable->pSubquery)) { - return false; - } - return isPrimaryKeyImpl(pTable, pExpr); -} - static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, const STableNode* pTable, bool* pFound) { SColumnNode* pCol = *pColRef; @@ -606,18 +604,19 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, } } } else { - SNodeList* pProjectList = getProjectList(((STempTableNode*)pTable)->pSubquery); - SNode* pNode; + STempTableNode* pTempTable = (STempTableNode*)pTable; + SNodeList* pProjectList = getProjectList(pTempTable->pSubquery); + SNode* pNode; FOREACH(pNode, pProjectList) { SExprNode* pExpr = (SExprNode*)pNode; if (0 == strcmp(pCol->colName, pExpr->aliasName)) { if (*pFound) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pCol->colName); } - setColumnInfoByExpr(pTable, pExpr, pColRef); + setColumnInfoByExpr(pTempTable, pExpr, pColRef); *pFound = true; - } else if (isPrimaryKey((STempTableNode*)pTable, pNode) && isInternalPrimaryKey(pCol)) { - setColumnInfoByExpr(pTable, pExpr, pColRef); + } else if (isPrimaryKey(pTempTable, pNode) && isInternalPrimaryKey(pCol)) { + setColumnInfoByExpr(pTempTable, pExpr, pColRef); *pFound = true; } } @@ -783,6 +782,13 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD if (pVal->placeholderNo > 0 || pVal->isNull) { return DEAL_RES_CONTINUE; } + if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) { + // TODO + // pVal->node.resType = targetDt; + pVal->translate = true; + pVal->isNull = true; + return DEAL_RES_CONTINUE; + } if (pVal->isDuration) { if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) != TSDB_CODE_SUCCESS) { @@ -1252,6 +1258,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType); + pSelect->hasTimeLineFunc = pSelect->hasLastRowFunc ? true : fmIsTimelineFunc(pFunc->funcId); } } @@ -1470,7 +1477,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName); pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode); if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode == getFuncInfo(pCxt, pFunc); + pCxt->errCode = getFuncInfo(pCxt, pFunc); } if (TSDB_CODE_SUCCESS == pCxt->errCode) { *pNode = (SNode*)pFunc; @@ -1626,6 +1633,16 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) return TSDB_CODE_SUCCESS; } +static int32_t checkWindowFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (NULL == pSelect->pWindow) { + return TSDB_CODE_SUCCESS; + } + if (NULL != pSelect->pWindow && !pSelect->hasAggFuncs) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN); + } + return TSDB_CODE_SUCCESS; +} + static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) { size_t vgroupNum = taosArrayGetSize(pVgs); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum); @@ -1984,34 +2001,38 @@ static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNod } static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { - if (NULL == pSelect->pProjectionList) { // select * ... - return createAllColumns(pCxt, &pSelect->pProjectionList); - } else { - SNode* pNode = NULL; - WHERE_EACH(pNode, pSelect->pProjectionList) { - int32_t code = TSDB_CODE_SUCCESS; - if (isMultiResFunc(pNode)) { - SNodeList* pFuncs = NULL; - code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs); - if (TSDB_CODE_SUCCESS == code) { - INSERT_LIST(pSelect->pProjectionList, pFuncs); - ERASE_NODE(pSelect->pProjectionList); - continue; - } - } else if (isTableStar(pNode)) { - SNodeList* pCols = NULL; - code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols); - if (TSDB_CODE_SUCCESS == code) { - INSERT_LIST(pSelect->pProjectionList, pCols); - ERASE_NODE(pSelect->pProjectionList); - continue; - } + SNode* pNode = NULL; + WHERE_EACH(pNode, pSelect->pProjectionList) { + int32_t code = TSDB_CODE_SUCCESS; + if (isStar(pNode)) { + SNodeList* pCols = NULL; + code = createAllColumns(pCxt, &pCols); + if (TSDB_CODE_SUCCESS == code) { + INSERT_LIST(pSelect->pProjectionList, pCols); + ERASE_NODE(pSelect->pProjectionList); + continue; } - if (TSDB_CODE_SUCCESS != code) { - return code; + } else if (isMultiResFunc(pNode)) { + SNodeList* pFuncs = NULL; + code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs); + if (TSDB_CODE_SUCCESS == code) { + INSERT_LIST(pSelect->pProjectionList, pFuncs); + ERASE_NODE(pSelect->pProjectionList); + continue; + } + } else if (isTableStar(pNode)) { + SNodeList* pCols = NULL; + code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols); + if (TSDB_CODE_SUCCESS == code) { + INSERT_LIST(pSelect->pProjectionList, pCols); + ERASE_NODE(pSelect->pProjectionList); + continue; } - WHERE_NEXT; } + if (TSDB_CODE_SUCCESS != code) { + return code; + } + WHERE_NEXT; } return TSDB_CODE_SUCCESS; } @@ -2126,7 +2147,7 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) { } if (NULL != pSelect->pGroupByList) { pCxt->currClause = SQL_CLAUSE_GROUP_BY; - pSelect->isTimeOrderQuery = false; + pSelect->isTimeLineResult = false; return translateExprList(pCxt, pSelect->pGroupByList); } return TSDB_CODE_SUCCESS; @@ -2460,9 +2481,9 @@ static int32_t createPrimaryKeyCol(STranslateContext* pCxt, SNode** pPrimaryKey) return code; } -static EDealRes rewriteTimelineFuncImpl(SNode* pNode, void* pContext) { +static EDealRes appendTsForImplicitTsFuncImpl(SNode* pNode, void* pContext) { STranslateContext* pCxt = pContext; - if (isTimelineFunc(pNode)) { + if (isImplicitTsFunc(pNode)) { SFunctionNode* pFunc = (SFunctionNode*)pNode; SNode* pPrimaryKey = NULL; pCxt->errCode = createPrimaryKeyCol(pCxt, &pPrimaryKey); @@ -2474,8 +2495,8 @@ static EDealRes rewriteTimelineFuncImpl(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static int32_t rewriteTimelineFunc(STranslateContext* pCxt, SSelectStmt* pSelect) { - nodesWalkSelectStmt(pSelect, SQL_CLAUSE_FROM, rewriteTimelineFuncImpl, pCxt); +static int32_t appendTsForImplicitTsFunc(STranslateContext* pCxt, SSelectStmt* pSelect) { + nodesWalkSelectStmt(pSelect, SQL_CLAUSE_FROM, appendTsForImplicitTsFuncImpl, pCxt); return pCxt->errCode; } @@ -2568,6 +2589,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { code = checkAggColCoexist(pCxt, pSelect); } + if (TSDB_CODE_SUCCESS == code) { + code = checkWindowFuncCoexist(pCxt, pSelect); + } if (TSDB_CODE_SUCCESS == code) { code = checkLimit(pCxt, pSelect); } @@ -2575,7 +2599,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect code = translateInterp(pCxt, pSelect); } if (TSDB_CODE_SUCCESS == code) { - code = rewriteTimelineFunc(pCxt, pSelect); + code = appendTsForImplicitTsFunc(pCxt, pSelect); } if (TSDB_CODE_SUCCESS == code) { code = replaceOrderByAlias(pCxt, pSelect->pProjectionList, pSelect->pOrderByList); @@ -3197,7 +3221,7 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN if (TSDB_CODE_SUCCESS == code) { if ((TSDB_DATA_TYPE_VARCHAR == pTag->dataType.type && pTag->dataType.bytes > TSDB_MAX_BINARY_LEN) || (TSDB_DATA_TYPE_NCHAR == pTag->dataType.type && pTag->dataType.bytes > TSDB_MAX_NCHAR_LEN)) { - code = code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN); + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN); } } if (TSDB_CODE_SUCCESS == code) { @@ -3610,8 +3634,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm pReq->numOfColumns = LIST_LENGTH(pStmt->pCols); pReq->numOfTags = LIST_LENGTH(pStmt->pTags); if (pStmt->pOptions->commentNull == false) { - pReq->comment = strdup(pStmt->pOptions->comment); - if (NULL == pReq->comment) { + pReq->pComment = strdup(pStmt->pOptions->comment); + if (NULL == pReq->pComment) { return TSDB_CODE_OUT_OF_MEMORY; } pReq->commentLen = strlen(pStmt->pOptions->comment); @@ -3619,6 +3643,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm pReq->commentLen = -1; } buildRollupFuncs(pStmt->pOptions->pRollupFuncs, &pReq->pFuncs); + pReq->numOfFuncs = taosArrayGetSize(pReq->pFuncs); SName tableName; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name); @@ -4204,6 +4229,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* 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); + pReq->igExpired = pStmt->pOptions->ignoreExpired; } return code; @@ -4794,6 +4820,15 @@ static const char* getSysTableName(ENodeType type) { return NULL; } +static SNode* createStarCol() { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return NULL; + } + strcpy(pCol->colName, "*"); + return (SNode*)pCol; +} + static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSelectStmt** pStmt) { SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { @@ -4811,6 +4846,11 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele strcpy(pRealTable->table.tableAlias, pTable); pSelect->pFromTable = (SNode*)pRealTable; + if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSelect->pProjectionList, createStarCol())) { + nodesDestroyNode((SNode*)pSelect); + return TSDB_CODE_OUT_OF_MEMORY; + } + *pStmt = pSelect; return TSDB_CODE_SUCCESS; @@ -4959,6 +4999,7 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) { SSelectStmt* pStmt = NULL; int32_t code = createSelectStmtForShowTableDist((SShowTableDistributedStmt*)pQuery->pRoot, &pStmt); if (TSDB_CODE_SUCCESS == code) { + NODES_DESTORY_LIST(pStmt->pProjectionList); code = nodesListMakeStrictAppend(&pStmt->pProjectionList, createBlockDistFunc()); } if (TSDB_CODE_SUCCESS == code) { @@ -5335,7 +5376,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau if (code != TSDB_CODE_SUCCESS) { goto end; } - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { + } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; if (IS_VAR_DATA_TYPE(pTagSchema->type)) { @@ -5602,8 +5643,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return TSDB_CODE_OUT_OF_MEMORY; } - if (DEAL_RES_ERROR == - translateValueImpl(pCxt, pStmt->pVal, schemaToDataType(pTableMeta->tableInfo.precision, pSchema))) { + SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); + if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt)) { return pCxt->errCode; } @@ -5612,7 +5653,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS } pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); - if (pStmt->pVal->node.resType.type == TSDB_DATA_TYPE_JSON) { + if (targetDt.type == TSDB_DATA_TYPE_JSON) { + pReq->isNull = 0; if (pStmt->pVal->literal && strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal); @@ -6011,7 +6053,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_EXPLAIN_STMT: pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; pQuery->haveResultSet = true; - pQuery->msgType = TDMT_VND_QUERY; + pQuery->msgType = TDMT_SCH_QUERY; break; case QUERY_NODE_DELETE_STMT: pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 202dd96581..168e51a2bb 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -185,19 +185,21 @@ static char* getSyntaxErrFormat(int32_t errCode) { case TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG: return "The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes"; case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC: - return "%s function does not supportted in fill query"; + return "%s function is not supported in fill query"; case TSDB_CODE_PAR_INVALID_WINDOW_PC: return "_WSTARTTS, _WENDTS and _WDURATION can only be used in window query"; case TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC: - return "%s function does not supportted in time window query"; + return "%s function is not supported in time window query"; case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC: - return "%s function does not supportted in stream query"; + return "%s function is not supported in stream query"; case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC: - return "%s function does not supportted in group query"; + return "%s function is not supported in group query"; case TSDB_CODE_PAR_INVALID_TABLE_OPTION: return "Invalid option %s"; case TSDB_CODE_PAR_INVALID_INTERP_CLAUSE: return "Invalid usage of RANGE clause, EVERY clause or FILL clause"; + case TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN: + return "No valid function in window query"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: @@ -219,6 +221,7 @@ int32_t buildInvalidOperationMsg(SMsgBuf* pBuf, const char* msg) { } int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char* sourceStr) { + if(pBuf == NULL) return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; const char* msgFormat1 = "syntax error near \'%s\'"; const char* msgFormat2 = "syntax error near \'%s\' (%s)"; const char* msgFormat3 = "%s"; @@ -337,16 +340,16 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) { static bool isValidateTag(char* input) { if (!input) return false; for (size_t i = 0; i < strlen(input); ++i) { - #ifdef WINDOWS +#ifdef WINDOWS if (input[i] < 0x20 || input[i] > 0x7E) return false; - #else +#else if (isprint(input[i]) == 0) return false; - #endif +#endif } return true; } -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, SMsgBuf* pMsgBuf) { +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf) { int32_t retCode = TSDB_CODE_SUCCESS; cJSON* root = NULL; SHashObj* keyHash = NULL; @@ -381,7 +384,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, SMs char* jsonKey = item->string; if (!isValidateTag(jsonKey)) { - fprintf(stdout,"%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__,__func__,taosGetSelfPthreadId());fflush(stdout); + fprintf(stdout, "%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__, __func__, taosGetSelfPthreadId()); + fflush(stdout); retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey); goto end; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 5eb9c72267..e4317d97b0 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 374 +#define YYNOCODE 375 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SNodeList* yy24; - SDataType yy48; - bool yy97; - SAlterOption yy189; - int32_t yy244; - EFillMode yy250; - EJoinType yy596; - EOrder yy598; - int8_t yy619; - SNode* yy652; - ENullOrder yy653; - SToken yy657; - EOperatorType yy700; - int64_t yy701; + SDataType yy34; + EJoinType yy162; + EOrder yy188; + SNode* yy212; + SAlterOption yy245; + EOperatorType yy290; + EFillMode yy294; + SToken yy329; + SNodeList* yy424; + ENullOrder yy607; + int64_t yy609; + int32_t yy610; + int8_t yy653; + bool yy737; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -141,15 +141,15 @@ typedef union { #define YYFALLBACK 1 #define YYNSTATE 653 #define YYNRULE 483 -#define YYNTOKEN 250 +#define YYNTOKEN 252 #define YY_MAX_SHIFT 652 -#define YY_MIN_SHIFTREDUCE 953 -#define YY_MAX_SHIFTREDUCE 1435 -#define YY_ERROR_ACTION 1436 -#define YY_ACCEPT_ACTION 1437 -#define YY_NO_ACTION 1438 -#define YY_MIN_REDUCE 1439 -#define YY_MAX_REDUCE 1921 +#define YY_MIN_SHIFTREDUCE 954 +#define YY_MAX_SHIFTREDUCE 1436 +#define YY_ERROR_ACTION 1437 +#define YY_ACCEPT_ACTION 1438 +#define YY_NO_ACTION 1439 +#define YY_MIN_REDUCE 1440 +#define YY_MAX_REDUCE 1922 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,679 +216,677 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2489) +#define YY_ACTTAB_COUNT (2471) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 567, 422, 1437, 423, 1474, 1742, 1673, 430, 317, 423, - /* 10 */ 1474, 111, 39, 37, 1504, 140, 1739, 1451, 460, 69, - /* 20 */ 326, 1440, 1236, 1742, 488, 151, 334, 526, 1573, 1564, - /* 30 */ 1261, 566, 115, 1311, 1739, 1234, 1847, 486, 1612, 484, - /* 40 */ 1739, 1568, 101, 1735, 1741, 100, 99, 98, 97, 96, - /* 50 */ 95, 94, 93, 92, 570, 119, 1306, 1625, 1755, 14, - /* 60 */ 1844, 1735, 1741, 343, 331, 1242, 373, 1735, 1741, 39, - /* 70 */ 37, 1372, 570, 1623, 566, 474, 473, 326, 570, 1236, - /* 80 */ 472, 1847, 1, 116, 469, 553, 1773, 468, 467, 466, - /* 90 */ 1311, 1625, 1234, 329, 529, 117, 1670, 567, 337, 1725, - /* 100 */ 1462, 549, 504, 1899, 649, 1843, 1899, 1623, 111, 528, - /* 110 */ 153, 1840, 1841, 1306, 1845, 465, 14, 156, 1313, 1314, - /* 120 */ 156, 1896, 1242, 1439, 1896, 1573, 1480, 1786, 1135, 1136, - /* 130 */ 88, 1756, 552, 1758, 1759, 548, 42, 570, 78, 2, - /* 140 */ 1832, 1725, 1899, 209, 319, 1828, 152, 110, 109, 108, - /* 150 */ 107, 106, 105, 104, 103, 102, 156, 439, 232, 1566, - /* 160 */ 1896, 649, 1501, 1237, 141, 1235, 505, 1860, 1530, 60, - /* 170 */ 520, 73, 474, 473, 644, 1313, 1314, 472, 1743, 338, - /* 180 */ 116, 469, 1618, 1620, 468, 467, 466, 1240, 1241, 1739, - /* 190 */ 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, 1304, - /* 200 */ 1305, 1307, 1308, 1309, 1310, 1312, 1315, 33, 32, 245, - /* 210 */ 246, 40, 38, 36, 35, 34, 1735, 1741, 421, 159, - /* 220 */ 1237, 425, 1235, 626, 625, 624, 341, 570, 623, 622, - /* 230 */ 621, 121, 616, 615, 614, 613, 612, 611, 610, 609, - /* 240 */ 131, 605, 1262, 986, 1240, 1241, 61, 1289, 1290, 1292, - /* 250 */ 1293, 1294, 1295, 1296, 545, 568, 1304, 1305, 1307, 1308, - /* 260 */ 1309, 1310, 1312, 1315, 39, 37, 566, 1236, 60, 490, - /* 270 */ 304, 1396, 326, 159, 1236, 40, 38, 36, 35, 34, - /* 280 */ 1234, 1261, 1406, 990, 991, 1311, 84, 1234, 1093, 593, - /* 290 */ 592, 591, 1097, 590, 1099, 1100, 589, 1102, 586, 120, - /* 300 */ 1108, 583, 1110, 1111, 580, 577, 159, 1565, 1306, 1899, - /* 310 */ 1242, 14, 512, 1394, 1395, 1397, 1398, 1242, 602, 1551, - /* 320 */ 379, 39, 37, 156, 60, 1755, 604, 1896, 43, 326, - /* 330 */ 1003, 1236, 1002, 1260, 2, 330, 60, 129, 128, 599, - /* 340 */ 598, 597, 1311, 138, 1234, 458, 336, 1259, 372, 649, - /* 350 */ 371, 526, 1575, 1773, 138, 1899, 649, 296, 1549, 339, - /* 360 */ 1004, 550, 244, 1575, 1899, 1306, 1725, 138, 549, 1898, - /* 370 */ 1313, 1314, 231, 1896, 1242, 1899, 1575, 439, 157, 119, - /* 380 */ 33, 32, 1896, 530, 40, 38, 36, 35, 34, 1897, - /* 390 */ 1379, 8, 567, 1896, 1786, 1663, 1260, 87, 1756, 552, - /* 400 */ 1758, 1759, 548, 161, 570, 159, 168, 1832, 1237, 364, - /* 410 */ 1235, 298, 1828, 649, 1773, 1237, 604, 1235, 515, 117, - /* 420 */ 1573, 83, 519, 1899, 1218, 1219, 1242, 1313, 1314, 366, - /* 430 */ 362, 80, 1240, 1241, 154, 1840, 1841, 158, 1845, 1240, - /* 440 */ 1241, 1896, 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, - /* 450 */ 568, 1304, 1305, 1307, 1308, 1309, 1310, 1312, 1315, 101, - /* 460 */ 518, 159, 100, 99, 98, 97, 96, 95, 94, 93, - /* 470 */ 92, 427, 1237, 159, 1235, 33, 32, 1258, 26, 40, - /* 480 */ 38, 36, 35, 34, 33, 32, 412, 1321, 40, 38, - /* 490 */ 36, 35, 34, 1260, 521, 516, 1240, 1241, 596, 1289, - /* 500 */ 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, 1304, 1305, - /* 510 */ 1307, 1308, 1309, 1310, 1312, 1315, 39, 37, 1316, 567, - /* 520 */ 202, 30, 240, 567, 326, 607, 1236, 1432, 159, 1461, - /* 530 */ 377, 1460, 170, 169, 378, 1745, 1003, 1311, 1002, 1234, - /* 540 */ 497, 1459, 28, 36, 35, 34, 7, 1573, 33, 32, - /* 550 */ 1386, 1573, 40, 38, 36, 35, 34, 33, 32, 1755, - /* 560 */ 1306, 40, 38, 36, 35, 34, 1004, 1291, 1458, 1242, - /* 570 */ 1725, 1747, 1725, 39, 37, 1755, 1619, 1620, 479, 71, - /* 580 */ 304, 326, 1725, 1236, 33, 32, 9, 1773, 40, 38, - /* 590 */ 36, 35, 34, 489, 1311, 550, 1234, 138, 69, 567, - /* 600 */ 1725, 567, 549, 1773, 11, 10, 1576, 201, 649, 1725, - /* 610 */ 382, 529, 397, 1431, 166, 1457, 1725, 1306, 549, 22, - /* 620 */ 1569, 482, 1313, 1314, 1550, 476, 1242, 1573, 1786, 1573, - /* 630 */ 200, 89, 1756, 552, 1758, 1759, 548, 429, 570, 67, - /* 640 */ 425, 1832, 66, 9, 1786, 1831, 1828, 88, 1756, 552, - /* 650 */ 1758, 1759, 548, 1055, 570, 55, 1725, 1832, 54, 526, - /* 660 */ 1562, 319, 1828, 152, 1291, 649, 1335, 1237, 1558, 1235, - /* 670 */ 33, 32, 1456, 1455, 40, 38, 36, 35, 34, 1313, - /* 680 */ 1314, 1548, 600, 1057, 1861, 1616, 1347, 119, 1454, 1340, - /* 690 */ 1453, 1240, 1241, 1450, 1289, 1290, 1292, 1293, 1294, 1295, - /* 700 */ 1296, 545, 568, 1304, 1305, 1307, 1308, 1309, 1310, 1312, - /* 710 */ 1315, 471, 470, 1725, 1725, 33, 32, 1371, 602, 40, - /* 720 */ 38, 36, 35, 34, 1237, 1367, 1235, 117, 27, 1725, - /* 730 */ 1449, 1725, 1448, 1447, 1725, 310, 1446, 129, 128, 599, - /* 740 */ 598, 597, 155, 1840, 1841, 1274, 1845, 1669, 1240, 1241, - /* 750 */ 305, 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, - /* 760 */ 1304, 1305, 1307, 1308, 1309, 1310, 1312, 1315, 39, 37, - /* 770 */ 295, 1725, 1258, 1725, 1725, 602, 326, 1725, 1236, 405, - /* 780 */ 464, 1847, 417, 311, 1445, 309, 308, 1668, 462, 1311, - /* 790 */ 305, 1234, 464, 1263, 129, 128, 599, 598, 597, 390, - /* 800 */ 58, 418, 463, 392, 567, 1842, 620, 618, 553, 567, - /* 810 */ 1260, 567, 1306, 567, 463, 398, 567, 1444, 567, 1671, - /* 820 */ 438, 1242, 1570, 1713, 1702, 1725, 1443, 498, 1755, 502, - /* 830 */ 534, 567, 1573, 383, 1625, 990, 991, 1573, 2, 1573, - /* 840 */ 267, 1573, 564, 1603, 1573, 537, 1573, 33, 32, 1560, - /* 850 */ 1624, 40, 38, 36, 35, 34, 1773, 137, 1725, 1573, - /* 860 */ 649, 608, 601, 1545, 550, 1616, 1556, 1725, 1442, 1725, - /* 870 */ 352, 549, 1491, 416, 1313, 1314, 411, 410, 409, 408, - /* 880 */ 407, 404, 403, 402, 401, 400, 396, 395, 394, 393, - /* 890 */ 387, 386, 385, 384, 475, 381, 380, 1786, 299, 1245, - /* 900 */ 88, 1756, 552, 1758, 1759, 548, 567, 570, 208, 1725, - /* 910 */ 1832, 1852, 1367, 1486, 319, 1828, 1912, 565, 188, 1237, - /* 920 */ 205, 1235, 1274, 212, 544, 1867, 193, 619, 195, 191, - /* 930 */ 1333, 194, 144, 1370, 1573, 477, 72, 456, 452, 448, - /* 940 */ 444, 187, 197, 1240, 1241, 196, 1289, 1290, 1292, 1293, - /* 950 */ 1294, 1295, 1296, 545, 568, 1304, 1305, 1307, 1308, 1309, - /* 960 */ 1310, 1312, 1315, 139, 567, 567, 70, 367, 273, 185, - /* 970 */ 52, 501, 595, 50, 199, 256, 340, 198, 1484, 542, - /* 980 */ 216, 1291, 271, 57, 1334, 1452, 56, 1531, 11, 10, - /* 990 */ 513, 235, 1573, 1573, 1434, 1435, 41, 41, 457, 41, - /* 1000 */ 480, 242, 171, 123, 126, 127, 491, 1339, 223, 1244, - /* 1010 */ 1027, 33, 32, 1393, 1774, 40, 38, 36, 35, 34, - /* 1020 */ 218, 342, 1475, 50, 575, 535, 126, 60, 127, 1248, - /* 1030 */ 526, 184, 177, 532, 182, 1613, 1341, 1297, 435, 1186, - /* 1040 */ 1028, 247, 538, 559, 253, 1086, 29, 324, 1328, 1329, - /* 1050 */ 1330, 1331, 1332, 1336, 1337, 1338, 112, 175, 119, 126, - /* 1060 */ 527, 1863, 299, 266, 1114, 86, 1118, 234, 1125, 5, - /* 1070 */ 3, 237, 239, 344, 1258, 347, 351, 306, 1055, 307, - /* 1080 */ 530, 263, 1202, 399, 167, 1665, 406, 414, 413, 419, - /* 1090 */ 1264, 415, 420, 428, 1333, 1267, 1123, 431, 117, 130, - /* 1100 */ 64, 63, 376, 432, 1266, 165, 174, 1325, 1755, 176, - /* 1110 */ 433, 370, 1268, 229, 1840, 525, 434, 524, 179, 436, - /* 1120 */ 1899, 1265, 294, 181, 183, 360, 68, 358, 354, 350, - /* 1130 */ 162, 345, 437, 186, 158, 440, 1773, 459, 1896, 1247, - /* 1140 */ 1707, 461, 91, 1563, 550, 297, 190, 1559, 1334, 1725, - /* 1150 */ 192, 549, 132, 264, 133, 203, 1561, 492, 1557, 134, - /* 1160 */ 135, 1755, 206, 493, 159, 499, 530, 503, 210, 1263, - /* 1170 */ 514, 1339, 1874, 316, 1864, 556, 496, 1786, 1873, 6, - /* 1180 */ 87, 1756, 552, 1758, 1759, 548, 1854, 570, 509, 1773, - /* 1190 */ 1832, 214, 511, 523, 298, 1828, 217, 550, 510, 508, - /* 1200 */ 146, 318, 1725, 1755, 549, 517, 1899, 224, 222, 225, - /* 1210 */ 29, 324, 1328, 1329, 1330, 1331, 1332, 1336, 1337, 1338, - /* 1220 */ 156, 507, 227, 1367, 1896, 118, 1262, 44, 539, 536, - /* 1230 */ 1786, 1773, 1848, 88, 1756, 552, 1758, 1759, 548, 550, - /* 1240 */ 570, 226, 228, 1832, 1725, 18, 549, 319, 1828, 1912, - /* 1250 */ 333, 332, 320, 1813, 560, 561, 1915, 1895, 1890, 249, - /* 1260 */ 1250, 533, 233, 236, 124, 540, 554, 555, 238, 125, - /* 1270 */ 1706, 1311, 1786, 1243, 251, 88, 1756, 552, 1758, 1759, - /* 1280 */ 548, 1755, 570, 265, 1675, 1832, 562, 557, 328, 319, - /* 1290 */ 1828, 1912, 79, 77, 1306, 1617, 1574, 573, 1546, 268, - /* 1300 */ 1851, 645, 646, 1242, 259, 648, 145, 289, 1755, 1773, - /* 1310 */ 51, 291, 290, 270, 272, 1719, 1718, 550, 62, 1717, - /* 1320 */ 1714, 346, 1725, 348, 549, 349, 1229, 1230, 163, 353, - /* 1330 */ 1712, 355, 356, 357, 1711, 359, 1773, 1710, 361, 530, - /* 1340 */ 1709, 1708, 571, 363, 550, 365, 1692, 368, 164, 1725, - /* 1350 */ 1786, 549, 1205, 280, 1756, 552, 1758, 1759, 548, 369, - /* 1360 */ 570, 1204, 1686, 1685, 374, 375, 530, 1684, 1683, 1174, - /* 1370 */ 1658, 1657, 1656, 65, 1655, 1654, 1755, 1786, 1653, 1899, - /* 1380 */ 280, 1756, 552, 1758, 1759, 548, 1652, 570, 1651, 388, - /* 1390 */ 389, 1650, 391, 158, 1649, 1648, 1647, 1896, 1646, 1645, - /* 1400 */ 1644, 1251, 1643, 1246, 1773, 1176, 1899, 1642, 1641, 1640, - /* 1410 */ 1639, 1638, 550, 1637, 1636, 122, 1635, 1725, 1755, 549, - /* 1420 */ 156, 1634, 1633, 1632, 1896, 1254, 1631, 1630, 1629, 1628, - /* 1430 */ 1627, 1626, 1503, 1471, 172, 424, 568, 1304, 1305, 1307, - /* 1440 */ 1308, 1309, 1310, 1755, 150, 1786, 1773, 1021, 89, 1756, - /* 1450 */ 552, 1758, 1759, 548, 547, 570, 113, 993, 1832, 1725, - /* 1460 */ 992, 549, 541, 1828, 426, 1470, 1700, 1694, 1682, 1681, - /* 1470 */ 1667, 1773, 180, 1552, 173, 114, 178, 1502, 1500, 550, - /* 1480 */ 526, 443, 442, 441, 1725, 1498, 549, 1786, 445, 447, - /* 1490 */ 287, 1756, 552, 1758, 1759, 548, 546, 570, 543, 1804, - /* 1500 */ 1755, 446, 1496, 450, 1494, 454, 449, 1483, 119, 453, - /* 1510 */ 1482, 451, 1786, 189, 455, 142, 1756, 552, 1758, 1759, - /* 1520 */ 548, 1467, 570, 1554, 1129, 1128, 1553, 1054, 1773, 49, - /* 1530 */ 530, 1053, 1052, 1051, 617, 1048, 550, 619, 1492, 312, - /* 1540 */ 1047, 1725, 1487, 549, 1046, 1485, 313, 314, 117, 481, - /* 1550 */ 478, 1466, 1465, 483, 485, 1464, 487, 1755, 1699, 90, - /* 1560 */ 531, 1913, 53, 229, 1840, 525, 1212, 524, 1693, 1786, - /* 1570 */ 1899, 494, 89, 1756, 552, 1758, 1759, 548, 1755, 570, - /* 1580 */ 1680, 1678, 1832, 1679, 156, 1773, 207, 1829, 1896, 136, - /* 1590 */ 495, 315, 1677, 550, 1676, 1408, 500, 4, 1725, 41, - /* 1600 */ 549, 45, 15, 215, 23, 47, 1773, 220, 25, 213, - /* 1610 */ 46, 1392, 506, 1385, 550, 143, 16, 219, 24, 1725, - /* 1620 */ 221, 549, 1745, 74, 230, 147, 1786, 1364, 17, 288, - /* 1630 */ 1756, 552, 1758, 1759, 548, 1755, 570, 1420, 13, 1419, - /* 1640 */ 1363, 321, 1425, 1414, 1424, 1423, 322, 1786, 10, 1326, - /* 1650 */ 283, 1756, 552, 1758, 1759, 548, 19, 570, 1755, 1282, - /* 1660 */ 1299, 148, 160, 1773, 31, 551, 1674, 1298, 12, 20, - /* 1670 */ 21, 550, 241, 1390, 1666, 243, 1725, 248, 549, 75, - /* 1680 */ 558, 250, 76, 252, 1744, 255, 1773, 1789, 80, 522, - /* 1690 */ 1301, 1252, 572, 574, 550, 1115, 569, 335, 578, 1725, - /* 1700 */ 1755, 549, 48, 576, 1786, 1112, 579, 142, 1756, 552, - /* 1710 */ 1758, 1759, 548, 323, 570, 1109, 1755, 581, 582, 584, - /* 1720 */ 587, 1092, 594, 1103, 1101, 585, 588, 1786, 1773, 1107, - /* 1730 */ 288, 1756, 552, 1758, 1759, 548, 547, 570, 81, 1106, - /* 1740 */ 1105, 1725, 82, 549, 1773, 1124, 59, 257, 1120, 1019, - /* 1750 */ 603, 1104, 550, 1914, 1043, 606, 258, 1725, 1061, 549, - /* 1760 */ 1041, 1036, 1040, 1039, 1038, 1037, 1755, 1035, 1034, 1786, - /* 1770 */ 1058, 325, 287, 1756, 552, 1758, 1759, 548, 1056, 570, - /* 1780 */ 1031, 1805, 1030, 1029, 1026, 1786, 1025, 1024, 288, 1756, - /* 1790 */ 552, 1758, 1759, 548, 1773, 570, 652, 1499, 627, 629, - /* 1800 */ 628, 1497, 550, 631, 632, 633, 1495, 1725, 635, 549, - /* 1810 */ 262, 636, 1493, 637, 639, 641, 640, 1481, 643, 983, - /* 1820 */ 1463, 327, 261, 1755, 149, 647, 1438, 1238, 650, 642, - /* 1830 */ 638, 634, 630, 260, 1438, 1786, 269, 1438, 288, 1756, - /* 1840 */ 552, 1758, 1759, 548, 651, 570, 1438, 1438, 1438, 1438, - /* 1850 */ 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, 85, 550, - /* 1860 */ 1438, 254, 1438, 1438, 1725, 1438, 549, 1438, 1438, 1438, - /* 1870 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, - /* 1880 */ 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, 1438, - /* 1890 */ 1438, 1438, 1786, 1438, 563, 274, 1756, 552, 1758, 1759, - /* 1900 */ 548, 1755, 570, 1438, 1438, 1438, 1438, 1438, 1438, 1438, - /* 1910 */ 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, 1438, - /* 1920 */ 550, 1438, 1438, 1438, 1438, 1725, 211, 549, 1438, 1773, - /* 1930 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, - /* 1940 */ 1438, 1438, 1725, 1755, 549, 1438, 1438, 1210, 1438, 204, - /* 1950 */ 1438, 1438, 1438, 1786, 1755, 1438, 275, 1756, 552, 1758, - /* 1960 */ 1759, 548, 1438, 570, 1438, 1755, 1438, 1438, 1438, 1438, - /* 1970 */ 1786, 1773, 1438, 276, 1756, 552, 1758, 1759, 548, 550, - /* 1980 */ 570, 1438, 1773, 1438, 1725, 1438, 549, 1438, 1438, 1438, - /* 1990 */ 550, 1438, 1438, 1773, 1438, 1725, 1438, 549, 1438, 1438, - /* 2000 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1755, 549, 1438, - /* 2010 */ 1438, 1438, 1786, 1438, 1438, 282, 1756, 552, 1758, 1759, - /* 2020 */ 548, 1438, 570, 1786, 1438, 1755, 284, 1756, 552, 1758, - /* 2030 */ 1759, 548, 1438, 570, 1786, 1773, 1438, 277, 1756, 552, - /* 2040 */ 1758, 1759, 548, 550, 570, 1438, 1438, 1438, 1725, 1755, - /* 2050 */ 549, 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, - /* 2060 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, - /* 2070 */ 1438, 1438, 1438, 1438, 1438, 1438, 1786, 1773, 1438, 285, - /* 2080 */ 1756, 552, 1758, 1759, 548, 550, 570, 1438, 1438, 1438, - /* 2090 */ 1725, 1438, 549, 1438, 1786, 1438, 1438, 278, 1756, 552, - /* 2100 */ 1758, 1759, 548, 1438, 570, 1755, 1438, 1438, 1438, 1438, - /* 2110 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1786, 1438, - /* 2120 */ 1438, 286, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, - /* 2130 */ 1438, 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, - /* 2140 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, - /* 2150 */ 1438, 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, - /* 2160 */ 1438, 1438, 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, - /* 2170 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 279, 1756, 552, - /* 2180 */ 1758, 1759, 548, 1773, 570, 1438, 1438, 1438, 1438, 1438, - /* 2190 */ 1438, 550, 1438, 1438, 1773, 1438, 1725, 1438, 549, 1438, - /* 2200 */ 1438, 1438, 550, 1438, 1438, 1438, 1438, 1725, 1755, 549, - /* 2210 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1755, - /* 2220 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 292, 1756, 552, - /* 2230 */ 1758, 1759, 548, 1755, 570, 1786, 1773, 1438, 293, 1756, - /* 2240 */ 552, 1758, 1759, 548, 550, 570, 1438, 1773, 1438, 1725, - /* 2250 */ 1438, 549, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, - /* 2260 */ 1725, 1773, 549, 1438, 1438, 1438, 1438, 1438, 1438, 550, - /* 2270 */ 1438, 1438, 1438, 1438, 1725, 1438, 549, 1786, 1438, 1438, - /* 2280 */ 1767, 1756, 552, 1758, 1759, 548, 1438, 570, 1786, 1755, - /* 2290 */ 1438, 1766, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, - /* 2300 */ 1438, 1438, 1786, 1755, 1438, 1765, 1756, 552, 1758, 1759, - /* 2310 */ 548, 1438, 570, 1438, 1438, 1438, 1438, 1773, 1438, 1438, - /* 2320 */ 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, - /* 2330 */ 1725, 1773, 549, 1438, 1438, 1438, 1438, 1438, 1438, 550, - /* 2340 */ 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, 1438, 1438, - /* 2350 */ 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, 1786, 1438, - /* 2360 */ 1438, 302, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, - /* 2370 */ 1438, 1438, 1786, 1438, 1438, 301, 1756, 552, 1758, 1759, - /* 2380 */ 548, 1773, 570, 1438, 1438, 1438, 1438, 1438, 1438, 550, - /* 2390 */ 1438, 1438, 1438, 1438, 1725, 1755, 549, 1438, 1438, 1438, - /* 2400 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1755, - /* 2410 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, - /* 2420 */ 1438, 1438, 1786, 1773, 1438, 303, 1756, 552, 1758, 1759, - /* 2430 */ 548, 550, 570, 1438, 1438, 1438, 1725, 1773, 549, 1438, - /* 2440 */ 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, - /* 2450 */ 1725, 1438, 549, 1438, 1438, 1438, 1438, 1438, 1438, 1438, - /* 2460 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 300, 1756, 552, - /* 2470 */ 1758, 1759, 548, 1438, 570, 1438, 1438, 1438, 1786, 1438, - /* 2480 */ 1438, 281, 1756, 552, 1758, 1759, 548, 1438, 570, + /* 0 */ 422, 1670, 423, 1475, 294, 1744, 1438, 430, 317, 423, + /* 10 */ 1475, 1563, 39, 37, 1505, 338, 1741, 69, 1619, 1621, + /* 20 */ 326, 1441, 1238, 1744, 1900, 1565, 334, 525, 373, 379, + /* 30 */ 115, 1674, 1775, 1313, 1741, 1236, 1741, 1899, 1552, 1569, + /* 40 */ 518, 1897, 101, 1737, 1743, 100, 99, 98, 97, 96, + /* 50 */ 95, 94, 93, 92, 570, 119, 1308, 987, 1757, 14, + /* 60 */ 61, 1737, 1743, 1737, 1743, 1244, 297, 343, 1900, 39, + /* 70 */ 37, 1376, 570, 439, 570, 474, 473, 326, 517, 1238, + /* 80 */ 472, 157, 1, 116, 469, 1897, 1775, 468, 467, 466, + /* 90 */ 1313, 1004, 1236, 1003, 528, 117, 439, 991, 992, 1727, + /* 100 */ 479, 548, 1380, 310, 649, 566, 458, 1900, 1262, 527, + /* 110 */ 153, 1842, 1843, 1308, 1847, 489, 14, 552, 1315, 1316, + /* 120 */ 157, 1005, 1244, 1550, 1897, 329, 412, 1788, 1671, 202, + /* 130 */ 88, 1758, 551, 1760, 1761, 547, 60, 570, 60, 2, + /* 140 */ 1834, 525, 210, 482, 319, 1830, 152, 476, 30, 240, + /* 150 */ 652, 311, 201, 309, 308, 140, 462, 1452, 156, 421, + /* 160 */ 464, 649, 425, 1239, 262, 1237, 1860, 43, 60, 119, + /* 170 */ 73, 330, 171, 170, 566, 1315, 1316, 55, 149, 138, + /* 180 */ 54, 604, 463, 642, 638, 634, 630, 260, 1576, 1242, + /* 190 */ 1243, 519, 1291, 1292, 1294, 1295, 1296, 1297, 1298, 544, + /* 200 */ 568, 1306, 1307, 1309, 1310, 1311, 1312, 1314, 1317, 117, + /* 210 */ 1263, 1669, 85, 1323, 294, 254, 372, 167, 371, 1262, + /* 220 */ 1239, 160, 1237, 427, 154, 1842, 1843, 1900, 1847, 1260, + /* 230 */ 1745, 33, 32, 504, 1263, 40, 38, 36, 35, 34, + /* 240 */ 158, 1741, 67, 525, 1897, 66, 1242, 1243, 563, 1291, + /* 250 */ 1292, 1294, 1295, 1296, 1297, 1298, 544, 568, 1306, 1307, + /* 260 */ 1309, 1310, 1311, 1312, 1314, 1317, 39, 37, 1737, 1743, + /* 270 */ 488, 119, 490, 1900, 326, 160, 1238, 160, 69, 570, + /* 280 */ 212, 1293, 300, 486, 60, 484, 157, 1313, 101, 1236, + /* 290 */ 1897, 100, 99, 98, 97, 96, 95, 94, 93, 92, + /* 300 */ 1570, 1211, 151, 205, 1900, 552, 1276, 160, 1136, 1137, + /* 310 */ 1308, 117, 1900, 14, 1335, 1613, 1672, 1898, 1262, 1244, + /* 320 */ 602, 1897, 566, 39, 37, 157, 155, 1842, 1843, 1897, + /* 330 */ 1847, 326, 604, 1238, 1502, 1004, 2, 1003, 1261, 129, + /* 340 */ 128, 599, 598, 597, 1313, 78, 1236, 1094, 593, 592, + /* 350 */ 591, 1098, 590, 1100, 1101, 589, 1103, 586, 649, 1109, + /* 360 */ 583, 1111, 1112, 580, 577, 1005, 1567, 1308, 1336, 36, + /* 370 */ 35, 34, 1315, 1316, 1664, 1463, 1244, 40, 38, 36, + /* 380 */ 35, 34, 33, 32, 42, 169, 40, 38, 36, 35, + /* 390 */ 34, 1341, 1293, 8, 541, 626, 625, 624, 341, 596, + /* 400 */ 623, 622, 621, 121, 616, 615, 614, 613, 612, 611, + /* 410 */ 610, 609, 131, 605, 141, 649, 1727, 1239, 1531, 1237, + /* 420 */ 33, 32, 1397, 160, 40, 38, 36, 35, 34, 1315, + /* 430 */ 1316, 1551, 29, 324, 1330, 1331, 1332, 1333, 1334, 1338, + /* 440 */ 1339, 1340, 600, 1242, 1243, 1617, 1291, 1292, 1294, 1295, + /* 450 */ 1296, 1297, 1298, 544, 568, 1306, 1307, 1309, 1310, 1311, + /* 460 */ 1312, 1314, 1317, 511, 1395, 1396, 1398, 1399, 1056, 567, + /* 470 */ 474, 473, 138, 1337, 1239, 472, 1237, 1264, 116, 469, + /* 480 */ 111, 1577, 468, 467, 466, 33, 32, 460, 1244, 40, + /* 490 */ 38, 36, 35, 34, 607, 1407, 1342, 1574, 1058, 1462, + /* 500 */ 1242, 1243, 203, 1291, 1292, 1294, 1295, 1296, 1297, 1298, + /* 510 */ 544, 568, 1306, 1307, 1309, 1310, 1311, 1312, 1314, 1317, + /* 520 */ 39, 37, 1318, 160, 1327, 602, 1620, 1621, 326, 1433, + /* 530 */ 1238, 567, 160, 471, 470, 189, 300, 27, 245, 246, + /* 540 */ 1727, 1313, 162, 1236, 129, 128, 599, 598, 597, 144, + /* 550 */ 1559, 525, 567, 1626, 456, 452, 448, 444, 188, 1574, + /* 560 */ 331, 71, 305, 111, 1308, 556, 1265, 336, 1335, 1624, + /* 570 */ 465, 11, 10, 1244, 339, 138, 497, 39, 37, 119, + /* 580 */ 1574, 1561, 138, 70, 1576, 326, 186, 1238, 33, 32, + /* 590 */ 9, 1576, 40, 38, 36, 35, 34, 84, 1313, 305, + /* 600 */ 1236, 529, 556, 1757, 567, 567, 464, 232, 1626, 1461, + /* 610 */ 120, 1460, 649, 1626, 567, 377, 378, 1432, 1566, 117, + /* 620 */ 337, 1308, 1336, 22, 1625, 382, 1315, 1316, 463, 1624, + /* 630 */ 1244, 1775, 1574, 1574, 230, 1842, 524, 1262, 523, 549, + /* 640 */ 1459, 1900, 1574, 364, 1727, 1341, 548, 9, 185, 178, + /* 650 */ 1727, 183, 1727, 1349, 159, 435, 33, 32, 1897, 514, + /* 660 */ 40, 38, 36, 35, 34, 366, 362, 429, 58, 649, + /* 670 */ 425, 1239, 1788, 1237, 176, 142, 1758, 551, 1760, 1761, + /* 680 */ 547, 1727, 570, 1315, 1316, 1549, 29, 324, 1330, 1331, + /* 690 */ 1332, 1333, 1334, 1338, 1339, 1340, 213, 1242, 1243, 1458, + /* 700 */ 1291, 1292, 1294, 1295, 1296, 1297, 1298, 544, 568, 1306, + /* 710 */ 1307, 1309, 1310, 1311, 1312, 1314, 1317, 1440, 267, 530, + /* 720 */ 1914, 1604, 567, 567, 567, 620, 618, 1557, 1239, 601, + /* 730 */ 1237, 1387, 1617, 397, 398, 438, 206, 520, 515, 1715, + /* 740 */ 1727, 110, 109, 108, 107, 106, 105, 104, 103, 102, + /* 750 */ 1574, 1574, 1574, 525, 1242, 1243, 543, 1291, 1292, 1294, + /* 760 */ 1295, 1296, 1297, 1298, 544, 568, 1306, 1307, 1309, 1310, + /* 770 */ 1311, 1312, 1314, 1317, 39, 37, 296, 1238, 1260, 602, + /* 780 */ 567, 119, 326, 567, 1238, 405, 352, 1457, 417, 1849, + /* 790 */ 1236, 1571, 1849, 595, 1703, 1313, 1373, 1236, 129, 128, + /* 800 */ 599, 598, 597, 529, 1456, 390, 567, 418, 1574, 392, + /* 810 */ 1293, 1574, 244, 1846, 991, 992, 1845, 498, 1308, 1453, + /* 820 */ 1244, 117, 567, 7, 1455, 1849, 1532, 1244, 1727, 1854, + /* 830 */ 1369, 1454, 194, 502, 1574, 192, 230, 1842, 524, 383, + /* 840 */ 523, 26, 235, 1900, 2, 1727, 533, 33, 32, 1844, + /* 850 */ 1574, 40, 38, 36, 35, 34, 157, 28, 512, 649, + /* 860 */ 1897, 44, 4, 33, 32, 1727, 649, 40, 38, 36, + /* 870 */ 35, 34, 1727, 457, 1219, 1220, 1451, 52, 501, 416, + /* 880 */ 1315, 1316, 411, 410, 409, 408, 407, 404, 403, 402, + /* 890 */ 401, 400, 396, 395, 394, 393, 387, 386, 385, 384, + /* 900 */ 1492, 381, 380, 531, 196, 567, 1450, 195, 567, 139, + /* 910 */ 536, 608, 1449, 1546, 273, 491, 564, 1727, 1239, 565, + /* 920 */ 1237, 198, 475, 200, 197, 1239, 199, 1237, 271, 57, + /* 930 */ 11, 10, 56, 1574, 33, 32, 1574, 1448, 40, 38, + /* 940 */ 36, 35, 34, 1757, 1242, 1243, 1447, 1727, 172, 1446, + /* 950 */ 1445, 1242, 1243, 1727, 1291, 1292, 1294, 1295, 1296, 1297, + /* 960 */ 1298, 544, 568, 1306, 1307, 1309, 1310, 1311, 1312, 1314, + /* 970 */ 1317, 1775, 567, 60, 567, 1435, 1436, 209, 1727, 549, + /* 980 */ 1444, 1487, 224, 256, 1727, 340, 548, 1727, 33, 32, + /* 990 */ 1727, 1727, 40, 38, 36, 35, 34, 1443, 1776, 619, + /* 1000 */ 1574, 529, 1574, 477, 1369, 72, 1747, 1247, 1246, 1276, + /* 1010 */ 50, 86, 1788, 217, 1372, 87, 1758, 551, 1760, 1761, + /* 1020 */ 547, 1727, 570, 1485, 1757, 1834, 1476, 33, 32, 299, + /* 1030 */ 1830, 40, 38, 36, 35, 34, 1481, 342, 1727, 367, + /* 1040 */ 1614, 1900, 1749, 534, 1757, 480, 64, 63, 376, 41, + /* 1050 */ 1394, 166, 1775, 219, 159, 41, 83, 370, 1897, 1864, + /* 1060 */ 549, 1028, 229, 526, 41, 1727, 80, 548, 242, 234, + /* 1070 */ 295, 237, 1775, 360, 123, 358, 354, 350, 163, 345, + /* 1080 */ 528, 239, 529, 3, 644, 1727, 5, 548, 126, 1343, + /* 1090 */ 344, 1029, 1260, 1788, 127, 1299, 87, 1758, 551, 1760, + /* 1100 */ 1761, 547, 50, 570, 1187, 347, 1834, 351, 247, 537, + /* 1110 */ 299, 1830, 160, 1788, 559, 306, 88, 1758, 551, 1760, + /* 1120 */ 1761, 547, 1900, 570, 1056, 307, 1834, 1203, 253, 263, + /* 1130 */ 319, 1830, 152, 575, 1087, 157, 1757, 1250, 1249, 1897, + /* 1140 */ 126, 127, 266, 112, 126, 399, 1666, 168, 406, 414, + /* 1150 */ 413, 415, 1861, 419, 1266, 420, 428, 1269, 432, 431, + /* 1160 */ 175, 177, 1268, 433, 1775, 1270, 434, 1267, 180, 137, + /* 1170 */ 436, 182, 549, 1115, 437, 184, 68, 1727, 440, 548, + /* 1180 */ 1119, 1126, 459, 1124, 130, 187, 461, 91, 1564, 191, + /* 1190 */ 1560, 298, 1708, 193, 132, 133, 1562, 1558, 264, 1757, + /* 1200 */ 134, 204, 135, 492, 493, 1788, 207, 316, 88, 1758, + /* 1210 */ 551, 1760, 1761, 547, 496, 570, 499, 503, 1834, 1265, + /* 1220 */ 211, 513, 319, 1830, 1913, 1875, 1757, 1775, 1865, 508, + /* 1230 */ 555, 510, 1874, 1868, 215, 549, 333, 332, 218, 318, + /* 1240 */ 1727, 516, 548, 6, 509, 522, 1252, 1856, 223, 507, + /* 1250 */ 228, 146, 506, 1369, 1775, 225, 118, 1313, 1264, 1245, + /* 1260 */ 320, 538, 549, 1850, 18, 124, 535, 1727, 1788, 548, + /* 1270 */ 125, 88, 1758, 551, 1760, 1761, 547, 226, 570, 227, + /* 1280 */ 1308, 1834, 553, 554, 1707, 319, 1830, 1913, 1815, 1244, + /* 1290 */ 1676, 1896, 557, 328, 561, 1788, 1891, 1757, 88, 1758, + /* 1300 */ 551, 1760, 1761, 547, 1916, 570, 532, 233, 1834, 539, + /* 1310 */ 236, 560, 319, 1830, 1913, 238, 265, 251, 562, 77, + /* 1320 */ 249, 1575, 79, 1853, 268, 1775, 573, 259, 571, 1547, + /* 1330 */ 1618, 645, 646, 549, 648, 145, 270, 272, 1727, 1721, + /* 1340 */ 548, 289, 291, 290, 1720, 62, 1719, 346, 1716, 348, + /* 1350 */ 349, 51, 1231, 1232, 164, 529, 353, 1714, 355, 356, + /* 1360 */ 357, 1713, 1757, 359, 1712, 361, 1788, 1711, 1710, 280, + /* 1370 */ 1758, 551, 1760, 1761, 547, 363, 570, 365, 1693, 165, + /* 1380 */ 368, 369, 1206, 1205, 1687, 1686, 374, 1253, 375, 1248, + /* 1390 */ 1775, 1685, 1684, 1175, 1659, 1900, 1658, 1657, 549, 65, + /* 1400 */ 1656, 1655, 1654, 1727, 1653, 548, 1652, 388, 159, 389, + /* 1410 */ 1651, 1650, 1897, 1256, 391, 1649, 1648, 1647, 1646, 1645, + /* 1420 */ 529, 1644, 1643, 1642, 568, 1306, 1307, 1309, 1310, 1311, + /* 1430 */ 1312, 1788, 1641, 1757, 280, 1758, 551, 1760, 1761, 547, + /* 1440 */ 1640, 570, 1639, 1638, 1637, 122, 1636, 1635, 1634, 1633, + /* 1450 */ 1632, 1631, 1177, 1630, 1629, 1757, 173, 49, 424, 113, + /* 1460 */ 1900, 1775, 1628, 1627, 1504, 1472, 994, 150, 1471, 549, + /* 1470 */ 114, 993, 426, 157, 1727, 174, 548, 1897, 1701, 1695, + /* 1480 */ 1683, 181, 1682, 1775, 179, 1668, 1553, 1022, 1503, 1501, + /* 1490 */ 441, 549, 1499, 1497, 445, 1495, 1727, 1484, 548, 443, + /* 1500 */ 447, 1483, 1788, 1468, 449, 89, 1758, 551, 1760, 1761, + /* 1510 */ 547, 451, 570, 442, 446, 1834, 453, 450, 1757, 1833, + /* 1520 */ 1830, 454, 455, 1555, 1788, 190, 1130, 89, 1758, 551, + /* 1530 */ 1760, 1761, 547, 1129, 570, 1554, 1757, 1834, 1493, 1055, + /* 1540 */ 1054, 540, 1830, 1053, 1052, 617, 1775, 1049, 1048, 619, + /* 1550 */ 1047, 312, 1488, 313, 546, 1486, 478, 481, 314, 1727, + /* 1560 */ 1467, 548, 483, 1466, 1775, 485, 1465, 487, 90, 1700, + /* 1570 */ 1694, 494, 549, 1681, 1213, 53, 136, 1727, 495, 548, + /* 1580 */ 208, 1679, 1680, 1678, 315, 1677, 41, 1788, 15, 1757, + /* 1590 */ 287, 1758, 551, 1760, 1761, 547, 545, 570, 542, 1806, + /* 1600 */ 23, 47, 221, 1409, 216, 1788, 214, 143, 89, 1758, + /* 1610 */ 551, 1760, 1761, 547, 220, 570, 1393, 1775, 1834, 24, + /* 1620 */ 222, 1747, 74, 1831, 1386, 549, 231, 500, 45, 25, + /* 1630 */ 1727, 46, 548, 16, 1366, 147, 1365, 1426, 17, 1415, + /* 1640 */ 1421, 1420, 321, 1757, 505, 10, 1425, 1424, 322, 148, + /* 1650 */ 1301, 19, 1284, 31, 1757, 1300, 1675, 1667, 1788, 12, + /* 1660 */ 1328, 288, 1758, 551, 1760, 1761, 547, 161, 570, 20, + /* 1670 */ 250, 1775, 21, 1746, 241, 550, 1391, 1223, 243, 549, + /* 1680 */ 248, 255, 1775, 13, 1727, 1303, 548, 1254, 574, 80, + /* 1690 */ 549, 75, 558, 252, 572, 1727, 76, 548, 1791, 569, + /* 1700 */ 48, 1093, 1116, 335, 576, 578, 1113, 579, 581, 1110, + /* 1710 */ 582, 1757, 1788, 584, 585, 283, 1758, 551, 1760, 1761, + /* 1720 */ 547, 1104, 570, 1788, 1102, 587, 142, 1758, 551, 1760, + /* 1730 */ 1761, 547, 1757, 570, 588, 1108, 594, 81, 1125, 1775, + /* 1740 */ 1107, 82, 1106, 1105, 59, 257, 1121, 549, 1020, 1044, + /* 1750 */ 1062, 603, 1727, 521, 548, 606, 258, 1042, 1041, 1037, + /* 1760 */ 1775, 1040, 1039, 1038, 1036, 1035, 323, 1057, 546, 1059, + /* 1770 */ 1032, 1915, 1500, 1727, 1757, 548, 1031, 1030, 1027, 1026, + /* 1780 */ 1788, 1025, 627, 288, 1758, 551, 1760, 1761, 547, 629, + /* 1790 */ 570, 1498, 628, 631, 633, 632, 1496, 1757, 635, 636, + /* 1800 */ 637, 1788, 1775, 1494, 287, 1758, 551, 1760, 1761, 547, + /* 1810 */ 549, 570, 639, 1807, 640, 1727, 1482, 548, 641, 643, + /* 1820 */ 984, 1464, 261, 647, 1439, 1775, 1240, 269, 650, 325, + /* 1830 */ 651, 1439, 1439, 549, 1439, 1439, 1439, 1439, 1727, 1439, + /* 1840 */ 548, 1439, 1439, 1788, 1439, 1439, 288, 1758, 551, 1760, + /* 1850 */ 1761, 547, 327, 570, 1757, 1439, 1439, 1439, 1439, 1439, + /* 1860 */ 1439, 1439, 1439, 1439, 1439, 1757, 1788, 1439, 1439, 288, + /* 1870 */ 1758, 551, 1760, 1761, 547, 1439, 570, 1439, 1439, 1757, + /* 1880 */ 1439, 1439, 1775, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 1890 */ 549, 1439, 1439, 1775, 1439, 1727, 1439, 548, 1439, 1439, + /* 1900 */ 1439, 549, 1439, 1439, 1439, 1439, 1727, 1775, 548, 1439, + /* 1910 */ 1439, 1439, 1439, 1439, 1439, 549, 1439, 1439, 1439, 1439, + /* 1920 */ 1727, 1757, 548, 1788, 1439, 1439, 274, 1758, 551, 1760, + /* 1930 */ 1761, 547, 1439, 570, 1788, 1757, 1439, 275, 1758, 551, + /* 1940 */ 1760, 1761, 547, 1439, 570, 1439, 1757, 1439, 1788, 1775, + /* 1950 */ 1439, 276, 1758, 551, 1760, 1761, 547, 549, 570, 1439, + /* 1960 */ 1439, 1439, 1727, 1775, 548, 1439, 1439, 1439, 1439, 1439, + /* 1970 */ 1439, 549, 1439, 1439, 1775, 1439, 1727, 1439, 548, 1439, + /* 1980 */ 1439, 1439, 549, 1439, 1439, 1439, 1439, 1727, 1757, 548, + /* 1990 */ 1788, 1439, 1439, 282, 1758, 551, 1760, 1761, 547, 1439, + /* 2000 */ 570, 1439, 1439, 1439, 1788, 1439, 1439, 284, 1758, 551, + /* 2010 */ 1760, 1761, 547, 1439, 570, 1788, 1775, 1439, 277, 1758, + /* 2020 */ 551, 1760, 1761, 547, 549, 570, 1439, 1439, 1439, 1727, + /* 2030 */ 1757, 548, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2040 */ 1439, 1757, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2050 */ 1439, 1439, 1439, 1757, 1439, 1439, 1439, 1788, 1775, 1439, + /* 2060 */ 285, 1758, 551, 1760, 1761, 547, 549, 570, 1439, 1775, + /* 2070 */ 1439, 1727, 1439, 548, 1439, 1439, 1439, 549, 1439, 1439, + /* 2080 */ 1439, 1775, 1727, 1439, 548, 1439, 1439, 1439, 1439, 549, + /* 2090 */ 1439, 1439, 1439, 1439, 1727, 1439, 548, 1439, 1439, 1788, + /* 2100 */ 1439, 1439, 278, 1758, 551, 1760, 1761, 547, 1757, 570, + /* 2110 */ 1788, 1439, 1439, 286, 1758, 551, 1760, 1761, 547, 1439, + /* 2120 */ 570, 1439, 1788, 1439, 1439, 279, 1758, 551, 1760, 1761, + /* 2130 */ 547, 1439, 570, 1439, 1439, 1757, 1775, 1439, 1439, 1439, + /* 2140 */ 1439, 1439, 1439, 1439, 549, 1439, 1439, 1439, 1439, 1727, + /* 2150 */ 1439, 548, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2160 */ 1439, 1439, 1757, 1775, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2170 */ 1439, 549, 1439, 1439, 1439, 1439, 1727, 1788, 548, 1439, + /* 2180 */ 292, 1758, 551, 1760, 1761, 547, 1439, 570, 1439, 1757, + /* 2190 */ 1775, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 549, 1439, + /* 2200 */ 1439, 1439, 1439, 1727, 1788, 548, 1439, 293, 1758, 551, + /* 2210 */ 1760, 1761, 547, 1439, 570, 1439, 1439, 1775, 1439, 1439, + /* 2220 */ 1439, 1439, 1439, 1439, 1439, 549, 1439, 1439, 1439, 1439, + /* 2230 */ 1727, 1788, 548, 1439, 1769, 1758, 551, 1760, 1761, 547, + /* 2240 */ 1439, 570, 1439, 1757, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2250 */ 1439, 1439, 1757, 1439, 1439, 1439, 1439, 1439, 1788, 1439, + /* 2260 */ 1439, 1768, 1758, 551, 1760, 1761, 547, 1439, 570, 1439, + /* 2270 */ 1757, 1775, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 549, + /* 2280 */ 1775, 1439, 1439, 1439, 1727, 1439, 548, 1439, 549, 1439, + /* 2290 */ 1439, 1439, 1439, 1727, 1439, 548, 1439, 1439, 1775, 1439, + /* 2300 */ 1439, 1439, 1439, 1439, 1439, 1439, 549, 1439, 1439, 1439, + /* 2310 */ 1439, 1727, 1788, 548, 1439, 1767, 1758, 551, 1760, 1761, + /* 2320 */ 547, 1788, 570, 1757, 303, 1758, 551, 1760, 1761, 547, + /* 2330 */ 1439, 570, 1439, 1439, 1439, 1439, 1439, 1757, 1439, 1788, + /* 2340 */ 1439, 1439, 302, 1758, 551, 1760, 1761, 547, 1439, 570, + /* 2350 */ 1439, 1775, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 549, + /* 2360 */ 1439, 1439, 1439, 1439, 1727, 1775, 548, 1439, 1439, 1439, + /* 2370 */ 1439, 1439, 1439, 549, 1439, 1439, 1439, 1439, 1727, 1439, + /* 2380 */ 548, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2390 */ 1439, 1757, 1788, 1439, 1439, 304, 1758, 551, 1760, 1761, + /* 2400 */ 547, 1439, 570, 1439, 1439, 1439, 1788, 1439, 1439, 301, + /* 2410 */ 1758, 551, 1760, 1761, 547, 1439, 570, 1439, 1439, 1775, + /* 2420 */ 1439, 1439, 1439, 1439, 1439, 1439, 1439, 549, 1439, 1439, + /* 2430 */ 1439, 1439, 1727, 1439, 548, 1439, 1439, 1439, 1439, 1439, + /* 2440 */ 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2450 */ 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, 1439, + /* 2460 */ 1788, 1439, 1439, 281, 1758, 551, 1760, 1761, 547, 1439, + /* 2470 */ 570, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 261, 257, 250, 259, 260, 283, 0, 257, 286, 259, - /* 10 */ 260, 272, 12, 13, 0, 252, 294, 254, 279, 265, - /* 20 */ 20, 0, 22, 283, 21, 280, 286, 261, 289, 283, - /* 30 */ 20, 20, 278, 33, 294, 35, 323, 34, 293, 36, - /* 40 */ 294, 287, 21, 321, 322, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 332, 289, 56, 281, 253, 59, - /* 60 */ 347, 321, 322, 311, 288, 65, 311, 321, 322, 12, - /* 70 */ 13, 14, 332, 297, 20, 61, 62, 20, 332, 22, - /* 80 */ 66, 323, 82, 69, 70, 296, 281, 73, 74, 75, - /* 90 */ 33, 281, 35, 304, 289, 329, 307, 261, 288, 294, - /* 100 */ 253, 296, 311, 351, 104, 347, 351, 297, 272, 343, - /* 110 */ 344, 345, 346, 56, 348, 279, 59, 365, 118, 119, - /* 120 */ 365, 369, 65, 0, 369, 289, 0, 322, 118, 119, - /* 130 */ 325, 326, 327, 328, 329, 330, 82, 332, 263, 82, - /* 140 */ 335, 294, 351, 56, 339, 340, 341, 24, 25, 26, - /* 150 */ 27, 28, 29, 30, 31, 32, 365, 58, 353, 284, - /* 160 */ 369, 104, 0, 163, 266, 165, 361, 362, 270, 82, - /* 170 */ 20, 84, 61, 62, 48, 118, 119, 66, 283, 292, - /* 180 */ 69, 70, 295, 296, 73, 74, 75, 187, 188, 294, - /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - /* 200 */ 200, 201, 202, 203, 204, 205, 206, 8, 9, 113, - /* 210 */ 114, 12, 13, 14, 15, 16, 321, 322, 258, 219, - /* 220 */ 163, 261, 165, 61, 62, 63, 64, 332, 66, 67, - /* 230 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - /* 240 */ 78, 79, 20, 4, 187, 188, 4, 190, 191, 192, + /* 0 */ 259, 308, 261, 262, 311, 285, 252, 259, 288, 261, + /* 10 */ 262, 284, 12, 13, 0, 294, 296, 267, 297, 298, + /* 20 */ 20, 0, 22, 285, 353, 285, 288, 263, 313, 263, + /* 30 */ 280, 0, 283, 33, 296, 35, 296, 366, 0, 289, + /* 40 */ 291, 370, 21, 323, 324, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 334, 291, 56, 4, 255, 59, + /* 60 */ 4, 323, 324, 323, 324, 65, 300, 313, 353, 12, + /* 70 */ 13, 14, 334, 58, 334, 61, 62, 20, 329, 22, + /* 80 */ 66, 366, 82, 69, 70, 370, 283, 73, 74, 75, + /* 90 */ 33, 20, 35, 22, 291, 331, 58, 44, 45, 296, + /* 100 */ 4, 298, 14, 37, 104, 20, 35, 353, 20, 345, + /* 110 */ 346, 347, 348, 56, 350, 19, 59, 298, 118, 119, + /* 120 */ 366, 50, 65, 0, 370, 306, 76, 324, 309, 33, + /* 130 */ 327, 328, 329, 330, 331, 332, 82, 334, 82, 82, + /* 140 */ 337, 263, 56, 47, 341, 342, 343, 51, 338, 339, + /* 150 */ 19, 85, 56, 87, 88, 254, 90, 256, 355, 260, + /* 160 */ 94, 104, 263, 163, 33, 165, 363, 82, 82, 291, + /* 170 */ 84, 275, 122, 123, 20, 118, 119, 81, 47, 283, + /* 180 */ 84, 58, 116, 52, 53, 54, 55, 56, 292, 189, + /* 190 */ 190, 20, 192, 193, 194, 195, 196, 197, 198, 199, + /* 200 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 331, + /* 210 */ 20, 308, 81, 14, 311, 84, 162, 56, 164, 20, + /* 220 */ 163, 221, 165, 14, 346, 347, 348, 353, 350, 20, + /* 230 */ 285, 8, 9, 313, 20, 12, 13, 14, 15, 16, + /* 240 */ 366, 296, 81, 263, 370, 84, 189, 190, 117, 192, /* 250 */ 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, - /* 260 */ 203, 204, 205, 206, 12, 13, 20, 22, 82, 311, - /* 270 */ 174, 187, 20, 219, 22, 12, 13, 14, 15, 16, - /* 280 */ 35, 20, 83, 44, 45, 33, 263, 35, 95, 96, - /* 290 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 276, - /* 300 */ 107, 108, 109, 110, 111, 112, 219, 284, 56, 351, - /* 310 */ 65, 59, 228, 229, 230, 231, 232, 65, 94, 0, - /* 320 */ 261, 12, 13, 365, 82, 253, 58, 369, 82, 20, - /* 330 */ 20, 22, 22, 20, 82, 273, 82, 113, 114, 115, - /* 340 */ 116, 117, 33, 281, 35, 35, 273, 20, 162, 104, - /* 350 */ 164, 261, 290, 281, 281, 351, 104, 298, 0, 273, - /* 360 */ 50, 289, 113, 290, 351, 56, 294, 281, 296, 365, - /* 370 */ 118, 119, 150, 369, 65, 351, 290, 58, 365, 289, - /* 380 */ 8, 9, 369, 311, 12, 13, 14, 15, 16, 365, - /* 390 */ 14, 82, 261, 369, 322, 289, 20, 325, 326, 327, - /* 400 */ 328, 329, 330, 272, 332, 219, 300, 335, 163, 158, - /* 410 */ 165, 339, 340, 104, 281, 163, 58, 165, 148, 329, - /* 420 */ 289, 82, 289, 351, 175, 176, 65, 118, 119, 178, - /* 430 */ 179, 92, 187, 188, 344, 345, 346, 365, 348, 187, - /* 440 */ 188, 369, 190, 191, 192, 193, 194, 195, 196, 197, - /* 450 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 21, - /* 460 */ 327, 219, 24, 25, 26, 27, 28, 29, 30, 31, - /* 470 */ 32, 14, 163, 219, 165, 8, 9, 20, 2, 12, - /* 480 */ 13, 14, 15, 16, 8, 9, 76, 14, 12, 13, - /* 490 */ 14, 15, 16, 20, 224, 225, 187, 188, 93, 190, - /* 500 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - /* 510 */ 201, 202, 203, 204, 205, 206, 12, 13, 14, 261, - /* 520 */ 114, 336, 337, 261, 20, 65, 22, 155, 219, 253, - /* 530 */ 272, 253, 122, 123, 272, 46, 20, 33, 22, 35, - /* 540 */ 315, 253, 2, 14, 15, 16, 39, 289, 8, 9, - /* 550 */ 83, 289, 12, 13, 14, 15, 16, 8, 9, 253, - /* 560 */ 56, 12, 13, 14, 15, 16, 50, 191, 253, 65, - /* 570 */ 294, 82, 294, 12, 13, 253, 295, 296, 4, 173, - /* 580 */ 174, 20, 294, 22, 8, 9, 82, 281, 12, 13, - /* 590 */ 14, 15, 16, 19, 33, 289, 35, 281, 265, 261, - /* 600 */ 294, 261, 296, 281, 1, 2, 290, 33, 104, 294, - /* 610 */ 272, 289, 272, 241, 56, 253, 294, 56, 296, 43, - /* 620 */ 287, 47, 118, 119, 0, 51, 65, 289, 322, 289, - /* 630 */ 56, 325, 326, 327, 328, 329, 330, 258, 332, 81, - /* 640 */ 261, 335, 84, 82, 322, 339, 340, 325, 326, 327, - /* 650 */ 328, 329, 330, 35, 332, 81, 294, 335, 84, 261, - /* 660 */ 282, 339, 340, 341, 191, 104, 145, 163, 282, 165, - /* 670 */ 8, 9, 253, 253, 12, 13, 14, 15, 16, 118, - /* 680 */ 119, 0, 291, 65, 362, 294, 83, 289, 253, 168, - /* 690 */ 253, 187, 188, 253, 190, 191, 192, 193, 194, 195, - /* 700 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 710 */ 206, 267, 268, 294, 294, 8, 9, 4, 94, 12, - /* 720 */ 13, 14, 15, 16, 163, 218, 165, 329, 207, 294, - /* 730 */ 253, 294, 253, 253, 294, 37, 253, 113, 114, 115, - /* 740 */ 116, 117, 344, 345, 346, 83, 348, 306, 187, 188, - /* 750 */ 309, 190, 191, 192, 193, 194, 195, 196, 197, 198, - /* 760 */ 199, 200, 201, 202, 203, 204, 205, 206, 12, 13, - /* 770 */ 18, 294, 20, 294, 294, 94, 20, 294, 22, 27, - /* 780 */ 94, 323, 30, 85, 253, 87, 88, 306, 90, 33, - /* 790 */ 309, 35, 94, 20, 113, 114, 115, 116, 117, 47, - /* 800 */ 3, 49, 116, 51, 261, 347, 267, 268, 296, 261, - /* 810 */ 20, 261, 56, 261, 116, 272, 261, 253, 261, 307, - /* 820 */ 272, 65, 272, 0, 272, 294, 253, 272, 253, 272, - /* 830 */ 43, 261, 289, 81, 281, 44, 45, 289, 82, 289, - /* 840 */ 274, 289, 272, 277, 289, 43, 289, 8, 9, 282, - /* 850 */ 297, 12, 13, 14, 15, 16, 281, 150, 294, 289, - /* 860 */ 104, 269, 291, 271, 289, 294, 282, 294, 253, 294, - /* 870 */ 47, 296, 0, 121, 118, 119, 124, 125, 126, 127, - /* 880 */ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - /* 890 */ 138, 139, 140, 141, 22, 143, 144, 322, 59, 35, - /* 900 */ 325, 326, 327, 328, 329, 330, 261, 332, 56, 294, - /* 910 */ 335, 217, 218, 0, 339, 340, 341, 272, 33, 163, - /* 920 */ 282, 165, 83, 150, 282, 350, 86, 43, 86, 89, - /* 930 */ 91, 89, 47, 220, 289, 22, 84, 52, 53, 54, - /* 940 */ 55, 56, 86, 187, 188, 89, 190, 191, 192, 193, - /* 950 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, - /* 960 */ 204, 205, 206, 18, 261, 261, 81, 83, 23, 84, - /* 970 */ 150, 151, 282, 43, 86, 272, 272, 89, 0, 59, - /* 980 */ 43, 191, 37, 38, 145, 254, 41, 270, 1, 2, - /* 990 */ 363, 372, 289, 289, 118, 119, 43, 43, 262, 43, - /* 1000 */ 22, 43, 57, 43, 43, 43, 318, 168, 358, 35, - /* 1010 */ 35, 8, 9, 83, 281, 12, 13, 14, 15, 16, - /* 1020 */ 83, 262, 260, 43, 43, 238, 43, 82, 43, 165, - /* 1030 */ 261, 146, 147, 236, 149, 293, 83, 83, 153, 83, - /* 1040 */ 65, 83, 240, 83, 83, 83, 207, 208, 209, 210, - /* 1050 */ 211, 212, 213, 214, 215, 216, 43, 172, 289, 43, - /* 1060 */ 349, 324, 59, 83, 83, 120, 83, 366, 83, 221, - /* 1070 */ 352, 366, 366, 320, 20, 261, 47, 319, 35, 267, - /* 1080 */ 311, 313, 161, 261, 42, 261, 301, 145, 299, 261, - /* 1090 */ 20, 299, 255, 255, 91, 20, 83, 317, 329, 83, - /* 1100 */ 155, 156, 157, 296, 20, 160, 265, 187, 253, 265, - /* 1110 */ 310, 166, 20, 344, 345, 346, 312, 348, 265, 310, - /* 1120 */ 351, 20, 177, 265, 265, 180, 265, 182, 183, 184, - /* 1130 */ 185, 186, 302, 265, 365, 261, 281, 255, 369, 165, - /* 1140 */ 294, 281, 261, 281, 289, 255, 281, 281, 145, 294, - /* 1150 */ 281, 296, 281, 317, 281, 263, 281, 171, 281, 281, - /* 1160 */ 281, 253, 263, 316, 219, 261, 311, 261, 263, 20, - /* 1170 */ 227, 168, 357, 310, 324, 226, 296, 322, 357, 233, - /* 1180 */ 325, 326, 327, 328, 329, 330, 360, 332, 294, 281, - /* 1190 */ 335, 305, 294, 154, 339, 340, 305, 289, 235, 234, - /* 1200 */ 357, 294, 294, 253, 296, 294, 351, 356, 359, 355, - /* 1210 */ 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, - /* 1220 */ 365, 222, 320, 218, 369, 289, 20, 42, 239, 237, - /* 1230 */ 322, 281, 323, 325, 326, 327, 328, 329, 330, 289, - /* 1240 */ 332, 354, 342, 335, 294, 82, 296, 339, 340, 341, - /* 1250 */ 12, 13, 242, 338, 147, 303, 373, 368, 350, 289, - /* 1260 */ 22, 368, 367, 367, 305, 368, 294, 294, 367, 305, - /* 1270 */ 294, 33, 322, 35, 263, 325, 326, 327, 328, 329, - /* 1280 */ 330, 253, 332, 277, 294, 335, 302, 294, 294, 339, - /* 1290 */ 340, 341, 82, 263, 56, 294, 289, 285, 271, 261, - /* 1300 */ 350, 36, 256, 65, 263, 255, 309, 275, 253, 281, - /* 1310 */ 314, 275, 275, 264, 251, 0, 0, 289, 42, 0, - /* 1320 */ 0, 73, 294, 35, 296, 181, 35, 35, 35, 181, - /* 1330 */ 0, 35, 35, 181, 0, 181, 281, 0, 35, 311, - /* 1340 */ 0, 0, 104, 22, 289, 35, 0, 168, 82, 294, - /* 1350 */ 322, 296, 165, 325, 326, 327, 328, 329, 330, 167, - /* 1360 */ 332, 163, 0, 0, 159, 158, 311, 0, 0, 46, - /* 1370 */ 0, 0, 0, 142, 0, 0, 253, 322, 0, 351, - /* 1380 */ 325, 326, 327, 328, 329, 330, 0, 332, 0, 137, - /* 1390 */ 35, 0, 137, 365, 0, 0, 0, 369, 0, 0, - /* 1400 */ 0, 163, 0, 165, 281, 22, 351, 0, 0, 0, - /* 1410 */ 0, 0, 289, 0, 0, 42, 0, 294, 253, 296, - /* 1420 */ 365, 0, 0, 0, 369, 187, 0, 0, 0, 0, - /* 1430 */ 0, 0, 0, 0, 42, 46, 198, 199, 200, 201, - /* 1440 */ 202, 203, 204, 253, 43, 322, 281, 60, 325, 326, - /* 1450 */ 327, 328, 329, 330, 289, 332, 39, 14, 335, 294, - /* 1460 */ 14, 296, 339, 340, 46, 0, 0, 0, 0, 0, - /* 1470 */ 0, 281, 154, 0, 40, 39, 39, 0, 0, 289, - /* 1480 */ 261, 39, 47, 35, 294, 0, 296, 322, 35, 39, - /* 1490 */ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - /* 1500 */ 253, 47, 0, 47, 0, 47, 35, 0, 289, 35, - /* 1510 */ 0, 39, 322, 89, 39, 325, 326, 327, 328, 329, - /* 1520 */ 330, 0, 332, 0, 35, 22, 0, 35, 281, 91, - /* 1530 */ 311, 35, 35, 35, 43, 35, 289, 43, 0, 22, - /* 1540 */ 35, 294, 0, 296, 35, 0, 22, 22, 329, 35, - /* 1550 */ 49, 0, 0, 35, 35, 0, 22, 253, 0, 20, - /* 1560 */ 370, 371, 150, 344, 345, 346, 35, 348, 0, 322, - /* 1570 */ 351, 22, 325, 326, 327, 328, 329, 330, 253, 332, - /* 1580 */ 0, 0, 335, 0, 365, 281, 147, 340, 369, 169, - /* 1590 */ 150, 150, 0, 289, 0, 83, 152, 43, 294, 43, - /* 1600 */ 296, 217, 223, 83, 82, 43, 281, 43, 43, 82, - /* 1610 */ 43, 83, 308, 83, 289, 82, 223, 82, 82, 294, - /* 1620 */ 46, 296, 46, 82, 46, 46, 322, 83, 43, 325, - /* 1630 */ 326, 327, 328, 329, 330, 253, 332, 35, 223, 35, - /* 1640 */ 83, 35, 83, 83, 35, 35, 35, 322, 2, 187, - /* 1650 */ 325, 326, 327, 328, 329, 330, 43, 332, 253, 22, - /* 1660 */ 83, 46, 46, 281, 82, 189, 0, 83, 82, 82, - /* 1670 */ 82, 289, 83, 83, 0, 82, 294, 82, 296, 82, - /* 1680 */ 148, 39, 82, 146, 46, 46, 281, 82, 92, 364, - /* 1690 */ 83, 22, 93, 35, 289, 83, 82, 35, 35, 294, - /* 1700 */ 253, 296, 82, 82, 322, 83, 82, 325, 326, 327, - /* 1710 */ 328, 329, 330, 308, 332, 83, 253, 35, 82, 35, - /* 1720 */ 35, 22, 94, 83, 83, 82, 82, 322, 281, 106, - /* 1730 */ 325, 326, 327, 328, 329, 330, 289, 332, 82, 106, - /* 1740 */ 106, 294, 82, 296, 281, 35, 82, 43, 22, 60, - /* 1750 */ 59, 106, 289, 371, 35, 80, 43, 294, 65, 296, - /* 1760 */ 35, 22, 35, 35, 35, 35, 253, 35, 35, 322, - /* 1770 */ 65, 308, 325, 326, 327, 328, 329, 330, 35, 332, - /* 1780 */ 35, 334, 35, 35, 35, 322, 35, 35, 325, 326, - /* 1790 */ 327, 328, 329, 330, 281, 332, 19, 0, 35, 39, - /* 1800 */ 47, 0, 289, 35, 47, 39, 0, 294, 35, 296, - /* 1810 */ 33, 47, 0, 39, 35, 39, 47, 0, 35, 35, - /* 1820 */ 0, 308, 22, 253, 47, 21, 374, 22, 21, 52, - /* 1830 */ 53, 54, 55, 56, 374, 322, 22, 374, 325, 326, - /* 1840 */ 327, 328, 329, 330, 20, 332, 374, 374, 374, 374, - /* 1850 */ 374, 281, 374, 374, 374, 374, 374, 374, 81, 289, - /* 1860 */ 374, 84, 374, 374, 294, 374, 296, 374, 374, 374, - /* 1870 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, - /* 1880 */ 374, 374, 374, 374, 253, 374, 374, 374, 374, 374, - /* 1890 */ 374, 374, 322, 374, 117, 325, 326, 327, 328, 329, - /* 1900 */ 330, 253, 332, 374, 374, 374, 374, 374, 374, 374, - /* 1910 */ 374, 374, 281, 374, 374, 374, 374, 374, 374, 374, - /* 1920 */ 289, 374, 374, 374, 374, 294, 149, 296, 374, 281, - /* 1930 */ 374, 374, 374, 374, 374, 374, 374, 289, 374, 374, - /* 1940 */ 374, 374, 294, 253, 296, 374, 374, 170, 374, 172, - /* 1950 */ 374, 374, 374, 322, 253, 374, 325, 326, 327, 328, - /* 1960 */ 329, 330, 374, 332, 374, 253, 374, 374, 374, 374, - /* 1970 */ 322, 281, 374, 325, 326, 327, 328, 329, 330, 289, - /* 1980 */ 332, 374, 281, 374, 294, 374, 296, 374, 374, 374, - /* 1990 */ 289, 374, 374, 281, 374, 294, 374, 296, 374, 374, - /* 2000 */ 374, 289, 374, 374, 374, 374, 294, 253, 296, 374, - /* 2010 */ 374, 374, 322, 374, 374, 325, 326, 327, 328, 329, - /* 2020 */ 330, 374, 332, 322, 374, 253, 325, 326, 327, 328, - /* 2030 */ 329, 330, 374, 332, 322, 281, 374, 325, 326, 327, - /* 2040 */ 328, 329, 330, 289, 332, 374, 374, 374, 294, 253, - /* 2050 */ 296, 374, 374, 281, 374, 374, 374, 374, 374, 374, - /* 2060 */ 374, 289, 374, 374, 374, 374, 294, 374, 296, 374, - /* 2070 */ 374, 374, 374, 374, 374, 374, 322, 281, 374, 325, - /* 2080 */ 326, 327, 328, 329, 330, 289, 332, 374, 374, 374, - /* 2090 */ 294, 374, 296, 374, 322, 374, 374, 325, 326, 327, - /* 2100 */ 328, 329, 330, 374, 332, 253, 374, 374, 374, 374, - /* 2110 */ 374, 374, 374, 374, 374, 374, 374, 374, 322, 374, - /* 2120 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, - /* 2130 */ 374, 374, 374, 281, 374, 374, 374, 374, 374, 374, - /* 2140 */ 374, 289, 374, 374, 374, 374, 294, 374, 296, 374, - /* 2150 */ 374, 374, 374, 374, 374, 253, 374, 374, 374, 374, - /* 2160 */ 374, 374, 374, 374, 374, 374, 253, 374, 374, 374, - /* 2170 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, - /* 2180 */ 328, 329, 330, 281, 332, 374, 374, 374, 374, 374, - /* 2190 */ 374, 289, 374, 374, 281, 374, 294, 374, 296, 374, - /* 2200 */ 374, 374, 289, 374, 374, 374, 374, 294, 253, 296, - /* 2210 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 253, - /* 2220 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, - /* 2230 */ 328, 329, 330, 253, 332, 322, 281, 374, 325, 326, - /* 2240 */ 327, 328, 329, 330, 289, 332, 374, 281, 374, 294, - /* 2250 */ 374, 296, 374, 374, 374, 289, 374, 374, 374, 374, - /* 2260 */ 294, 281, 296, 374, 374, 374, 374, 374, 374, 289, - /* 2270 */ 374, 374, 374, 374, 294, 374, 296, 322, 374, 374, - /* 2280 */ 325, 326, 327, 328, 329, 330, 374, 332, 322, 253, - /* 2290 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, - /* 2300 */ 374, 374, 322, 253, 374, 325, 326, 327, 328, 329, - /* 2310 */ 330, 374, 332, 374, 374, 374, 374, 281, 374, 374, - /* 2320 */ 374, 374, 374, 374, 374, 289, 374, 374, 374, 374, - /* 2330 */ 294, 281, 296, 374, 374, 374, 374, 374, 374, 289, - /* 2340 */ 374, 374, 374, 374, 294, 374, 296, 374, 374, 374, - /* 2350 */ 374, 374, 374, 253, 374, 374, 374, 374, 322, 374, - /* 2360 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, - /* 2370 */ 374, 374, 322, 374, 374, 325, 326, 327, 328, 329, - /* 2380 */ 330, 281, 332, 374, 374, 374, 374, 374, 374, 289, - /* 2390 */ 374, 374, 374, 374, 294, 253, 296, 374, 374, 374, - /* 2400 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 253, - /* 2410 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, - /* 2420 */ 374, 374, 322, 281, 374, 325, 326, 327, 328, 329, - /* 2430 */ 330, 289, 332, 374, 374, 374, 294, 281, 296, 374, - /* 2440 */ 374, 374, 374, 374, 374, 289, 374, 374, 374, 374, - /* 2450 */ 294, 374, 296, 374, 374, 374, 374, 374, 374, 374, - /* 2460 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, - /* 2470 */ 328, 329, 330, 374, 332, 374, 374, 374, 322, 374, - /* 2480 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, + /* 260 */ 203, 204, 205, 206, 207, 208, 12, 13, 323, 324, + /* 270 */ 21, 291, 313, 353, 20, 221, 22, 221, 267, 334, + /* 280 */ 149, 193, 59, 34, 82, 36, 366, 33, 21, 35, + /* 290 */ 370, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 300 */ 289, 170, 282, 172, 353, 298, 83, 221, 118, 119, + /* 310 */ 56, 331, 353, 59, 91, 295, 309, 366, 20, 65, + /* 320 */ 94, 370, 20, 12, 13, 366, 346, 347, 348, 370, + /* 330 */ 350, 20, 58, 22, 0, 20, 82, 22, 20, 113, + /* 340 */ 114, 115, 116, 117, 33, 265, 35, 95, 96, 97, + /* 350 */ 98, 99, 100, 101, 102, 103, 104, 105, 104, 107, + /* 360 */ 108, 109, 110, 111, 112, 50, 286, 56, 145, 14, + /* 370 */ 15, 16, 118, 119, 291, 255, 65, 12, 13, 14, + /* 380 */ 15, 16, 8, 9, 82, 302, 12, 13, 14, 15, + /* 390 */ 16, 168, 193, 82, 59, 61, 62, 63, 64, 93, + /* 400 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + /* 410 */ 76, 77, 78, 79, 268, 104, 296, 163, 272, 165, + /* 420 */ 8, 9, 189, 221, 12, 13, 14, 15, 16, 118, + /* 430 */ 119, 0, 209, 210, 211, 212, 213, 214, 215, 216, + /* 440 */ 217, 218, 293, 189, 190, 296, 192, 193, 194, 195, + /* 450 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 460 */ 206, 207, 208, 230, 231, 232, 233, 234, 35, 263, + /* 470 */ 61, 62, 283, 145, 163, 66, 165, 20, 69, 70, + /* 480 */ 274, 292, 73, 74, 75, 8, 9, 281, 65, 12, + /* 490 */ 13, 14, 15, 16, 65, 83, 168, 291, 65, 255, + /* 500 */ 189, 190, 114, 192, 193, 194, 195, 196, 197, 198, + /* 510 */ 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + /* 520 */ 12, 13, 14, 221, 189, 94, 297, 298, 20, 155, + /* 530 */ 22, 263, 221, 269, 270, 33, 59, 209, 113, 114, + /* 540 */ 296, 33, 274, 35, 113, 114, 115, 116, 117, 47, + /* 550 */ 284, 263, 263, 283, 52, 53, 54, 55, 56, 291, + /* 560 */ 290, 173, 174, 274, 56, 177, 20, 275, 91, 299, + /* 570 */ 281, 1, 2, 65, 275, 283, 317, 12, 13, 291, + /* 580 */ 291, 284, 283, 81, 292, 20, 84, 22, 8, 9, + /* 590 */ 82, 292, 12, 13, 14, 15, 16, 265, 33, 174, + /* 600 */ 35, 313, 177, 255, 263, 263, 94, 150, 283, 255, + /* 610 */ 278, 255, 104, 283, 263, 274, 274, 243, 286, 331, + /* 620 */ 290, 56, 145, 43, 299, 274, 118, 119, 116, 299, + /* 630 */ 65, 283, 291, 291, 346, 347, 348, 20, 350, 291, + /* 640 */ 255, 353, 291, 158, 296, 168, 298, 82, 146, 147, + /* 650 */ 296, 149, 296, 83, 366, 153, 8, 9, 370, 148, + /* 660 */ 12, 13, 14, 15, 16, 180, 181, 260, 3, 104, + /* 670 */ 263, 163, 324, 165, 172, 327, 328, 329, 330, 331, + /* 680 */ 332, 296, 334, 118, 119, 0, 209, 210, 211, 212, + /* 690 */ 213, 214, 215, 216, 217, 218, 150, 189, 190, 255, + /* 700 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + /* 710 */ 202, 203, 204, 205, 206, 207, 208, 0, 276, 371, + /* 720 */ 372, 279, 263, 263, 263, 269, 270, 284, 163, 293, + /* 730 */ 165, 83, 296, 274, 274, 274, 284, 226, 227, 0, + /* 740 */ 296, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 750 */ 291, 291, 291, 263, 189, 190, 284, 192, 193, 194, + /* 760 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 770 */ 205, 206, 207, 208, 12, 13, 18, 22, 20, 94, + /* 780 */ 263, 291, 20, 263, 22, 27, 47, 255, 30, 325, + /* 790 */ 35, 274, 325, 284, 274, 33, 4, 35, 113, 114, + /* 800 */ 115, 116, 117, 313, 255, 47, 263, 49, 291, 51, + /* 810 */ 193, 291, 113, 349, 44, 45, 349, 274, 56, 256, + /* 820 */ 65, 331, 263, 39, 255, 325, 272, 65, 296, 219, + /* 830 */ 220, 255, 86, 274, 291, 89, 346, 347, 348, 81, + /* 840 */ 350, 2, 373, 353, 82, 296, 43, 8, 9, 349, + /* 850 */ 291, 12, 13, 14, 15, 16, 366, 2, 364, 104, + /* 860 */ 370, 42, 43, 8, 9, 296, 104, 12, 13, 14, + /* 870 */ 15, 16, 296, 264, 175, 176, 255, 150, 151, 121, + /* 880 */ 118, 119, 124, 125, 126, 127, 128, 129, 130, 131, + /* 890 */ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, + /* 900 */ 0, 143, 144, 238, 86, 263, 255, 89, 263, 18, + /* 910 */ 43, 271, 255, 273, 23, 320, 274, 296, 163, 274, + /* 920 */ 165, 86, 22, 86, 89, 163, 89, 165, 37, 38, + /* 930 */ 1, 2, 41, 291, 8, 9, 291, 255, 12, 13, + /* 940 */ 14, 15, 16, 255, 189, 190, 255, 296, 57, 255, + /* 950 */ 255, 189, 190, 296, 192, 193, 194, 195, 196, 197, + /* 960 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + /* 970 */ 208, 283, 263, 82, 263, 118, 119, 56, 296, 291, + /* 980 */ 255, 0, 360, 274, 296, 274, 298, 296, 8, 9, + /* 990 */ 296, 296, 12, 13, 14, 15, 16, 255, 283, 43, + /* 1000 */ 291, 313, 291, 22, 220, 84, 46, 35, 35, 83, + /* 1010 */ 43, 120, 324, 43, 222, 327, 328, 329, 330, 331, + /* 1020 */ 332, 296, 334, 0, 255, 337, 262, 8, 9, 341, + /* 1030 */ 342, 12, 13, 14, 15, 16, 0, 264, 296, 83, + /* 1040 */ 295, 353, 82, 240, 255, 22, 155, 156, 157, 43, + /* 1050 */ 83, 160, 283, 83, 366, 43, 82, 166, 370, 326, + /* 1060 */ 291, 35, 344, 351, 43, 296, 92, 298, 43, 367, + /* 1070 */ 179, 367, 283, 182, 43, 184, 185, 186, 187, 188, + /* 1080 */ 291, 367, 313, 354, 48, 296, 223, 298, 43, 83, + /* 1090 */ 322, 65, 20, 324, 43, 83, 327, 328, 329, 330, + /* 1100 */ 331, 332, 43, 334, 83, 263, 337, 47, 83, 242, + /* 1110 */ 341, 342, 221, 324, 83, 321, 327, 328, 329, 330, + /* 1120 */ 331, 332, 353, 334, 35, 269, 337, 161, 83, 315, + /* 1130 */ 341, 342, 343, 43, 83, 366, 255, 165, 165, 370, + /* 1140 */ 43, 43, 83, 43, 43, 263, 263, 42, 303, 145, + /* 1150 */ 301, 301, 363, 263, 20, 257, 257, 20, 298, 319, + /* 1160 */ 267, 267, 20, 312, 283, 20, 314, 20, 267, 150, + /* 1170 */ 312, 267, 291, 83, 304, 267, 267, 296, 263, 298, + /* 1180 */ 83, 83, 257, 83, 83, 267, 283, 263, 283, 283, + /* 1190 */ 283, 257, 296, 283, 283, 283, 283, 283, 319, 255, + /* 1200 */ 283, 265, 283, 171, 318, 324, 265, 312, 327, 328, + /* 1210 */ 329, 330, 331, 332, 298, 334, 263, 263, 337, 20, + /* 1220 */ 265, 229, 341, 342, 343, 359, 255, 283, 326, 296, + /* 1230 */ 228, 296, 359, 352, 307, 291, 12, 13, 307, 296, + /* 1240 */ 296, 296, 298, 235, 237, 154, 22, 362, 361, 236, + /* 1250 */ 322, 359, 224, 220, 283, 358, 291, 33, 20, 35, + /* 1260 */ 244, 241, 291, 325, 82, 307, 239, 296, 324, 298, + /* 1270 */ 307, 327, 328, 329, 330, 331, 332, 357, 334, 356, + /* 1280 */ 56, 337, 296, 296, 296, 341, 342, 343, 340, 65, + /* 1290 */ 296, 369, 296, 296, 305, 324, 352, 255, 327, 328, + /* 1300 */ 329, 330, 331, 332, 374, 334, 369, 368, 337, 369, + /* 1310 */ 368, 147, 341, 342, 343, 368, 279, 265, 304, 265, + /* 1320 */ 291, 291, 82, 352, 263, 283, 287, 265, 104, 273, + /* 1330 */ 296, 36, 258, 291, 257, 311, 266, 253, 296, 0, + /* 1340 */ 298, 277, 277, 277, 0, 42, 0, 73, 0, 35, + /* 1350 */ 183, 316, 35, 35, 35, 313, 183, 0, 35, 35, + /* 1360 */ 183, 0, 255, 183, 0, 35, 324, 0, 0, 327, + /* 1370 */ 328, 329, 330, 331, 332, 22, 334, 35, 0, 82, + /* 1380 */ 168, 167, 165, 163, 0, 0, 159, 163, 158, 165, + /* 1390 */ 283, 0, 0, 46, 0, 353, 0, 0, 291, 142, + /* 1400 */ 0, 0, 0, 296, 0, 298, 0, 137, 366, 35, + /* 1410 */ 0, 0, 370, 189, 137, 0, 0, 0, 0, 0, + /* 1420 */ 313, 0, 0, 0, 200, 201, 202, 203, 204, 205, + /* 1430 */ 206, 324, 0, 255, 327, 328, 329, 330, 331, 332, + /* 1440 */ 0, 334, 0, 0, 0, 42, 0, 0, 0, 0, + /* 1450 */ 0, 0, 22, 0, 0, 255, 42, 91, 46, 39, + /* 1460 */ 353, 283, 0, 0, 0, 0, 14, 43, 0, 291, + /* 1470 */ 39, 14, 46, 366, 296, 40, 298, 370, 0, 0, + /* 1480 */ 0, 154, 0, 283, 39, 0, 0, 60, 0, 0, + /* 1490 */ 35, 291, 0, 0, 35, 0, 296, 0, 298, 39, + /* 1500 */ 39, 0, 324, 0, 35, 327, 328, 329, 330, 331, + /* 1510 */ 332, 39, 334, 47, 47, 337, 35, 47, 255, 341, + /* 1520 */ 342, 47, 39, 0, 324, 89, 35, 327, 328, 329, + /* 1530 */ 330, 331, 332, 22, 334, 0, 255, 337, 0, 35, + /* 1540 */ 35, 341, 342, 35, 35, 43, 283, 35, 35, 43, + /* 1550 */ 35, 22, 0, 22, 291, 0, 49, 35, 22, 296, + /* 1560 */ 0, 298, 35, 0, 283, 35, 0, 22, 20, 0, + /* 1570 */ 0, 22, 291, 0, 35, 150, 169, 296, 150, 298, + /* 1580 */ 147, 0, 0, 0, 150, 0, 43, 324, 225, 255, + /* 1590 */ 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, + /* 1600 */ 82, 43, 43, 83, 83, 324, 82, 82, 327, 328, + /* 1610 */ 329, 330, 331, 332, 82, 334, 83, 283, 337, 82, + /* 1620 */ 46, 46, 82, 342, 83, 291, 46, 152, 219, 43, + /* 1630 */ 296, 43, 298, 225, 83, 46, 83, 83, 43, 83, + /* 1640 */ 35, 35, 35, 255, 310, 2, 35, 35, 35, 46, + /* 1650 */ 83, 43, 22, 82, 255, 83, 0, 0, 324, 82, + /* 1660 */ 189, 327, 328, 329, 330, 331, 332, 46, 334, 82, + /* 1670 */ 39, 283, 82, 46, 83, 191, 83, 178, 82, 291, + /* 1680 */ 82, 46, 283, 225, 296, 83, 298, 22, 35, 92, + /* 1690 */ 291, 82, 148, 146, 93, 296, 82, 298, 82, 82, + /* 1700 */ 82, 22, 83, 35, 82, 35, 83, 82, 35, 83, + /* 1710 */ 82, 255, 324, 35, 82, 327, 328, 329, 330, 331, + /* 1720 */ 332, 83, 334, 324, 83, 35, 327, 328, 329, 330, + /* 1730 */ 331, 332, 255, 334, 82, 106, 94, 82, 35, 283, + /* 1740 */ 106, 82, 106, 106, 82, 43, 22, 291, 60, 35, + /* 1750 */ 65, 59, 296, 365, 298, 80, 43, 35, 35, 22, + /* 1760 */ 283, 35, 35, 35, 35, 35, 310, 35, 291, 65, + /* 1770 */ 35, 372, 0, 296, 255, 298, 35, 35, 35, 35, + /* 1780 */ 324, 35, 35, 327, 328, 329, 330, 331, 332, 39, + /* 1790 */ 334, 0, 47, 35, 39, 47, 0, 255, 35, 47, + /* 1800 */ 39, 324, 283, 0, 327, 328, 329, 330, 331, 332, + /* 1810 */ 291, 334, 35, 336, 47, 296, 0, 298, 39, 35, + /* 1820 */ 35, 0, 22, 21, 375, 283, 22, 22, 21, 310, + /* 1830 */ 20, 375, 375, 291, 375, 375, 375, 375, 296, 375, + /* 1840 */ 298, 375, 375, 324, 375, 375, 327, 328, 329, 330, + /* 1850 */ 331, 332, 310, 334, 255, 375, 375, 375, 375, 375, + /* 1860 */ 375, 375, 375, 375, 375, 255, 324, 375, 375, 327, + /* 1870 */ 328, 329, 330, 331, 332, 375, 334, 375, 375, 255, + /* 1880 */ 375, 375, 283, 375, 375, 375, 375, 375, 375, 375, + /* 1890 */ 291, 375, 375, 283, 375, 296, 375, 298, 375, 375, + /* 1900 */ 375, 291, 375, 375, 375, 375, 296, 283, 298, 375, + /* 1910 */ 375, 375, 375, 375, 375, 291, 375, 375, 375, 375, + /* 1920 */ 296, 255, 298, 324, 375, 375, 327, 328, 329, 330, + /* 1930 */ 331, 332, 375, 334, 324, 255, 375, 327, 328, 329, + /* 1940 */ 330, 331, 332, 375, 334, 375, 255, 375, 324, 283, + /* 1950 */ 375, 327, 328, 329, 330, 331, 332, 291, 334, 375, + /* 1960 */ 375, 375, 296, 283, 298, 375, 375, 375, 375, 375, + /* 1970 */ 375, 291, 375, 375, 283, 375, 296, 375, 298, 375, + /* 1980 */ 375, 375, 291, 375, 375, 375, 375, 296, 255, 298, + /* 1990 */ 324, 375, 375, 327, 328, 329, 330, 331, 332, 375, + /* 2000 */ 334, 375, 375, 375, 324, 375, 375, 327, 328, 329, + /* 2010 */ 330, 331, 332, 375, 334, 324, 283, 375, 327, 328, + /* 2020 */ 329, 330, 331, 332, 291, 334, 375, 375, 375, 296, + /* 2030 */ 255, 298, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2040 */ 375, 255, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2050 */ 375, 375, 375, 255, 375, 375, 375, 324, 283, 375, + /* 2060 */ 327, 328, 329, 330, 331, 332, 291, 334, 375, 283, + /* 2070 */ 375, 296, 375, 298, 375, 375, 375, 291, 375, 375, + /* 2080 */ 375, 283, 296, 375, 298, 375, 375, 375, 375, 291, + /* 2090 */ 375, 375, 375, 375, 296, 375, 298, 375, 375, 324, + /* 2100 */ 375, 375, 327, 328, 329, 330, 331, 332, 255, 334, + /* 2110 */ 324, 375, 375, 327, 328, 329, 330, 331, 332, 375, + /* 2120 */ 334, 375, 324, 375, 375, 327, 328, 329, 330, 331, + /* 2130 */ 332, 375, 334, 375, 375, 255, 283, 375, 375, 375, + /* 2140 */ 375, 375, 375, 375, 291, 375, 375, 375, 375, 296, + /* 2150 */ 375, 298, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2160 */ 375, 375, 255, 283, 375, 375, 375, 375, 375, 375, + /* 2170 */ 375, 291, 375, 375, 375, 375, 296, 324, 298, 375, + /* 2180 */ 327, 328, 329, 330, 331, 332, 375, 334, 375, 255, + /* 2190 */ 283, 375, 375, 375, 375, 375, 375, 375, 291, 375, + /* 2200 */ 375, 375, 375, 296, 324, 298, 375, 327, 328, 329, + /* 2210 */ 330, 331, 332, 375, 334, 375, 375, 283, 375, 375, + /* 2220 */ 375, 375, 375, 375, 375, 291, 375, 375, 375, 375, + /* 2230 */ 296, 324, 298, 375, 327, 328, 329, 330, 331, 332, + /* 2240 */ 375, 334, 375, 255, 375, 375, 375, 375, 375, 375, + /* 2250 */ 375, 375, 255, 375, 375, 375, 375, 375, 324, 375, + /* 2260 */ 375, 327, 328, 329, 330, 331, 332, 375, 334, 375, + /* 2270 */ 255, 283, 375, 375, 375, 375, 375, 375, 375, 291, + /* 2280 */ 283, 375, 375, 375, 296, 375, 298, 375, 291, 375, + /* 2290 */ 375, 375, 375, 296, 375, 298, 375, 375, 283, 375, + /* 2300 */ 375, 375, 375, 375, 375, 375, 291, 375, 375, 375, + /* 2310 */ 375, 296, 324, 298, 375, 327, 328, 329, 330, 331, + /* 2320 */ 332, 324, 334, 255, 327, 328, 329, 330, 331, 332, + /* 2330 */ 375, 334, 375, 375, 375, 375, 375, 255, 375, 324, + /* 2340 */ 375, 375, 327, 328, 329, 330, 331, 332, 375, 334, + /* 2350 */ 375, 283, 375, 375, 375, 375, 375, 375, 375, 291, + /* 2360 */ 375, 375, 375, 375, 296, 283, 298, 375, 375, 375, + /* 2370 */ 375, 375, 375, 291, 375, 375, 375, 375, 296, 375, + /* 2380 */ 298, 375, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2390 */ 375, 255, 324, 375, 375, 327, 328, 329, 330, 331, + /* 2400 */ 332, 375, 334, 375, 375, 375, 324, 375, 375, 327, + /* 2410 */ 328, 329, 330, 331, 332, 375, 334, 375, 375, 283, + /* 2420 */ 375, 375, 375, 375, 375, 375, 375, 291, 375, 375, + /* 2430 */ 375, 375, 296, 375, 298, 375, 375, 375, 375, 375, + /* 2440 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2450 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, + /* 2460 */ 324, 375, 375, 327, 328, 329, 330, 331, 332, 375, + /* 2470 */ 334, }; #define YY_SHIFT_COUNT (652) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1824) +#define YY_SHIFT_MAX (1821) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 945, 0, 0, 57, 252, 252, 252, 252, 309, 309, - /* 10 */ 252, 252, 504, 561, 756, 561, 561, 561, 561, 561, - /* 20 */ 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - /* 30 */ 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - /* 40 */ 561, 561, 54, 54, 246, 246, 246, 1238, 1238, 1238, - /* 50 */ 1238, 186, 87, 254, 11, 11, 239, 239, 242, 10, - /* 60 */ 254, 254, 11, 11, 11, 11, 11, 11, 11, 11, - /* 70 */ 99, 11, 11, 11, 150, 261, 313, 11, 11, 313, - /* 80 */ 11, 313, 313, 313, 11, 268, 752, 839, 1003, 1003, - /* 90 */ 438, 111, 245, 245, 245, 245, 245, 245, 245, 245, - /* 100 */ 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, - /* 110 */ 245, 698, 10, 457, 457, 319, 618, 222, 222, 222, - /* 120 */ 358, 618, 327, 261, 6, 6, 313, 313, 361, 361, - /* 130 */ 405, 460, 193, 193, 193, 193, 193, 193, 193, 1777, - /* 140 */ 21, 14, 372, 84, 310, 406, 270, 376, 473, 516, - /* 150 */ 791, 686, 773, 694, 507, 694, 797, 797, 797, 713, - /* 160 */ 790, 848, 1054, 1029, 1043, 921, 1054, 1054, 1042, 942, - /* 170 */ 942, 1054, 1070, 1070, 1075, 99, 261, 99, 1084, 1092, - /* 180 */ 99, 1084, 99, 1101, 99, 99, 1054, 99, 1070, 313, - /* 190 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 200 */ 1054, 1070, 361, 1075, 268, 986, 261, 268, 1054, 1054, - /* 210 */ 1084, 268, 1149, 361, 943, 949, 361, 943, 949, 361, - /* 220 */ 361, 313, 946, 1039, 943, 963, 965, 999, 848, 1005, - /* 230 */ 327, 1206, 1185, 989, 992, 1010, 989, 992, 989, 992, - /* 240 */ 1163, 949, 361, 361, 361, 361, 361, 949, 361, 1107, - /* 250 */ 327, 1101, 268, 405, 268, 327, 1210, 361, 460, 1054, - /* 260 */ 268, 1265, 1070, 2489, 2489, 2489, 2489, 2489, 2489, 2489, - /* 270 */ 162, 885, 123, 574, 199, 576, 467, 476, 540, 707, - /* 280 */ 662, 549, 549, 549, 549, 549, 549, 549, 549, 624, - /* 290 */ 681, 224, 263, 263, 251, 558, 410, 3, 603, 521, - /* 300 */ 529, 529, 529, 529, 249, 96, 823, 884, 840, 842, - /* 310 */ 856, 888, 872, 913, 978, 852, 820, 930, 937, 987, - /* 320 */ 876, 787, 802, 953, 920, 954, 489, 956, 958, 960, - /* 330 */ 961, 962, 864, 974, 980, 981, 983, 985, 1013, 1016, - /* 340 */ 339, 975, 126, 1315, 1316, 1276, 1319, 1248, 1320, 1288, - /* 350 */ 1144, 1291, 1292, 1293, 1148, 1330, 1296, 1297, 1152, 1334, - /* 360 */ 1154, 1337, 1303, 1340, 1321, 1341, 1310, 1346, 1266, 1179, - /* 370 */ 1192, 1187, 1198, 1362, 1363, 1205, 1207, 1367, 1368, 1323, - /* 380 */ 1370, 1371, 1372, 1231, 1374, 1375, 1378, 1386, 1388, 1252, - /* 390 */ 1355, 1391, 1255, 1394, 1395, 1396, 1398, 1399, 1400, 1402, - /* 400 */ 1407, 1408, 1409, 1410, 1411, 1413, 1414, 1373, 1416, 1421, - /* 410 */ 1422, 1423, 1426, 1427, 1383, 1428, 1429, 1430, 1431, 1432, - /* 420 */ 1433, 1392, 1417, 1401, 1443, 1389, 1446, 1418, 1465, 1434, - /* 430 */ 1436, 1466, 1467, 1468, 1437, 1318, 1469, 1470, 1473, 1387, - /* 440 */ 1477, 1478, 1448, 1435, 1442, 1485, 1453, 1454, 1450, 1502, - /* 450 */ 1471, 1456, 1472, 1504, 1474, 1458, 1475, 1507, 1510, 1521, - /* 460 */ 1523, 1438, 1424, 1489, 1503, 1526, 1492, 1496, 1497, 1498, - /* 470 */ 1491, 1494, 1500, 1505, 1509, 1538, 1517, 1542, 1524, 1501, - /* 480 */ 1545, 1525, 1514, 1551, 1518, 1552, 1519, 1555, 1534, 1539, - /* 490 */ 1558, 1412, 1531, 1568, 1420, 1549, 1440, 1439, 1580, 1581, - /* 500 */ 1441, 1444, 1583, 1592, 1594, 1554, 1556, 1379, 1522, 1512, - /* 510 */ 1527, 1520, 1562, 1528, 1533, 1535, 1536, 1530, 1564, 1574, - /* 520 */ 1576, 1541, 1565, 1393, 1544, 1557, 1578, 1384, 1567, 1579, - /* 530 */ 1559, 1585, 1415, 1560, 1602, 1604, 1606, 1609, 1610, 1611, - /* 540 */ 1560, 1646, 1462, 1613, 1577, 1582, 1584, 1615, 1586, 1587, - /* 550 */ 1616, 1637, 1476, 1588, 1589, 1590, 1593, 1666, 1595, 1532, - /* 560 */ 1597, 1674, 1642, 1537, 1600, 1596, 1638, 1639, 1605, 1607, - /* 570 */ 1614, 1669, 1620, 1599, 1612, 1658, 1662, 1621, 1622, 1663, - /* 580 */ 1624, 1632, 1682, 1636, 1640, 1684, 1643, 1641, 1685, 1644, - /* 590 */ 1623, 1633, 1634, 1645, 1699, 1628, 1656, 1660, 1710, 1664, - /* 600 */ 1704, 1704, 1726, 1689, 1691, 1719, 1693, 1675, 1713, 1725, - /* 610 */ 1727, 1728, 1729, 1730, 1739, 1732, 1733, 1705, 1491, 1743, - /* 620 */ 1494, 1745, 1747, 1748, 1749, 1751, 1752, 1797, 1763, 1753, - /* 630 */ 1760, 1801, 1768, 1757, 1766, 1806, 1773, 1764, 1774, 1812, - /* 640 */ 1779, 1769, 1776, 1817, 1783, 1784, 1820, 1800, 1804, 1805, - /* 650 */ 1814, 1807, 1824, + /* 0 */ 891, 0, 0, 57, 57, 254, 254, 254, 311, 311, + /* 10 */ 254, 254, 508, 565, 762, 565, 565, 565, 565, 565, + /* 20 */ 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, + /* 30 */ 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, + /* 40 */ 565, 565, 302, 302, 85, 85, 85, 1224, 1224, 1224, + /* 50 */ 1224, 54, 86, 202, 154, 154, 53, 53, 56, 190, + /* 60 */ 202, 202, 154, 154, 154, 154, 154, 154, 154, 154, + /* 70 */ 15, 154, 154, 154, 171, 214, 298, 154, 154, 298, + /* 80 */ 154, 298, 298, 298, 154, 274, 758, 223, 477, 477, + /* 90 */ 267, 409, 755, 755, 755, 755, 755, 755, 755, 755, + /* 100 */ 755, 755, 755, 755, 755, 755, 755, 755, 755, 755, + /* 110 */ 755, 66, 190, 209, 209, 38, 433, 457, 457, 457, + /* 120 */ 123, 433, 318, 214, 31, 31, 298, 298, 423, 423, + /* 130 */ 306, 429, 252, 252, 252, 252, 252, 252, 252, 131, + /* 140 */ 21, 14, 374, 233, 71, 388, 511, 88, 199, 315, + /* 150 */ 770, 512, 546, 610, 784, 610, 819, 665, 665, 665, + /* 160 */ 792, 617, 863, 1072, 1060, 1089, 966, 1072, 1072, 1105, + /* 170 */ 1004, 1004, 1072, 1134, 1134, 1137, 15, 214, 15, 1142, + /* 180 */ 1145, 15, 1142, 15, 1147, 15, 15, 1072, 15, 1134, + /* 190 */ 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, + /* 200 */ 298, 1072, 1134, 423, 1137, 274, 1032, 214, 274, 1072, + /* 210 */ 1072, 1142, 274, 1199, 423, 992, 1002, 423, 992, 1002, + /* 220 */ 423, 423, 298, 1008, 1091, 992, 1007, 1013, 1028, 863, + /* 230 */ 1033, 318, 1238, 1020, 1027, 1016, 1020, 1027, 1020, 1027, + /* 240 */ 1182, 1002, 423, 423, 423, 423, 423, 1002, 423, 1164, + /* 250 */ 318, 1147, 274, 306, 274, 318, 1240, 423, 429, 1072, + /* 260 */ 274, 1295, 1134, 2471, 2471, 2471, 2471, 2471, 2471, 2471, + /* 270 */ 334, 502, 717, 96, 412, 580, 648, 839, 855, 1019, + /* 280 */ 926, 980, 980, 980, 980, 980, 980, 980, 980, 431, + /* 290 */ 685, 226, 365, 365, 425, 485, 161, 50, 249, 570, + /* 300 */ 328, 355, 355, 355, 355, 699, 739, 956, 746, 818, + /* 310 */ 835, 837, 900, 981, 1023, 921, 727, 967, 970, 929, + /* 320 */ 857, 803, 867, 1006, 335, 1012, 960, 1021, 1025, 1031, + /* 330 */ 1045, 1051, 972, 973, 1059, 1090, 1097, 1098, 1100, 1101, + /* 340 */ 974, 1026, 1036, 1339, 1344, 1303, 1346, 1274, 1348, 1314, + /* 350 */ 1167, 1317, 1318, 1319, 1173, 1357, 1323, 1324, 1177, 1361, + /* 360 */ 1180, 1364, 1330, 1367, 1353, 1368, 1342, 1378, 1297, 1212, + /* 370 */ 1214, 1217, 1220, 1384, 1385, 1227, 1230, 1391, 1392, 1347, + /* 380 */ 1394, 1396, 1397, 1257, 1400, 1401, 1402, 1404, 1406, 1270, + /* 390 */ 1374, 1410, 1277, 1411, 1415, 1416, 1417, 1418, 1419, 1421, + /* 400 */ 1422, 1423, 1432, 1440, 1442, 1443, 1444, 1403, 1446, 1447, + /* 410 */ 1448, 1449, 1450, 1451, 1430, 1453, 1454, 1462, 1463, 1464, + /* 420 */ 1465, 1414, 1420, 1424, 1452, 1412, 1457, 1426, 1468, 1435, + /* 430 */ 1431, 1478, 1479, 1480, 1445, 1327, 1482, 1485, 1486, 1427, + /* 440 */ 1488, 1489, 1455, 1466, 1460, 1492, 1459, 1467, 1461, 1493, + /* 450 */ 1469, 1470, 1472, 1495, 1481, 1474, 1483, 1497, 1501, 1503, + /* 460 */ 1523, 1366, 1436, 1491, 1511, 1535, 1504, 1505, 1508, 1509, + /* 470 */ 1502, 1506, 1512, 1513, 1515, 1538, 1529, 1552, 1531, 1507, + /* 480 */ 1555, 1536, 1522, 1560, 1527, 1563, 1530, 1566, 1545, 1548, + /* 490 */ 1569, 1425, 1539, 1570, 1407, 1549, 1428, 1433, 1573, 1581, + /* 500 */ 1434, 1475, 1582, 1583, 1585, 1543, 1363, 1518, 1520, 1524, + /* 510 */ 1521, 1558, 1533, 1525, 1532, 1537, 1541, 1559, 1574, 1575, + /* 520 */ 1540, 1586, 1408, 1551, 1553, 1580, 1409, 1588, 1589, 1554, + /* 530 */ 1595, 1458, 1556, 1605, 1606, 1607, 1611, 1612, 1613, 1556, + /* 540 */ 1643, 1471, 1608, 1567, 1571, 1572, 1603, 1577, 1587, 1621, + /* 550 */ 1630, 1484, 1590, 1591, 1593, 1596, 1499, 1656, 1598, 1544, + /* 560 */ 1609, 1657, 1631, 1547, 1614, 1597, 1627, 1635, 1616, 1602, + /* 570 */ 1617, 1665, 1618, 1601, 1619, 1653, 1668, 1622, 1623, 1670, + /* 580 */ 1625, 1626, 1673, 1628, 1638, 1678, 1632, 1641, 1690, 1652, + /* 590 */ 1629, 1634, 1636, 1637, 1679, 1642, 1655, 1659, 1703, 1662, + /* 600 */ 1702, 1702, 1724, 1688, 1692, 1714, 1685, 1675, 1713, 1722, + /* 610 */ 1723, 1726, 1727, 1728, 1737, 1729, 1730, 1704, 1502, 1732, + /* 620 */ 1506, 1735, 1741, 1742, 1743, 1744, 1746, 1772, 1747, 1745, + /* 630 */ 1750, 1791, 1758, 1748, 1755, 1796, 1763, 1752, 1761, 1803, + /* 640 */ 1777, 1767, 1779, 1816, 1784, 1785, 1821, 1800, 1802, 1804, + /* 650 */ 1805, 1807, 1810, }; #define YY_REDUCE_COUNT (269) -#define YY_REDUCE_MIN (-287) -#define YY_REDUCE_MAX (2156) +#define YY_REDUCE_MIN (-329) +#define YY_REDUCE_MAX (2136) static const short yy_reduce_ofst[] = { - /* 0 */ -248, 72, 855, -195, 322, 575, 908, 950, 1028, 1055, - /* 10 */ 306, 1123, 1165, 1190, 1247, 1304, 1325, 1382, 1405, 1447, - /* 20 */ 1463, 1513, 1570, 1631, 1648, 1690, 1701, 1712, 1754, 1772, - /* 30 */ 1796, 1852, 1902, 1913, 1955, 1966, 1980, 2036, 2050, 2100, - /* 40 */ 2142, 2156, 769, 1219, -234, 90, 398, -278, -260, -254, - /* 50 */ -105, -245, -209, -42, -261, -164, -256, -250, 4, -113, - /* 60 */ 13, 24, 131, 258, 262, 338, 340, 543, 548, 550, - /* 70 */ -246, 552, 555, 557, 133, -211, 62, 570, 645, -224, - /* 80 */ 703, 73, -190, 86, 704, 23, 59, 185, 185, 185, - /* 90 */ -237, -102, -153, 276, 278, 288, 315, 362, 419, 420, - /* 100 */ 435, 437, 440, 477, 479, 480, 483, 531, 564, 573, - /* 110 */ 615, -255, 281, -40, 379, 333, 444, -287, -242, 458, - /* 120 */ -125, 539, 106, 512, 441, 481, 316, 553, 391, 571, - /* 130 */ 566, 592, 378, 386, 567, 584, 638, 642, 690, 225, - /* 140 */ 731, 717, 619, 627, 736, 688, 650, 733, 733, 759, - /* 150 */ 762, 742, 737, 711, 711, 711, 701, 705, 706, 718, - /* 160 */ 733, 753, 814, 758, 812, 768, 822, 824, 785, 789, - /* 170 */ 792, 828, 837, 838, 780, 841, 807, 844, 800, 804, - /* 180 */ 853, 809, 858, 830, 859, 861, 874, 868, 882, 860, - /* 190 */ 862, 865, 866, 869, 871, 873, 875, 877, 878, 879, - /* 200 */ 881, 890, 846, 836, 892, 847, 880, 899, 904, 906, - /* 210 */ 863, 905, 850, 894, 815, 886, 898, 821, 891, 907, - /* 220 */ 911, 733, 826, 849, 843, 851, 854, 887, 902, 711, - /* 230 */ 936, 909, 900, 889, 895, 883, 893, 896, 897, 901, - /* 240 */ 915, 959, 972, 973, 976, 990, 993, 964, 994, 952, - /* 250 */ 970, 984, 1011, 1006, 1030, 1007, 1012, 1001, 1027, 1038, - /* 260 */ 1041, 1046, 1050, 996, 997, 1032, 1036, 1037, 1049, 1063, + /* 0 */ -246, 688, 769, -197, 789, 881, 944, 971, 1042, 1107, + /* 10 */ 1178, 1200, 1263, 348, 1281, 1334, 1388, 1399, 1456, 1477, + /* 20 */ 1519, 1542, 1599, 1610, 1624, 1666, 1680, 1691, 1733, 1775, + /* 30 */ 1786, 1798, 1853, 1880, 1907, 1934, 1988, 1997, 2015, 2068, + /* 40 */ 2082, 2136, 288, 490, -236, -122, -20, -280, -262, -260, + /* 50 */ -55, -285, -80, -41, 206, 289, -259, -252, -329, -279, + /* 60 */ -126, -49, 268, 341, 342, 351, 459, 460, 461, 517, + /* 70 */ -250, 520, 543, 559, -251, -181, -104, 642, 645, 270, + /* 80 */ 709, 292, 330, 299, 711, 332, -234, -190, -190, -190, + /* 90 */ -99, 146, 120, 244, 354, 356, 385, 444, 532, 549, + /* 100 */ 569, 576, 621, 651, 657, 682, 691, 694, 695, 725, + /* 110 */ 742, 20, 229, -101, 407, 11, 264, 464, 467, 500, + /* 120 */ 80, 456, 83, 7, -307, -97, 189, 325, 149, 436, + /* 130 */ 442, 640, -273, 266, 297, 443, 452, 472, 509, 259, + /* 140 */ 563, 554, 469, 494, 609, 595, 622, 715, 715, 773, + /* 150 */ 764, 745, 733, 712, 712, 712, 718, 702, 704, 714, + /* 160 */ 729, 715, 768, 842, 794, 856, 814, 882, 883, 845, + /* 170 */ 849, 850, 890, 898, 899, 840, 893, 860, 894, 851, + /* 180 */ 852, 901, 858, 904, 870, 908, 909, 915, 918, 925, + /* 190 */ 903, 905, 906, 907, 910, 911, 912, 913, 914, 917, + /* 200 */ 919, 924, 934, 896, 879, 936, 886, 916, 941, 953, + /* 210 */ 954, 895, 955, 902, 933, 866, 927, 935, 873, 931, + /* 220 */ 943, 945, 715, 885, 887, 892, 897, 920, 923, 928, + /* 230 */ 712, 965, 938, 922, 939, 930, 937, 942, 940, 947, + /* 240 */ 948, 958, 986, 987, 988, 994, 996, 963, 997, 989, + /* 250 */ 1029, 1014, 1052, 1037, 1054, 1030, 1039, 1034, 1056, 1061, + /* 260 */ 1062, 1074, 1077, 1035, 1024, 1064, 1065, 1066, 1070, 1084, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 10 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 20 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 30 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 40 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 50 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 60 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 70 */ 1508, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 80 */ 1436, 1436, 1436, 1436, 1436, 1506, 1659, 1436, 1834, 1436, - /* 90 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 100 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 110 */ 1436, 1436, 1436, 1436, 1436, 1508, 1436, 1846, 1846, 1846, - /* 120 */ 1506, 1436, 1436, 1436, 1703, 1703, 1436, 1436, 1436, 1436, - /* 130 */ 1602, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1695, - /* 140 */ 1436, 1436, 1916, 1436, 1436, 1701, 1870, 1436, 1436, 1436, - /* 150 */ 1436, 1555, 1862, 1838, 1852, 1839, 1901, 1901, 1901, 1855, - /* 160 */ 1436, 1866, 1436, 1436, 1436, 1687, 1436, 1436, 1664, 1661, - /* 170 */ 1661, 1436, 1436, 1436, 1436, 1508, 1436, 1508, 1436, 1436, - /* 180 */ 1508, 1436, 1508, 1436, 1508, 1508, 1436, 1508, 1436, 1436, - /* 190 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 200 */ 1436, 1436, 1436, 1436, 1506, 1697, 1436, 1506, 1436, 1436, - /* 210 */ 1436, 1506, 1436, 1436, 1877, 1875, 1436, 1877, 1875, 1436, - /* 220 */ 1436, 1436, 1889, 1885, 1877, 1893, 1891, 1868, 1866, 1852, - /* 230 */ 1436, 1436, 1836, 1907, 1903, 1919, 1907, 1903, 1907, 1903, - /* 240 */ 1436, 1875, 1436, 1436, 1436, 1436, 1436, 1875, 1436, 1436, - /* 250 */ 1436, 1436, 1506, 1436, 1506, 1436, 1571, 1436, 1436, 1436, - /* 260 */ 1506, 1468, 1436, 1689, 1703, 1605, 1605, 1605, 1509, 1441, - /* 270 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 280 */ 1436, 1772, 1888, 1887, 1810, 1809, 1808, 1806, 1771, 1436, - /* 290 */ 1436, 1567, 1770, 1769, 1436, 1436, 1436, 1436, 1436, 1436, - /* 300 */ 1763, 1764, 1762, 1761, 1436, 1436, 1436, 1436, 1436, 1436, - /* 310 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1835, - /* 320 */ 1436, 1904, 1908, 1436, 1436, 1436, 1746, 1436, 1436, 1436, - /* 330 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 340 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 350 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 360 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 370 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 380 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 390 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 400 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 410 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 420 */ 1436, 1436, 1436, 1473, 1436, 1436, 1436, 1436, 1436, 1436, - /* 430 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 440 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 450 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 460 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 470 */ 1536, 1535, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 480 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 490 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 500 */ 1436, 1436, 1436, 1436, 1436, 1859, 1869, 1436, 1436, 1436, - /* 510 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 520 */ 1746, 1436, 1886, 1436, 1845, 1841, 1436, 1436, 1837, 1436, - /* 530 */ 1436, 1902, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 540 */ 1436, 1830, 1436, 1803, 1436, 1436, 1436, 1436, 1436, 1436, - /* 550 */ 1436, 1436, 1757, 1436, 1436, 1436, 1436, 1707, 1436, 1436, - /* 560 */ 1436, 1436, 1436, 1436, 1436, 1436, 1745, 1436, 1788, 1436, - /* 570 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1599, 1436, 1436, - /* 580 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 590 */ 1584, 1582, 1581, 1580, 1436, 1577, 1436, 1436, 1436, 1436, - /* 600 */ 1608, 1607, 1436, 1436, 1436, 1436, 1436, 1436, 1528, 1436, - /* 610 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1519, 1436, - /* 620 */ 1518, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 630 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 640 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, - /* 650 */ 1436, 1436, 1436, + /* 0 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 10 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 20 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 30 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 40 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 50 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 60 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 70 */ 1509, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 80 */ 1437, 1437, 1437, 1437, 1437, 1507, 1660, 1437, 1836, 1437, + /* 90 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 100 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 110 */ 1437, 1437, 1437, 1437, 1437, 1509, 1437, 1848, 1848, 1848, + /* 120 */ 1507, 1437, 1437, 1437, 1704, 1704, 1437, 1437, 1437, 1437, + /* 130 */ 1603, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1696, + /* 140 */ 1437, 1437, 1917, 1437, 1437, 1702, 1871, 1437, 1437, 1437, + /* 150 */ 1437, 1556, 1863, 1840, 1854, 1841, 1838, 1902, 1902, 1902, + /* 160 */ 1857, 1437, 1867, 1437, 1437, 1437, 1688, 1437, 1437, 1665, + /* 170 */ 1662, 1662, 1437, 1437, 1437, 1437, 1509, 1437, 1509, 1437, + /* 180 */ 1437, 1509, 1437, 1509, 1437, 1509, 1509, 1437, 1509, 1437, + /* 190 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 200 */ 1437, 1437, 1437, 1437, 1437, 1507, 1698, 1437, 1507, 1437, + /* 210 */ 1437, 1437, 1507, 1437, 1437, 1878, 1876, 1437, 1878, 1876, + /* 220 */ 1437, 1437, 1437, 1890, 1886, 1878, 1894, 1892, 1869, 1867, + /* 230 */ 1854, 1437, 1437, 1908, 1904, 1920, 1908, 1904, 1908, 1904, + /* 240 */ 1437, 1876, 1437, 1437, 1437, 1437, 1437, 1876, 1437, 1437, + /* 250 */ 1437, 1437, 1507, 1437, 1507, 1437, 1572, 1437, 1437, 1437, + /* 260 */ 1507, 1469, 1437, 1690, 1704, 1606, 1606, 1606, 1510, 1442, + /* 270 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 280 */ 1437, 1774, 1889, 1888, 1812, 1811, 1810, 1808, 1773, 1437, + /* 290 */ 1437, 1568, 1772, 1771, 1437, 1437, 1437, 1437, 1437, 1437, + /* 300 */ 1437, 1765, 1766, 1764, 1763, 1437, 1437, 1437, 1437, 1437, + /* 310 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1837, + /* 320 */ 1437, 1905, 1909, 1437, 1437, 1437, 1748, 1437, 1437, 1437, + /* 330 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 340 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 350 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 360 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 370 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 380 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 390 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 400 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 410 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 420 */ 1437, 1437, 1437, 1474, 1437, 1437, 1437, 1437, 1437, 1437, + /* 430 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 440 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 450 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 460 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 470 */ 1537, 1536, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 480 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 490 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 500 */ 1437, 1437, 1437, 1437, 1437, 1870, 1437, 1437, 1437, 1437, + /* 510 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1748, + /* 520 */ 1437, 1887, 1437, 1847, 1843, 1437, 1437, 1839, 1437, 1437, + /* 530 */ 1903, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 540 */ 1832, 1437, 1805, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 550 */ 1437, 1759, 1437, 1437, 1437, 1437, 1437, 1708, 1437, 1437, + /* 560 */ 1437, 1437, 1437, 1437, 1437, 1437, 1747, 1437, 1790, 1437, + /* 570 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1600, 1437, 1437, + /* 580 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 590 */ 1585, 1583, 1582, 1581, 1437, 1578, 1437, 1437, 1437, 1437, + /* 600 */ 1609, 1608, 1437, 1437, 1437, 1437, 1437, 1437, 1529, 1437, + /* 610 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1520, 1437, + /* 620 */ 1519, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 630 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 640 */ 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, + /* 650 */ 1437, 1437, 1437, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1085,6 +1083,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* TRIGGER => nothing */ 0, /* AT_ONCE => nothing */ 0, /* WINDOW_CLOSE => nothing */ + 0, /* IGNORE => nothing */ + 0, /* EXPIRED => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ 0, /* TRANSACTION => nothing */ @@ -1152,12 +1152,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 243, /* NK_BITNOT => ID */ - 243, /* INSERT => ID */ - 243, /* VALUES => ID */ - 243, /* IMPORT => ID */ - 243, /* NK_SEMI => ID */ - 243, /* FILE => ID */ + 245, /* NK_BITNOT => ID */ + 245, /* INSERT => ID */ + 245, /* VALUES => ID */ + 245, /* IMPORT => ID */ + 245, /* NK_SEMI => ID */ + 245, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1422,203 +1422,204 @@ static const char *const yyTokenName[] = { /* 174 */ "TRIGGER", /* 175 */ "AT_ONCE", /* 176 */ "WINDOW_CLOSE", - /* 177 */ "KILL", - /* 178 */ "CONNECTION", - /* 179 */ "TRANSACTION", - /* 180 */ "BALANCE", - /* 181 */ "VGROUP", - /* 182 */ "MERGE", - /* 183 */ "REDISTRIBUTE", - /* 184 */ "SPLIT", - /* 185 */ "SYNCDB", - /* 186 */ "DELETE", - /* 187 */ "NULL", - /* 188 */ "NK_QUESTION", - /* 189 */ "NK_ARROW", - /* 190 */ "ROWTS", - /* 191 */ "TBNAME", - /* 192 */ "QSTARTTS", - /* 193 */ "QENDTS", - /* 194 */ "WSTARTTS", - /* 195 */ "WENDTS", - /* 196 */ "WDURATION", - /* 197 */ "CAST", - /* 198 */ "NOW", - /* 199 */ "TODAY", - /* 200 */ "TIMEZONE", - /* 201 */ "CLIENT_VERSION", - /* 202 */ "SERVER_VERSION", - /* 203 */ "SERVER_STATUS", - /* 204 */ "CURRENT_USER", - /* 205 */ "COUNT", - /* 206 */ "LAST_ROW", - /* 207 */ "BETWEEN", - /* 208 */ "IS", - /* 209 */ "NK_LT", - /* 210 */ "NK_GT", - /* 211 */ "NK_LE", - /* 212 */ "NK_GE", - /* 213 */ "NK_NE", - /* 214 */ "MATCH", - /* 215 */ "NMATCH", - /* 216 */ "CONTAINS", - /* 217 */ "JOIN", - /* 218 */ "INNER", - /* 219 */ "SELECT", - /* 220 */ "DISTINCT", - /* 221 */ "WHERE", - /* 222 */ "PARTITION", - /* 223 */ "BY", - /* 224 */ "SESSION", - /* 225 */ "STATE_WINDOW", - /* 226 */ "SLIDING", - /* 227 */ "FILL", - /* 228 */ "VALUE", - /* 229 */ "NONE", - /* 230 */ "PREV", - /* 231 */ "LINEAR", - /* 232 */ "NEXT", - /* 233 */ "HAVING", - /* 234 */ "RANGE", - /* 235 */ "EVERY", - /* 236 */ "ORDER", - /* 237 */ "SLIMIT", - /* 238 */ "SOFFSET", - /* 239 */ "LIMIT", - /* 240 */ "OFFSET", - /* 241 */ "ASC", - /* 242 */ "NULLS", - /* 243 */ "ID", - /* 244 */ "NK_BITNOT", - /* 245 */ "INSERT", - /* 246 */ "VALUES", - /* 247 */ "IMPORT", - /* 248 */ "NK_SEMI", - /* 249 */ "FILE", - /* 250 */ "cmd", - /* 251 */ "account_options", - /* 252 */ "alter_account_options", - /* 253 */ "literal", - /* 254 */ "alter_account_option", - /* 255 */ "user_name", - /* 256 */ "sysinfo_opt", - /* 257 */ "privileges", - /* 258 */ "priv_level", - /* 259 */ "priv_type_list", - /* 260 */ "priv_type", - /* 261 */ "db_name", - /* 262 */ "dnode_endpoint", - /* 263 */ "not_exists_opt", - /* 264 */ "db_options", - /* 265 */ "exists_opt", - /* 266 */ "alter_db_options", - /* 267 */ "integer_list", - /* 268 */ "variable_list", - /* 269 */ "retention_list", - /* 270 */ "alter_db_option", - /* 271 */ "retention", - /* 272 */ "full_table_name", - /* 273 */ "column_def_list", - /* 274 */ "tags_def_opt", - /* 275 */ "table_options", - /* 276 */ "multi_create_clause", - /* 277 */ "tags_def", - /* 278 */ "multi_drop_clause", - /* 279 */ "alter_table_clause", - /* 280 */ "alter_table_options", - /* 281 */ "column_name", - /* 282 */ "type_name", - /* 283 */ "signed_literal", - /* 284 */ "create_subtable_clause", - /* 285 */ "specific_tags_opt", - /* 286 */ "literal_list", - /* 287 */ "drop_table_clause", - /* 288 */ "col_name_list", - /* 289 */ "table_name", - /* 290 */ "column_def", - /* 291 */ "duration_list", - /* 292 */ "rollup_func_list", - /* 293 */ "alter_table_option", - /* 294 */ "duration_literal", - /* 295 */ "rollup_func_name", - /* 296 */ "function_name", - /* 297 */ "col_name", - /* 298 */ "db_name_cond_opt", - /* 299 */ "like_pattern_opt", - /* 300 */ "table_name_cond", - /* 301 */ "from_db_opt", - /* 302 */ "index_name", - /* 303 */ "index_options", - /* 304 */ "func_list", - /* 305 */ "sliding_opt", - /* 306 */ "sma_stream_opt", - /* 307 */ "func", - /* 308 */ "expression_list", - /* 309 */ "stream_options", - /* 310 */ "topic_name", - /* 311 */ "query_expression", - /* 312 */ "cgroup_name", - /* 313 */ "analyze_opt", - /* 314 */ "explain_options", - /* 315 */ "agg_func_opt", - /* 316 */ "bufsize_opt", - /* 317 */ "stream_name", - /* 318 */ "into_opt", - /* 319 */ "dnode_list", - /* 320 */ "where_clause_opt", - /* 321 */ "signed", - /* 322 */ "literal_func", - /* 323 */ "table_alias", - /* 324 */ "column_alias", - /* 325 */ "expression", - /* 326 */ "pseudo_column", - /* 327 */ "column_reference", - /* 328 */ "function_expression", - /* 329 */ "subquery", - /* 330 */ "star_func", - /* 331 */ "star_func_para_list", - /* 332 */ "noarg_func", - /* 333 */ "other_para_list", - /* 334 */ "star_func_para", - /* 335 */ "predicate", - /* 336 */ "compare_op", - /* 337 */ "in_op", - /* 338 */ "in_predicate_value", - /* 339 */ "boolean_value_expression", - /* 340 */ "boolean_primary", - /* 341 */ "common_expression", - /* 342 */ "from_clause_opt", - /* 343 */ "table_reference_list", - /* 344 */ "table_reference", - /* 345 */ "table_primary", - /* 346 */ "joined_table", - /* 347 */ "alias_opt", - /* 348 */ "parenthesized_joined_table", - /* 349 */ "join_type", - /* 350 */ "search_condition", - /* 351 */ "query_specification", - /* 352 */ "set_quantifier_opt", - /* 353 */ "select_list", - /* 354 */ "partition_by_clause_opt", - /* 355 */ "range_opt", - /* 356 */ "every_opt", - /* 357 */ "fill_opt", - /* 358 */ "twindow_clause_opt", - /* 359 */ "group_by_clause_opt", - /* 360 */ "having_clause_opt", - /* 361 */ "select_sublist", - /* 362 */ "select_item", - /* 363 */ "fill_mode", - /* 364 */ "group_by_list", - /* 365 */ "query_expression_body", - /* 366 */ "order_by_clause_opt", - /* 367 */ "slimit_clause_opt", - /* 368 */ "limit_clause_opt", - /* 369 */ "query_primary", - /* 370 */ "sort_specification_list", - /* 371 */ "sort_specification", - /* 372 */ "ordering_specification_opt", - /* 373 */ "null_ordering_opt", + /* 177 */ "IGNORE", + /* 178 */ "EXPIRED", + /* 179 */ "KILL", + /* 180 */ "CONNECTION", + /* 181 */ "TRANSACTION", + /* 182 */ "BALANCE", + /* 183 */ "VGROUP", + /* 184 */ "MERGE", + /* 185 */ "REDISTRIBUTE", + /* 186 */ "SPLIT", + /* 187 */ "SYNCDB", + /* 188 */ "DELETE", + /* 189 */ "NULL", + /* 190 */ "NK_QUESTION", + /* 191 */ "NK_ARROW", + /* 192 */ "ROWTS", + /* 193 */ "TBNAME", + /* 194 */ "QSTARTTS", + /* 195 */ "QENDTS", + /* 196 */ "WSTARTTS", + /* 197 */ "WENDTS", + /* 198 */ "WDURATION", + /* 199 */ "CAST", + /* 200 */ "NOW", + /* 201 */ "TODAY", + /* 202 */ "TIMEZONE", + /* 203 */ "CLIENT_VERSION", + /* 204 */ "SERVER_VERSION", + /* 205 */ "SERVER_STATUS", + /* 206 */ "CURRENT_USER", + /* 207 */ "COUNT", + /* 208 */ "LAST_ROW", + /* 209 */ "BETWEEN", + /* 210 */ "IS", + /* 211 */ "NK_LT", + /* 212 */ "NK_GT", + /* 213 */ "NK_LE", + /* 214 */ "NK_GE", + /* 215 */ "NK_NE", + /* 216 */ "MATCH", + /* 217 */ "NMATCH", + /* 218 */ "CONTAINS", + /* 219 */ "JOIN", + /* 220 */ "INNER", + /* 221 */ "SELECT", + /* 222 */ "DISTINCT", + /* 223 */ "WHERE", + /* 224 */ "PARTITION", + /* 225 */ "BY", + /* 226 */ "SESSION", + /* 227 */ "STATE_WINDOW", + /* 228 */ "SLIDING", + /* 229 */ "FILL", + /* 230 */ "VALUE", + /* 231 */ "NONE", + /* 232 */ "PREV", + /* 233 */ "LINEAR", + /* 234 */ "NEXT", + /* 235 */ "HAVING", + /* 236 */ "RANGE", + /* 237 */ "EVERY", + /* 238 */ "ORDER", + /* 239 */ "SLIMIT", + /* 240 */ "SOFFSET", + /* 241 */ "LIMIT", + /* 242 */ "OFFSET", + /* 243 */ "ASC", + /* 244 */ "NULLS", + /* 245 */ "ID", + /* 246 */ "NK_BITNOT", + /* 247 */ "INSERT", + /* 248 */ "VALUES", + /* 249 */ "IMPORT", + /* 250 */ "NK_SEMI", + /* 251 */ "FILE", + /* 252 */ "cmd", + /* 253 */ "account_options", + /* 254 */ "alter_account_options", + /* 255 */ "literal", + /* 256 */ "alter_account_option", + /* 257 */ "user_name", + /* 258 */ "sysinfo_opt", + /* 259 */ "privileges", + /* 260 */ "priv_level", + /* 261 */ "priv_type_list", + /* 262 */ "priv_type", + /* 263 */ "db_name", + /* 264 */ "dnode_endpoint", + /* 265 */ "not_exists_opt", + /* 266 */ "db_options", + /* 267 */ "exists_opt", + /* 268 */ "alter_db_options", + /* 269 */ "integer_list", + /* 270 */ "variable_list", + /* 271 */ "retention_list", + /* 272 */ "alter_db_option", + /* 273 */ "retention", + /* 274 */ "full_table_name", + /* 275 */ "column_def_list", + /* 276 */ "tags_def_opt", + /* 277 */ "table_options", + /* 278 */ "multi_create_clause", + /* 279 */ "tags_def", + /* 280 */ "multi_drop_clause", + /* 281 */ "alter_table_clause", + /* 282 */ "alter_table_options", + /* 283 */ "column_name", + /* 284 */ "type_name", + /* 285 */ "signed_literal", + /* 286 */ "create_subtable_clause", + /* 287 */ "specific_tags_opt", + /* 288 */ "literal_list", + /* 289 */ "drop_table_clause", + /* 290 */ "col_name_list", + /* 291 */ "table_name", + /* 292 */ "column_def", + /* 293 */ "duration_list", + /* 294 */ "rollup_func_list", + /* 295 */ "alter_table_option", + /* 296 */ "duration_literal", + /* 297 */ "rollup_func_name", + /* 298 */ "function_name", + /* 299 */ "col_name", + /* 300 */ "db_name_cond_opt", + /* 301 */ "like_pattern_opt", + /* 302 */ "table_name_cond", + /* 303 */ "from_db_opt", + /* 304 */ "index_name", + /* 305 */ "index_options", + /* 306 */ "func_list", + /* 307 */ "sliding_opt", + /* 308 */ "sma_stream_opt", + /* 309 */ "func", + /* 310 */ "expression_list", + /* 311 */ "stream_options", + /* 312 */ "topic_name", + /* 313 */ "query_expression", + /* 314 */ "cgroup_name", + /* 315 */ "analyze_opt", + /* 316 */ "explain_options", + /* 317 */ "agg_func_opt", + /* 318 */ "bufsize_opt", + /* 319 */ "stream_name", + /* 320 */ "into_opt", + /* 321 */ "dnode_list", + /* 322 */ "where_clause_opt", + /* 323 */ "signed", + /* 324 */ "literal_func", + /* 325 */ "table_alias", + /* 326 */ "column_alias", + /* 327 */ "expression", + /* 328 */ "pseudo_column", + /* 329 */ "column_reference", + /* 330 */ "function_expression", + /* 331 */ "subquery", + /* 332 */ "star_func", + /* 333 */ "star_func_para_list", + /* 334 */ "noarg_func", + /* 335 */ "other_para_list", + /* 336 */ "star_func_para", + /* 337 */ "predicate", + /* 338 */ "compare_op", + /* 339 */ "in_op", + /* 340 */ "in_predicate_value", + /* 341 */ "boolean_value_expression", + /* 342 */ "boolean_primary", + /* 343 */ "common_expression", + /* 344 */ "from_clause_opt", + /* 345 */ "table_reference_list", + /* 346 */ "table_reference", + /* 347 */ "table_primary", + /* 348 */ "joined_table", + /* 349 */ "alias_opt", + /* 350 */ "parenthesized_joined_table", + /* 351 */ "join_type", + /* 352 */ "search_condition", + /* 353 */ "query_specification", + /* 354 */ "set_quantifier_opt", + /* 355 */ "select_list", + /* 356 */ "partition_by_clause_opt", + /* 357 */ "range_opt", + /* 358 */ "every_opt", + /* 359 */ "fill_opt", + /* 360 */ "twindow_clause_opt", + /* 361 */ "group_by_clause_opt", + /* 362 */ "having_clause_opt", + /* 363 */ "select_item", + /* 364 */ "fill_mode", + /* 365 */ "group_by_list", + /* 366 */ "query_expression_body", + /* 367 */ "order_by_clause_opt", + /* 368 */ "slimit_clause_opt", + /* 369 */ "limit_clause_opt", + /* 370 */ "query_primary", + /* 371 */ "sort_specification_list", + /* 372 */ "sort_specification", + /* 373 */ "ordering_specification_opt", + /* 374 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1895,160 +1896,160 @@ static const char *const yyRuleName[] = { /* 266 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", /* 267 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", /* 268 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 269 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 270 */ "cmd ::= KILL QUERY NK_STRING", - /* 271 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 272 */ "cmd ::= BALANCE VGROUP", - /* 273 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 274 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 275 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 276 */ "dnode_list ::= DNODE NK_INTEGER", - /* 277 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 278 */ "cmd ::= SYNCDB db_name REPLICA", - /* 279 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 280 */ "cmd ::= query_expression", - /* 281 */ "literal ::= NK_INTEGER", - /* 282 */ "literal ::= NK_FLOAT", - /* 283 */ "literal ::= NK_STRING", - /* 284 */ "literal ::= NK_BOOL", - /* 285 */ "literal ::= TIMESTAMP NK_STRING", - /* 286 */ "literal ::= duration_literal", - /* 287 */ "literal ::= NULL", - /* 288 */ "literal ::= NK_QUESTION", - /* 289 */ "duration_literal ::= NK_VARIABLE", - /* 290 */ "signed ::= NK_INTEGER", - /* 291 */ "signed ::= NK_PLUS NK_INTEGER", - /* 292 */ "signed ::= NK_MINUS NK_INTEGER", - /* 293 */ "signed ::= NK_FLOAT", - /* 294 */ "signed ::= NK_PLUS NK_FLOAT", - /* 295 */ "signed ::= NK_MINUS NK_FLOAT", - /* 296 */ "signed_literal ::= signed", - /* 297 */ "signed_literal ::= NK_STRING", - /* 298 */ "signed_literal ::= NK_BOOL", - /* 299 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 300 */ "signed_literal ::= duration_literal", - /* 301 */ "signed_literal ::= NULL", - /* 302 */ "signed_literal ::= literal_func", - /* 303 */ "literal_list ::= signed_literal", - /* 304 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 305 */ "db_name ::= NK_ID", - /* 306 */ "table_name ::= NK_ID", - /* 307 */ "column_name ::= NK_ID", - /* 308 */ "function_name ::= NK_ID", - /* 309 */ "table_alias ::= NK_ID", - /* 310 */ "column_alias ::= NK_ID", - /* 311 */ "user_name ::= NK_ID", - /* 312 */ "index_name ::= NK_ID", - /* 313 */ "topic_name ::= NK_ID", - /* 314 */ "stream_name ::= NK_ID", - /* 315 */ "cgroup_name ::= NK_ID", - /* 316 */ "expression ::= literal", - /* 317 */ "expression ::= pseudo_column", - /* 318 */ "expression ::= column_reference", - /* 319 */ "expression ::= function_expression", - /* 320 */ "expression ::= subquery", - /* 321 */ "expression ::= NK_LP expression NK_RP", - /* 322 */ "expression ::= NK_PLUS expression", - /* 323 */ "expression ::= NK_MINUS expression", - /* 324 */ "expression ::= expression NK_PLUS expression", - /* 325 */ "expression ::= expression NK_MINUS expression", - /* 326 */ "expression ::= expression NK_STAR expression", - /* 327 */ "expression ::= expression NK_SLASH expression", - /* 328 */ "expression ::= expression NK_REM expression", - /* 329 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 330 */ "expression ::= expression NK_BITAND expression", - /* 331 */ "expression ::= expression NK_BITOR expression", - /* 332 */ "expression_list ::= expression", - /* 333 */ "expression_list ::= expression_list NK_COMMA expression", - /* 334 */ "column_reference ::= column_name", - /* 335 */ "column_reference ::= table_name NK_DOT column_name", - /* 336 */ "pseudo_column ::= ROWTS", - /* 337 */ "pseudo_column ::= TBNAME", - /* 338 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 339 */ "pseudo_column ::= QSTARTTS", - /* 340 */ "pseudo_column ::= QENDTS", - /* 341 */ "pseudo_column ::= WSTARTTS", - /* 342 */ "pseudo_column ::= WENDTS", - /* 343 */ "pseudo_column ::= WDURATION", - /* 344 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 345 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 346 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 347 */ "function_expression ::= literal_func", - /* 348 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 349 */ "literal_func ::= NOW", - /* 350 */ "noarg_func ::= NOW", - /* 351 */ "noarg_func ::= TODAY", - /* 352 */ "noarg_func ::= TIMEZONE", - /* 353 */ "noarg_func ::= DATABASE", - /* 354 */ "noarg_func ::= CLIENT_VERSION", - /* 355 */ "noarg_func ::= SERVER_VERSION", - /* 356 */ "noarg_func ::= SERVER_STATUS", - /* 357 */ "noarg_func ::= CURRENT_USER", - /* 358 */ "noarg_func ::= USER", - /* 359 */ "star_func ::= COUNT", - /* 360 */ "star_func ::= FIRST", - /* 361 */ "star_func ::= LAST", - /* 362 */ "star_func ::= LAST_ROW", - /* 363 */ "star_func_para_list ::= NK_STAR", - /* 364 */ "star_func_para_list ::= other_para_list", - /* 365 */ "other_para_list ::= star_func_para", - /* 366 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 367 */ "star_func_para ::= expression", - /* 368 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 369 */ "predicate ::= expression compare_op expression", - /* 370 */ "predicate ::= expression BETWEEN expression AND expression", - /* 371 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 372 */ "predicate ::= expression IS NULL", - /* 373 */ "predicate ::= expression IS NOT NULL", - /* 374 */ "predicate ::= expression in_op in_predicate_value", - /* 375 */ "compare_op ::= NK_LT", - /* 376 */ "compare_op ::= NK_GT", - /* 377 */ "compare_op ::= NK_LE", - /* 378 */ "compare_op ::= NK_GE", - /* 379 */ "compare_op ::= NK_NE", - /* 380 */ "compare_op ::= NK_EQ", - /* 381 */ "compare_op ::= LIKE", - /* 382 */ "compare_op ::= NOT LIKE", - /* 383 */ "compare_op ::= MATCH", - /* 384 */ "compare_op ::= NMATCH", - /* 385 */ "compare_op ::= CONTAINS", - /* 386 */ "in_op ::= IN", - /* 387 */ "in_op ::= NOT IN", - /* 388 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 389 */ "boolean_value_expression ::= boolean_primary", - /* 390 */ "boolean_value_expression ::= NOT boolean_primary", - /* 391 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 392 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 393 */ "boolean_primary ::= predicate", - /* 394 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 395 */ "common_expression ::= expression", - /* 396 */ "common_expression ::= boolean_value_expression", - /* 397 */ "from_clause_opt ::=", - /* 398 */ "from_clause_opt ::= FROM table_reference_list", - /* 399 */ "table_reference_list ::= table_reference", - /* 400 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 401 */ "table_reference ::= table_primary", - /* 402 */ "table_reference ::= joined_table", - /* 403 */ "table_primary ::= table_name alias_opt", - /* 404 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 405 */ "table_primary ::= subquery alias_opt", - /* 406 */ "table_primary ::= parenthesized_joined_table", - /* 407 */ "alias_opt ::=", - /* 408 */ "alias_opt ::= table_alias", - /* 409 */ "alias_opt ::= AS table_alias", - /* 410 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 411 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 412 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 413 */ "join_type ::=", - /* 414 */ "join_type ::= INNER", - /* 415 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 416 */ "set_quantifier_opt ::=", - /* 417 */ "set_quantifier_opt ::= DISTINCT", - /* 418 */ "set_quantifier_opt ::= ALL", - /* 419 */ "select_list ::= NK_STAR", - /* 420 */ "select_list ::= select_sublist", - /* 421 */ "select_sublist ::= select_item", - /* 422 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 269 */ "stream_options ::= stream_options IGNORE EXPIRED", + /* 270 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 271 */ "cmd ::= KILL QUERY NK_STRING", + /* 272 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 273 */ "cmd ::= BALANCE VGROUP", + /* 274 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 275 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 276 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 277 */ "dnode_list ::= DNODE NK_INTEGER", + /* 278 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 279 */ "cmd ::= SYNCDB db_name REPLICA", + /* 280 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 281 */ "cmd ::= query_expression", + /* 282 */ "literal ::= NK_INTEGER", + /* 283 */ "literal ::= NK_FLOAT", + /* 284 */ "literal ::= NK_STRING", + /* 285 */ "literal ::= NK_BOOL", + /* 286 */ "literal ::= TIMESTAMP NK_STRING", + /* 287 */ "literal ::= duration_literal", + /* 288 */ "literal ::= NULL", + /* 289 */ "literal ::= NK_QUESTION", + /* 290 */ "duration_literal ::= NK_VARIABLE", + /* 291 */ "signed ::= NK_INTEGER", + /* 292 */ "signed ::= NK_PLUS NK_INTEGER", + /* 293 */ "signed ::= NK_MINUS NK_INTEGER", + /* 294 */ "signed ::= NK_FLOAT", + /* 295 */ "signed ::= NK_PLUS NK_FLOAT", + /* 296 */ "signed ::= NK_MINUS NK_FLOAT", + /* 297 */ "signed_literal ::= signed", + /* 298 */ "signed_literal ::= NK_STRING", + /* 299 */ "signed_literal ::= NK_BOOL", + /* 300 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 301 */ "signed_literal ::= duration_literal", + /* 302 */ "signed_literal ::= NULL", + /* 303 */ "signed_literal ::= literal_func", + /* 304 */ "literal_list ::= signed_literal", + /* 305 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 306 */ "db_name ::= NK_ID", + /* 307 */ "table_name ::= NK_ID", + /* 308 */ "column_name ::= NK_ID", + /* 309 */ "function_name ::= NK_ID", + /* 310 */ "table_alias ::= NK_ID", + /* 311 */ "column_alias ::= NK_ID", + /* 312 */ "user_name ::= NK_ID", + /* 313 */ "index_name ::= NK_ID", + /* 314 */ "topic_name ::= NK_ID", + /* 315 */ "stream_name ::= NK_ID", + /* 316 */ "cgroup_name ::= NK_ID", + /* 317 */ "expression ::= literal", + /* 318 */ "expression ::= pseudo_column", + /* 319 */ "expression ::= column_reference", + /* 320 */ "expression ::= function_expression", + /* 321 */ "expression ::= subquery", + /* 322 */ "expression ::= NK_LP expression NK_RP", + /* 323 */ "expression ::= NK_PLUS expression", + /* 324 */ "expression ::= NK_MINUS expression", + /* 325 */ "expression ::= expression NK_PLUS expression", + /* 326 */ "expression ::= expression NK_MINUS expression", + /* 327 */ "expression ::= expression NK_STAR expression", + /* 328 */ "expression ::= expression NK_SLASH expression", + /* 329 */ "expression ::= expression NK_REM expression", + /* 330 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 331 */ "expression ::= expression NK_BITAND expression", + /* 332 */ "expression ::= expression NK_BITOR expression", + /* 333 */ "expression_list ::= expression", + /* 334 */ "expression_list ::= expression_list NK_COMMA expression", + /* 335 */ "column_reference ::= column_name", + /* 336 */ "column_reference ::= table_name NK_DOT column_name", + /* 337 */ "pseudo_column ::= ROWTS", + /* 338 */ "pseudo_column ::= TBNAME", + /* 339 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 340 */ "pseudo_column ::= QSTARTTS", + /* 341 */ "pseudo_column ::= QENDTS", + /* 342 */ "pseudo_column ::= WSTARTTS", + /* 343 */ "pseudo_column ::= WENDTS", + /* 344 */ "pseudo_column ::= WDURATION", + /* 345 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 346 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 347 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 348 */ "function_expression ::= literal_func", + /* 349 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 350 */ "literal_func ::= NOW", + /* 351 */ "noarg_func ::= NOW", + /* 352 */ "noarg_func ::= TODAY", + /* 353 */ "noarg_func ::= TIMEZONE", + /* 354 */ "noarg_func ::= DATABASE", + /* 355 */ "noarg_func ::= CLIENT_VERSION", + /* 356 */ "noarg_func ::= SERVER_VERSION", + /* 357 */ "noarg_func ::= SERVER_STATUS", + /* 358 */ "noarg_func ::= CURRENT_USER", + /* 359 */ "noarg_func ::= USER", + /* 360 */ "star_func ::= COUNT", + /* 361 */ "star_func ::= FIRST", + /* 362 */ "star_func ::= LAST", + /* 363 */ "star_func ::= LAST_ROW", + /* 364 */ "star_func_para_list ::= NK_STAR", + /* 365 */ "star_func_para_list ::= other_para_list", + /* 366 */ "other_para_list ::= star_func_para", + /* 367 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 368 */ "star_func_para ::= expression", + /* 369 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 370 */ "predicate ::= expression compare_op expression", + /* 371 */ "predicate ::= expression BETWEEN expression AND expression", + /* 372 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 373 */ "predicate ::= expression IS NULL", + /* 374 */ "predicate ::= expression IS NOT NULL", + /* 375 */ "predicate ::= expression in_op in_predicate_value", + /* 376 */ "compare_op ::= NK_LT", + /* 377 */ "compare_op ::= NK_GT", + /* 378 */ "compare_op ::= NK_LE", + /* 379 */ "compare_op ::= NK_GE", + /* 380 */ "compare_op ::= NK_NE", + /* 381 */ "compare_op ::= NK_EQ", + /* 382 */ "compare_op ::= LIKE", + /* 383 */ "compare_op ::= NOT LIKE", + /* 384 */ "compare_op ::= MATCH", + /* 385 */ "compare_op ::= NMATCH", + /* 386 */ "compare_op ::= CONTAINS", + /* 387 */ "in_op ::= IN", + /* 388 */ "in_op ::= NOT IN", + /* 389 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 390 */ "boolean_value_expression ::= boolean_primary", + /* 391 */ "boolean_value_expression ::= NOT boolean_primary", + /* 392 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 393 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 394 */ "boolean_primary ::= predicate", + /* 395 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 396 */ "common_expression ::= expression", + /* 397 */ "common_expression ::= boolean_value_expression", + /* 398 */ "from_clause_opt ::=", + /* 399 */ "from_clause_opt ::= FROM table_reference_list", + /* 400 */ "table_reference_list ::= table_reference", + /* 401 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 402 */ "table_reference ::= table_primary", + /* 403 */ "table_reference ::= joined_table", + /* 404 */ "table_primary ::= table_name alias_opt", + /* 405 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 406 */ "table_primary ::= subquery alias_opt", + /* 407 */ "table_primary ::= parenthesized_joined_table", + /* 408 */ "alias_opt ::=", + /* 409 */ "alias_opt ::= table_alias", + /* 410 */ "alias_opt ::= AS table_alias", + /* 411 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 412 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 413 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 414 */ "join_type ::=", + /* 415 */ "join_type ::= INNER", + /* 416 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 417 */ "set_quantifier_opt ::=", + /* 418 */ "set_quantifier_opt ::= DISTINCT", + /* 419 */ "set_quantifier_opt ::= ALL", + /* 420 */ "select_list ::= select_item", + /* 421 */ "select_list ::= select_list NK_COMMA select_item", + /* 422 */ "select_item ::= NK_STAR", /* 423 */ "select_item ::= common_expression", /* 424 */ "select_item ::= common_expression column_alias", /* 425 */ "select_item ::= common_expression AS column_alias", @@ -2235,182 +2236,181 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 250: /* cmd */ - case 253: /* literal */ - case 264: /* db_options */ - case 266: /* alter_db_options */ - case 271: /* retention */ - case 272: /* full_table_name */ - case 275: /* table_options */ - case 279: /* alter_table_clause */ - case 280: /* alter_table_options */ - case 283: /* signed_literal */ - case 284: /* create_subtable_clause */ - case 287: /* drop_table_clause */ - case 290: /* column_def */ - case 294: /* duration_literal */ - case 295: /* rollup_func_name */ - case 297: /* col_name */ - case 298: /* db_name_cond_opt */ - case 299: /* like_pattern_opt */ - case 300: /* table_name_cond */ - case 301: /* from_db_opt */ - case 303: /* index_options */ - case 305: /* sliding_opt */ - case 306: /* sma_stream_opt */ - case 307: /* func */ - case 309: /* stream_options */ - case 311: /* query_expression */ - case 314: /* explain_options */ - case 318: /* into_opt */ - case 320: /* where_clause_opt */ - case 321: /* signed */ - case 322: /* literal_func */ - case 325: /* expression */ - case 326: /* pseudo_column */ - case 327: /* column_reference */ - case 328: /* function_expression */ - case 329: /* subquery */ - case 334: /* star_func_para */ - case 335: /* predicate */ - case 338: /* in_predicate_value */ - case 339: /* boolean_value_expression */ - case 340: /* boolean_primary */ - case 341: /* common_expression */ - case 342: /* from_clause_opt */ - case 343: /* table_reference_list */ - case 344: /* table_reference */ - case 345: /* table_primary */ - case 346: /* joined_table */ - case 348: /* parenthesized_joined_table */ - case 350: /* search_condition */ - case 351: /* query_specification */ - case 355: /* range_opt */ - case 356: /* every_opt */ - case 357: /* fill_opt */ - case 358: /* twindow_clause_opt */ - case 360: /* having_clause_opt */ - case 362: /* select_item */ - case 365: /* query_expression_body */ - case 367: /* slimit_clause_opt */ - case 368: /* limit_clause_opt */ - case 369: /* query_primary */ - case 371: /* sort_specification */ + case 252: /* cmd */ + case 255: /* literal */ + case 266: /* db_options */ + case 268: /* alter_db_options */ + case 273: /* retention */ + case 274: /* full_table_name */ + case 277: /* table_options */ + case 281: /* alter_table_clause */ + case 282: /* alter_table_options */ + case 285: /* signed_literal */ + case 286: /* create_subtable_clause */ + case 289: /* drop_table_clause */ + case 292: /* column_def */ + case 296: /* duration_literal */ + case 297: /* rollup_func_name */ + case 299: /* col_name */ + case 300: /* db_name_cond_opt */ + case 301: /* like_pattern_opt */ + case 302: /* table_name_cond */ + case 303: /* from_db_opt */ + case 305: /* index_options */ + case 307: /* sliding_opt */ + case 308: /* sma_stream_opt */ + case 309: /* func */ + case 311: /* stream_options */ + case 313: /* query_expression */ + case 316: /* explain_options */ + case 320: /* into_opt */ + case 322: /* where_clause_opt */ + case 323: /* signed */ + case 324: /* literal_func */ + case 327: /* expression */ + case 328: /* pseudo_column */ + case 329: /* column_reference */ + case 330: /* function_expression */ + case 331: /* subquery */ + case 336: /* star_func_para */ + case 337: /* predicate */ + case 340: /* in_predicate_value */ + case 341: /* boolean_value_expression */ + case 342: /* boolean_primary */ + case 343: /* common_expression */ + case 344: /* from_clause_opt */ + case 345: /* table_reference_list */ + case 346: /* table_reference */ + case 347: /* table_primary */ + case 348: /* joined_table */ + case 350: /* parenthesized_joined_table */ + case 352: /* search_condition */ + case 353: /* query_specification */ + case 357: /* range_opt */ + case 358: /* every_opt */ + case 359: /* fill_opt */ + case 360: /* twindow_clause_opt */ + case 362: /* having_clause_opt */ + case 363: /* select_item */ + case 366: /* query_expression_body */ + case 368: /* slimit_clause_opt */ + case 369: /* limit_clause_opt */ + case 370: /* query_primary */ + case 372: /* sort_specification */ { - nodesDestroyNode((yypminor->yy652)); + nodesDestroyNode((yypminor->yy212)); } break; - case 251: /* account_options */ - case 252: /* alter_account_options */ - case 254: /* alter_account_option */ - case 316: /* bufsize_opt */ + case 253: /* account_options */ + case 254: /* alter_account_options */ + case 256: /* alter_account_option */ + case 318: /* bufsize_opt */ { } break; - case 255: /* user_name */ - case 258: /* priv_level */ - case 261: /* db_name */ - case 262: /* dnode_endpoint */ - case 281: /* column_name */ - case 289: /* table_name */ - case 296: /* function_name */ - case 302: /* index_name */ - case 310: /* topic_name */ - case 312: /* cgroup_name */ - case 317: /* stream_name */ - case 323: /* table_alias */ - case 324: /* column_alias */ - case 330: /* star_func */ - case 332: /* noarg_func */ - case 347: /* alias_opt */ + case 257: /* user_name */ + case 260: /* priv_level */ + case 263: /* db_name */ + case 264: /* dnode_endpoint */ + case 283: /* column_name */ + case 291: /* table_name */ + case 298: /* function_name */ + case 304: /* index_name */ + case 312: /* topic_name */ + case 314: /* cgroup_name */ + case 319: /* stream_name */ + case 325: /* table_alias */ + case 326: /* column_alias */ + case 332: /* star_func */ + case 334: /* noarg_func */ + case 349: /* alias_opt */ { } break; - case 256: /* sysinfo_opt */ + case 258: /* sysinfo_opt */ { } break; - case 257: /* privileges */ - case 259: /* priv_type_list */ - case 260: /* priv_type */ + case 259: /* privileges */ + case 261: /* priv_type_list */ + case 262: /* priv_type */ { } break; - case 263: /* not_exists_opt */ - case 265: /* exists_opt */ - case 313: /* analyze_opt */ - case 315: /* agg_func_opt */ - case 352: /* set_quantifier_opt */ + case 265: /* not_exists_opt */ + case 267: /* exists_opt */ + case 315: /* analyze_opt */ + case 317: /* agg_func_opt */ + case 354: /* set_quantifier_opt */ { } break; - case 267: /* integer_list */ - case 268: /* variable_list */ - case 269: /* retention_list */ - case 273: /* column_def_list */ - case 274: /* tags_def_opt */ - case 276: /* multi_create_clause */ - case 277: /* tags_def */ - case 278: /* multi_drop_clause */ - case 285: /* specific_tags_opt */ - case 286: /* literal_list */ - case 288: /* col_name_list */ - case 291: /* duration_list */ - case 292: /* rollup_func_list */ - case 304: /* func_list */ - case 308: /* expression_list */ - case 319: /* dnode_list */ - case 331: /* star_func_para_list */ - case 333: /* other_para_list */ - case 353: /* select_list */ - case 354: /* partition_by_clause_opt */ - case 359: /* group_by_clause_opt */ - case 361: /* select_sublist */ - case 364: /* group_by_list */ - case 366: /* order_by_clause_opt */ - case 370: /* sort_specification_list */ + case 269: /* integer_list */ + case 270: /* variable_list */ + case 271: /* retention_list */ + case 275: /* column_def_list */ + case 276: /* tags_def_opt */ + case 278: /* multi_create_clause */ + case 279: /* tags_def */ + case 280: /* multi_drop_clause */ + case 287: /* specific_tags_opt */ + case 288: /* literal_list */ + case 290: /* col_name_list */ + case 293: /* duration_list */ + case 294: /* rollup_func_list */ + case 306: /* func_list */ + case 310: /* expression_list */ + case 321: /* dnode_list */ + case 333: /* star_func_para_list */ + case 335: /* other_para_list */ + case 355: /* select_list */ + case 356: /* partition_by_clause_opt */ + case 361: /* group_by_clause_opt */ + case 365: /* group_by_list */ + case 367: /* order_by_clause_opt */ + case 371: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy24)); + nodesDestroyList((yypminor->yy424)); } break; - case 270: /* alter_db_option */ - case 293: /* alter_table_option */ + case 272: /* alter_db_option */ + case 295: /* alter_table_option */ { } break; - case 282: /* type_name */ + case 284: /* type_name */ { } break; - case 336: /* compare_op */ - case 337: /* in_op */ + case 338: /* compare_op */ + case 339: /* in_op */ { } break; - case 349: /* join_type */ + case 351: /* join_type */ { } break; - case 363: /* fill_mode */ + case 364: /* fill_mode */ { } break; - case 372: /* ordering_specification_opt */ + case 373: /* ordering_specification_opt */ { } break; - case 373: /* null_ordering_opt */ + case 374: /* null_ordering_opt */ { } @@ -2709,489 +2709,489 @@ 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[] = { - { 250, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 250, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 251, 0 }, /* (2) account_options ::= */ - { 251, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 251, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 251, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 251, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 251, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 251, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 251, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 251, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 251, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 252, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 252, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 254, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 254, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 254, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 254, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 254, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 254, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 254, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 254, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 254, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 254, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 250, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 250, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 250, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 250, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 250, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 256, 0 }, /* (29) sysinfo_opt ::= */ - { 256, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 250, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 250, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 257, -1 }, /* (33) privileges ::= ALL */ - { 257, -1 }, /* (34) privileges ::= priv_type_list */ - { 259, -1 }, /* (35) priv_type_list ::= priv_type */ - { 259, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 260, -1 }, /* (37) priv_type ::= READ */ - { 260, -1 }, /* (38) priv_type ::= WRITE */ - { 258, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 258, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 250, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 250, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 250, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 250, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 250, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 250, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 250, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 250, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 262, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 262, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 262, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 250, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 250, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 250, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 250, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 250, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 250, -2 }, /* (64) cmd ::= USE db_name */ - { 250, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 263, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ - { 263, 0 }, /* (67) not_exists_opt ::= */ - { 265, -2 }, /* (68) exists_opt ::= IF EXISTS */ - { 265, 0 }, /* (69) exists_opt ::= */ - { 264, 0 }, /* (70) db_options ::= */ - { 264, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ - { 264, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ - { 264, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ - { 264, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ - { 264, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ - { 264, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ - { 264, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ - { 264, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ - { 264, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ - { 264, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ - { 264, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ - { 264, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 264, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ - { 264, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ - { 264, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ - { 264, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ - { 264, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ - { 264, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 264, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ - { 264, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 266, -1 }, /* (91) alter_db_options ::= alter_db_option */ - { 266, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ - { 270, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ - { 270, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ - { 270, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ - { 270, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ - { 270, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ - { 270, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ - { 270, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ - { 270, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ - { 270, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ - { 267, -1 }, /* (102) integer_list ::= NK_INTEGER */ - { 267, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 268, -1 }, /* (104) variable_list ::= NK_VARIABLE */ - { 268, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 269, -1 }, /* (106) retention_list ::= retention */ - { 269, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ - { 271, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 250, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 250, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ - { 250, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 250, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ - { 250, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ - { 250, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ - { 250, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ - { 279, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ - { 279, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 279, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 279, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 279, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 279, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 279, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 279, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 279, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 279, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 276, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ - { 276, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 284, -10 }, /* (128) 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 */ - { 278, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ - { 278, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 287, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ - { 285, 0 }, /* (132) specific_tags_opt ::= */ - { 285, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 272, -1 }, /* (134) full_table_name ::= table_name */ - { 272, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ - { 273, -1 }, /* (136) column_def_list ::= column_def */ - { 273, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ - { 290, -2 }, /* (138) column_def ::= column_name type_name */ - { 290, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ - { 282, -1 }, /* (140) type_name ::= BOOL */ - { 282, -1 }, /* (141) type_name ::= TINYINT */ - { 282, -1 }, /* (142) type_name ::= SMALLINT */ - { 282, -1 }, /* (143) type_name ::= INT */ - { 282, -1 }, /* (144) type_name ::= INTEGER */ - { 282, -1 }, /* (145) type_name ::= BIGINT */ - { 282, -1 }, /* (146) type_name ::= FLOAT */ - { 282, -1 }, /* (147) type_name ::= DOUBLE */ - { 282, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 282, -1 }, /* (149) type_name ::= TIMESTAMP */ - { 282, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 282, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ - { 282, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ - { 282, -2 }, /* (153) type_name ::= INT UNSIGNED */ - { 282, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ - { 282, -1 }, /* (155) type_name ::= JSON */ - { 282, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 282, -1 }, /* (157) type_name ::= MEDIUMBLOB */ - { 282, -1 }, /* (158) type_name ::= BLOB */ - { 282, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 282, -1 }, /* (160) type_name ::= DECIMAL */ - { 282, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 282, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 274, 0 }, /* (163) tags_def_opt ::= */ - { 274, -1 }, /* (164) tags_def_opt ::= tags_def */ - { 277, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 275, 0 }, /* (166) table_options ::= */ - { 275, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ - { 275, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ - { 275, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ - { 275, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 275, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ - { 275, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 280, -1 }, /* (173) alter_table_options ::= alter_table_option */ - { 280, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ - { 293, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ - { 293, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ - { 291, -1 }, /* (177) duration_list ::= duration_literal */ - { 291, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ - { 292, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ - { 292, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 295, -1 }, /* (181) rollup_func_name ::= function_name */ - { 295, -1 }, /* (182) rollup_func_name ::= FIRST */ - { 295, -1 }, /* (183) rollup_func_name ::= LAST */ - { 288, -1 }, /* (184) col_name_list ::= col_name */ - { 288, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ - { 297, -1 }, /* (186) col_name ::= column_name */ - { 250, -2 }, /* (187) cmd ::= SHOW DNODES */ - { 250, -2 }, /* (188) cmd ::= SHOW USERS */ - { 250, -2 }, /* (189) cmd ::= SHOW DATABASES */ - { 250, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 250, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 250, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 250, -2 }, /* (193) cmd ::= SHOW MNODES */ - { 250, -2 }, /* (194) cmd ::= SHOW MODULES */ - { 250, -2 }, /* (195) cmd ::= SHOW QNODES */ - { 250, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ - { 250, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 250, -2 }, /* (198) cmd ::= SHOW STREAMS */ - { 250, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ - { 250, -2 }, /* (200) cmd ::= SHOW APPS */ - { 250, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ - { 250, -2 }, /* (202) cmd ::= SHOW LICENCE */ - { 250, -2 }, /* (203) cmd ::= SHOW GRANTS */ - { 250, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ - { 250, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ - { 250, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ - { 250, -2 }, /* (207) cmd ::= SHOW QUERIES */ - { 250, -2 }, /* (208) cmd ::= SHOW SCORES */ - { 250, -2 }, /* (209) cmd ::= SHOW TOPICS */ - { 250, -2 }, /* (210) cmd ::= SHOW VARIABLES */ - { 250, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ - { 250, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 250, -2 }, /* (213) cmd ::= SHOW BNODES */ - { 250, -2 }, /* (214) cmd ::= SHOW SNODES */ - { 250, -2 }, /* (215) cmd ::= SHOW CLUSTER */ - { 250, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ - { 250, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 250, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ - { 250, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ - { 298, 0 }, /* (220) db_name_cond_opt ::= */ - { 298, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ - { 299, 0 }, /* (222) like_pattern_opt ::= */ - { 299, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ - { 300, -1 }, /* (224) table_name_cond ::= table_name */ - { 301, 0 }, /* (225) from_db_opt ::= */ - { 301, -2 }, /* (226) from_db_opt ::= FROM db_name */ - { 250, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 250, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ - { 303, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 303, -12 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - { 304, -1 }, /* (231) func_list ::= func */ - { 304, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ - { 307, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ - { 306, 0 }, /* (234) sma_stream_opt ::= */ - { 306, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 306, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 250, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 250, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 250, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 250, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 250, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 250, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ - { 250, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 250, -2 }, /* (244) cmd ::= DESC full_table_name */ - { 250, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ - { 250, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ - { 250, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 313, 0 }, /* (248) analyze_opt ::= */ - { 313, -1 }, /* (249) analyze_opt ::= ANALYZE */ - { 314, 0 }, /* (250) explain_options ::= */ - { 314, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 314, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ - { 250, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 250, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 250, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ - { 315, 0 }, /* (256) agg_func_opt ::= */ - { 315, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ - { 316, 0 }, /* (258) bufsize_opt ::= */ - { 316, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 250, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 250, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ - { 318, 0 }, /* (262) into_opt ::= */ - { 318, -2 }, /* (263) into_opt ::= INTO full_table_name */ - { 309, 0 }, /* (264) stream_options ::= */ - { 309, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 309, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 309, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 309, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ - { 250, -3 }, /* (269) cmd ::= KILL CONNECTION NK_INTEGER */ - { 250, -3 }, /* (270) cmd ::= KILL QUERY NK_STRING */ - { 250, -3 }, /* (271) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 250, -2 }, /* (272) cmd ::= BALANCE VGROUP */ - { 250, -4 }, /* (273) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 250, -4 }, /* (274) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 250, -3 }, /* (275) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 319, -2 }, /* (276) dnode_list ::= DNODE NK_INTEGER */ - { 319, -3 }, /* (277) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 250, -3 }, /* (278) cmd ::= SYNCDB db_name REPLICA */ - { 250, -4 }, /* (279) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 250, -1 }, /* (280) cmd ::= query_expression */ - { 253, -1 }, /* (281) literal ::= NK_INTEGER */ - { 253, -1 }, /* (282) literal ::= NK_FLOAT */ - { 253, -1 }, /* (283) literal ::= NK_STRING */ - { 253, -1 }, /* (284) literal ::= NK_BOOL */ - { 253, -2 }, /* (285) literal ::= TIMESTAMP NK_STRING */ - { 253, -1 }, /* (286) literal ::= duration_literal */ - { 253, -1 }, /* (287) literal ::= NULL */ - { 253, -1 }, /* (288) literal ::= NK_QUESTION */ - { 294, -1 }, /* (289) duration_literal ::= NK_VARIABLE */ - { 321, -1 }, /* (290) signed ::= NK_INTEGER */ - { 321, -2 }, /* (291) signed ::= NK_PLUS NK_INTEGER */ - { 321, -2 }, /* (292) signed ::= NK_MINUS NK_INTEGER */ - { 321, -1 }, /* (293) signed ::= NK_FLOAT */ - { 321, -2 }, /* (294) signed ::= NK_PLUS NK_FLOAT */ - { 321, -2 }, /* (295) signed ::= NK_MINUS NK_FLOAT */ - { 283, -1 }, /* (296) signed_literal ::= signed */ - { 283, -1 }, /* (297) signed_literal ::= NK_STRING */ - { 283, -1 }, /* (298) signed_literal ::= NK_BOOL */ - { 283, -2 }, /* (299) signed_literal ::= TIMESTAMP NK_STRING */ - { 283, -1 }, /* (300) signed_literal ::= duration_literal */ - { 283, -1 }, /* (301) signed_literal ::= NULL */ - { 283, -1 }, /* (302) signed_literal ::= literal_func */ - { 286, -1 }, /* (303) literal_list ::= signed_literal */ - { 286, -3 }, /* (304) literal_list ::= literal_list NK_COMMA signed_literal */ - { 261, -1 }, /* (305) db_name ::= NK_ID */ - { 289, -1 }, /* (306) table_name ::= NK_ID */ - { 281, -1 }, /* (307) column_name ::= NK_ID */ - { 296, -1 }, /* (308) function_name ::= NK_ID */ - { 323, -1 }, /* (309) table_alias ::= NK_ID */ - { 324, -1 }, /* (310) column_alias ::= NK_ID */ - { 255, -1 }, /* (311) user_name ::= NK_ID */ - { 302, -1 }, /* (312) index_name ::= NK_ID */ - { 310, -1 }, /* (313) topic_name ::= NK_ID */ - { 317, -1 }, /* (314) stream_name ::= NK_ID */ - { 312, -1 }, /* (315) cgroup_name ::= NK_ID */ - { 325, -1 }, /* (316) expression ::= literal */ - { 325, -1 }, /* (317) expression ::= pseudo_column */ - { 325, -1 }, /* (318) expression ::= column_reference */ - { 325, -1 }, /* (319) expression ::= function_expression */ - { 325, -1 }, /* (320) expression ::= subquery */ - { 325, -3 }, /* (321) expression ::= NK_LP expression NK_RP */ - { 325, -2 }, /* (322) expression ::= NK_PLUS expression */ - { 325, -2 }, /* (323) expression ::= NK_MINUS expression */ - { 325, -3 }, /* (324) expression ::= expression NK_PLUS expression */ - { 325, -3 }, /* (325) expression ::= expression NK_MINUS expression */ - { 325, -3 }, /* (326) expression ::= expression NK_STAR expression */ - { 325, -3 }, /* (327) expression ::= expression NK_SLASH expression */ - { 325, -3 }, /* (328) expression ::= expression NK_REM expression */ - { 325, -3 }, /* (329) expression ::= column_reference NK_ARROW NK_STRING */ - { 325, -3 }, /* (330) expression ::= expression NK_BITAND expression */ - { 325, -3 }, /* (331) expression ::= expression NK_BITOR expression */ - { 308, -1 }, /* (332) expression_list ::= expression */ - { 308, -3 }, /* (333) expression_list ::= expression_list NK_COMMA expression */ - { 327, -1 }, /* (334) column_reference ::= column_name */ - { 327, -3 }, /* (335) column_reference ::= table_name NK_DOT column_name */ - { 326, -1 }, /* (336) pseudo_column ::= ROWTS */ - { 326, -1 }, /* (337) pseudo_column ::= TBNAME */ - { 326, -3 }, /* (338) pseudo_column ::= table_name NK_DOT TBNAME */ - { 326, -1 }, /* (339) pseudo_column ::= QSTARTTS */ - { 326, -1 }, /* (340) pseudo_column ::= QENDTS */ - { 326, -1 }, /* (341) pseudo_column ::= WSTARTTS */ - { 326, -1 }, /* (342) pseudo_column ::= WENDTS */ - { 326, -1 }, /* (343) pseudo_column ::= WDURATION */ - { 328, -4 }, /* (344) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 328, -4 }, /* (345) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 328, -6 }, /* (346) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 328, -1 }, /* (347) function_expression ::= literal_func */ - { 322, -3 }, /* (348) literal_func ::= noarg_func NK_LP NK_RP */ - { 322, -1 }, /* (349) literal_func ::= NOW */ - { 332, -1 }, /* (350) noarg_func ::= NOW */ - { 332, -1 }, /* (351) noarg_func ::= TODAY */ - { 332, -1 }, /* (352) noarg_func ::= TIMEZONE */ - { 332, -1 }, /* (353) noarg_func ::= DATABASE */ - { 332, -1 }, /* (354) noarg_func ::= CLIENT_VERSION */ - { 332, -1 }, /* (355) noarg_func ::= SERVER_VERSION */ - { 332, -1 }, /* (356) noarg_func ::= SERVER_STATUS */ - { 332, -1 }, /* (357) noarg_func ::= CURRENT_USER */ - { 332, -1 }, /* (358) noarg_func ::= USER */ - { 330, -1 }, /* (359) star_func ::= COUNT */ - { 330, -1 }, /* (360) star_func ::= FIRST */ - { 330, -1 }, /* (361) star_func ::= LAST */ - { 330, -1 }, /* (362) star_func ::= LAST_ROW */ - { 331, -1 }, /* (363) star_func_para_list ::= NK_STAR */ - { 331, -1 }, /* (364) star_func_para_list ::= other_para_list */ - { 333, -1 }, /* (365) other_para_list ::= star_func_para */ - { 333, -3 }, /* (366) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 334, -1 }, /* (367) star_func_para ::= expression */ - { 334, -3 }, /* (368) star_func_para ::= table_name NK_DOT NK_STAR */ - { 335, -3 }, /* (369) predicate ::= expression compare_op expression */ - { 335, -5 }, /* (370) predicate ::= expression BETWEEN expression AND expression */ - { 335, -6 }, /* (371) predicate ::= expression NOT BETWEEN expression AND expression */ - { 335, -3 }, /* (372) predicate ::= expression IS NULL */ - { 335, -4 }, /* (373) predicate ::= expression IS NOT NULL */ - { 335, -3 }, /* (374) predicate ::= expression in_op in_predicate_value */ - { 336, -1 }, /* (375) compare_op ::= NK_LT */ - { 336, -1 }, /* (376) compare_op ::= NK_GT */ - { 336, -1 }, /* (377) compare_op ::= NK_LE */ - { 336, -1 }, /* (378) compare_op ::= NK_GE */ - { 336, -1 }, /* (379) compare_op ::= NK_NE */ - { 336, -1 }, /* (380) compare_op ::= NK_EQ */ - { 336, -1 }, /* (381) compare_op ::= LIKE */ - { 336, -2 }, /* (382) compare_op ::= NOT LIKE */ - { 336, -1 }, /* (383) compare_op ::= MATCH */ - { 336, -1 }, /* (384) compare_op ::= NMATCH */ - { 336, -1 }, /* (385) compare_op ::= CONTAINS */ - { 337, -1 }, /* (386) in_op ::= IN */ - { 337, -2 }, /* (387) in_op ::= NOT IN */ - { 338, -3 }, /* (388) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 339, -1 }, /* (389) boolean_value_expression ::= boolean_primary */ - { 339, -2 }, /* (390) boolean_value_expression ::= NOT boolean_primary */ - { 339, -3 }, /* (391) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 339, -3 }, /* (392) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 340, -1 }, /* (393) boolean_primary ::= predicate */ - { 340, -3 }, /* (394) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 341, -1 }, /* (395) common_expression ::= expression */ - { 341, -1 }, /* (396) common_expression ::= boolean_value_expression */ - { 342, 0 }, /* (397) from_clause_opt ::= */ - { 342, -2 }, /* (398) from_clause_opt ::= FROM table_reference_list */ - { 343, -1 }, /* (399) table_reference_list ::= table_reference */ - { 343, -3 }, /* (400) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 344, -1 }, /* (401) table_reference ::= table_primary */ - { 344, -1 }, /* (402) table_reference ::= joined_table */ - { 345, -2 }, /* (403) table_primary ::= table_name alias_opt */ - { 345, -4 }, /* (404) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 345, -2 }, /* (405) table_primary ::= subquery alias_opt */ - { 345, -1 }, /* (406) table_primary ::= parenthesized_joined_table */ - { 347, 0 }, /* (407) alias_opt ::= */ - { 347, -1 }, /* (408) alias_opt ::= table_alias */ - { 347, -2 }, /* (409) alias_opt ::= AS table_alias */ - { 348, -3 }, /* (410) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 348, -3 }, /* (411) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 346, -6 }, /* (412) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 349, 0 }, /* (413) join_type ::= */ - { 349, -1 }, /* (414) join_type ::= INNER */ - { 351, -12 }, /* (415) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 352, 0 }, /* (416) set_quantifier_opt ::= */ - { 352, -1 }, /* (417) set_quantifier_opt ::= DISTINCT */ - { 352, -1 }, /* (418) set_quantifier_opt ::= ALL */ - { 353, -1 }, /* (419) select_list ::= NK_STAR */ - { 353, -1 }, /* (420) select_list ::= select_sublist */ - { 361, -1 }, /* (421) select_sublist ::= select_item */ - { 361, -3 }, /* (422) select_sublist ::= select_sublist NK_COMMA select_item */ - { 362, -1 }, /* (423) select_item ::= common_expression */ - { 362, -2 }, /* (424) select_item ::= common_expression column_alias */ - { 362, -3 }, /* (425) select_item ::= common_expression AS column_alias */ - { 362, -3 }, /* (426) select_item ::= table_name NK_DOT NK_STAR */ - { 320, 0 }, /* (427) where_clause_opt ::= */ - { 320, -2 }, /* (428) where_clause_opt ::= WHERE search_condition */ - { 354, 0 }, /* (429) partition_by_clause_opt ::= */ - { 354, -3 }, /* (430) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 358, 0 }, /* (431) twindow_clause_opt ::= */ - { 358, -6 }, /* (432) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 358, -4 }, /* (433) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 358, -6 }, /* (434) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 358, -8 }, /* (435) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 305, 0 }, /* (436) sliding_opt ::= */ - { 305, -4 }, /* (437) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 357, 0 }, /* (438) fill_opt ::= */ - { 357, -4 }, /* (439) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 357, -6 }, /* (440) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 363, -1 }, /* (441) fill_mode ::= NONE */ - { 363, -1 }, /* (442) fill_mode ::= PREV */ - { 363, -1 }, /* (443) fill_mode ::= NULL */ - { 363, -1 }, /* (444) fill_mode ::= LINEAR */ - { 363, -1 }, /* (445) fill_mode ::= NEXT */ - { 359, 0 }, /* (446) group_by_clause_opt ::= */ - { 359, -3 }, /* (447) group_by_clause_opt ::= GROUP BY group_by_list */ - { 364, -1 }, /* (448) group_by_list ::= expression */ - { 364, -3 }, /* (449) group_by_list ::= group_by_list NK_COMMA expression */ - { 360, 0 }, /* (450) having_clause_opt ::= */ - { 360, -2 }, /* (451) having_clause_opt ::= HAVING search_condition */ - { 355, 0 }, /* (452) range_opt ::= */ - { 355, -6 }, /* (453) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 356, 0 }, /* (454) every_opt ::= */ - { 356, -4 }, /* (455) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 311, -4 }, /* (456) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 365, -1 }, /* (457) query_expression_body ::= query_primary */ - { 365, -4 }, /* (458) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 365, -3 }, /* (459) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 369, -1 }, /* (460) query_primary ::= query_specification */ - { 369, -6 }, /* (461) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 366, 0 }, /* (462) order_by_clause_opt ::= */ - { 366, -3 }, /* (463) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 367, 0 }, /* (464) slimit_clause_opt ::= */ - { 367, -2 }, /* (465) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 367, -4 }, /* (466) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 367, -4 }, /* (467) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 368, 0 }, /* (468) limit_clause_opt ::= */ - { 368, -2 }, /* (469) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 368, -4 }, /* (470) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 368, -4 }, /* (471) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 329, -3 }, /* (472) subquery ::= NK_LP query_expression NK_RP */ - { 350, -1 }, /* (473) search_condition ::= common_expression */ - { 370, -1 }, /* (474) sort_specification_list ::= sort_specification */ - { 370, -3 }, /* (475) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 371, -3 }, /* (476) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 372, 0 }, /* (477) ordering_specification_opt ::= */ - { 372, -1 }, /* (478) ordering_specification_opt ::= ASC */ - { 372, -1 }, /* (479) ordering_specification_opt ::= DESC */ - { 373, 0 }, /* (480) null_ordering_opt ::= */ - { 373, -2 }, /* (481) null_ordering_opt ::= NULLS FIRST */ - { 373, -2 }, /* (482) null_ordering_opt ::= NULLS LAST */ + { 252, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 252, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 253, 0 }, /* (2) account_options ::= */ + { 253, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 253, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 253, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 253, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 253, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 253, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 253, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 253, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 253, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 254, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 254, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 256, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 256, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 256, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 256, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 256, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 256, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 256, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 256, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 256, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 256, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 252, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 252, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 252, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 252, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 252, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 258, 0 }, /* (29) sysinfo_opt ::= */ + { 258, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 252, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 252, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 259, -1 }, /* (33) privileges ::= ALL */ + { 259, -1 }, /* (34) privileges ::= priv_type_list */ + { 261, -1 }, /* (35) priv_type_list ::= priv_type */ + { 261, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 262, -1 }, /* (37) priv_type ::= READ */ + { 262, -1 }, /* (38) priv_type ::= WRITE */ + { 260, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 260, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 252, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 252, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 252, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 252, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 252, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 252, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 252, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 252, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 264, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 264, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 264, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 252, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 252, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 252, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 252, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 252, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 252, -2 }, /* (64) cmd ::= USE db_name */ + { 252, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 265, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ + { 265, 0 }, /* (67) not_exists_opt ::= */ + { 267, -2 }, /* (68) exists_opt ::= IF EXISTS */ + { 267, 0 }, /* (69) exists_opt ::= */ + { 266, 0 }, /* (70) db_options ::= */ + { 266, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ + { 266, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ + { 266, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ + { 266, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ + { 266, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ + { 266, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ + { 266, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ + { 266, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ + { 266, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ + { 266, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ + { 266, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ + { 266, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 266, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ + { 266, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ + { 266, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ + { 266, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ + { 266, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ + { 266, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 266, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ + { 266, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 268, -1 }, /* (91) alter_db_options ::= alter_db_option */ + { 268, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ + { 272, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ + { 272, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ + { 272, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ + { 272, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ + { 272, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ + { 272, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ + { 272, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ + { 272, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ + { 272, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ + { 269, -1 }, /* (102) integer_list ::= NK_INTEGER */ + { 269, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 270, -1 }, /* (104) variable_list ::= NK_VARIABLE */ + { 270, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 271, -1 }, /* (106) retention_list ::= retention */ + { 271, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ + { 273, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 252, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 252, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ + { 252, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 252, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ + { 252, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ + { 252, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ + { 252, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ + { 281, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ + { 281, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 281, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 281, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 281, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 281, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 281, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 281, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 281, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 281, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 278, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ + { 278, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 286, -10 }, /* (128) 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 */ + { 280, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ + { 280, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 289, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ + { 287, 0 }, /* (132) specific_tags_opt ::= */ + { 287, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 274, -1 }, /* (134) full_table_name ::= table_name */ + { 274, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ + { 275, -1 }, /* (136) column_def_list ::= column_def */ + { 275, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ + { 292, -2 }, /* (138) column_def ::= column_name type_name */ + { 292, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ + { 284, -1 }, /* (140) type_name ::= BOOL */ + { 284, -1 }, /* (141) type_name ::= TINYINT */ + { 284, -1 }, /* (142) type_name ::= SMALLINT */ + { 284, -1 }, /* (143) type_name ::= INT */ + { 284, -1 }, /* (144) type_name ::= INTEGER */ + { 284, -1 }, /* (145) type_name ::= BIGINT */ + { 284, -1 }, /* (146) type_name ::= FLOAT */ + { 284, -1 }, /* (147) type_name ::= DOUBLE */ + { 284, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 284, -1 }, /* (149) type_name ::= TIMESTAMP */ + { 284, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 284, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ + { 284, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ + { 284, -2 }, /* (153) type_name ::= INT UNSIGNED */ + { 284, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ + { 284, -1 }, /* (155) type_name ::= JSON */ + { 284, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 284, -1 }, /* (157) type_name ::= MEDIUMBLOB */ + { 284, -1 }, /* (158) type_name ::= BLOB */ + { 284, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 284, -1 }, /* (160) type_name ::= DECIMAL */ + { 284, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 284, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 276, 0 }, /* (163) tags_def_opt ::= */ + { 276, -1 }, /* (164) tags_def_opt ::= tags_def */ + { 279, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 277, 0 }, /* (166) table_options ::= */ + { 277, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ + { 277, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ + { 277, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ + { 277, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 277, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ + { 277, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 282, -1 }, /* (173) alter_table_options ::= alter_table_option */ + { 282, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ + { 295, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ + { 295, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ + { 293, -1 }, /* (177) duration_list ::= duration_literal */ + { 293, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ + { 294, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ + { 294, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 297, -1 }, /* (181) rollup_func_name ::= function_name */ + { 297, -1 }, /* (182) rollup_func_name ::= FIRST */ + { 297, -1 }, /* (183) rollup_func_name ::= LAST */ + { 290, -1 }, /* (184) col_name_list ::= col_name */ + { 290, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ + { 299, -1 }, /* (186) col_name ::= column_name */ + { 252, -2 }, /* (187) cmd ::= SHOW DNODES */ + { 252, -2 }, /* (188) cmd ::= SHOW USERS */ + { 252, -2 }, /* (189) cmd ::= SHOW DATABASES */ + { 252, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 252, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 252, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 252, -2 }, /* (193) cmd ::= SHOW MNODES */ + { 252, -2 }, /* (194) cmd ::= SHOW MODULES */ + { 252, -2 }, /* (195) cmd ::= SHOW QNODES */ + { 252, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ + { 252, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 252, -2 }, /* (198) cmd ::= SHOW STREAMS */ + { 252, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ + { 252, -2 }, /* (200) cmd ::= SHOW APPS */ + { 252, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ + { 252, -2 }, /* (202) cmd ::= SHOW LICENCE */ + { 252, -2 }, /* (203) cmd ::= SHOW GRANTS */ + { 252, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ + { 252, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ + { 252, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ + { 252, -2 }, /* (207) cmd ::= SHOW QUERIES */ + { 252, -2 }, /* (208) cmd ::= SHOW SCORES */ + { 252, -2 }, /* (209) cmd ::= SHOW TOPICS */ + { 252, -2 }, /* (210) cmd ::= SHOW VARIABLES */ + { 252, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ + { 252, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 252, -2 }, /* (213) cmd ::= SHOW BNODES */ + { 252, -2 }, /* (214) cmd ::= SHOW SNODES */ + { 252, -2 }, /* (215) cmd ::= SHOW CLUSTER */ + { 252, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ + { 252, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 252, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ + { 252, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ + { 300, 0 }, /* (220) db_name_cond_opt ::= */ + { 300, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ + { 301, 0 }, /* (222) like_pattern_opt ::= */ + { 301, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ + { 302, -1 }, /* (224) table_name_cond ::= table_name */ + { 303, 0 }, /* (225) from_db_opt ::= */ + { 303, -2 }, /* (226) from_db_opt ::= FROM db_name */ + { 252, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 252, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ + { 305, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 305, -12 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 306, -1 }, /* (231) func_list ::= func */ + { 306, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ + { 309, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ + { 308, 0 }, /* (234) sma_stream_opt ::= */ + { 308, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 308, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 252, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 252, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 252, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 252, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 252, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 252, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ + { 252, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 252, -2 }, /* (244) cmd ::= DESC full_table_name */ + { 252, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ + { 252, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ + { 252, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 315, 0 }, /* (248) analyze_opt ::= */ + { 315, -1 }, /* (249) analyze_opt ::= ANALYZE */ + { 316, 0 }, /* (250) explain_options ::= */ + { 316, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 316, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ + { 252, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 252, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 252, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ + { 317, 0 }, /* (256) agg_func_opt ::= */ + { 317, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ + { 318, 0 }, /* (258) bufsize_opt ::= */ + { 318, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 252, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 252, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ + { 320, 0 }, /* (262) into_opt ::= */ + { 320, -2 }, /* (263) into_opt ::= INTO full_table_name */ + { 311, 0 }, /* (264) stream_options ::= */ + { 311, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 311, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 311, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 311, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ + { 311, -3 }, /* (269) stream_options ::= stream_options IGNORE EXPIRED */ + { 252, -3 }, /* (270) cmd ::= KILL CONNECTION NK_INTEGER */ + { 252, -3 }, /* (271) cmd ::= KILL QUERY NK_STRING */ + { 252, -3 }, /* (272) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 252, -2 }, /* (273) cmd ::= BALANCE VGROUP */ + { 252, -4 }, /* (274) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 252, -4 }, /* (275) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 252, -3 }, /* (276) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 321, -2 }, /* (277) dnode_list ::= DNODE NK_INTEGER */ + { 321, -3 }, /* (278) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 252, -3 }, /* (279) cmd ::= SYNCDB db_name REPLICA */ + { 252, -4 }, /* (280) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 252, -1 }, /* (281) cmd ::= query_expression */ + { 255, -1 }, /* (282) literal ::= NK_INTEGER */ + { 255, -1 }, /* (283) literal ::= NK_FLOAT */ + { 255, -1 }, /* (284) literal ::= NK_STRING */ + { 255, -1 }, /* (285) literal ::= NK_BOOL */ + { 255, -2 }, /* (286) literal ::= TIMESTAMP NK_STRING */ + { 255, -1 }, /* (287) literal ::= duration_literal */ + { 255, -1 }, /* (288) literal ::= NULL */ + { 255, -1 }, /* (289) literal ::= NK_QUESTION */ + { 296, -1 }, /* (290) duration_literal ::= NK_VARIABLE */ + { 323, -1 }, /* (291) signed ::= NK_INTEGER */ + { 323, -2 }, /* (292) signed ::= NK_PLUS NK_INTEGER */ + { 323, -2 }, /* (293) signed ::= NK_MINUS NK_INTEGER */ + { 323, -1 }, /* (294) signed ::= NK_FLOAT */ + { 323, -2 }, /* (295) signed ::= NK_PLUS NK_FLOAT */ + { 323, -2 }, /* (296) signed ::= NK_MINUS NK_FLOAT */ + { 285, -1 }, /* (297) signed_literal ::= signed */ + { 285, -1 }, /* (298) signed_literal ::= NK_STRING */ + { 285, -1 }, /* (299) signed_literal ::= NK_BOOL */ + { 285, -2 }, /* (300) signed_literal ::= TIMESTAMP NK_STRING */ + { 285, -1 }, /* (301) signed_literal ::= duration_literal */ + { 285, -1 }, /* (302) signed_literal ::= NULL */ + { 285, -1 }, /* (303) signed_literal ::= literal_func */ + { 288, -1 }, /* (304) literal_list ::= signed_literal */ + { 288, -3 }, /* (305) literal_list ::= literal_list NK_COMMA signed_literal */ + { 263, -1 }, /* (306) db_name ::= NK_ID */ + { 291, -1 }, /* (307) table_name ::= NK_ID */ + { 283, -1 }, /* (308) column_name ::= NK_ID */ + { 298, -1 }, /* (309) function_name ::= NK_ID */ + { 325, -1 }, /* (310) table_alias ::= NK_ID */ + { 326, -1 }, /* (311) column_alias ::= NK_ID */ + { 257, -1 }, /* (312) user_name ::= NK_ID */ + { 304, -1 }, /* (313) index_name ::= NK_ID */ + { 312, -1 }, /* (314) topic_name ::= NK_ID */ + { 319, -1 }, /* (315) stream_name ::= NK_ID */ + { 314, -1 }, /* (316) cgroup_name ::= NK_ID */ + { 327, -1 }, /* (317) expression ::= literal */ + { 327, -1 }, /* (318) expression ::= pseudo_column */ + { 327, -1 }, /* (319) expression ::= column_reference */ + { 327, -1 }, /* (320) expression ::= function_expression */ + { 327, -1 }, /* (321) expression ::= subquery */ + { 327, -3 }, /* (322) expression ::= NK_LP expression NK_RP */ + { 327, -2 }, /* (323) expression ::= NK_PLUS expression */ + { 327, -2 }, /* (324) expression ::= NK_MINUS expression */ + { 327, -3 }, /* (325) expression ::= expression NK_PLUS expression */ + { 327, -3 }, /* (326) expression ::= expression NK_MINUS expression */ + { 327, -3 }, /* (327) expression ::= expression NK_STAR expression */ + { 327, -3 }, /* (328) expression ::= expression NK_SLASH expression */ + { 327, -3 }, /* (329) expression ::= expression NK_REM expression */ + { 327, -3 }, /* (330) expression ::= column_reference NK_ARROW NK_STRING */ + { 327, -3 }, /* (331) expression ::= expression NK_BITAND expression */ + { 327, -3 }, /* (332) expression ::= expression NK_BITOR expression */ + { 310, -1 }, /* (333) expression_list ::= expression */ + { 310, -3 }, /* (334) expression_list ::= expression_list NK_COMMA expression */ + { 329, -1 }, /* (335) column_reference ::= column_name */ + { 329, -3 }, /* (336) column_reference ::= table_name NK_DOT column_name */ + { 328, -1 }, /* (337) pseudo_column ::= ROWTS */ + { 328, -1 }, /* (338) pseudo_column ::= TBNAME */ + { 328, -3 }, /* (339) pseudo_column ::= table_name NK_DOT TBNAME */ + { 328, -1 }, /* (340) pseudo_column ::= QSTARTTS */ + { 328, -1 }, /* (341) pseudo_column ::= QENDTS */ + { 328, -1 }, /* (342) pseudo_column ::= WSTARTTS */ + { 328, -1 }, /* (343) pseudo_column ::= WENDTS */ + { 328, -1 }, /* (344) pseudo_column ::= WDURATION */ + { 330, -4 }, /* (345) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 330, -4 }, /* (346) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 330, -6 }, /* (347) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 330, -1 }, /* (348) function_expression ::= literal_func */ + { 324, -3 }, /* (349) literal_func ::= noarg_func NK_LP NK_RP */ + { 324, -1 }, /* (350) literal_func ::= NOW */ + { 334, -1 }, /* (351) noarg_func ::= NOW */ + { 334, -1 }, /* (352) noarg_func ::= TODAY */ + { 334, -1 }, /* (353) noarg_func ::= TIMEZONE */ + { 334, -1 }, /* (354) noarg_func ::= DATABASE */ + { 334, -1 }, /* (355) noarg_func ::= CLIENT_VERSION */ + { 334, -1 }, /* (356) noarg_func ::= SERVER_VERSION */ + { 334, -1 }, /* (357) noarg_func ::= SERVER_STATUS */ + { 334, -1 }, /* (358) noarg_func ::= CURRENT_USER */ + { 334, -1 }, /* (359) noarg_func ::= USER */ + { 332, -1 }, /* (360) star_func ::= COUNT */ + { 332, -1 }, /* (361) star_func ::= FIRST */ + { 332, -1 }, /* (362) star_func ::= LAST */ + { 332, -1 }, /* (363) star_func ::= LAST_ROW */ + { 333, -1 }, /* (364) star_func_para_list ::= NK_STAR */ + { 333, -1 }, /* (365) star_func_para_list ::= other_para_list */ + { 335, -1 }, /* (366) other_para_list ::= star_func_para */ + { 335, -3 }, /* (367) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 336, -1 }, /* (368) star_func_para ::= expression */ + { 336, -3 }, /* (369) star_func_para ::= table_name NK_DOT NK_STAR */ + { 337, -3 }, /* (370) predicate ::= expression compare_op expression */ + { 337, -5 }, /* (371) predicate ::= expression BETWEEN expression AND expression */ + { 337, -6 }, /* (372) predicate ::= expression NOT BETWEEN expression AND expression */ + { 337, -3 }, /* (373) predicate ::= expression IS NULL */ + { 337, -4 }, /* (374) predicate ::= expression IS NOT NULL */ + { 337, -3 }, /* (375) predicate ::= expression in_op in_predicate_value */ + { 338, -1 }, /* (376) compare_op ::= NK_LT */ + { 338, -1 }, /* (377) compare_op ::= NK_GT */ + { 338, -1 }, /* (378) compare_op ::= NK_LE */ + { 338, -1 }, /* (379) compare_op ::= NK_GE */ + { 338, -1 }, /* (380) compare_op ::= NK_NE */ + { 338, -1 }, /* (381) compare_op ::= NK_EQ */ + { 338, -1 }, /* (382) compare_op ::= LIKE */ + { 338, -2 }, /* (383) compare_op ::= NOT LIKE */ + { 338, -1 }, /* (384) compare_op ::= MATCH */ + { 338, -1 }, /* (385) compare_op ::= NMATCH */ + { 338, -1 }, /* (386) compare_op ::= CONTAINS */ + { 339, -1 }, /* (387) in_op ::= IN */ + { 339, -2 }, /* (388) in_op ::= NOT IN */ + { 340, -3 }, /* (389) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 341, -1 }, /* (390) boolean_value_expression ::= boolean_primary */ + { 341, -2 }, /* (391) boolean_value_expression ::= NOT boolean_primary */ + { 341, -3 }, /* (392) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 341, -3 }, /* (393) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 342, -1 }, /* (394) boolean_primary ::= predicate */ + { 342, -3 }, /* (395) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 343, -1 }, /* (396) common_expression ::= expression */ + { 343, -1 }, /* (397) common_expression ::= boolean_value_expression */ + { 344, 0 }, /* (398) from_clause_opt ::= */ + { 344, -2 }, /* (399) from_clause_opt ::= FROM table_reference_list */ + { 345, -1 }, /* (400) table_reference_list ::= table_reference */ + { 345, -3 }, /* (401) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 346, -1 }, /* (402) table_reference ::= table_primary */ + { 346, -1 }, /* (403) table_reference ::= joined_table */ + { 347, -2 }, /* (404) table_primary ::= table_name alias_opt */ + { 347, -4 }, /* (405) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 347, -2 }, /* (406) table_primary ::= subquery alias_opt */ + { 347, -1 }, /* (407) table_primary ::= parenthesized_joined_table */ + { 349, 0 }, /* (408) alias_opt ::= */ + { 349, -1 }, /* (409) alias_opt ::= table_alias */ + { 349, -2 }, /* (410) alias_opt ::= AS table_alias */ + { 350, -3 }, /* (411) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 350, -3 }, /* (412) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 348, -6 }, /* (413) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 351, 0 }, /* (414) join_type ::= */ + { 351, -1 }, /* (415) join_type ::= INNER */ + { 353, -12 }, /* (416) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 354, 0 }, /* (417) set_quantifier_opt ::= */ + { 354, -1 }, /* (418) set_quantifier_opt ::= DISTINCT */ + { 354, -1 }, /* (419) set_quantifier_opt ::= ALL */ + { 355, -1 }, /* (420) select_list ::= select_item */ + { 355, -3 }, /* (421) select_list ::= select_list NK_COMMA select_item */ + { 363, -1 }, /* (422) select_item ::= NK_STAR */ + { 363, -1 }, /* (423) select_item ::= common_expression */ + { 363, -2 }, /* (424) select_item ::= common_expression column_alias */ + { 363, -3 }, /* (425) select_item ::= common_expression AS column_alias */ + { 363, -3 }, /* (426) select_item ::= table_name NK_DOT NK_STAR */ + { 322, 0 }, /* (427) where_clause_opt ::= */ + { 322, -2 }, /* (428) where_clause_opt ::= WHERE search_condition */ + { 356, 0 }, /* (429) partition_by_clause_opt ::= */ + { 356, -3 }, /* (430) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 360, 0 }, /* (431) twindow_clause_opt ::= */ + { 360, -6 }, /* (432) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 360, -4 }, /* (433) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 360, -6 }, /* (434) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 360, -8 }, /* (435) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 307, 0 }, /* (436) sliding_opt ::= */ + { 307, -4 }, /* (437) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 359, 0 }, /* (438) fill_opt ::= */ + { 359, -4 }, /* (439) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 359, -6 }, /* (440) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 364, -1 }, /* (441) fill_mode ::= NONE */ + { 364, -1 }, /* (442) fill_mode ::= PREV */ + { 364, -1 }, /* (443) fill_mode ::= NULL */ + { 364, -1 }, /* (444) fill_mode ::= LINEAR */ + { 364, -1 }, /* (445) fill_mode ::= NEXT */ + { 361, 0 }, /* (446) group_by_clause_opt ::= */ + { 361, -3 }, /* (447) group_by_clause_opt ::= GROUP BY group_by_list */ + { 365, -1 }, /* (448) group_by_list ::= expression */ + { 365, -3 }, /* (449) group_by_list ::= group_by_list NK_COMMA expression */ + { 362, 0 }, /* (450) having_clause_opt ::= */ + { 362, -2 }, /* (451) having_clause_opt ::= HAVING search_condition */ + { 357, 0 }, /* (452) range_opt ::= */ + { 357, -6 }, /* (453) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 358, 0 }, /* (454) every_opt ::= */ + { 358, -4 }, /* (455) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 313, -4 }, /* (456) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 366, -1 }, /* (457) query_expression_body ::= query_primary */ + { 366, -4 }, /* (458) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 366, -3 }, /* (459) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 370, -1 }, /* (460) query_primary ::= query_specification */ + { 370, -6 }, /* (461) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 367, 0 }, /* (462) order_by_clause_opt ::= */ + { 367, -3 }, /* (463) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 368, 0 }, /* (464) slimit_clause_opt ::= */ + { 368, -2 }, /* (465) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 368, -4 }, /* (466) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 368, -4 }, /* (467) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 369, 0 }, /* (468) limit_clause_opt ::= */ + { 369, -2 }, /* (469) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 369, -4 }, /* (470) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 369, -4 }, /* (471) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 331, -3 }, /* (472) subquery ::= NK_LP query_expression NK_RP */ + { 352, -1 }, /* (473) search_condition ::= common_expression */ + { 371, -1 }, /* (474) sort_specification_list ::= sort_specification */ + { 371, -3 }, /* (475) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 372, -3 }, /* (476) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 373, 0 }, /* (477) ordering_specification_opt ::= */ + { 373, -1 }, /* (478) ordering_specification_opt ::= ASC */ + { 373, -1 }, /* (479) ordering_specification_opt ::= DESC */ + { 374, 0 }, /* (480) null_ordering_opt ::= */ + { 374, -2 }, /* (481) null_ordering_opt ::= NULLS FIRST */ + { 374, -2 }, /* (482) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3280,11 +3280,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,251,&yymsp[0].minor); + yy_destructor(yypParser,253,&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,252,&yymsp[0].minor); + yy_destructor(yypParser,254,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3298,20 +3298,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,251,&yymsp[-2].minor); +{ yy_destructor(yypParser,253,&yymsp[-2].minor); { } - yy_destructor(yypParser,253,&yymsp[0].minor); + yy_destructor(yypParser,255,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,254,&yymsp[0].minor); +{ yy_destructor(yypParser,256,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,252,&yymsp[-1].minor); +{ yy_destructor(yypParser,254,&yymsp[-1].minor); { } - yy_destructor(yypParser,254,&yymsp[0].minor); + yy_destructor(yypParser,256,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3325,72 +3325,72 @@ 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,253,&yymsp[0].minor); + yy_destructor(yypParser,255,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy0, yymsp[0].minor.yy619); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy329, &yymsp[-1].minor.yy0, yymsp[0].minor.yy653); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy329, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy329, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy329, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy329); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy619 = 1; } +{ yymsp[1].minor.yy653 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy619 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy653 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy701, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy609, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy701, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy609, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy609 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy701 = yymsp[0].minor.yy701; } - yymsp[0].minor.yy701 = yylhsminor.yy701; +{ yylhsminor.yy609 = yymsp[0].minor.yy609; } + yymsp[0].minor.yy609 = yylhsminor.yy609; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy701 = yymsp[-2].minor.yy701 | yymsp[0].minor.yy701; } - yymsp[-2].minor.yy701 = yylhsminor.yy701; +{ yylhsminor.yy609 = yymsp[-2].minor.yy609 | yymsp[0].minor.yy609; } + yymsp[-2].minor.yy609 = yylhsminor.yy609; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy609 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy609 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy657 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy657 = yylhsminor.yy657; +{ yylhsminor.yy329 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy329 = yylhsminor.yy329; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy657 = yymsp[-2].minor.yy657; } - yymsp[-2].minor.yy657 = yylhsminor.yy657; +{ yylhsminor.yy329 = yymsp[-2].minor.yy329; } + yymsp[-2].minor.yy329 = yylhsminor.yy329; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy657, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy329, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy329); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3407,32 +3407,32 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 305: /* db_name ::= NK_ID */ yytestcase(yyruleno==305); - case 306: /* table_name ::= NK_ID */ yytestcase(yyruleno==306); - case 307: /* column_name ::= NK_ID */ yytestcase(yyruleno==307); - case 308: /* function_name ::= NK_ID */ yytestcase(yyruleno==308); - case 309: /* table_alias ::= NK_ID */ yytestcase(yyruleno==309); - case 310: /* column_alias ::= NK_ID */ yytestcase(yyruleno==310); - case 311: /* user_name ::= NK_ID */ yytestcase(yyruleno==311); - case 312: /* index_name ::= NK_ID */ yytestcase(yyruleno==312); - case 313: /* topic_name ::= NK_ID */ yytestcase(yyruleno==313); - case 314: /* stream_name ::= NK_ID */ yytestcase(yyruleno==314); - case 315: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==315); - case 350: /* noarg_func ::= NOW */ yytestcase(yyruleno==350); - case 351: /* noarg_func ::= TODAY */ yytestcase(yyruleno==351); - case 352: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==352); - case 353: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==353); - case 354: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==354); - case 355: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==355); - case 356: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==356); - case 357: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==357); - case 358: /* noarg_func ::= USER */ yytestcase(yyruleno==358); - case 359: /* star_func ::= COUNT */ yytestcase(yyruleno==359); - case 360: /* star_func ::= FIRST */ yytestcase(yyruleno==360); - case 361: /* star_func ::= LAST */ yytestcase(yyruleno==361); - case 362: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==362); -{ yylhsminor.yy657 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy657 = yylhsminor.yy657; + case 306: /* db_name ::= NK_ID */ yytestcase(yyruleno==306); + case 307: /* table_name ::= NK_ID */ yytestcase(yyruleno==307); + case 308: /* column_name ::= NK_ID */ yytestcase(yyruleno==308); + case 309: /* function_name ::= NK_ID */ yytestcase(yyruleno==309); + case 310: /* table_alias ::= NK_ID */ yytestcase(yyruleno==310); + case 311: /* column_alias ::= NK_ID */ yytestcase(yyruleno==311); + case 312: /* user_name ::= NK_ID */ yytestcase(yyruleno==312); + case 313: /* index_name ::= NK_ID */ yytestcase(yyruleno==313); + case 314: /* topic_name ::= NK_ID */ yytestcase(yyruleno==314); + case 315: /* stream_name ::= NK_ID */ yytestcase(yyruleno==315); + case 316: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==316); + case 351: /* noarg_func ::= NOW */ yytestcase(yyruleno==351); + case 352: /* noarg_func ::= TODAY */ yytestcase(yyruleno==352); + case 353: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==353); + case 354: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==354); + case 355: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==355); + case 356: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==356); + case 357: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==357); + case 358: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==358); + case 359: /* noarg_func ::= USER */ yytestcase(yyruleno==359); + case 360: /* star_func ::= COUNT */ yytestcase(yyruleno==360); + case 361: /* star_func ::= FIRST */ yytestcase(yyruleno==361); + case 362: /* star_func ::= LAST */ yytestcase(yyruleno==362); + case 363: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==363); +{ yylhsminor.yy329 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy329 = yylhsminor.yy329; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3465,156 +3465,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy657, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy737, &yymsp[-1].minor.yy329, yymsp[0].minor.yy212); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy737, &yymsp[0].minor.yy329); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy329); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy657, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy329, yymsp[0].minor.yy212); } break; case 66: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy97 = true; } +{ yymsp[-2].minor.yy737 = true; } break; case 67: /* not_exists_opt ::= */ case 69: /* exists_opt ::= */ yytestcase(yyruleno==69); case 248: /* analyze_opt ::= */ yytestcase(yyruleno==248); case 256: /* agg_func_opt ::= */ yytestcase(yyruleno==256); - case 416: /* set_quantifier_opt ::= */ yytestcase(yyruleno==416); -{ yymsp[1].minor.yy97 = false; } + case 417: /* set_quantifier_opt ::= */ yytestcase(yyruleno==417); +{ yymsp[1].minor.yy737 = false; } break; case 68: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy97 = true; } +{ yymsp[-1].minor.yy737 = true; } break; case 70: /* db_options ::= */ -{ yymsp[1].minor.yy652 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy212 = createDefaultDatabaseOptions(pCxt); } break; case 71: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 72: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 73: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 74: /* db_options ::= db_options DURATION NK_INTEGER */ case 75: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==75); -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 76: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 77: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 78: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 79: /* db_options ::= db_options KEEP integer_list */ case 80: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==80); -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_KEEP, yymsp[0].minor.yy24); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_KEEP, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 81: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 82: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 83: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 84: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 85: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 86: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 87: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 88: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 89: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_RETENTIONS, yymsp[0].minor.yy24); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_RETENTIONS, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 90: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setDatabaseOption(pCxt, yymsp[-2].minor.yy212, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 91: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy652 = createAlterDatabaseOptions(pCxt); yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yylhsminor.yy652, &yymsp[0].minor.yy189); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterDatabaseOptions(pCxt); yylhsminor.yy212 = setAlterDatabaseOption(pCxt, yylhsminor.yy212, &yymsp[0].minor.yy245); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 92: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy652, &yymsp[0].minor.yy189); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy212, &yymsp[0].minor.yy245); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 93: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 94: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 95: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= KEEP integer_list */ case 97: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==97); -{ yymsp[-1].minor.yy189.type = DB_OPTION_KEEP; yymsp[-1].minor.yy189.pList = yymsp[0].minor.yy24; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_KEEP; yymsp[-1].minor.yy245.pList = yymsp[0].minor.yy424; } break; case 98: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_PAGES; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_PAGES; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 99: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 100: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_STRICT; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_STRICT; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 101: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = DB_OPTION_WAL; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = DB_OPTION_WAL; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 102: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 277: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==277); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; + case 278: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==278); +{ 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 104: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy24 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 106: /* retention_list ::= retention */ case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); @@ -3623,265 +3623,264 @@ static YYACTIONTYPE yy_reduce( case 179: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==179); case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); case 231: /* func_list ::= func */ yytestcase(yyruleno==231); - case 303: /* literal_list ::= signed_literal */ yytestcase(yyruleno==303); - case 365: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==365); - case 421: /* select_sublist ::= select_item */ yytestcase(yyruleno==421); + case 304: /* literal_list ::= signed_literal */ yytestcase(yyruleno==304); + case 366: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==366); + case 420: /* select_list ::= select_item */ yytestcase(yyruleno==420); case 474: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==474); -{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy652); } - yymsp[0].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = createNodeList(pCxt, yymsp[0].minor.yy212); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 107: /* retention_list ::= retention_list NK_COMMA retention */ case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); case 180: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==180); case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); case 232: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==232); - case 304: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==304); - case 366: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==366); - case 422: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==422); + case 305: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==305); + case 367: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==367); + case 421: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==421); case 475: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==475); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy652); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, yymsp[0].minor.yy212); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy652 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy652, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy737, yymsp[-5].minor.yy212, yymsp[-3].minor.yy424, yymsp[-1].minor.yy424, yymsp[0].minor.yy212); } break; case 110: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 112: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy737, yymsp[0].minor.yy212); } break; case 114: /* cmd ::= ALTER TABLE alter_table_clause */ case 115: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==115); - case 280: /* cmd ::= query_expression */ yytestcase(yyruleno==280); -{ pCxt->pRootNode = yymsp[0].minor.yy652; } + case 281: /* cmd ::= query_expression */ yytestcase(yyruleno==281); +{ pCxt->pRootNode = yymsp[0].minor.yy212; } break; case 116: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy652 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy329, yymsp[0].minor.yy34); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy657); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy212, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy329); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy329, yymsp[0].minor.yy34); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy329, &yymsp[0].minor.yy329); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy329, yymsp[0].minor.yy34); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy657); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy212, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy329); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy329, yymsp[0].minor.yy34); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy212, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy329, &yymsp[0].minor.yy329); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy652 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy652, &yymsp[-2].minor.yy657, yymsp[0].minor.yy652); } - yymsp[-5].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy212, &yymsp[-2].minor.yy329, yymsp[0].minor.yy212); } + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; case 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy652); } - yymsp[-1].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-1].minor.yy424, yymsp[0].minor.yy212); } + yymsp[-1].minor.yy424 = yylhsminor.yy424; break; case 128: /* 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.yy652 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy97, yymsp[-8].minor.yy652, yymsp[-6].minor.yy652, yymsp[-5].minor.yy24, yymsp[-2].minor.yy24, yymsp[0].minor.yy652); } - yymsp[-9].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy737, yymsp[-8].minor.yy212, yymsp[-6].minor.yy212, yymsp[-5].minor.yy424, yymsp[-2].minor.yy424, yymsp[0].minor.yy212); } + yymsp[-9].minor.yy212 = yylhsminor.yy212; break; case 131: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy652 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy652); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createDropTableClause(pCxt, yymsp[-1].minor.yy737, yymsp[0].minor.yy212); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 132: /* specific_tags_opt ::= */ case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); case 429: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==429); case 446: /* group_by_clause_opt ::= */ yytestcase(yyruleno==446); case 462: /* order_by_clause_opt ::= */ yytestcase(yyruleno==462); -{ yymsp[1].minor.yy24 = NULL; } +{ yymsp[1].minor.yy424 = NULL; } break; case 133: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } +{ yymsp[-2].minor.yy424 = yymsp[-1].minor.yy424; } break; case 134: /* full_table_name ::= table_name */ -{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy657, NULL); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy329, NULL); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 135: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657, NULL); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createRealTableNode(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329, NULL); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 138: /* column_def ::= column_name type_name */ -{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48, NULL); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy329, yymsp[0].minor.yy34, NULL); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-2].minor.yy48, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy329, yymsp[-2].minor.yy34, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 140: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 141: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 142: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 143: /* type_name ::= INT */ case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_INT); } break; case 145: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 146: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 147: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 149: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 151: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 152: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 153: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 154: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 155: /* type_name ::= JSON */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 158: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 160: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 164: /* tags_def_opt ::= tags_def */ - case 364: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==364); - case 420: /* select_list ::= select_sublist */ yytestcase(yyruleno==420); -{ yylhsminor.yy24 = yymsp[0].minor.yy24; } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 365: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==365); +{ yylhsminor.yy424 = yymsp[0].minor.yy424; } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } +{ yymsp[-3].minor.yy424 = yymsp[-1].minor.yy424; } break; case 166: /* table_options ::= */ -{ yymsp[1].minor.yy652 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy212 = createDefaultTableOptions(pCxt); } break; case 167: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-2].minor.yy212, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 168: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy24); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-2].minor.yy212, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 169: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy24); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-2].minor.yy212, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy24); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-4].minor.yy212, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 171: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-2].minor.yy212, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_SMA, yymsp[-1].minor.yy24); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-4].minor.yy212, TABLE_OPTION_SMA, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 173: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy652 = createAlterTableOptions(pCxt); yylhsminor.yy652 = setTableOption(pCxt, yylhsminor.yy652, yymsp[0].minor.yy189.type, &yymsp[0].minor.yy189.val); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createAlterTableOptions(pCxt); yylhsminor.yy212 = setTableOption(pCxt, yylhsminor.yy212, yymsp[0].minor.yy245.type, &yymsp[0].minor.yy245.val); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 174: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy189.type, &yymsp[0].minor.yy189.val); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setTableOption(pCxt, yymsp[-1].minor.yy212, yymsp[0].minor.yy245.type, &yymsp[0].minor.yy245.val); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 175: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy189.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 176: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy189.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy245.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy245.val = yymsp[0].minor.yy0; } break; case 177: /* duration_list ::= duration_literal */ - case 332: /* expression_list ::= expression */ yytestcase(yyruleno==332); -{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 333: /* expression_list ::= expression */ yytestcase(yyruleno==333); +{ yylhsminor.yy424 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 333: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==333); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; + case 334: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==334); +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 181: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy657, NULL); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createFunctionNode(pCxt, &yymsp[0].minor.yy329, NULL); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 182: /* rollup_func_name ::= FIRST */ case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); -{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 186: /* col_name ::= column_name */ -{ yylhsminor.yy652 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy657); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy329); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 187: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -3893,13 +3892,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, OP_TYPE_LIKE); } break; case 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, OP_TYPE_LIKE); } break; case 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy652, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy212, NULL, OP_TYPE_LIKE); } break; case 193: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -3914,7 +3913,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy652, yymsp[-1].minor.yy652, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy212, yymsp[-1].minor.yy212, OP_TYPE_EQUAL); } break; case 198: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -3933,13 +3932,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy329); } break; case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy212); } break; case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy212); } break; case 207: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -3972,7 +3971,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy212); } break; case 218: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -3982,15 +3981,15 @@ static YYACTIONTYPE yy_reduce( break; case 220: /* db_name_cond_opt ::= */ case 225: /* from_db_opt ::= */ yytestcase(yyruleno==225); -{ yymsp[1].minor.yy652 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy212 = createDefaultDatabaseCondValue(pCxt); } break; case 221: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy657); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy329); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 222: /* like_pattern_opt ::= */ case 262: /* into_opt ::= */ yytestcase(yyruleno==262); - case 397: /* from_clause_opt ::= */ yytestcase(yyruleno==397); + case 398: /* from_clause_opt ::= */ yytestcase(yyruleno==398); case 427: /* where_clause_opt ::= */ yytestcase(yyruleno==427); case 431: /* twindow_clause_opt ::= */ yytestcase(yyruleno==431); case 436: /* sliding_opt ::= */ yytestcase(yyruleno==436); @@ -4000,680 +3999,685 @@ static YYACTIONTYPE yy_reduce( case 454: /* every_opt ::= */ yytestcase(yyruleno==454); case 464: /* slimit_clause_opt ::= */ yytestcase(yyruleno==464); case 468: /* limit_clause_opt ::= */ yytestcase(yyruleno==468); -{ yymsp[1].minor.yy652 = NULL; } +{ yymsp[1].minor.yy212 = NULL; } break; case 223: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 224: /* table_name_cond ::= table_name */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy657); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy329); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 226: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy657); } +{ yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy329); } break; case 227: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy657, NULL, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy737, &yymsp[-3].minor.yy329, &yymsp[-1].minor.yy329, NULL, yymsp[0].minor.yy212); } break; case 228: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy737, &yymsp[0].minor.yy329); } break; case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy652 = createIndexOption(pCxt, yymsp[-7].minor.yy24, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } +{ yymsp[-9].minor.yy212 = createIndexOption(pCxt, yymsp[-7].minor.yy424, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), NULL, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; case 230: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy652 = createIndexOption(pCxt, yymsp[-9].minor.yy24, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } +{ yymsp[-11].minor.yy212 = createIndexOption(pCxt, yymsp[-9].minor.yy424, releaseRawExprNode(pCxt, yymsp[-5].minor.yy212), releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; case 233: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-1].minor.yy24); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createFunctionNode(pCxt, &yymsp[-3].minor.yy329, yymsp[-1].minor.yy424); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 234: /* sma_stream_opt ::= */ case 264: /* stream_options ::= */ yytestcase(yyruleno==264); -{ yymsp[1].minor.yy652 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy212 = createStreamOptions(pCxt); } break; case 235: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ case 268: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==268); -{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ ((SStreamOptions*)yymsp[-2].minor.yy212)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy212); yylhsminor.yy212 = yymsp[-2].minor.yy212; } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 236: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ ((SStreamOptions*)yymsp[-2].minor.yy212)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy212); yylhsminor.yy212 = yymsp[-2].minor.yy212; } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy657, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy737, &yymsp[-2].minor.yy329, yymsp[0].minor.yy212); } break; case 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, &yymsp[0].minor.yy657, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy737, &yymsp[-3].minor.yy329, &yymsp[0].minor.yy329, false); } break; case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy97, &yymsp[-5].minor.yy657, &yymsp[0].minor.yy657, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy737, &yymsp[-5].minor.yy329, &yymsp[0].minor.yy329, true); } break; case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, yymsp[0].minor.yy652, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy737, &yymsp[-3].minor.yy329, yymsp[0].minor.yy212, false); } break; case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy97, &yymsp[-5].minor.yy657, yymsp[0].minor.yy652, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy737, &yymsp[-5].minor.yy329, yymsp[0].minor.yy212, true); } break; case 242: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy737, &yymsp[0].minor.yy329); } break; case 243: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy737, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329); } break; case 244: /* cmd ::= DESC full_table_name */ case 245: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==245); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy212); } break; case 246: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 247: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy97, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy737, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; case 249: /* analyze_opt ::= ANALYZE */ case 257: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==257); - case 417: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==417); -{ yymsp[0].minor.yy97 = true; } + case 418: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==418); +{ yymsp[0].minor.yy737 = true; } break; case 250: /* explain_options ::= */ -{ yymsp[1].minor.yy652 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy212 = createDefaultExplainOptions(pCxt); } break; case 251: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy652 = setExplainVerbose(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setExplainVerbose(pCxt, yymsp[-2].minor.yy212, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 252: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy652 = setExplainRatio(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setExplainRatio(pCxt, yymsp[-2].minor.yy212, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 253: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy24); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy424); } break; case 254: /* 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.yy97, yymsp[-8].minor.yy97, &yymsp[-5].minor.yy657, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy48, yymsp[0].minor.yy244); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy737, yymsp[-8].minor.yy737, &yymsp[-5].minor.yy329, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy34, yymsp[0].minor.yy610); } break; case 255: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy737, &yymsp[0].minor.yy329); } break; case 258: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy244 = 0; } +{ yymsp[1].minor.yy610 = 0; } break; case 259: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy244 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy610 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 260: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy97, &yymsp[-4].minor.yy657, yymsp[-2].minor.yy652, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy737, &yymsp[-4].minor.yy329, yymsp[-2].minor.yy212, yymsp[-3].minor.yy212, yymsp[0].minor.yy212); } break; case 261: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy737, &yymsp[0].minor.yy329); } break; case 263: /* into_opt ::= INTO full_table_name */ - case 398: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==398); + case 399: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==399); case 428: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==428); case 451: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==451); -{ yymsp[-1].minor.yy652 = yymsp[0].minor.yy652; } +{ yymsp[-1].minor.yy212 = yymsp[0].minor.yy212; } break; case 265: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ ((SStreamOptions*)yymsp[-2].minor.yy212)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy212 = yymsp[-2].minor.yy212; } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 266: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ ((SStreamOptions*)yymsp[-2].minor.yy212)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy212 = yymsp[-2].minor.yy212; } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 267: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy652)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-3].minor.yy652; } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ ((SStreamOptions*)yymsp[-3].minor.yy212)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy212)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy212); yylhsminor.yy212 = yymsp[-3].minor.yy212; } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 269: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 269: /* stream_options ::= stream_options IGNORE EXPIRED */ +{ ((SStreamOptions*)yymsp[-2].minor.yy212)->ignoreExpired = true; yylhsminor.yy212 = yymsp[-2].minor.yy212; } + yymsp[-2].minor.yy212 = yylhsminor.yy212; + break; + case 270: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 270: /* cmd ::= KILL QUERY NK_STRING */ + case 271: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 271: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 272: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 272: /* cmd ::= BALANCE VGROUP */ + case 273: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 273: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 274: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 274: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy24); } + case 275: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy424); } break; - case 275: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 276: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 276: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 277: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 278: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy657); } + case 279: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy329); } break; - case 279: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } + case 280: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; - case 281: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 282: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 282: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 283: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 283: /* literal ::= NK_STRING */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 284: /* literal ::= NK_STRING */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 284: /* literal ::= NK_BOOL */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 285: /* literal ::= NK_BOOL */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 285: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + case 286: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 286: /* literal ::= duration_literal */ - case 296: /* signed_literal ::= signed */ yytestcase(yyruleno==296); - case 316: /* expression ::= literal */ yytestcase(yyruleno==316); - case 317: /* expression ::= pseudo_column */ yytestcase(yyruleno==317); - case 318: /* expression ::= column_reference */ yytestcase(yyruleno==318); - case 319: /* expression ::= function_expression */ yytestcase(yyruleno==319); - case 320: /* expression ::= subquery */ yytestcase(yyruleno==320); - case 347: /* function_expression ::= literal_func */ yytestcase(yyruleno==347); - case 389: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==389); - case 393: /* boolean_primary ::= predicate */ yytestcase(yyruleno==393); - case 395: /* common_expression ::= expression */ yytestcase(yyruleno==395); - case 396: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==396); - case 399: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==399); - case 401: /* table_reference ::= table_primary */ yytestcase(yyruleno==401); - case 402: /* table_reference ::= joined_table */ yytestcase(yyruleno==402); - case 406: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==406); + case 287: /* literal ::= duration_literal */ + case 297: /* signed_literal ::= signed */ yytestcase(yyruleno==297); + case 317: /* expression ::= literal */ yytestcase(yyruleno==317); + case 318: /* expression ::= pseudo_column */ yytestcase(yyruleno==318); + case 319: /* expression ::= column_reference */ yytestcase(yyruleno==319); + case 320: /* expression ::= function_expression */ yytestcase(yyruleno==320); + case 321: /* expression ::= subquery */ yytestcase(yyruleno==321); + case 348: /* function_expression ::= literal_func */ yytestcase(yyruleno==348); + case 390: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==390); + case 394: /* boolean_primary ::= predicate */ yytestcase(yyruleno==394); + case 396: /* common_expression ::= expression */ yytestcase(yyruleno==396); + case 397: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==397); + case 400: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==400); + case 402: /* table_reference ::= table_primary */ yytestcase(yyruleno==402); + case 403: /* table_reference ::= joined_table */ yytestcase(yyruleno==403); + case 407: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==407); case 457: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==457); case 460: /* query_primary ::= query_specification */ yytestcase(yyruleno==460); -{ yylhsminor.yy652 = yymsp[0].minor.yy652; } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = yymsp[0].minor.yy212; } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 287: /* literal ::= NULL */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 288: /* literal ::= NULL */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 288: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 289: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 289: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 290: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 290: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 291: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 291: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 292: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 292: /* signed ::= NK_MINUS NK_INTEGER */ + case 293: /* 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.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 293: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 294: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 294: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 295: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 295: /* signed ::= NK_MINUS NK_FLOAT */ + case 296: /* 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.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 297: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 298: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 298: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 299: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 299: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 300: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 300: /* signed_literal ::= duration_literal */ - case 302: /* signed_literal ::= literal_func */ yytestcase(yyruleno==302); - case 367: /* star_func_para ::= expression */ yytestcase(yyruleno==367); + case 301: /* signed_literal ::= duration_literal */ + case 303: /* signed_literal ::= literal_func */ yytestcase(yyruleno==303); + case 368: /* star_func_para ::= expression */ yytestcase(yyruleno==368); case 423: /* select_item ::= common_expression */ yytestcase(yyruleno==423); case 473: /* search_condition ::= common_expression */ yytestcase(yyruleno==473); -{ yylhsminor.yy652 = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); } - yymsp[0].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = releaseRawExprNode(pCxt, yymsp[0].minor.yy212); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 301: /* signed_literal ::= NULL */ -{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 302: /* signed_literal ::= NULL */ +{ yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 321: /* expression ::= NK_LP expression NK_RP */ - case 394: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==394); -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 322: /* expression ::= NK_LP expression NK_RP */ + case 395: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==395); +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 322: /* expression ::= NK_PLUS expression */ + case 323: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 323: /* expression ::= NK_MINUS expression */ + case 324: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy212), NULL)); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 324: /* expression ::= expression NK_PLUS expression */ + case 325: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 325: /* expression ::= expression NK_MINUS expression */ + case 326: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 326: /* expression ::= expression NK_STAR expression */ + case 327: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 327: /* expression ::= expression NK_SLASH expression */ + case 328: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 328: /* expression ::= expression NK_REM expression */ + case 329: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 329: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 330: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 330: /* expression ::= expression NK_BITAND expression */ + case 331: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 331: /* expression ::= expression NK_BITOR expression */ + case 332: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 334: /* column_reference ::= column_name */ -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy657, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy657)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 335: /* column_reference ::= column_name */ +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy329, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy329)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 335: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657, createColumnNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 336: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329, createColumnNode(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy329)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 336: /* pseudo_column ::= ROWTS */ - case 337: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==337); - case 339: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==339); - case 340: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==340); - case 341: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==341); - case 342: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==342); - case 343: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==343); - case 349: /* literal_func ::= NOW */ yytestcase(yyruleno==349); -{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy652 = yylhsminor.yy652; + case 337: /* pseudo_column ::= ROWTS */ + case 338: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==338); + case 340: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==340); + case 341: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==341); + case 342: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==342); + case 343: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==343); + case 344: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==344); + case 350: /* literal_func ::= NOW */ yytestcase(yyruleno==350); +{ yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; - case 338: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy657)))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 339: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy329)))); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 344: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 345: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==345); -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-1].minor.yy24)); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; + case 345: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 346: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==346); +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy329, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy329, yymsp[-1].minor.yy424)); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 346: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy48)); } - yymsp[-5].minor.yy652 = yylhsminor.yy652; + case 347: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), yymsp[-1].minor.yy34)); } + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; - case 348: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy657, NULL)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 349: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy329, NULL)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 363: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy24 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 364: /* 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 368: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 369: /* star_func_para ::= table_name NK_DOT NK_STAR */ case 426: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==426); -{ yylhsminor.yy652 = createColumnNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy329, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 369: /* predicate ::= expression compare_op expression */ - case 374: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==374); + case 370: /* predicate ::= expression compare_op expression */ + case 375: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==375); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy700, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy290, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 370: /* predicate ::= expression BETWEEN expression AND expression */ + case 371: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy212), releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-4].minor.yy652 = yylhsminor.yy652; + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; - case 371: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 372: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy212), releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-5].minor.yy652 = yylhsminor.yy652; + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; - case 372: /* predicate ::= expression IS NULL */ + case 373: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), NULL)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 373: /* predicate ::= expression IS NOT NULL */ + case 374: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), NULL)); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 375: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_THAN; } + case 376: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_THAN; } break; - case 376: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_THAN; } + case 377: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_THAN; } break; - case 377: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_EQUAL; } + case 378: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_EQUAL; } break; - case 378: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_EQUAL; } + case 379: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_EQUAL; } break; - case 379: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy700 = OP_TYPE_NOT_EQUAL; } + case 380: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy290 = OP_TYPE_NOT_EQUAL; } break; - case 380: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy700 = OP_TYPE_EQUAL; } + case 381: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy290 = OP_TYPE_EQUAL; } break; - case 381: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy700 = OP_TYPE_LIKE; } + case 382: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LIKE; } break; - case 382: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_LIKE; } + case 383: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_LIKE; } break; - case 383: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy700 = OP_TYPE_MATCH; } + case 384: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_MATCH; } break; - case 384: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy700 = OP_TYPE_NMATCH; } + case 385: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_NMATCH; } break; - case 385: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy700 = OP_TYPE_JSON_CONTAINS; } + case 386: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy290 = OP_TYPE_JSON_CONTAINS; } break; - case 386: /* in_op ::= IN */ -{ yymsp[0].minor.yy700 = OP_TYPE_IN; } + case 387: /* in_op ::= IN */ +{ yymsp[0].minor.yy290 = OP_TYPE_IN; } break; - case 387: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_IN; } + case 388: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_IN; } break; - case 388: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 389: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 390: /* boolean_value_expression ::= NOT boolean_primary */ + case 391: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy212), NULL)); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 391: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 392: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 392: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 393: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); - yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 400: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy652 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, NULL); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; + case 401: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy212 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, NULL); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 403: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + case 404: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy212 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy329, &yymsp[0].minor.yy329); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 404: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; + case 405: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy212 = createRealTableNode(pCxt, &yymsp[-3].minor.yy329, &yymsp[-1].minor.yy329, &yymsp[0].minor.yy329); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 405: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy652 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy657); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; + case 406: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy212 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212), &yymsp[0].minor.yy329); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; - case 407: /* alias_opt ::= */ -{ yymsp[1].minor.yy657 = nil_token; } + case 408: /* alias_opt ::= */ +{ yymsp[1].minor.yy329 = nil_token; } break; - case 408: /* alias_opt ::= table_alias */ -{ yylhsminor.yy657 = yymsp[0].minor.yy657; } - yymsp[0].minor.yy657 = yylhsminor.yy657; + case 409: /* alias_opt ::= table_alias */ +{ yylhsminor.yy329 = yymsp[0].minor.yy329; } + yymsp[0].minor.yy329 = yylhsminor.yy329; break; - case 409: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy657 = yymsp[0].minor.yy657; } + case 410: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy329 = yymsp[0].minor.yy329; } break; - case 410: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 411: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==411); -{ yymsp[-2].minor.yy652 = yymsp[-1].minor.yy652; } + case 411: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 412: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==412); +{ yymsp[-2].minor.yy212 = yymsp[-1].minor.yy212; } break; - case 412: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy652 = createJoinTableNode(pCxt, yymsp[-4].minor.yy596, yymsp[-5].minor.yy652, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } - yymsp[-5].minor.yy652 = yylhsminor.yy652; + case 413: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy212 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; - case 413: /* join_type ::= */ -{ yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } + case 414: /* join_type ::= */ +{ yymsp[1].minor.yy162 = JOIN_TYPE_INNER; } break; - case 414: /* join_type ::= INNER */ -{ yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } + case 415: /* join_type ::= INNER */ +{ yymsp[0].minor.yy162 = JOIN_TYPE_INNER; } break; - case 415: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 416: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy652 = createSelectStmt(pCxt, yymsp[-10].minor.yy97, yymsp[-9].minor.yy24, yymsp[-8].minor.yy652); - yymsp[-11].minor.yy652 = addWhereClause(pCxt, yymsp[-11].minor.yy652, yymsp[-7].minor.yy652); - yymsp[-11].minor.yy652 = addPartitionByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-6].minor.yy24); - yymsp[-11].minor.yy652 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy652, yymsp[-2].minor.yy652); - yymsp[-11].minor.yy652 = addGroupByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-1].minor.yy24); - yymsp[-11].minor.yy652 = addHavingClause(pCxt, yymsp[-11].minor.yy652, yymsp[0].minor.yy652); - yymsp[-11].minor.yy652 = addRangeClause(pCxt, yymsp[-11].minor.yy652, yymsp[-5].minor.yy652); - yymsp[-11].minor.yy652 = addEveryClause(pCxt, yymsp[-11].minor.yy652, yymsp[-4].minor.yy652); - yymsp[-11].minor.yy652 = addFillClause(pCxt, yymsp[-11].minor.yy652, yymsp[-3].minor.yy652); + yymsp[-11].minor.yy212 = createSelectStmt(pCxt, yymsp[-10].minor.yy737, yymsp[-9].minor.yy424, yymsp[-8].minor.yy212); + yymsp[-11].minor.yy212 = addWhereClause(pCxt, yymsp[-11].minor.yy212, yymsp[-7].minor.yy212); + yymsp[-11].minor.yy212 = addPartitionByClause(pCxt, yymsp[-11].minor.yy212, yymsp[-6].minor.yy424); + yymsp[-11].minor.yy212 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy212, yymsp[-2].minor.yy212); + yymsp[-11].minor.yy212 = addGroupByClause(pCxt, yymsp[-11].minor.yy212, yymsp[-1].minor.yy424); + yymsp[-11].minor.yy212 = addHavingClause(pCxt, yymsp[-11].minor.yy212, yymsp[0].minor.yy212); + yymsp[-11].minor.yy212 = addRangeClause(pCxt, yymsp[-11].minor.yy212, yymsp[-5].minor.yy212); + yymsp[-11].minor.yy212 = addEveryClause(pCxt, yymsp[-11].minor.yy212, yymsp[-4].minor.yy212); + yymsp[-11].minor.yy212 = addFillClause(pCxt, yymsp[-11].minor.yy212, yymsp[-3].minor.yy212); } break; - case 418: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy97 = false; } + case 419: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy737 = false; } break; - case 419: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy24 = NULL; } + case 422: /* select_item ::= NK_STAR */ +{ yylhsminor.yy212 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 424: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy657); } - yymsp[-1].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212), &yymsp[0].minor.yy329); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 425: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), &yymsp[0].minor.yy657); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), &yymsp[0].minor.yy329); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 430: /* partition_by_clause_opt ::= PARTITION BY expression_list */ case 447: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==447); case 463: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==463); -{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } +{ yymsp[-2].minor.yy424 = yymsp[0].minor.yy424; } break; case 432: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy652 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } +{ yymsp[-5].minor.yy212 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } break; case 433: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy652 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } +{ yymsp[-3].minor.yy212 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } break; case 434: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } +{ yymsp[-5].minor.yy212 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), NULL, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; case 435: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } +{ yymsp[-7].minor.yy212 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy212), releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; case 437: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ case 455: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==455); -{ yymsp[-3].minor.yy652 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy652); } +{ yymsp[-3].minor.yy212 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy212); } break; case 439: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy652 = createFillNode(pCxt, yymsp[-1].minor.yy250, NULL); } +{ yymsp[-3].minor.yy212 = createFillNode(pCxt, yymsp[-1].minor.yy294, NULL); } break; case 440: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy652 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } +{ yymsp[-5].minor.yy212 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } break; case 441: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy250 = FILL_MODE_NONE; } +{ yymsp[0].minor.yy294 = FILL_MODE_NONE; } break; case 442: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy250 = FILL_MODE_PREV; } +{ yymsp[0].minor.yy294 = FILL_MODE_PREV; } break; case 443: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy250 = FILL_MODE_NULL; } +{ yymsp[0].minor.yy294 = FILL_MODE_NULL; } break; case 444: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy250 = FILL_MODE_LINEAR; } +{ yymsp[0].minor.yy294 = FILL_MODE_LINEAR; } break; case 445: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy250 = FILL_MODE_NEXT; } +{ yymsp[0].minor.yy294 = FILL_MODE_NEXT; } break; case 448: /* group_by_list ::= expression */ -{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[0].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 449: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 453: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy652 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } +{ yymsp[-5].minor.yy212 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } break; case 456: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy652 = addOrderByClause(pCxt, yymsp[-3].minor.yy652, yymsp[-2].minor.yy24); - yylhsminor.yy652 = addSlimitClause(pCxt, yylhsminor.yy652, yymsp[-1].minor.yy652); - yylhsminor.yy652 = addLimitClause(pCxt, yylhsminor.yy652, yymsp[0].minor.yy652); + yylhsminor.yy212 = addOrderByClause(pCxt, yymsp[-3].minor.yy212, yymsp[-2].minor.yy424); + yylhsminor.yy212 = addSlimitClause(pCxt, yylhsminor.yy212, yymsp[-1].minor.yy212); + yylhsminor.yy212 = addLimitClause(pCxt, yylhsminor.yy212, yymsp[0].minor.yy212); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 458: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } - yymsp[-3].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 459: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 461: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy652 = yymsp[-4].minor.yy652; } - yy_destructor(yypParser,366,&yymsp[-3].minor); - yy_destructor(yypParser,367,&yymsp[-2].minor); - yy_destructor(yypParser,368,&yymsp[-1].minor); +{ yymsp[-5].minor.yy212 = yymsp[-4].minor.yy212; } + yy_destructor(yypParser,367,&yymsp[-3].minor); + yy_destructor(yypParser,368,&yymsp[-2].minor); + yy_destructor(yypParser,369,&yymsp[-1].minor); break; case 465: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ case 469: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==469); -{ yymsp[-1].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +{ yymsp[-1].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; case 466: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ case 470: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==470); -{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +{ yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; case 467: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ case 471: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==471); -{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +{ yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; case 472: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy652); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 476: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy652 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), yymsp[-1].minor.yy598, yymsp[0].minor.yy653); } - yymsp[-2].minor.yy652 = yylhsminor.yy652; +{ yylhsminor.yy212 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), yymsp[-1].minor.yy188, yymsp[0].minor.yy607); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 477: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy598 = ORDER_ASC; } +{ yymsp[1].minor.yy188 = ORDER_ASC; } break; case 478: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy598 = ORDER_ASC; } +{ yymsp[0].minor.yy188 = ORDER_ASC; } break; case 479: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy598 = ORDER_DESC; } +{ yymsp[0].minor.yy188 = ORDER_DESC; } break; case 480: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy653 = NULL_ORDER_DEFAULT; } +{ yymsp[1].minor.yy607 = NULL_ORDER_DEFAULT; } break; case 481: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy653 = NULL_ORDER_FIRST; } +{ yymsp[-1].minor.yy607 = NULL_ORDER_FIRST; } break; case 482: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy653 = NULL_ORDER_LAST; } +{ yymsp[-1].minor.yy607 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 7de92bba0c..0a980fa889 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -372,7 +372,7 @@ TEST_F(ParserInitialCTest, createStable) { expect.watermark2 = watermark2; // expect.ttl = ttl; if (nullptr != pComment) { - expect.comment = strdup(pComment); + expect.pComment = strdup(pComment); expect.commentLen = strlen(pComment); } }; @@ -443,7 +443,7 @@ TEST_F(ParserInitialCTest, createStable) { } } if (expect.commentLen > 0) { - ASSERT_EQ(std::string(req.comment), std::string(expect.comment)); + ASSERT_EQ(std::string(req.pComment), std::string(expect.pComment)); } if (expect.ast1Len > 0) { ASSERT_EQ(std::string(req.pAst1), std::string(expect.pAst1)); @@ -526,20 +526,22 @@ TEST_F(ParserInitialCTest, createStream) { memset(&expect, 0, sizeof(SCMCreateStreamReq)); }; - auto setCreateStreamReqFunc = - [&](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; - }; + auto setCreateStreamReqFunc = [&](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, int8_t igExpired = 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; + expect.igExpired = igExpired; + }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT); @@ -555,6 +557,7 @@ TEST_F(ParserInitialCTest, createStream) { ASSERT_EQ(req.triggerType, expect.triggerType); ASSERT_EQ(req.maxDelay, expect.maxDelay); ASSERT_EQ(req.watermark, expect.watermark); + ASSERT_EQ(req.igExpired, expect.igExpired); tFreeSCMCreateStreamReq(&req); }); @@ -571,9 +574,10 @@ TEST_F(ParserInitialCTest, createStream) { clearCreateStreamReq(); setCreateStreamReqFunc( - "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"); + "s1", "test", + "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired into st1 as select * from t1", + "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 1); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED INTO st1 AS SELECT * FROM t1"); clearCreateStreamReq(); } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index d170482c48..56353f7095 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -542,6 +542,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt pIdfRowsFunc->isTailFunc = pSelect->hasTailFunc; pIdfRowsFunc->isUniqueFunc = pSelect->hasUniqueFunc; + pIdfRowsFunc->isTimeLineFunc = pSelect->hasTimeLineFunc; // indefinite rows functions and _select_values functions int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, fmIsVectorFunc, &pIdfRowsFunc->pFuncs); @@ -614,10 +615,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm if (pCxt->pPlanCxt->streamQuery) { pWindow->triggerType = pCxt->pPlanCxt->triggerType; pWindow->watermark = pCxt->pPlanCxt->watermark; - } - - if (pCxt->pPlanCxt->rSmaQuery) { - /*pWindow->filesFactor = pCxt->pPlanCxt->filesFactor;*/ + pWindow->igExpired = pCxt->pPlanCxt->igExpired; } if (TSDB_CODE_SUCCESS == code) { @@ -730,6 +728,9 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } SFillNode* pFillNode = (SFillNode*)(((SIntervalWindowNode*)pSelect->pWindow)->pFill); + if (FILL_MODE_NONE == pFillNode->mode) { + return TSDB_CODE_SUCCESS; + } SFillLogicNode* pFill = (SFillLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL); if (NULL == pFill) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index b1e5b542e3..fb27602c21 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -227,8 +227,7 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) { pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit; pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType; pScan->watermark = ((SWindowLogicNode*)pParent)->watermark; - pScan->tsColId = ((SColumnNode*)((SWindowLogicNode*)pParent)->pTspk)->colId; - pScan->filesFactor = ((SWindowLogicNode*)pParent)->filesFactor; + pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired; } } @@ -477,10 +476,16 @@ static int32_t pushDownCondOptPushCondToScan(SOptimizeContext* pCxt, SScanLogicN return pushDownCondOptAppendCond(&pScan->node.pConditions, pCond); } +static int32_t pushDownCondOptPushCondToProject(SOptimizeContext* pCxt, SProjectLogicNode* pProject, SNode** pCond) { + return pushDownCondOptAppendCond(&pProject->node.pConditions, pCond); +} + static int32_t pushDownCondOptPushCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) { switch (nodeType(pChild)) { case QUERY_NODE_LOGIC_PLAN_SCAN: return pushDownCondOptPushCondToScan(pCxt, (SScanLogicNode*)pChild, pCond); + case QUERY_NODE_LOGIC_PLAN_PROJECT: + return pushDownCondOptPushCondToProject(pCxt, (SProjectLogicNode*)pChild, pCond); default: break; } @@ -587,11 +592,161 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p return code; } -static int32_t pushDownCondOptDealAgg(SOptimizeContext* pCxt, SAggLogicNode* pAgg) { - // todo +typedef struct SPartAggCondContext { + SAggLogicNode* pAgg; + bool hasAggFunc; +} SPartAggCondContext; + +static EDealRes partAggCondHasAggFuncImpl(SNode* pNode, void* pContext) { + SPartAggCondContext* pCxt = pContext; + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + SNode* pAggFunc = NULL; + FOREACH(pAggFunc, pCxt->pAgg->pAggFuncs) { + if (strcmp(((SColumnNode*)pNode)->colName, ((SFunctionNode*)pAggFunc)->node.aliasName) == 0) { + pCxt->hasAggFunc = true; + return DEAL_RES_END; + } + } + } + return DEAL_RES_CONTINUE; +} + +static int32_t partitionAggCondHasAggFunc(SAggLogicNode* pAgg, SNode* pCond) { + SPartAggCondContext cxt = {.pAgg = pAgg, .hasAggFunc = false}; + nodesWalkExpr(pCond, partAggCondHasAggFuncImpl, &cxt); + return cxt.hasAggFunc; +} + +static int32_t partitionAggCondConj(SAggLogicNode* pAgg, SNode** ppAggFuncCond, SNode** ppGroupKeyCond) { + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pAgg->node.pConditions; + int32_t code = TSDB_CODE_SUCCESS; + + SNodeList* pAggFuncConds = NULL; + SNodeList* pGroupKeyConds = NULL; + SNode* pCond = NULL; + FOREACH(pCond, pLogicCond->pParameterList) { + if (partitionAggCondHasAggFunc(pAgg, pCond)) { + code = nodesListMakeAppend(&pAggFuncConds, nodesCloneNode(pCond)); + } else { + code = nodesListMakeAppend(&pGroupKeyConds, nodesCloneNode(pCond)); + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + SNode* pTempAggFuncCond = NULL; + SNode* pTempGroupKeyCond = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempAggFuncCond, &pAggFuncConds); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempGroupKeyCond, &pGroupKeyConds); + } + + if (TSDB_CODE_SUCCESS == code) { + *ppAggFuncCond = pTempAggFuncCond; + *ppGroupKeyCond = pTempGroupKeyCond; + } else { + nodesDestroyList(pAggFuncConds); + nodesDestroyList(pGroupKeyConds); + nodesDestroyNode(pTempAggFuncCond); + nodesDestroyNode(pTempGroupKeyCond); + } + pAgg->node.pConditions = NULL; + return code; +} + +static int32_t partitionAggCond(SAggLogicNode* pAgg, SNode** ppAggFunCond, SNode** ppGroupKeyCond) { + SNode* pAggNodeCond = pAgg->node.pConditions; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(pAggNodeCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)(pAggNodeCond))->condType) { + return partitionAggCondConj(pAgg, ppAggFunCond, ppGroupKeyCond); + } + if (partitionAggCondHasAggFunc(pAgg, pAggNodeCond)) { + *ppAggFunCond = pAggNodeCond; + } else { + *ppGroupKeyCond = pAggNodeCond; + } + pAgg->node.pConditions = NULL; return TSDB_CODE_SUCCESS; } +static int32_t pushCondToAggCond(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode** pAggFuncCond) { + pushDownCondOptAppendCond(&pAgg->node.pConditions, pAggFuncCond); + return TSDB_CODE_SUCCESS; +} + +typedef struct SRewriteAggGroupKeyCondContext { + SAggLogicNode* pAgg; + int32_t errCode; +} SRewriteAggGroupKeyCondContext; + +static EDealRes rewriteAggGroupKeyCondForPushDownImpl(SNode** pNode, void* pContext) { + SRewriteAggGroupKeyCondContext* pCxt = pContext; + SAggLogicNode* pAgg = pCxt->pAgg; + if (QUERY_NODE_COLUMN == nodeType(*pNode)) { + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, pAgg->pGroupKeys) { + SNode* pGroup = NULL; + FOREACH(pGroup, ((SGroupingSetNode*)pGroupKey)->pParameterList) { + if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) { + SNode* pExpr = nodesCloneNode(pGroup); + if (pExpr == NULL) { + pCxt->errCode = terrno; + return DEAL_RES_ERROR; + } + nodesDestroyNode(*pNode); + *pNode = pExpr; + } + } + } + return DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static int32_t rewriteAggGroupKeyCondForPushDown(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode* pGroupKeyCond) { + SRewriteAggGroupKeyCondContext cxt = {.pAgg = pAgg, .errCode = TSDB_CODE_SUCCESS}; + nodesRewriteExpr(&pGroupKeyCond, rewriteAggGroupKeyCondForPushDownImpl, &cxt); + return cxt.errCode; +} + +static int32_t pushDownCondOptDealAgg(SOptimizeContext* pCxt, SAggLogicNode* pAgg) { + if (NULL == pAgg->node.pConditions || + OPTIMIZE_FLAG_TEST_MASK(pAgg->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) { + return TSDB_CODE_SUCCESS; + } + // TODO: remove it after full implementation of pushing down to child + if (1 != LIST_LENGTH(pAgg->node.pChildren) || + QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pAgg->node.pChildren, 0)) && + QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(nodesListGetNode(pAgg->node.pChildren, 0))) { + return TSDB_CODE_SUCCESS; + } + + SNode* pAggFuncCond = NULL; + SNode* pGroupKeyCond = NULL; + int32_t code = partitionAggCond(pAgg, &pAggFuncCond, &pGroupKeyCond); + if (TSDB_CODE_SUCCESS == code && NULL != pAggFuncCond) { + code = pushCondToAggCond(pCxt, pAgg, &pAggFuncCond); + } + if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeyCond) { + code = rewriteAggGroupKeyCondForPushDown(pCxt, pAgg, pGroupKeyCond); + } + if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeyCond) { + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0); + code = pushDownCondOptPushCondToChild(pCxt, pChild, &pGroupKeyCond); + } + if (TSDB_CODE_SUCCESS == code) { + OPTIMIZE_FLAG_SET_MASK(pAgg->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE); + pCxt->optimized = true; + } else { + nodesDestroyNode(pGroupKeyCond); + nodesDestroyNode(pAggFuncCond); + } + return code; +} + static int32_t pushDownCondOptimizeImpl(SOptimizeContext* pCxt, SLogicNode* pLogicNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pLogicNode)) { @@ -1307,9 +1462,17 @@ static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicN TSWAP(pSort->node.pChildren, pIndef->node.pChildren); pSort->node.precision = pIndef->node.precision; + SFunctionNode* pTail = NULL; + SNode* pFunc = NULL; + FOREACH(pFunc, pIndef->pFuncs) { + if (FUNCTION_TYPE_TAIL == ((SFunctionNode*)pFunc)->funcType) { + pTail = (SFunctionNode*)pFunc; + break; + } + } + // tail(expr, [limit, offset,] _rowts) - SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0); - int32_t rowtsIndex = LIST_LENGTH(pTail->pParameterList) - 1; + int32_t rowtsIndex = LIST_LENGTH(pTail->pParameterList) - 1; int32_t code = nodesListMakeStrictAppend( &pSort->pSortKeys, rewriteTailOptCreateOrderByExpr(nodesListGetNode(pTail->pParameterList, rowtsIndex))); @@ -1329,12 +1492,12 @@ static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicN return code; } -static SNode* rewriteTailOptCreateProjectExpr(SFunctionNode* pTail) { - SNode* pExpr = nodesCloneNode(nodesListGetNode(pTail->pParameterList, 0)); +static SNode* rewriteTailOptCreateProjectExpr(SFunctionNode* pFunc) { + SNode* pExpr = nodesCloneNode(nodesListGetNode(pFunc->pParameterList, 0)); if (NULL == pExpr) { return NULL; } - strcpy(((SExprNode*)pExpr)->aliasName, pTail->node.aliasName); + strcpy(((SExprNode*)pExpr)->aliasName, pFunc->node.aliasName); return pExpr; } @@ -1347,12 +1510,22 @@ static int32_t rewriteTailOptCreateProject(SIndefRowsFuncLogicNode* pIndef, SLog TSWAP(pProject->node.pTargets, pIndef->node.pTargets); pProject->node.precision = pIndef->node.precision; - // tail(expr, [limit, offset,] _rowts) - SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0); - int32_t limitIndex = LIST_LENGTH(pTail->pParameterList) > 2 ? 1 : -1; - int32_t offsetIndex = LIST_LENGTH(pTail->pParameterList) > 3 ? 2 : -1; + int32_t code = TSDB_CODE_SUCCESS; + SFunctionNode* pTail = NULL; + SNode* pFunc = NULL; + FOREACH(pFunc, pIndef->pFuncs) { + code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteTailOptCreateProjectExpr((SFunctionNode*)pFunc)); + if (TSDB_CODE_SUCCESS != code) { + break; + } + if (FUNCTION_TYPE_TAIL == ((SFunctionNode*)pFunc)->funcType) { + pTail = (SFunctionNode*)pFunc; + } + } - int32_t code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteTailOptCreateProjectExpr(pTail)); + // tail(expr, [limit, offset,] _rowts) + int32_t limitIndex = LIST_LENGTH(pTail->pParameterList) > 2 ? 1 : -1; + int32_t offsetIndex = LIST_LENGTH(pTail->pParameterList) > 3 ? 2 : -1; if (TSDB_CODE_SUCCESS == code) { code = rewriteTailOptCreateLimit(limitIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, limitIndex), offsetIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, offsetIndex), @@ -1707,9 +1880,9 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { } static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) { - SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0); - SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS}; + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0); + SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS}; nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt); int32_t code = cxt.errCode; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 0f19db26a5..aac9c25f77 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -534,8 +534,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->slidingUnit = pScanLogicNode->slidingUnit; pTableScan->triggerType = pScanLogicNode->triggerType; pTableScan->watermark = pScanLogicNode->watermark; - pTableScan->tsColId = pScanLogicNode->tsColId; - pTableScan->filesFactor = pScanLogicNode->filesFactor; + pTableScan->igExpired = pScanLogicNode->igExpired; return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); } @@ -1054,7 +1053,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* pWindow->triggerType = pWindowLogicNode->triggerType; pWindow->watermark = pWindowLogicNode->watermark; - pWindow->filesFactor = pWindowLogicNode->filesFactor; + pWindow->igExpired = pWindowLogicNode->igExpired; if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pWindow; @@ -1555,7 +1554,11 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) { code = buildVnodeModifySubplan(pCxt, pLogicSubplan, pSubplan); } else { - pSubplan->msgType = TDMT_VND_QUERY; + if (SUBPLAN_TYPE_SCAN == pSubplan->subplanType) { + pSubplan->msgType = TDMT_SCH_QUERY; + } else { + pSubplan->msgType = TDMT_SCH_MERGE_QUERY; + } code = createPhysiNode(pCxt, pLogicSubplan->pNode, pSubplan, &pSubplan->pNode); if (TSDB_CODE_SUCCESS == code && !pCxt->pPlanCxt->streamQuery && !pCxt->pPlanCxt->topicQuery) { code = createDataDispatcher(pCxt, pSubplan->pNode, &pSubplan->pDataSink); diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index b886fca2af..bf841e6679 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -35,6 +35,8 @@ TEST_F(PlanBasicTest, whereClause) { run("SELECT * FROM t1 WHERE c1 > 10"); run("SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'"); + + run("SELECT ts, c1 FROM t1 WHERE ts > NOW AND ts IS NULL AND (c1 > 0 OR c3 < 20)"); } TEST_F(PlanBasicTest, func) { @@ -103,6 +105,22 @@ TEST_F(PlanBasicTest, lastRowFunc) { run("SELECT LAST_ROW(c1), SUM(c3) FROM t1"); } +TEST_F(PlanBasicTest, timeLineFunc) { + useDb("root", "test"); + + run("SELECT CSUM(c1) FROM t1"); + + run("SELECT CSUM(c1) FROM st1"); +} + +TEST_F(PlanBasicTest, multiResFunc) { + useDb("root", "test"); + + run("SELECT LAST(*) FROM t1"); + + run("SELECT LAST(c1 + 10, c2) FROM st1"); +} + TEST_F(PlanBasicTest, sampleFunc) { useDb("root", "test"); diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 9ba149a33b..a3a15869eb 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -216,7 +216,8 @@ void destroyQueryExecRes(SQueryExecRes* pRes) { tFreeSSubmitRsp((SSubmitRsp*)pRes->res); break; } - case TDMT_VND_QUERY: { + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: { taosArrayDestroy((SArray*)pRes->res); break; } @@ -304,18 +305,21 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t char* parseTagDatatoJson(void* p) { char* string = NULL; - cJSON* json = cJSON_CreateObject(); - if (json == NULL) { - goto end; - } - SArray* pTagVals = NULL; + cJSON* json = NULL; if (tTagToValArray((const STag*)p, &pTagVals) != 0) { goto end; } int16_t nCols = taosArrayGetSize(pTagVals); + if (nCols == 0) { + goto end; + } char tagJsonKey[256] = {0}; + json = cJSON_CreateObject(); + if (json == NULL) { + goto end; + } for (int j = 0; j < nCols; ++j) { STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j); // json key encode by binary @@ -373,6 +377,10 @@ char* parseTagDatatoJson(void* p) { string = cJSON_PrintUnformatted(json); end: cJSON_Delete(json); + taosArrayDestroy(pTagVals); + if(string == NULL){ + string = strdup(TSDB_DATA_NULL_STR_L); + } return string; } diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index b433a88001..908149c3ea 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -20,7 +20,9 @@ #include "systable.h" #pragma GCC diagnostic push +#ifdef COMPILER_SUPPORTS_CXX13 #pragma GCC diagnostic ignored "-Wformat-truncation" +#endif int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)) = {0}; int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0}; diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index 2368b13dd6..6faffa13b3 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -75,6 +75,7 @@ typedef struct SQWDebug { bool lockEnable; bool statusEnable; bool dumpEnable; + bool tmp; } SQWDebug; extern SQWDebug gQWDebug; @@ -82,6 +83,7 @@ extern SQWDebug gQWDebug; typedef struct SQWMsg { void *node; int32_t code; + int32_t msgType; char *msg; int32_t msgLen; SRpcHandleInfo connInfo; @@ -100,6 +102,7 @@ typedef struct SQWHbInfo { typedef struct SQWPhaseInput { int32_t code; + int32_t msgType; } SQWPhaseInput; typedef struct SQWPhaseOutput { @@ -119,6 +122,8 @@ typedef struct SQWTaskCtx { int8_t phase; int8_t taskType; int8_t explain; + int32_t queryType; + int32_t execId; bool queryFetched; bool queryEnd; @@ -197,8 +202,8 @@ typedef struct SQWorkerMgmt { int32_t paramIdx; } SQWorkerMgmt; -#define QW_FPARAMS_DEF SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId -#define QW_IDS() sId, qId, tId, rId +#define QW_FPARAMS_DEF SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId +#define QW_IDS() sId, qId, tId, rId, eId #define QW_FPARAMS() mgmt, QW_IDS() #define QW_STAT_INC(_item, _n) atomic_add_fetch_64(&(_item), _n) @@ -223,15 +228,18 @@ typedef struct SQWorkerMgmt { #define QW_TASK_READY(status) \ (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || \ status == JOB_TASK_STATUS_PARTIAL_SUCCEED) -#define QW_SET_QTID(id, qId, tId) \ - do { \ - *(uint64_t *)(id) = (qId); \ - *(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \ +#define QW_SET_QTID(id, qId, tId, eId) \ + do { \ + *(uint64_t *)(id) = (qId); \ + *(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \ + *(int32_t *)((char *)(id) + sizeof(qId) + sizeof(tId)) = (eId); \ } while (0) -#define QW_GET_QTID(id, qId, tId) \ - do { \ - (qId) = *(uint64_t *)(id); \ - (tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); \ + +#define QW_GET_QTID(id, qId, tId, eId) \ + do { \ + (qId) = *(uint64_t *)(id); \ + (tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); \ + (eId) = *(int32_t *)((char *)(id) + sizeof(qId) + sizeof(tId)); \ } while (0) #define QW_ERR_RET(c) \ @@ -273,22 +281,22 @@ typedef struct SQWorkerMgmt { #define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__) #define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__) -#define QW_TASK_ELOG(param, ...) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_WLOG(param, ...) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_DLOG(param, ...) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) +#define QW_TASK_ELOG(param, ...) qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__) +#define QW_TASK_WLOG(param, ...) qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__) +#define QW_TASK_DLOG(param, ...) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__) #define QW_TASK_DLOGL(param, ...) \ - qDebugL("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) + qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__) -#define QW_TASK_ELOG_E(param) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) -#define QW_TASK_WLOG_E(param) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) -#define QW_TASK_DLOG_E(param) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) +#define QW_TASK_ELOG_E(param) qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId) +#define QW_TASK_WLOG_E(param) qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId) +#define QW_TASK_DLOG_E(param) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId) #define QW_SCH_TASK_ELOG(param, ...) \ - qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) + qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) #define QW_SCH_TASK_WLOG(param, ...) \ - qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) + qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) #define QW_SCH_TASK_DLOG(param, ...) \ - qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) + qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) #define QW_LOCK_DEBUG(...) \ do { \ @@ -362,6 +370,8 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx); void qwDbgDumpMgmtInfo(SQWorker *mgmt); int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore); +int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet); +int32_t qwAddTaskCtx(QW_FPARAMS_DEF); #ifdef __cplusplus diff --git a/source/libs/qworker/inc/qwMsg.h b/source/libs/qworker/inc/qwMsg.h index 8c7c030dce..9e9d1f44cb 100644 --- a/source/libs/qworker/inc/qwMsg.h +++ b/source/libs/qworker/inc/qwMsg.h @@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, i int32_t code); void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete); int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn); -int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo); +int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo); int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num); void qwFreeFetchRsp(void *msg); int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp); diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index add9700a3a..68058334ab 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -9,7 +9,7 @@ #include "tmsg.h" #include "tname.h" -SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false}; +SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .tmp = false}; int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) { if (!gQWDebug.statusEnable) { @@ -121,3 +121,90 @@ void qwDbgDumpMgmtInfo(SQWorker *mgmt) { } +int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet) { + int32_t contLen = 0; + char* rsp = NULL; + + if (pEpSet) { + contLen = tSerializeSEpSet(NULL, 0, pEpSet); + rsp = rpcMallocCont(contLen); + tSerializeSEpSet(rsp, contLen, pEpSet); + } + + SRpcMsg rpcRsp = { + .msgType = rspType, + .pCont = rsp, + .contLen = contLen, + .code = code, + .info = *pConn, + }; + rpcRsp.info.hasEpSet = 1; + + tmsgSendRsp(&rpcRsp); + + qDebug("response %s msg, code: %s", TMSG_INFO(rspType), tstrerror(code)); + + return TSDB_CODE_SUCCESS; +} + +int32_t qwDbgResponseREdirect(SQWMsg *qwMsg, SQWTaskCtx *ctx) { + if (gQWDebug.tmp) { + if (TDMT_SCH_QUERY == qwMsg->msgType) { + SEpSet epSet = {0}; + epSet.inUse = 1; + epSet.numOfEps = 3; + strcpy(epSet.eps[0].fqdn, "localhost"); + epSet.eps[0].port = 7100; + strcpy(epSet.eps[1].fqdn, "localhost"); + epSet.eps[1].port = 7200; + strcpy(epSet.eps[2].fqdn, "localhost"); + epSet.eps[2].port = 7300; + + qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet); + gQWDebug.tmp = false; + return TSDB_CODE_SUCCESS; + } + + if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType) { + ctx->phase = QW_PHASE_POST_QUERY; + qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL); + gQWDebug.tmp = false; + return TSDB_CODE_SUCCESS; + } + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t qwDbgEnableDebug(char *option) { + if (0 == strcasecmp(option, "lock")) { + gQWDebug.lockEnable = true; + qDebug("qw lock debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "status")) { + gQWDebug.statusEnable = true; + qDebug("qw status debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "dump")) { + gQWDebug.dumpEnable = true; + qDebug("qw dump debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "tmp")) { + gQWDebug.tmp = true; + qDebug("qw tmp debug enabled"); + return TSDB_CODE_SUCCESS; + } + + qError("invalid qw debug option:%s", option); + + return TSDB_CODE_APP_ERROR; +} + + diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 82a62b5c5a..cc4228f7c7 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -43,7 +43,7 @@ void qwFreeFetchRsp(void *msg) { } } -int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo) { +int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo) { SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp)); pRsp->code = code; if (tbInfo) { @@ -53,7 +53,7 @@ int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo* } SRpcMsg rpcRsp = { - .msgType = TDMT_VND_QUERY_RSP, + .msgType = rspType, .pCont = pRsp, .contLen = sizeof(*pRsp), .code = code, @@ -73,7 +73,7 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execIn tSerializeSExplainRsp(pRsp, contLen, &rsp); SRpcMsg rpcRsp = { - .msgType = TDMT_VND_EXPLAIN_RSP, + .msgType = TDMT_SCH_EXPLAIN_RSP, .pCont = pRsp, .contLen = contLen, .code = 0, @@ -92,7 +92,7 @@ int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus); SRpcMsg rpcRsp = { - .msgType = TDMT_VND_QUERY_HEARTBEAT_RSP, + .msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP, .contLen = contLen, .pCont = pRsp, .code = code, @@ -112,7 +112,7 @@ int32_t qwBuildAndSendFetchRsp(SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, i } SRpcMsg rpcRsp = { - .msgType = TDMT_VND_FETCH_RSP, + .msgType = TDMT_SCH_FETCH_RSP, .pCont = pRsp, .contLen = sizeof(*pRsp) + dataLength, .code = code, @@ -129,7 +129,7 @@ int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code) { pRsp->code = code; SRpcMsg rpcRsp = { - .msgType = TDMT_VND_CANCEL_TASK_RSP, + .msgType = TDMT_SCH_CANCEL_TASK_RSP, .pCont = pRsp, .contLen = sizeof(*pRsp), .code = code, @@ -145,7 +145,7 @@ int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code) { pRsp->code = code; SRpcMsg rpcRsp = { - .msgType = TDMT_VND_DROP_TASK_RSP, + .msgType = TDMT_SCH_DROP_TASK_RSP, .pCont = pRsp, .contLen = sizeof(*pRsp), .code = code, @@ -156,6 +156,41 @@ int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code) { return TSDB_CODE_SUCCESS; } +int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { + STaskDropReq *req = (STaskDropReq *)rpcMallocCont(sizeof(STaskDropReq)); + if (NULL == req) { + QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(STaskDropReq)); + QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + req->header.vgId = mgmt->nodeId; + req->sId = sId; + req->queryId = qId; + req->taskId = tId; + req->refId = rId; + req->execId = eId; + + SRpcMsg pNewMsg = { + .msgType = TDMT_SCH_DROP_TASK, + .pCont = req, + .contLen = sizeof(STaskDropReq), + .code = 0, + .info = *pConn, + }; + + int32_t code = tmsgPutToQueue(&mgmt->msgCb, FETCH_QUEUE, &pNewMsg); + if (TSDB_CODE_SUCCESS != code) { + QW_SCH_TASK_ELOG("put drop task msg to queue failed, vgId:%d, code:%s", mgmt->nodeId, tstrerror(code)); + rpcFreeCont(req); + QW_ERR_RET(code); + } + + QW_SCH_TASK_DLOG("drop task msg put to queue, vgId:%d", mgmt->nodeId); + + return TSDB_CODE_SUCCESS; +} + + int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq)); if (NULL == req) { @@ -167,9 +202,10 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { req->sId = sId; req->queryId = qId; req->taskId = tId; + req->execId = eId; SRpcMsg pNewMsg = { - .msgType = TDMT_VND_QUERY_CONTINUE, + .msgType = TDMT_SCH_QUERY_CONTINUE, .pCont = req, .contLen = sizeof(SQueryContinueReq), .code = 0, @@ -202,10 +238,10 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { req->refId = htobe64(rId); SRpcMsg brokenMsg = { - .msgType = TDMT_VND_DROP_TASK, + .msgType = TDMT_SCH_DROP_TASK, .pCont = req, .contLen = sizeof(STaskDropReq), - .code = TSDB_CODE_RPC_NETWORK_UNAVAIL, + .code = TSDB_CODE_RPC_BROKEN_LINK, .info = *pConn, }; @@ -236,10 +272,10 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo * } SRpcMsg brokenMsg = { - .msgType = TDMT_VND_QUERY_HEARTBEAT, + .msgType = TDMT_SCH_QUERY_HEARTBEAT, .pCont = msg, .contLen = msgSize, - .code = TSDB_CODE_RPC_NETWORK_UNAVAIL, + .code = TSDB_CODE_RPC_BROKEN_LINK, .info = *pConn, }; @@ -266,6 +302,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { msg->queryId = be64toh(msg->queryId); msg->taskId = be64toh(msg->taskId); msg->refId = be64toh(msg->refId); + msg->execId = ntohl(msg->execId); msg->phyLen = ntohl(msg->phyLen); msg->sqlLen = ntohl(msg->sqlLen); @@ -273,6 +310,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = msg->refId; + int32_t eId = msg->execId; SQWMsg qwMsg = {.msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info}; @@ -295,6 +333,7 @@ int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = msg->refId; + int32_t eId = msg->execId; QW_SCH_TASK_DLOG("Abort prerocessQuery start, handle:%p", pMsg->info.handle); qwAbortPrerocessQuery(QW_FPARAMS()); @@ -324,10 +363,11 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = msg->refId; + int32_t eId = msg->execId; - SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info}; + SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info, .msgType = pMsg->msgType}; char * sql = strndup(msg->msg, msg->sqlLen); - QW_SCH_TASK_DLOG("processQuery start, node:%p, handle:%p, sql:%s", node, pMsg->info.handle, sql); + QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, sql:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql); QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType, msg->explain, sql)); QW_SCH_TASK_DLOG("processQuery end, node:%p", node); @@ -356,6 +396,7 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = 0; + int32_t eId = msg->execId; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info}; @@ -387,11 +428,13 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); msg->taskId = be64toh(msg->taskId); + msg->execId = ntohl(msg->execId); uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = 0; + int32_t eId = msg->execId; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info}; @@ -437,11 +480,13 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in msg->queryId = be64toh(msg->queryId); msg->taskId = be64toh(msg->taskId); msg->refId = be64toh(msg->refId); + msg->execId = ntohl(msg->execId); uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = msg->refId; + int32_t eId = msg->execId; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info}; @@ -476,15 +521,17 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int6 msg->queryId = be64toh(msg->queryId); msg->taskId = be64toh(msg->taskId); msg->refId = be64toh(msg->refId); + msg->execId = ntohl(msg->execId); uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; int64_t rId = msg->refId; + int32_t eId = msg->execId; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info}; - if (TSDB_CODE_RPC_NETWORK_UNAVAIL == pMsg->code) { + if (TSDB_CODE_RPC_BROKEN_LINK == pMsg->code) { QW_SCH_TASK_DLOG("receive drop task due to network broken, error:%s", tstrerror(pMsg->code)); } @@ -522,7 +569,7 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_ uint64_t sId = req.sId; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info}; - if (TSDB_CODE_RPC_NETWORK_UNAVAIL == pMsg->code) { + if (TSDB_CODE_RPC_BROKEN_LINK == pMsg->code) { QW_SCH_DLOG("receive Hb msg due to network broken, error:%s", tstrerror(pMsg->code)); } @@ -553,6 +600,7 @@ int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SR uint64_t qId = req.queryId; uint64_t tId = req.taskId; int64_t rId = 0; + int32_t eId = -1; SQWMsg qwMsg = {.node = node, .msg = req.msg, .msgLen = req.phyLen, .connInfo = pMsg->info}; QW_SCH_TASK_DLOG("processDelete start, node:%p, handle:%p, sql:%s", node, pMsg->info.handle, req.sql); diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index 0759cf360a..1fb0a34314 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -135,8 +135,8 @@ int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchS void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt) { QW_UNLOCK(rwType, &mgmt->schLock); } int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, SQWTaskStatus **task) { - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); QW_LOCK(rwType, &sch->tasksLock); *task = taosHashGet(sch->tasksHash, id, sizeof(id)); @@ -151,8 +151,8 @@ int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, S int32_t qwAddTaskStatusImpl(QW_FPARAMS_DEF, SQWSchStatus *sch, int32_t rwType, int32_t status, SQWTaskStatus **task) { int32_t code = 0; - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); SQWTaskStatus ntask = {0}; ntask.status = status; @@ -207,8 +207,8 @@ int32_t qwAddAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch void qwReleaseTaskStatus(int32_t rwType, SQWSchStatus *sch) { QW_UNLOCK(rwType, &sch->tasksLock); } int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); *ctx = taosHashAcquire(mgmt->ctxHash, id, sizeof(id)); if (NULL == (*ctx)) { @@ -220,8 +220,8 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { } int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); *ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id)); if (NULL == (*ctx)) { @@ -233,8 +233,8 @@ int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { } int32_t qwAddTaskCtxImpl(QW_FPARAMS_DEF, bool acquire, SQWTaskCtx **ctx) { - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); SQWTaskCtx nctx = {0}; @@ -314,8 +314,8 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { } int32_t qwDropTaskCtx(QW_FPARAMS_DEF) { - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); SQWTaskCtx octx; SQWTaskCtx *ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id)); @@ -348,8 +348,8 @@ int32_t qwDropTaskStatus(QW_FPARAMS_DEF) { SQWTaskStatus *task = NULL; int32_t code = 0; - char id[sizeof(qId) + sizeof(tId)] = {0}; - QW_SET_QTID(id, qId, tId); + char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0}; + QW_SET_QTID(id, qId, tId, eId); if (qwAcquireScheduler(mgmt, sId, QW_WRITE, &sch)) { QW_TASK_WLOG_E("scheduler does not exist"); diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 4250785f7c..949b67249f 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -168,7 +168,7 @@ int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) // TODO GET EXECUTOR API TO GET MORE INFO - QW_GET_QTID(key, status.queryId, status.taskId); + QW_GET_QTID(key, status.queryId, status.taskId, status.execId); status.status = taskStatus->status; status.refId = taskStatus->refId; @@ -417,17 +417,10 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp } if (QW_PHASE_POST_QUERY == phase) { -#if 0 - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_READY)) { - readyConnection = &ctx->connInfo; - QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY); - } -#else connInfo = ctx->ctrlConnInfo; rspConnection = &connInfo; QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY); -#endif } if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { @@ -458,8 +451,8 @@ _return: } if (rspConnection) { - qwBuildAndSendQueryRsp(rspConnection, code, ctx ? &ctx->tbInfo : NULL); - QW_TASK_DLOG("ready msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code)); + qwBuildAndSendQueryRsp(input->msgType + 1, rspConnection, code, ctx ? &ctx->tbInfo : NULL); + QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code)); } if (ctx) { @@ -500,7 +493,9 @@ int32_t qwPrerocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { QW_ERR_JRET(qwRegisterQueryBrokenLinkArg(QW_FPARAMS(), &qwMsg->connInfo)); - QW_ERR_JRET(qwAddAcquireTaskCtx(QW_FPARAMS(), &ctx)); + QW_ERR_JRET(qwAddTaskCtx(QW_FPARAMS())); + + QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx)); ctx->ctrlConnInfo = qwMsg->connInfo; @@ -530,8 +525,9 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx)); - atomic_store_8(&ctx->taskType, taskType); - atomic_store_8(&ctx->explain, explain); + ctx->taskType = taskType; + ctx->explain = explain; + ctx->queryType = qwMsg->msgType; QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg); @@ -571,6 +567,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex _return: input.code = code; + input.msgType = qwMsg->msgType; code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_QUERY, &input, NULL); // if (!queryRsped) { @@ -739,8 +736,6 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { SQWTaskCtx *ctx = NULL; bool locked = false; - // TODO : TASK ALREADY REMOVED AND A NEW DROP MSG RECEIVED - QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx)); QW_LOCK(QW_WRITE, &ctx->lock); diff --git a/source/libs/qworker/test/qworkerTests.cpp b/source/libs/qworker/test/qworkerTests.cpp index 5bb6acee60..bc37400249 100644 --- a/source/libs/qworker/test/qworkerTests.cpp +++ b/source/libs/qworker/test/qworkerTests.cpp @@ -122,7 +122,7 @@ void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) { qwtqueryMsg.taskId = htobe64(1); qwtqueryMsg.phyLen = htonl(100); qwtqueryMsg.sqlLen = 0; - queryRpc->msgType = TDMT_VND_QUERY; + queryRpc->msgType = TDMT_SCH_QUERY; queryRpc->pCont = &qwtqueryMsg; queryRpc->contLen = sizeof(SSubQueryMsg) + 100; } @@ -131,7 +131,7 @@ void qwtBuildFetchReqMsg(SResFetchReq *fetchMsg, SRpcMsg *fetchRpc) { fetchMsg->sId = htobe64(1); fetchMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId)); fetchMsg->taskId = htobe64(1); - fetchRpc->msgType = TDMT_VND_FETCH; + fetchRpc->msgType = TDMT_SCH_FETCH; fetchRpc->pCont = fetchMsg; fetchRpc->contLen = sizeof(SResFetchReq); } @@ -140,7 +140,7 @@ void qwtBuildDropReqMsg(STaskDropReq *dropMsg, SRpcMsg *dropRpc) { dropMsg->sId = htobe64(1); dropMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId)); dropMsg->taskId = htobe64(1); - dropRpc->msgType = TDMT_VND_DROP_TASK; + dropRpc->msgType = TDMT_SCH_DROP_TASK; dropRpc->pCont = dropMsg; dropRpc->contLen = sizeof(STaskDropReq); } @@ -202,7 +202,8 @@ void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) void qwtRpcSendResponse(const SRpcMsg *pRsp) { switch (pRsp->msgType) { - case TDMT_VND_QUERY_RSP: { + case TDMT_SCH_QUERY_RSP: + case TDMT_SCH_MERGE_QUERY_RSP: { SQueryTableRsp *rsp = (SQueryTableRsp *)pRsp->pCont; if (pRsp->code) { @@ -213,7 +214,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) { rpcFreeCont(rsp); break; } - case TDMT_VND_FETCH_RSP: { + case TDMT_SCH_FETCH_RSP: { SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)pRsp->pCont; if (0 == pRsp->code && 0 == rsp->completed) { @@ -229,7 +230,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) { break; } - case TDMT_VND_DROP_TASK_RSP: { + case TDMT_SCH_DROP_TASK_RSP: { STaskDropRsp *rsp = (STaskDropRsp *)pRsp->pCont; rpcFreeCont(rsp); @@ -756,9 +757,9 @@ void *queryQueueThread(void *param) { } } - if (TDMT_VND_QUERY == queryRpc->msgType) { + if (TDMT_SCH_QUERY == queryRpc->msgType) { qWorkerProcessQueryMsg(mockPointer, mgmt, queryRpc, 0); - } else if (TDMT_VND_QUERY_CONTINUE == queryRpc->msgType) { + } else if (TDMT_SCH_QUERY_CONTINUE == queryRpc->msgType) { qWorkerProcessCQueryMsg(mockPointer, mgmt, queryRpc, 0); } else { printf("unknown msg in query queue, type:%d\n", queryRpc->msgType); @@ -813,13 +814,13 @@ void *fetchQueueThread(void *param) { } switch (fetchRpc->msgType) { - case TDMT_VND_FETCH: + case TDMT_SCH_FETCH: qWorkerProcessFetchMsg(mockPointer, mgmt, fetchRpc, 0); break; - case TDMT_VND_CANCEL_TASK: + case TDMT_SCH_CANCEL_TASK: qWorkerProcessCancelMsg(mockPointer, mgmt, fetchRpc, 0); break; - case TDMT_VND_DROP_TASK: + case TDMT_SCH_DROP_TASK: qWorkerProcessDropMsg(mockPointer, mgmt, fetchRpc, 0); break; default: diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index b8bcae161b..42be99d08b 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -192,6 +192,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_TIMESTAMP: return 18; + case TSDB_DATA_TYPE_JSON: + terrno = TSDB_CODE_QRY_JSON_IN_ERROR; + return 0; default: assert(0); } @@ -215,6 +218,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_TIMESTAMP: return 24; + case TSDB_DATA_TYPE_JSON: + terrno = TSDB_CODE_QRY_JSON_IN_ERROR; + return 0; default: assert(0); } @@ -2059,7 +2065,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t } if (colIdxi > 1) { - qsort(colIdx, colIdxi, sizeof(uint32_t), getComparFunc(TSDB_DATA_TYPE_USMALLINT, 0)); + taosSort(colIdx, colIdxi, sizeof(uint32_t), getComparFunc(TSDB_DATA_TYPE_USMALLINT, 0)); } for (uint32_t l = 0; l < colIdxi; ++l) { @@ -2294,7 +2300,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR return TSDB_CODE_SUCCESS; } - qsort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx); + taosSort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx); int32_t pEnd = 0, cStart = 0, cEnd = 0; uint32_t pColNum = 0, cColNum = 0; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cef8ff7075..d093c8bdbd 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -287,7 +287,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC int32_t code = 0; if (NULL == pParamList) { if (ctx->pBlockList) { - SSDataBlock *pBlock = taosArrayGet(ctx->pBlockList, 0); + SSDataBlock *pBlock = taosArrayGetP(ctx->pBlockList, 0); *rowNum = pBlock->info.rows; } else { *rowNum = 1; @@ -551,7 +551,9 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp SScalarParam* pLeft = ¶ms[0]; SScalarParam* pRight = paramNum > 1 ? ¶ms[1] : NULL; + terrno = TSDB_CODE_SUCCESS; OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC); + code = terrno; _return: for (int32_t i = 0; i < paramNum; ++i) { @@ -693,7 +695,11 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { res->node.resType.scale = output.columnData->info.scale; res->node.resType.precision = output.columnData->info.precision; int32_t type = output.columnData->info.type; - if (IS_VAR_DATA_TYPE(type)) { + if (type == TSDB_DATA_TYPE_JSON){ + int32_t len = getJsonValueLen(output.columnData->pData); + res->datum.p = taosMemoryCalloc(len, 1); + memcpy(res->datum.p, output.columnData->pData, len); + } else if (IS_VAR_DATA_TYPE(type)) { res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1); memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData)); } else { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 76c0e48740..3a219b78b5 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1152,42 +1152,30 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu char tmp[TSDB_MAX_JSON_TAG_LEN] = {0}; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { - if (colDataIsNull_s(pInput[0].columnData, i)) { - colDataAppendNULL(pOutput->columnData, i); - continue; - } - char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[i]; + SArray* pTagVals = taosArrayInit(8, sizeof(STagVal)); + STag* pTag = NULL; - if(type == TSDB_DATA_TYPE_NCHAR){ - if (varDataTLen(input) > TSDB_MAX_JSON_TAG_LEN){ - colDataAppendNULL(pOutput->columnData, i); - continue; - } - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), tmp); - if (len < 0) { - colDataAppendNULL(pOutput->columnData, i); - continue; - } - tmp[len] = 0; + if (colDataIsNull_s(pInput[0].columnData, i)) { + tTagNew(pTagVals, 1, true, &pTag); }else{ + char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[i]; if (varDataLen(input) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){ - colDataAppendNULL(pOutput->columnData, i); - continue; + taosArrayDestroy(pTagVals); + return TSDB_CODE_FAILED; } memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; + if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){ + tTagNew(pTagVals, 1, true, &pTag); + } } - if(!tjsonValidateJson(tmp)){ - colDataAppendNULL(pOutput->columnData, i); - continue; - } - - colDataAppend(pOutput->columnData, i, input, false); + colDataAppend(pOutput->columnData, i, (const char*)pTag, false); + tTagFree(pTag); + taosArrayDestroy(pTagVals); } pOutput->numOfRows = pInput->numOfRows; - return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 292db3db1f..18bbacd5b7 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -160,6 +160,9 @@ int64_t getVectorBigintValue_JSON(void *src, int32_t index){ return 0; } else if(*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY convertNcharToDouble(data+CHAR_BYTES, &out); + } else if(tTagIsJson(data)){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return 0; } else { convertNumberToNumber(data+CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); } @@ -416,6 +419,9 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in else if(*data == TSDB_DATA_TYPE_NCHAR) { data += CHAR_BYTES; convertType = TSDB_DATA_TYPE_NCHAR; + } else if(tTagIsJson(data)){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return terrno; } else { convertNumberToNumber(data+CHAR_BYTES, colDataGetNumData(pOut->columnData, i), *data, outType); continue; @@ -461,7 +467,10 @@ double getVectorDoubleValue_JSON(void *src, int32_t index){ return out; } else if(*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY convertNcharToDouble(data+CHAR_BYTES, &out); - } else { + } else if(tTagIsJson(data)){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return 0; + } else{ convertNumberToNumber(data+CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); } return out; @@ -493,10 +502,18 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t } if(typeLeft == TSDB_DATA_TYPE_JSON){ + if(tTagIsJson(*pLeftData)){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return false; + } typeLeft = **pLeftData; (*pLeftData) ++; } if(typeRight == TSDB_DATA_TYPE_JSON){ + if(tTagIsJson(*pLeftData)){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; + return false; + } typeRight = **pRightData; (*pRightData) ++; } @@ -1576,7 +1593,11 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; + __compar_fn_t fp = filterGetCompFunc(GET_PARAM_TYPE(pLeft), optr); + if(terrno != TSDB_CODE_SUCCESS){ + return; + } pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); @@ -1709,6 +1730,7 @@ void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, STagVal getJsonValue(char *json, char *key, bool *isExist) { STagVal val = {.pKey = key}; if (tTagIsJson((const STag *)json) == false){ + terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; if(isExist){ *isExist = false; } diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 5998ab6965..aaa8274ce8 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -125,7 +125,7 @@ typedef struct SSchTaskCallbackParam { uint64_t queryId; int64_t refId; uint64_t taskId; - int32_t execIdx; + int32_t execId; void *pTrans; } SSchTaskCallbackParam; @@ -171,7 +171,7 @@ typedef struct SSchTask { uint64_t taskId; // task id SRWLatch lock; // task lock int32_t maxExecTimes; // task may exec times - int32_t execIdx; // task current execute try index + int32_t execId; // task current execute try index SSchLevel *level; // level SRWLatch planLock; // task update plan lock SSubplan *plan; // subplan @@ -244,9 +244,9 @@ extern SSchedulerMgmt schMgmt; #define SCH_LOG_TASK_START_TS(_task) \ do { \ int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \ + int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ (_task)->profile.execUseTime[idx] = us; \ - if (0 == (_task)->execIdx) { \ + if (0 == (_task)->execId) { \ (_task)->profile.startTs = us; \ } \ } while (0) @@ -254,7 +254,7 @@ extern SSchedulerMgmt schMgmt; #define SCH_LOG_TASK_WAIT_TS(_task) \ do { \ int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \ + int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ (_task)->profile.waitTime += us - (_task)->profile.execUseTime[idx]; \ } while (0) @@ -262,12 +262,12 @@ extern SSchedulerMgmt schMgmt; #define SCH_LOG_TASK_END_TS(_task) \ do { \ int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \ + int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ (_task)->profile.execUseTime[idx] = us - (_task)->profile.execUseTime[idx]; \ (_task)->profile.endTs = us; \ } while (0) -#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec) +#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execId % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec) #define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children)) @@ -275,8 +275,7 @@ extern SSchedulerMgmt schMgmt; #define SCH_UNLOCK_TASK(_task) SCH_UNLOCK(SCH_WRITE, &(_task)->lock) #define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1) -#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0) -#define SCH_GET_TASK_LASTMSG_TYPE(_task) ((_task) ? atomic_load_32(&(_task)->lastMsgType) : -1) +#define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1) #define SCH_IS_DATA_SRC_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) #define SCH_IS_DATA_SRC_TASK(task) (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) @@ -307,6 +306,11 @@ extern SSchedulerMgmt schMgmt; #define SCH_IS_WAIT_ALL_JOB(_job) (!SCH_IS_QUERY_JOB(_job)) #define SCH_IS_NEED_DROP_JOB(_job) (SCH_IS_QUERY_JOB(_job)) #define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode) +#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) +#define SCH_SUB_TASK_NETWORK_ERR(_code, _len) (SCH_NETWORK_ERR(_code) && ((_len) > 0)) +#define SCH_NEED_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH) +#define SCH_NEED_REDIRECT(_msgType, _code, _rspLen) (SCH_NEED_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_SUB_TASK_NETWORK_ERR(_code, _rspLen))) +#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_NEED_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) #define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum) #define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse]) @@ -317,13 +321,13 @@ extern SSchedulerMgmt schMgmt; #define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__) #define SCH_TASK_ELOG(param, ...) \ - qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__) + qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) #define SCH_TASK_DLOG(param, ...) \ - qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__) + qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) #define SCH_TASK_DLOGL(param, ...) \ - qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__) + qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) #define SCH_TASK_WLOG(param, ...) \ - qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__) + qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) #define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) #define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) @@ -354,7 +358,7 @@ void schFreeJobImpl(void *job); int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx); int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask); int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans); -int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code); +int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code); void schFreeRpcCtx(SRpcCtx *pCtx); int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp); bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus); @@ -365,7 +369,7 @@ void schProcessOnDataFetched(SSchJob *job); int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask); void schFreeRpcCtxVal(const void *arg); int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb); -int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx); +int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId); int32_t schExecStaticExplainJob(SSchedulerReq *pReq, int64_t *job, bool sync); int32_t schExecJobImpl(SSchedulerReq *pReq, SSchJob *pJob, bool sync); int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus); @@ -377,13 +381,15 @@ int32_t schExecJob(SSchedulerReq *pReq, int64_t *pJob, SQueryResult *pRes); int32_t schAsyncExecJob(SSchedulerReq *pReq, int64_t *pJob); int32_t schFetchRows(SSchJob *pJob); int32_t schAsyncFetchRows(SSchJob *pJob); -int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx); +int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId); int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList); void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo); char* schGetOpStr(SCH_OP_TYPE type); int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync); int32_t schInitJob(SSchedulerReq *pReq, SSchJob **pSchJob); int32_t schSetJobQueryRes(SSchJob* pJob, SQueryResult* pRes); +int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSet); +int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode); #ifdef __cplusplus diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index bd3a944c3f..6e4838e50c 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -28,7 +28,7 @@ FORCE_INLINE int32_t schReleaseJob(int64_t refId) { qDebug("sch release jobId:0x int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) { pTask->plan = pPlan; pTask->level = pLevel; - pTask->execIdx = -1; + pTask->execId = -1; pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES; pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC; SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START); @@ -429,59 +429,59 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx) { +int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId) { SSchNodeInfo nodeInfo = {.addr = *addr, .handle = NULL}; - if (taosHashPut(pTask->execNodes, &execIdx, sizeof(execIdx), &nodeInfo, sizeof(nodeInfo))) { + if (taosHashPut(pTask->execNodes, &execId, sizeof(execId), &nodeInfo, sizeof(nodeInfo))) { SCH_TASK_ELOG("taosHashPut nodeInfo to execNodes failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - SCH_TASK_DLOG("task execNode added, execIdx:%d", execIdx); + SCH_TASK_DLOG("task execNode added, execId:%d", execId); return TSDB_CODE_SUCCESS; } -int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execIdx) { +int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId) { if (NULL == pTask->execNodes) { return TSDB_CODE_SUCCESS; } - if (taosHashRemove(pTask->execNodes, &execIdx, sizeof(execIdx))) { - SCH_TASK_ELOG("fail to remove execIdx %d from execNodeList", execIdx); + if (taosHashRemove(pTask->execNodes, &execId, sizeof(execId))) { + SCH_TASK_ELOG("fail to remove execId %d from execNodeList", execId); } else { - SCH_TASK_DLOG("execIdx %d removed from execNodeList", execIdx); + SCH_TASK_DLOG("execId %d removed from execNodeList", execId); } - if (execIdx != pTask->execIdx) { // ignore it - SCH_TASK_DLOG("execIdx %d is not current execIdx %d", execIdx, pTask->execIdx); + if (execId != pTask->execId) { // ignore it + SCH_TASK_DLOG("execId %d is not current execId %d", execId, pTask->execId); SCH_RET(TSDB_CODE_SCH_IGNORE_ERROR); } return TSDB_CODE_SUCCESS; } -int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execIdx) { +int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId) { if (taosHashGetSize(pTask->execNodes) <= 0) { return TSDB_CODE_SUCCESS; } - SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execIdx, sizeof(execIdx)); + SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId)); nodeInfo->handle = handle; - SCH_TASK_DLOG("handle updated to %p for execIdx %d", handle, execIdx); + SCH_TASK_DLOG("handle updated to %p for execId %d", handle, execId); return TSDB_CODE_SUCCESS; } -int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx) { +int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId) { if (dropExecNode) { - SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execIdx)); + SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execId)); } SCH_SET_TASK_HANDLE(pTask, handle); - schUpdateTaskExecNode(pJob, pTask, handle, execIdx); + schUpdateTaskExecNode(pJob, pTask, handle, execId); return TSDB_CODE_SUCCESS; } @@ -683,6 +683,25 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_SUCCESS; } +int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSet) { + if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) { + SCH_TASK_ELOG("not able to update cndidate addr, addr num %d", (int32_t)(pTask->candidateAddrs ? taosArrayGetSize(pTask->candidateAddrs): 0)); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); + } + + SQueryNodeAddr* pAddr = taosArrayGet(pTask->candidateAddrs, 0); + + SEp* pOld = &pAddr->epSet.eps[pAddr->epSet.inUse]; + SEp* pNew = &pEpSet->eps[pEpSet->inUse]; + + SCH_TASK_DLOG("update task ep from %s:%d to %s:%d", pOld->fqdn, pOld->port, pNew->fqdn, pNew->port); + + memcpy(&pAddr->epSet, pEpSet, sizeof(pAddr->epSet)); + + return TSDB_CODE_SUCCESS; +} + + int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) { int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId)); if (code) { @@ -810,23 +829,22 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo } } - if ((pTask->execIdx + 1) >= pTask->maxExecTimes) { + if ((pTask->execId + 1) >= pTask->maxExecTimes) { *needRetry = false; - SCH_TASK_DLOG("task no more retry since reach max try times, execIdx:%d", pTask->execIdx); + SCH_TASK_DLOG("task no more retry since reach max try times, execId:%d", pTask->execId); return TSDB_CODE_SUCCESS; } - if (!NEED_SCHEDULER_RETRY_ERROR(errCode)) { + if (!SCH_NEED_RETRY(pTask->lastMsgType, errCode)) { *needRetry = false; SCH_TASK_DLOG("task no more retry cause of errCode, errCode:%x - %s", errCode, tstrerror(errCode)); return TSDB_CODE_SUCCESS; } - // TODO CHECK epList/condidateList if (SCH_IS_DATA_SRC_TASK(pTask)) { - if ((pTask->execIdx + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) { + if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) { *needRetry = false; - SCH_TASK_DLOG("task no more retry since all ep tried, execIdx:%d, epNum:%d", pTask->execIdx, + SCH_TASK_DLOG("task no more retry since all ep tried, execId:%d, epNum:%d", pTask->execId, SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)); return TSDB_CODE_SUCCESS; } @@ -842,7 +860,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo } *needRetry = true; - SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execIdx + 1, errCode, tstrerror(errCode)); + SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execId + 1, errCode, tstrerror(errCode)); return TSDB_CODE_SUCCESS; } @@ -854,7 +872,6 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) { SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START); if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { - SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask)); SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask)); } @@ -1155,6 +1172,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { SDownstreamSourceNode source = {.type = QUERY_NODE_DOWNSTREAM_SOURCE, .taskId = pTask->taskId, .schedId = schMgmt.sId, + .execId = pTask->execId, .addr = pTask->succeedAddr}; qSetSubplanExecutionNode(parent->plan, pTask->plan->id.groupId, &source); SCH_UNLOCK(SCH_WRITE, &parent->lock); @@ -1184,7 +1202,7 @@ int32_t schFetchFromRemote(SSchJob *pJob) { return TSDB_CODE_SUCCESS; } - SCH_ERR_JRET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, TDMT_VND_FETCH)); + SCH_ERR_JRET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, TDMT_SCH_FETCH)); return TSDB_CODE_SUCCESS; @@ -1223,7 +1241,7 @@ void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) { while (nodeInfo) { SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle); - schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_VND_DROP_TASK); + schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_SCH_DROP_TASK); nodeInfo = taosHashIterate(pTask->execNodes, nodeInfo); } @@ -1238,8 +1256,9 @@ int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) { } SCH_LOCK_TASK(pTask); - if (JOB_TASK_STATUS_EXECUTING == pTask->status && pJob->fetchTask != pTask && taosArrayGetSize(pTask->candidateAddrs) > 1) { - SCH_TASK_DLOG("task execIdx %d will be rescheduled now", pTask->execIdx); + if (SCH_TASK_TIMEOUT(pTask) && JOB_TASK_STATUS_EXECUTING == pTask->status && + pJob->fetchTask != pTask && taosArrayGetSize(pTask->candidateAddrs) > 1) { + SCH_TASK_DLOG("task execId %d will be rescheduled now", pTask->execId); schDropTaskOnExecNode(pJob, pTask); taosHashClear(pTask->execNodes); schProcessOnTaskFailure(pJob, pTask, TSDB_CODE_SCH_TIMEOUT_ERROR); @@ -1258,6 +1277,9 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) { for (int32_t i = 0; i < taskNum; ++i) { STaskStatus *taskStatus = taosArrayGet(pStatusList, i); + qDebug("QID:%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d task status in server: %s", + taskStatus->queryId, taskStatus->taskId, taskStatus->execId, jobTaskStatusStr(taskStatus->status)); + SSchJob *pJob = schAcquireJob(taskStatus->refId); if (NULL == pJob) { qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId, @@ -1266,8 +1288,6 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) { continue; } - SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, jobTaskStatusStr(taskStatus->status)); - pTask = NULL; schGetTaskInJob(pJob, taskStatus->taskId, &pTask); if (NULL == pTask) { @@ -1275,6 +1295,13 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) { schReleaseJob(taskStatus->refId); continue; } + + if (taskStatus->execId != pTask->execId) { + // TODO DROP TASK FROM SERVER!!!! + SCH_TASK_DLOG("EID %d in hb rsp mis-match", taskStatus->execId); + schReleaseJob(taskStatus->refId); + continue; + } if (taskStatus->status == JOB_TASK_STATUS_FAILED) { // RECORD AND HANDLE ERROR!!!! @@ -1282,7 +1309,7 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) { continue; } - if (taskStatus->status == JOB_TASK_STATUS_NOT_START && SCH_TASK_TIMEOUT(pTask)) { + if (taskStatus->status == JOB_TASK_STATUS_NOT_START) { schRescheduleTask(pJob, pTask); } @@ -1308,7 +1335,7 @@ int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) { tbInfo.tversion = rsp->tversion; taosArrayPush((SArray *)pJob->execRes.res, &tbInfo); - pJob->execRes.msgType = TDMT_VND_QUERY; + pJob->execRes.msgType = TDMT_SCH_QUERY; } return TSDB_CODE_SUCCESS; @@ -1345,9 +1372,9 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { int32_t code = 0; atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1); - pTask->execIdx++; + pTask->execId++; - SCH_TASK_DLOG("start to launch task's %dth exec", pTask->execIdx); + SCH_TASK_DLOG("start to launch task's %dth exec", pTask->execId); SCH_LOG_TASK_START_TS(pTask); @@ -1658,5 +1685,94 @@ _return: SCH_RET(code); } +int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode) { + int32_t code = 0; + int8_t status = 0; + if (schJobNeedToStop(pJob, &status)) { + SCH_TASK_ELOG("redirect will no continue cause of job status %s", jobTaskStatusStr(status)); + SCH_RET(atomic_load_32(&pJob->errCode)); + } + + if ((pTask->execId + 1) >= pTask->maxExecTimes) { + SCH_TASK_DLOG("task no more retry since reach max try times, execId:%d", pTask->execId); + schProcessOnJobFailure(pJob, rspCode); + return TSDB_CODE_SUCCESS; + } + + SCH_TASK_DLOG("task will be redirected now, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); + + schDropTaskOnExecNode(pJob, pTask); + taosHashClear(pTask->execNodes); + SCH_ERR_JRET(schRemoveTaskFromExecList(pJob, pTask)); + schDeregisterTaskHb(pJob, pTask); + atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1); + taosMemoryFreeClear(pTask->msg); + pTask->msgLen = 0; + pTask->lastMsgType = 0; + memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr)); + + if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (pData) { + SCH_ERR_JRET(schUpdateTaskCandidateAddr(pJob, pTask, pData->pEpSet)); + } + + if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { + if (JOB_TASK_STATUS_EXECUTING == SCH_GET_TASK_STATUS(pTask)) { + SCH_ERR_JRET(schLaunchTasksInFlowCtrlList(pJob, pTask)); + } + } + + SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START); + + SCH_ERR_JRET(schLaunchTask(pJob, pTask)); + + return TSDB_CODE_SUCCESS; + } + + + // merge plan + + pTask->childReady = 0; + + qClearSubplanExecutionNode(pTask->plan); + + SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START); + + int32_t childrenNum = taosArrayGetSize(pTask->children); + for (int32_t i = 0; i < childrenNum; ++i) { + SSchTask* pChild = taosArrayGetP(pTask->children, i); + SCH_LOCK_TASK(pChild); + schDoTaskRedirect(pJob, pChild, NULL, rspCode); + SCH_UNLOCK_TASK(pChild); + } + + return TSDB_CODE_SUCCESS; + +_return: + + code = schProcessOnTaskFailure(pJob, pTask, code); + + SCH_RET(code); +} + +int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode) { + int32_t code = 0; + + if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (NULL == pData->pEpSet) { + SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode)); + SCH_ERR_JRET(rspCode); + } + } + + SCH_RET(schDoTaskRedirect(pJob, pTask, pData, rspCode)); + +_return: + + schProcessOnTaskFailure(pJob, pTask, code); + + SCH_RET(code); +} + diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 0bd747785c..02e7b085ae 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -23,14 +23,15 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { - int32_t lastMsgType = SCH_GET_TASK_LASTMSG_TYPE(pTask); + int32_t lastMsgType = pTask->lastMsgType; int32_t taskStatus = SCH_GET_TASK_STATUS(pTask); int32_t reqMsgType = msgType - 1; switch (msgType) { case TDMT_SCH_LINK_BROKEN: - case TDMT_VND_EXPLAIN_RSP: + case TDMT_SCH_EXPLAIN_RSP: return TSDB_CODE_SUCCESS; - case TDMT_VND_QUERY_RSP: // query_rsp may be processed later than ready_rsp + case TDMT_SCH_MERGE_QUERY_RSP: + case TDMT_SCH_QUERY_RSP: // query_rsp may be processed later than ready_rsp if (lastMsgType != reqMsgType && -1 != lastMsgType) { SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); @@ -41,9 +42,9 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy TMSG_INFO(msgType)); } - SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); + //SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; - case TDMT_VND_FETCH_RSP: + case TDMT_SCH_FETCH_RSP: if (lastMsgType != reqMsgType && -1 != lastMsgType) { SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); @@ -56,7 +57,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); + //SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; case TDMT_VND_CREATE_TABLE_RSP: case TDMT_VND_DROP_TABLE_RSP: @@ -81,7 +82,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); + //SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; } @@ -90,15 +91,6 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) { int32_t code = 0; - int8_t status = 0; - - if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode); - taosMemoryFreeClear(msg); - SCH_RET(atomic_load_32(&pJob->errCode)); - } - - SCH_ERR_JRET(schValidateReceivedMsgType(pJob, pTask, msgType)); switch (msgType) { case TDMT_VND_CREATE_TABLE_RSP: { @@ -247,7 +239,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch break; } - case TDMT_VND_QUERY_RSP: { + case TDMT_SCH_QUERY_RSP: + case TDMT_SCH_MERGE_QUERY_RSP: { SQueryTableRsp *rsp = (SQueryTableRsp *)msg; SCH_ERR_JRET(rspCode); @@ -264,7 +257,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch break; } - case TDMT_VND_EXPLAIN_RSP: { + case TDMT_SCH_EXPLAIN_RSP: { SCH_ERR_JRET(rspCode); if (NULL == msg) { SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); @@ -294,7 +287,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch } break; } - case TDMT_VND_FETCH_RSP: { + case TDMT_SCH_FETCH_RSP: { SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg; SCH_ERR_JRET(rspCode); @@ -342,8 +335,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch schProcessOnDataFetched(pJob); break; } - case TDMT_VND_DROP_TASK_RSP: { - // SHOULD NEVER REACH HERE + case TDMT_SCH_DROP_TASK_RSP: { + // NEVER REACH HERE SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:0x%" PRIx64, pJob->refId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); break; @@ -367,8 +360,9 @@ _return: } -int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { +int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; + int32_t msgType = pMsg->msgType; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; SSchTask *pTask = NULL; @@ -385,15 +379,31 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in SCH_TASK_DLOG("rsp msg received, type:%s, handle:%p, code:%s", TMSG_INFO(msgType), pMsg->handle, tstrerror(rspCode)); - if (pParam->execIdx != pTask->execIdx) { - SCH_TASK_DLOG("execIdx %d mis-match current execIdx %d", pParam->execIdx, pTask->execIdx); + if (pParam->execId != pTask->execId) { + SCH_TASK_DLOG("execId %d mis-match current execId %d", pParam->execId, pTask->execId); goto _return; } - bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || rspCode == TSDB_CODE_RPC_NETWORK_UNAVAIL); - SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, pParam->execIdx)); + bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); + SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, pParam->execId)); + + int8_t status = 0; + if (schJobNeedToStop(pJob, &status)) { + SCH_TASK_ELOG("rsp will not be processed cause of job status %s, rspCode:0x%x", jobTaskStatusStr(status), rspCode); + code = atomic_load_32(&pJob->errCode); + goto _return; + } + + SCH_ERR_JRET(schValidateReceivedMsgType(pJob, pTask, msgType)); + + int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); + if (SCH_NEED_REDIRECT(reqType, rspCode, pMsg->len)) { + code = schHandleRedirect(pJob, pTask, (SDataBuf *)pMsg, rspCode); + goto _return; + } - SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode)); + code = schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode); + pMsg->pData = NULL; _return: @@ -405,50 +415,19 @@ _return: schReleaseJob(pParam->refId); } + taosMemoryFreeClear(pMsg->pData); taosMemoryFreeClear(param); SCH_RET(code); } -int32_t schHandleSubmitCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_SUBMIT_RSP, code); -} - -int32_t schHandleCreateTbCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_CREATE_TABLE_RSP, code); -} - -int32_t schHandleDropTbCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_DROP_TABLE_RSP, code); -} - -int32_t schHandleAlterTbCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_ALTER_TABLE_RSP, code); -} - -int32_t schHandleQueryCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_QUERY_RSP, code); -} - -int32_t schHandleDeleteCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_DELETE_RSP, code); -} - -int32_t schHandleFetchCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_FETCH_RSP, code); -} - -int32_t schHandleExplainCallback(void *param, const SDataBuf *pMsg, int32_t code) { - return schHandleCallback(param, pMsg, TDMT_VND_EXPLAIN_RSP, code); -} - -int32_t schHandleDropCallback(void *param, const SDataBuf *pMsg, int32_t code) { +int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId, code); taosMemoryFreeClear(param); return TSDB_CODE_SUCCESS; } -int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t code) { +int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchCallbackParamHeader *head = (SSchCallbackParamHeader *)param; rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); @@ -461,7 +440,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId, NULL)); } else { - SCH_ERR_RET(schHandleCallback(param, pMsg, TDMT_SCH_LINK_BROKEN, code)); + SCH_ERR_RET(schHandleCallback(param, pMsg, code)); } return TSDB_CODE_SUCCESS; @@ -480,7 +459,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo param->refId = pJob->refId; param->taskId = SCH_TASK_ID(pTask); param->pTrans = pJob->conn.pTrans; - param->execIdx = pTask->execIdx; + param->execId = pTask->execId; *pParam = param; return TSDB_CODE_SUCCESS; @@ -557,33 +536,20 @@ _return: int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { switch (msgType) { case TDMT_VND_CREATE_TABLE: - *fp = schHandleCreateTbCallback; - break; case TDMT_VND_DROP_TABLE: - *fp = schHandleDropTbCallback; - break; case TDMT_VND_ALTER_TABLE: - *fp = schHandleAlterTbCallback; - break; case TDMT_VND_SUBMIT: - *fp = schHandleSubmitCallback; - break; - case TDMT_VND_QUERY: - *fp = schHandleQueryCallback; - break; + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: case TDMT_VND_DELETE: - *fp = schHandleDeleteCallback; + case TDMT_SCH_EXPLAIN: + case TDMT_SCH_FETCH: + *fp = schHandleCallback; break; - case TDMT_VND_EXPLAIN: - *fp = schHandleExplainCallback; - break; - case TDMT_VND_FETCH: - *fp = schHandleFetchCallback; - break; - case TDMT_VND_DROP_TASK: + case TDMT_SCH_DROP_TASK: *fp = schHandleDropCallback; break; - case TDMT_VND_QUERY_HEARTBEAT: + case TDMT_SCH_QUERY_HEARTBEAT: *fp = schHandleHbCallback; break; case TDMT_SCH_LINK_BROKEN: @@ -692,9 +658,9 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP; + int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP; __async_send_cb_fn_t fp = NULL; - SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp)); + SCH_ERR_JRET(schGetCallbackFp(TDMT_SCH_QUERY_HEARTBEAT, &fp)); param->nodeEpId = epId; param->pTrans = pJob->conn.pTrans; @@ -722,7 +688,7 @@ _return: SCH_RET(code); } -int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { +int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchedulerHbRsp rsp = {0}; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; @@ -784,9 +750,9 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { } SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; - SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, NULL, 0, TDMT_VND_EXPLAIN, &trans, false, &pExplainMsgSendInfo)); + SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, NULL, 0, TDMT_SCH_EXPLAIN, &trans, false, &pExplainMsgSendInfo)); - int32_t msgType = TDMT_VND_EXPLAIN_RSP; + int32_t msgType = TDMT_SCH_EXPLAIN_RSP; SRpcCtxVal ctxVal = {.val = pExplainMsgSendInfo, .clone = schCloneSMsgSendInfo}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); @@ -882,7 +848,7 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, SSchTrans *trans, SQuery SEpSet *epSet = &addr->epSet; SMsgSendInfo *pMsgSendInfo = NULL; - bool isHb = (TDMT_VND_QUERY_HEARTBEAT == msgType); + bool isHb = (TDMT_SCH_QUERY_HEARTBEAT == msgType); SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, msg, msgSize, msgType, trans, isHb, &pMsgSendInfo)); SCH_ERR_JRET(schUpdateSendTargetInfo(pMsgSendInfo, addr, pTask)); @@ -890,6 +856,9 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, SSchTrans *trans, SQuery addr->nodeId, epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, trans->pTrans, trans->pHandle); + if (pTask) { + pTask->lastMsgType = msgType; + } int64_t transporterId = 0; code = asyncSendMsgToServerExt(trans->pTrans, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx); @@ -926,7 +895,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray* taskAction) { int32_t code = 0; SRpcCtx rpcCtx = {0}; SSchTrans trans = {0}; - int32_t msgType = TDMT_VND_QUERY_HEARTBEAT; + int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT; req.header.vgId = nodeEpId->nodeId; req.sId = schMgmt.sId; @@ -1032,7 +1001,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, tSerializeSVDeleteReq(msg, msgSize, &req); break; } - case TDMT_VND_QUERY: { + case TDMT_SCH_QUERY: + case TDMT_SCH_MERGE_QUERY: { SCH_ERR_RET(schMakeQueryRpcCtx(pJob, pTask, &rpcCtx)); uint32_t len = strlen(pJob->sql); @@ -1049,6 +1019,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, pMsg->queryId = htobe64(pJob->queryId); pMsg->taskId = htobe64(pTask->taskId); pMsg->refId = htobe64(pJob->refId); + pMsg->execId = htonl(pTask->execId); pMsg->taskType = TASK_TYPE_TEMP; pMsg->explain = SCH_IS_EXPLAIN_JOB(pJob); pMsg->phyLen = htonl(pTask->msgLen); @@ -1060,7 +1031,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, persistHandle = true; break; } - case TDMT_VND_FETCH: { + case TDMT_SCH_FETCH: { msgSize = sizeof(SResFetchReq); msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { @@ -1075,10 +1046,11 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, pMsg->sId = htobe64(schMgmt.sId); pMsg->queryId = htobe64(pJob->queryId); pMsg->taskId = htobe64(pTask->taskId); + pMsg->execId = htonl(pTask->execId); break; } - case TDMT_VND_DROP_TASK: { + case TDMT_SCH_DROP_TASK: { msgSize = sizeof(STaskDropReq); msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { @@ -1094,9 +1066,10 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, pMsg->queryId = htobe64(pJob->queryId); pMsg->taskId = htobe64(pTask->taskId); pMsg->refId = htobe64(pJob->refId); + pMsg->execId = htonl(pTask->execId); break; } - case TDMT_VND_QUERY_HEARTBEAT: { + case TDMT_SCH_QUERY_HEARTBEAT: { SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx)); SSchedulerHbReq req = {0}; @@ -1129,21 +1102,19 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, break; } - SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType); - SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL))); - if (msgType == TDMT_VND_QUERY) { - SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execIdx)); + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) { + SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId)); } return TSDB_CODE_SUCCESS; _return: - SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); + pTask->lastMsgType = -1; schFreeRpcCtx(&rpcCtx); taosMemoryFreeClear(msg); diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index b372ee3ead..098699744d 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -118,7 +118,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { scanPlan->level = 1; scanPlan->pParents = nodesMakeList(); scanPlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); - scanPlan->msgType = TDMT_VND_QUERY; + scanPlan->msgType = TDMT_SCH_QUERY; mergePlan->id.queryId = qId; mergePlan->id.groupId = schtMergeTemplateId; @@ -130,7 +130,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { mergePlan->pChildren = nodesMakeList(); mergePlan->pParents = NULL; mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); - mergePlan->msgType = TDMT_VND_QUERY; + mergePlan->msgType = TDMT_SCH_QUERY; merge->pNodeList = nodesMakeList(); scan->pNodeList = nodesMakeList(); @@ -181,7 +181,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { scanPlan[i].level = 1; scanPlan[i].pParents = nodesMakeList(); scanPlan[i].pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); - scanPlan[i].msgType = TDMT_VND_QUERY; + scanPlan[i].msgType = TDMT_SCH_QUERY; nodesListAppend(scanPlan[i].pParents, (SNode*)mergePlan); nodesListAppend(mergePlan->pChildren, (SNode*)(scanPlan + i)); @@ -198,7 +198,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { mergePlan->pParents = NULL; mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); - mergePlan->msgType = TDMT_VND_QUERY; + mergePlan->msgType = TDMT_SCH_QUERY; nodesListAppend(merge->pNodeList, (SNode*)mergePlan); @@ -412,7 +412,7 @@ void *schtCreateFetchRspThread(void *param) { rsp->completed = 1; rsp->numOfRows = 10; - code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_VND_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0); + code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_SCH_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0); schReleaseJob(job); @@ -445,7 +445,7 @@ void *schtFetchRspThread(void *aa) { dataBuf.pData = rsp; dataBuf.len = sizeof(*rsp); - code = schHandleCallback(param, &dataBuf, TDMT_VND_FETCH_RSP, 0); + code = schHandleCallback(param, &dataBuf, TDMT_SCH_FETCH_RSP, 0); assert(code == 0 || code); } @@ -547,7 +547,7 @@ void* schtRunJobThread(void *aa) { dataBuf.pData = &rsp; dataBuf.len = sizeof(rsp); - code = schHandleCallback(param, &dataBuf, TDMT_VND_QUERY_RSP, 0); + code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); assert(code == 0 || code); pIter = taosHashIterate(execTasks, pIter); @@ -566,7 +566,7 @@ void* schtRunJobThread(void *aa) { dataBuf.pData = &rsp; dataBuf.len = sizeof(rsp); - code = schHandleCallback(param, &dataBuf, TDMT_VND_QUERY_RSP, 0); + code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); assert(code == 0 || code); pIter = taosHashIterate(execTasks, pIter); @@ -677,7 +677,7 @@ TEST(queryTest, normalCase) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); @@ -688,7 +688,7 @@ TEST(queryTest, normalCase) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); @@ -780,7 +780,7 @@ TEST(queryTest, readyFirstCase) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); @@ -791,7 +791,7 @@ TEST(queryTest, readyFirstCase) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); @@ -896,9 +896,9 @@ TEST(queryTest, flowCtrlCase) { taosHashCancelIterate(pJob->execTasks, pIter); - if (task->lastMsgType == TDMT_VND_QUERY) { + if (task->lastMsgType == TDMT_SCH_QUERY) { SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); } else { diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index e9b311db9a..529615d4fd 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -88,3 +88,12 @@ SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit) { memcpy(pSubmitClone, pSubmit, sizeof(SStreamDataSubmit)); return pSubmitClone; } + +void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) { + int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1); + ASSERT(ref >= 0); + if (ref == 0) { + taosMemoryFree(pDataSubmit->data); + taosMemoryFree(pDataSubmit->dataRef); + } +} diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index b3be35fba3..d178c19615 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -63,7 +63,6 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) continue; } - // TODO: do we need free memory? SSDataBlock block = {0}; assignOneDataBlock(&block, output); block.info.childId = pTask->selfChildId; diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index d5a4da60f5..f82ef1b42f 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -41,12 +41,3 @@ void streamQueueClose(SStreamQueue* queue) { return; } } - -void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) { - int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1); - ASSERT(ref >= 0); - if (ref == 0) { - taosMemoryFree(pDataSubmit->data); - taosMemoryFree(pDataSubmit->dataRef); - } -} diff --git a/source/libs/sync/inc/syncAppendEntries.h b/source/libs/sync/inc/syncAppendEntries.h index 98df22d51b..e15c85d73b 100644 --- a/source/libs/sync/inc/syncAppendEntries.h +++ b/source/libs/sync/inc/syncAppendEntries.h @@ -94,6 +94,7 @@ extern "C" { // int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg); int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMsg); +int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatch* pMsg); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncAppendEntriesReply.h b/source/libs/sync/inc/syncAppendEntriesReply.h index e509a50dc4..70ce5a72c6 100644 --- a/source/libs/sync/inc/syncAppendEntriesReply.h +++ b/source/libs/sync/inc/syncAppendEntriesReply.h @@ -42,6 +42,12 @@ extern "C" { // int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg); int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg); +int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntriesReply* pMsg); + +typedef struct SReaderParam { + SyncIndex start; + SyncIndex end; +} SReaderParam; #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index d58ae83dd3..66e5d28bdd 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -67,6 +67,7 @@ typedef struct SSyncNode { char path[TSDB_FILENAME_LEN]; char raftStorePath[TSDB_FILENAME_LEN * 2]; char configPath[TSDB_FILENAME_LEN * 2]; + int32_t batchSize; // sync io SWal* pWal; @@ -170,6 +171,7 @@ void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); diff --git a/source/libs/sync/inc/syncReplication.h b/source/libs/sync/inc/syncReplication.h index 4b1f5b4638..07e12460da 100644 --- a/source/libs/sync/inc/syncReplication.h +++ b/source/libs/sync/inc/syncReplication.h @@ -53,8 +53,10 @@ extern "C" { // int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode); int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode); +int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode); int32_t syncNodeReplicate(SSyncNode* pSyncNode); int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntries* pMsg); +int32_t syncNodeAppendEntriesBatch(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntriesBatch* pMsg); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 14688f8912..6801e7212a 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -56,8 +56,8 @@ typedef struct SSyncSnapshotSender { SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex); void snapshotSenderDestroy(SSyncSnapshotSender *pSender); bool snapshotSenderIsStart(SSyncSnapshotSender *pSender); -void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader); -void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); +int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader); +int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); @@ -80,9 +80,9 @@ typedef struct SSyncSnapshotReceiver { SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId fromId); void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); -bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); +int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); +int32_t snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); +bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index a10b81d165..be48227d40 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -628,6 +628,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { #endif +static int32_t syncNodeMakeLogSame2(SSyncNode* ths, SyncAppendEntriesBatch* pMsg) { return 0; } + static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t code; @@ -719,6 +721,283 @@ static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries return false; } +int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatch* pMsg) { + int32_t ret = 0; + int32_t code = 0; + + // if already drop replica, do not process + if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) { + syncNodeEventLog(ths, "recv sync-append-entries-batch, maybe replica already dropped"); + return ret; + } + + // maybe update term + 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); + + // candidate to follower + // + // operation: + // to follower + do { + bool condition = pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE; + if (condition) { + syncNodeEventLog(ths, "recv sync-append-entries-batch, candidate to follower"); + + syncNodeBecomeFollower(ths, "from candidate by append entries"); + // do not reply? + return ret; + } + } while (0); + + // fake match2 + // + // condition1: + // preIndex <= my commit index + // + // operation: + // if hasAppendEntries && pMsg->prevLogIndex == ths->commitIndex, append entry + // match my-commit-index or my-commit-index + 1 + // no operation on log + do { + bool condition = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && + (pMsg->prevLogIndex <= ths->commitIndex); + if (condition) { + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), + "recv sync-append-entries-batch, fake match2, pre-index:%ld, pre-term:%lu, datalen:%d", + pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); + syncNodeEventLog(ths, logBuf); + } while (0); + + SyncIndex matchIndex = ths->commitIndex; + bool hasAppendEntries = pMsg->dataLen > 0; + if (hasAppendEntries && pMsg->prevLogIndex == ths->commitIndex) { + SRpcMsg rpcMsgArr[SYNC_MAX_BATCH_SIZE]; + memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + int32_t retArrSize = 0; + syncAppendEntriesBatch2RpcMsgArray(pMsg, rpcMsgArr, SYNC_MAX_BATCH_SIZE, &retArrSize); + + // make log same + do { + SyncIndex logLastIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore); + bool hasExtraEntries = logLastIndex > pMsg->prevLogIndex; + + if (hasExtraEntries) { + // make log same, rollback deleted entries + code = syncNodeMakeLogSame2(ths, pMsg); + ASSERT(code == 0); + } + + } while (0); + + // append entry batch + for (int32_t i = 0; i < retArrSize; ++i) { + SSyncRaftEntry* pAppendEntry = syncEntryBuild(1234); + code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); + if (code != 0) { + return -1; + } + + code = syncNodePreCommit(ths, pAppendEntry); + ASSERT(code == 0); + + syncEntryDestory(pAppendEntry); + } + + // fsync once + SSyncLogStoreData* pData = ths->pLogStore->data; + SWal* pWal = pData->pWal; + walFsync(pWal, true); + + // update match index + matchIndex = pMsg->prevLogIndex + retArrSize; + } + + // prepare response msg + SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->privateTerm = ths->pNewNodeReceiver->privateTerm; + pReply->success = true; + pReply->matchIndex = matchIndex; + + // send response + SRpcMsg rpcMsg; + syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); + syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + syncAppendEntriesReplyDestroy(pReply); + + return ret; + } + } while (0); + + // calculate logOK here, before will coredump, due to fake match + // bool logOK = syncNodeOnAppendEntriesLogOK(ths, pMsg); + bool logOK = true; + + // not match + // + // condition1: + // term < myTerm + // + // condition2: + // !logOK + // + // operation: + // not match + // no operation on log + do { + bool condition1 = pMsg->term < ths->pRaftStore->currentTerm; + bool condition2 = + (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK; + bool condition = condition1 || condition2; + + if (condition) { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, not match, pre-index:%ld, pre-term:%lu, datalen:%d", + pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); + syncNodeEventLog(ths, logBuf); + + // prepare response msg + SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->privateTerm = ths->pNewNodeReceiver->privateTerm; + pReply->success = false; + pReply->matchIndex = SYNC_INDEX_INVALID; + + // send response + SRpcMsg rpcMsg; + syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); + syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + syncAppendEntriesReplyDestroy(pReply); + + return ret; + } + } while (0); + + // really match + // + // condition: + // logOK + // + // operation: + // match + // make log same + do { + bool condition = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && logOK; + if (condition) { + // has extra entries (> preIndex) in local log + SyncIndex myLastIndex = syncNodeGetLastIndex(ths); + bool hasExtraEntries = myLastIndex > pMsg->prevLogIndex; + + // has entries in SyncAppendEntries msg + bool hasAppendEntries = pMsg->dataLen > 0; + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, match, pre-index:%ld, pre-term:%lu, datalen:%d", + pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); + syncNodeEventLog(ths, logBuf); + + if (hasExtraEntries) { + // make log same, rollback deleted entries + // code = syncNodeMakeLogSame(ths, pMsg); + ASSERT(code == 0); + } + + int32_t retArrSize = 0; + if (hasAppendEntries) { + SRpcMsg rpcMsgArr[SYNC_MAX_BATCH_SIZE]; + memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + syncAppendEntriesBatch2RpcMsgArray(pMsg, rpcMsgArr, SYNC_MAX_BATCH_SIZE, &retArrSize); + + // append entry batch + for (int32_t i = 0; i < retArrSize; ++i) { + SSyncRaftEntry* pAppendEntry = syncEntryBuild(1234); + code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); + if (code != 0) { + return -1; + } + + code = syncNodePreCommit(ths, pAppendEntry); + ASSERT(code == 0); + + syncEntryDestory(pAppendEntry); + } + + // fsync once + SSyncLogStoreData* pData = ths->pLogStore->data; + SWal* pWal = pData->pWal; + walFsync(pWal, true); + } + + // prepare response msg + SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->privateTerm = ths->pNewNodeReceiver->privateTerm; + pReply->success = true; + pReply->matchIndex = hasAppendEntries ? pMsg->prevLogIndex + retArrSize : pMsg->prevLogIndex; + + // send response + SRpcMsg rpcMsg; + syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); + syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + syncAppendEntriesReplyDestroy(pReply); + + // maybe update commit index, leader notice me + if (pMsg->commitIndex > ths->commitIndex) { + // has commit entry in local + if (pMsg->commitIndex <= ths->pLogStore->syncLogLastIndex(ths->pLogStore)) { + // advance commit index to sanpshot first + SSnapshot snapshot; + ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); + if (snapshot.lastApplyIndex >= 0 && snapshot.lastApplyIndex > ths->commitIndex) { + SyncIndex commitBegin = ths->commitIndex; + SyncIndex commitEnd = snapshot.lastApplyIndex; + ths->commitIndex = snapshot.lastApplyIndex; + + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%ld to index:%ld", commitBegin, + commitEnd); + syncNodeEventLog(ths, eventLog); + } + + SyncIndex beginIndex = ths->commitIndex + 1; + SyncIndex endIndex = pMsg->commitIndex; + + // update commit index + ths->commitIndex = pMsg->commitIndex; + + // call back Wal + code = ths->pLogStore->updateCommitIndex(ths->pLogStore, ths->commitIndex); + ASSERT(code == 0); + + code = syncNodeCommit(ths, beginIndex, endIndex, ths->state); + ASSERT(code == 0); + } + } + return ret; + } + } while (0); + + return ret; +} + int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t ret = 0; int32_t code = 0; diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 10f2745651..629d83eb51 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -108,48 +108,82 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p return ret; } -#if 0 -int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { +// only start once +static void syncNodeStartSnapshot(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, SyncTerm lastApplyTerm, + SyncAppendEntriesReply* pMsg) { + // get sender + SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); + ASSERT(pSender != NULL); + + SSnapshot snapshot = { + .data = NULL, .lastApplyIndex = endIndex, .lastApplyTerm = lastApplyTerm, .lastConfigIndex = SYNC_INDEX_INVALID}; + + void* pReader = NULL; + SReaderParam readerParam = {.start = beginIndex, .end = endIndex}; + ths->pFsm->FpSnapshotStartRead(ths->pFsm, &readerParam, &pReader); + if (!snapshotSenderIsStart(pSender) && pMsg->privateTerm < pSender->privateTerm) { + ASSERT(pReader != NULL); + snapshotSenderStart(pSender, snapshot, pReader); + + } else { + if (pReader != NULL) { + ths->pFsm->FpSnapshotStopRead(ths->pFsm, pReader); + } + } +} + +int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { int32_t ret = 0; - char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesReplyCb== term:%lu", ths->pRaftStore->currentTerm); - syncAppendEntriesReplyLog2(logBuf, pMsg); - - if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, - ths->pRaftStore->currentTerm); - return ret; + // if already drop replica, do not process + if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) { + syncNodeEventLog(ths, "recv sync-append-entries-reply, maybe replica already dropped"); + return -1; } - syncIndexMgrLog2("==syncNodeOnAppendEntriesReplyCb== before pNextIndex", ths->pNextIndex); - syncIndexMgrLog2("==syncNodeOnAppendEntriesReplyCb== before pMatchIndex", ths->pMatchIndex); - - // no need this code, because if I receive reply.term, then I must have sent for that term. - // if (pMsg->term > ths->pRaftStore->currentTerm) { - // syncNodeUpdateTerm(ths, pMsg->term); - // } + // drop stale response + if (pMsg->term < ths->pRaftStore->currentTerm) { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%lu, drop stale response", pMsg->term); + syncNodeEventLog(ths, logBuf); + return -1; + } + // error term if (pMsg->term > ths->pRaftStore->currentTerm) { - char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "syncNodeOnAppendEntriesReplyCb error term, receive:%lu current:%lu", pMsg->term, - ths->pRaftStore->currentTerm); - syncNodeLog2(logBuf, ths); - sError("%s", logBuf); - return ret; + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%lu", pMsg->term); + syncNodeErrorLog(ths, logBuf); + return -1; } ASSERT(pMsg->term == ths->pRaftStore->currentTerm); if (pMsg->success) { - // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] - syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); + SyncIndex newNextIndex = pMsg->matchIndex + 1; + SyncIndex newMatchIndex = pMsg->matchIndex; - // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] - syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); + if (ths->pLogStore->syncLogExist(ths->pLogStore, newNextIndex) && + ths->pLogStore->syncLogExist(ths->pLogStore, newNextIndex - 1)) { + // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] + syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), newNextIndex); - // maybe commit - syncMaybeAdvanceCommitIndex(ths); + // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] + syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), newMatchIndex); + + // maybe commit + if (ths->state == TAOS_SYNC_STATE_LEADER) { + syncMaybeAdvanceCommitIndex(ths); + } + } else { + // start snapshot + SSnapshot snapshot; + ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); + syncNodeStartSnapshot(ths, newMatchIndex + 1, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pMsg); + + syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), snapshot.lastApplyIndex + 1); + syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), newMatchIndex); + } } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); @@ -157,18 +191,35 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p // notice! int64, uint64 if (nextIndex > SYNC_INDEX_BEGIN) { --nextIndex; + + if (ths->pLogStore->syncLogExist(ths->pLogStore, nextIndex) && + ths->pLogStore->syncLogExist(ths->pLogStore, nextIndex - 1)) { + // do nothing + } else { + SSyncRaftEntry* pEntry; + int32_t code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, nextIndex, &pEntry); + ASSERT(code == 0); + syncNodeStartSnapshot(ths, SYNC_INDEX_BEGIN, nextIndex, pEntry->term, pMsg); + + // get sender + SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); + ASSERT(pSender != NULL); + SyncIndex sentryIndex = pSender->snapshot.lastApplyIndex + 1; + + // update nextIndex to sentryIndex + if (nextIndex <= sentryIndex) { + nextIndex = sentryIndex; + } + } + } else { nextIndex = SYNC_INDEX_BEGIN; } syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex); } - syncIndexMgrLog2("==syncNodeOnAppendEntriesReplyCb== after pNextIndex", ths->pNextIndex); - syncIndexMgrLog2("==syncNodeOnAppendEntriesReplyCb== after pMatchIndex", ths->pMatchIndex); - - return ret; + return 0; } -#endif int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { int32_t ret = 0; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index d32153e5ed..ddda60bc18 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -50,7 +50,6 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths); // process message ---- int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); -int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex); // life cycle static void syncFreeNode(void* param); @@ -627,6 +626,94 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { return ret; } +int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { + if (arrSize < 0) { + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + return -1; + } + + int32_t ret = 0; + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + return -1; + } + ASSERT(rid == pSyncNode->rid); + ret = syncNodeProposeBatch(pSyncNode, pMsgArr, pIsWeakArr, arrSize); + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return ret; +} + +static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { + for (int32_t i = 0; i < arrSize; ++i) { + if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE) { + return false; + } + + if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { + return false; + } + } + + return true; +} + +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { + if (!syncNodeBatchOK(pMsgArr, arrSize)) { + syncNodeErrorLog(pSyncNode, "sync propose batch error"); + terrno = TSDB_CODE_SYN_BATCH_ERROR; + return -1; + } + + if (arrSize > SYNC_MAX_BATCH_SIZE) { + syncNodeErrorLog(pSyncNode, "sync propose match batch error"); + terrno = TSDB_CODE_SYN_BATCH_ERROR; + return -1; + } + + if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + syncNodeErrorLog(pSyncNode, "sync propose not leader"); + terrno = TSDB_CODE_SYN_NOT_LEADER; + return -1; + } + + if (pSyncNode->changing) { + syncNodeErrorLog(pSyncNode, "sync propose not ready"); + terrno = TSDB_CODE_SYN_PROPOSE_NOT_READY; + return -1; + } + + SRaftMeta raftArr[SYNC_MAX_BATCH_SIZE]; + for (int i = 0; i < arrSize; ++i) { + SRespStub stub; + stub.createTime = taosGetTimestampMs(); + stub.rpcMsg = pMsgArr[i]; + uint64_t seqNum = syncRespMgrAdd(pSyncNode->pSyncRespMgr, &stub); + + raftArr[i].isWeak = pIsWeakArr[i]; + raftArr[i].seqNum = seqNum; + } + + SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgArr, raftArr, arrSize, pSyncNode->vgId); + ASSERT(pSyncMsg != NULL); + + SRpcMsg rpcMsg; + syncClientRequestBatch2RpcMsg(pSyncMsg, &rpcMsg); + taosMemoryFree(pSyncMsg); // only free msg body, do not free rpc msg content + + if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) { + // enqueue msg ok + + } else { + sError("enqueue msg error, FpEqMsg is NULL"); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + return -1; + } + + return 0; +} + int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { int32_t ret = 0; @@ -2362,6 +2449,49 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI return ret; } +int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* pMsg) { + int32_t code = 0; + + if (ths->state != TAOS_SYNC_STATE_LEADER) { + // call FpCommitCb, delete resp mgr + return -1; + } + + SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); + SyncTerm term = ths->pRaftStore->currentTerm; + + int32_t raftMetaArrayLen = sizeof(SRaftMeta) * pMsg->dataCount; + int32_t rpcArrayLen = sizeof(SRpcMsg) * pMsg->dataCount; + SRaftMeta* raftMetaArr = (SRaftMeta*)(pMsg->data); + SRpcMsg* msgArr = (SRpcMsg*)((char*)(pMsg->data) + raftMetaArrayLen); + for (int32_t i = 0; i < pMsg->dataCount; ++i) { + SSyncRaftEntry* pEntry = syncEntryBuild(msgArr[i].contLen); + ASSERT(pEntry != NULL); + + pEntry->originalRpcType = msgArr[i].msgType; + pEntry->seqNum = raftMetaArr[i].seqNum; + pEntry->isWeak = raftMetaArr[i].isWeak; + pEntry->term = term; + pEntry->index = index; + memcpy(pEntry->data, msgArr[i].pCont, msgArr[i].contLen); + ASSERT(msgArr[i].contLen == pEntry->dataLen); + + code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); + if (code != 0) { + // del resp mgr, call FpCommitCb + ASSERT(0); + return -1; + } + } + + // fsync once + SSyncLogStoreData* pData = ths->pLogStore->data; + SWal* pWal = pData->pWal; + walFsync(pWal, true); + + return 0; +} + static void syncFreeNode(void* param) { SSyncNode* pNode = param; // inner object already free diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 119a178893..ad352df59f 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -591,7 +591,7 @@ void syncPingReplySerialize(const SyncPingReply* pMsg, char* buf, uint32_t bufLe void syncPingReplyDeserialize(const char* buf, uint32_t len, SyncPingReply* pMsg) { memcpy(pMsg, buf, len); ASSERT(len == pMsg->bytes); - ASSERT(pMsg->bytes == sizeof(SyncPing) + pMsg->dataLen); + ASSERT(pMsg->bytes == sizeof(SyncPingReply) + pMsg->dataLen); } char* syncPingReplySerialize2(const SyncPingReply* pMsg, uint32_t* len) { @@ -956,6 +956,48 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { } } +// ---- message process SyncClientRequestBatch---- + +// block1: +// block2: SRaftMeta array +// block3: rpc msg array (with pCont) + +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, + int32_t vgId) { + ASSERT(rpcMsgArr != NULL); + ASSERT(arrSize > 0); + + int32_t dataLen = 0; + int32_t raftMetaArrayLen = sizeof(SRaftMeta) * arrSize; + int32_t rpcArrayLen = sizeof(SRpcMsg) * arrSize; + dataLen += (raftMetaArrayLen + rpcArrayLen); + + uint32_t bytes = sizeof(SyncClientRequestBatch) + dataLen; + SyncClientRequestBatch* pMsg = taosMemoryMalloc(bytes); + memset(pMsg, 0, bytes); + pMsg->bytes = bytes; + pMsg->vgId = vgId; + pMsg->msgType = TDMT_SYNC_CLIENT_REQUEST_BATCH; + pMsg->dataCount = arrSize; + pMsg->dataLen = dataLen; + + SRaftMeta* raftMetaArr = (SRaftMeta*)(pMsg->data); + SRpcMsg* msgArr = (SRpcMsg*)((char*)(pMsg->data) + raftMetaArrayLen); + + for (int i = 0; i < arrSize; ++i) { + // init raftMetaArr + raftMetaArr[i].isWeak = raftArr[i].isWeak; + raftMetaArr[i].seqNum = raftArr[i].seqNum; + + // init msgArr + msgArr[i] = rpcMsgArr[i]; + } + + return pMsg; +} + +void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg) {} + // ---- message process SyncRequestVote---- SyncRequestVote* syncRequestVoteBuild(int32_t vgId) { uint32_t bytes = sizeof(SyncRequestVote); @@ -1426,6 +1468,279 @@ void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg) { } } +// ---- message process SyncAppendEntriesBatch---- + +// block1: SOffsetAndContLen +// block2: SOffsetAndContLen Array +// block3: SRpcMsg Array +// block4: SRpcMsg pCont Array + +SyncAppendEntriesBatch* syncAppendEntriesBatchBuild(SRpcMsg* rpcMsgArr, int32_t arrSize, int32_t vgId) { + ASSERT(rpcMsgArr != NULL); + ASSERT(arrSize > 0); + + int32_t dataLen = 0; + int32_t metaArrayLen = sizeof(SOffsetAndContLen) * arrSize; // + int32_t rpcArrayLen = sizeof(SRpcMsg) * arrSize; // SRpcMsg + int32_t contArrayLen = 0; + for (int i = 0; i < arrSize; ++i) { // SRpcMsg pCont + contArrayLen += rpcMsgArr[i].contLen; + } + dataLen += (metaArrayLen + rpcArrayLen + contArrayLen); + + uint32_t bytes = sizeof(SyncAppendEntriesBatch) + dataLen; + SyncAppendEntriesBatch* pMsg = taosMemoryMalloc(bytes); + memset(pMsg, 0, bytes); + pMsg->bytes = bytes; + pMsg->vgId = vgId; + pMsg->msgType = TDMT_SYNC_APPEND_ENTRIES_BATCH; + pMsg->dataCount = arrSize; + pMsg->dataLen = dataLen; + + SOffsetAndContLen* metaArr = (SOffsetAndContLen*)(pMsg->data); + SRpcMsg* msgArr = (SRpcMsg*)((char*)(pMsg->data) + metaArrayLen); + char* pData = pMsg->data; + + for (int i = 0; i < arrSize; ++i) { + // init + if (i == 0) { + metaArr[i].offset = metaArrayLen + rpcArrayLen; + metaArr[i].contLen = rpcMsgArr[i].contLen; + } else { + metaArr[i].offset = metaArr[i - 1].offset + metaArr[i - 1].contLen; + metaArr[i].contLen = rpcMsgArr[i].contLen; + } + + // init msgArr + msgArr[i] = rpcMsgArr[i]; + + // init data + ASSERT(rpcMsgArr[i].contLen == metaArr[i].contLen); + memcpy(pData + metaArr[i].offset, rpcMsgArr[i].pCont, rpcMsgArr[i].contLen); + } + + return pMsg; +} + +void syncAppendEntriesBatchDestroy(SyncAppendEntriesBatch* pMsg) { + if (pMsg != NULL) { + taosMemoryFree(pMsg); + } +} + +void syncAppendEntriesBatchSerialize(const SyncAppendEntriesBatch* pMsg, char* buf, uint32_t bufLen) { + ASSERT(pMsg->bytes <= bufLen); + memcpy(buf, pMsg, pMsg->bytes); +} + +void syncAppendEntriesBatchDeserialize(const char* buf, uint32_t len, SyncAppendEntriesBatch* pMsg) { + memcpy(pMsg, buf, len); + ASSERT(len == pMsg->bytes); + ASSERT(pMsg->bytes == sizeof(SyncAppendEntriesBatch) + pMsg->dataLen); +} + +char* syncAppendEntriesBatchSerialize2(const SyncAppendEntriesBatch* pMsg, uint32_t* len) { + char* buf = taosMemoryMalloc(pMsg->bytes); + ASSERT(buf != NULL); + syncAppendEntriesBatchSerialize(pMsg, buf, pMsg->bytes); + if (len != NULL) { + *len = pMsg->bytes; + } + return buf; +} + +SyncAppendEntriesBatch* syncAppendEntriesBatchDeserialize2(const char* buf, uint32_t len) { + uint32_t bytes = *((uint32_t*)buf); + SyncAppendEntriesBatch* pMsg = taosMemoryMalloc(bytes); + ASSERT(pMsg != NULL); + syncAppendEntriesBatchDeserialize(buf, len, pMsg); + ASSERT(len == pMsg->bytes); + return pMsg; +} + +void syncAppendEntriesBatch2RpcMsg(const SyncAppendEntriesBatch* pMsg, SRpcMsg* pRpcMsg) { + memset(pRpcMsg, 0, sizeof(*pRpcMsg)); + pRpcMsg->msgType = pMsg->msgType; + pRpcMsg->contLen = pMsg->bytes; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + syncAppendEntriesBatchSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen); +} + +void syncAppendEntriesBatchFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntriesBatch* pMsg) { + syncAppendEntriesBatchDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg); +} + +SyncAppendEntriesBatch* syncAppendEntriesBatchFromRpcMsg2(const SRpcMsg* pRpcMsg) { + SyncAppendEntriesBatch* pMsg = syncAppendEntriesBatchDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen); + ASSERT(pMsg != NULL); + return pMsg; +} + +cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg) { + char u64buf[128] = {0}; + 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] = {0}; + 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] = {0}; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->prevLogIndex); + cJSON_AddStringToObject(pRoot, "prevLogIndex", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + cJSON_AddStringToObject(pRoot, "prevLogTerm", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->commitIndex); + cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); + + cJSON_AddNumberToObject(pRoot, "dataCount", pMsg->dataCount); + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + + int32_t metaArrayLen = sizeof(SOffsetAndContLen) * pMsg->dataCount; // + int32_t rpcArrayLen = sizeof(SRpcMsg) * pMsg->dataCount; // SRpcMsg + int32_t contArrayLen = pMsg->dataLen - metaArrayLen - rpcArrayLen; + + cJSON_AddNumberToObject(pRoot, "metaArrayLen", metaArrayLen); + cJSON_AddNumberToObject(pRoot, "rpcArrayLen", rpcArrayLen); + cJSON_AddNumberToObject(pRoot, "contArrayLen", contArrayLen); + + SOffsetAndContLen* metaArr = (SOffsetAndContLen*)(pMsg->data); + SRpcMsg* msgArr = (SRpcMsg*)(pMsg->data + metaArrayLen); + void* pData = (void*)(pMsg->data + metaArrayLen + rpcArrayLen); + + cJSON* pMetaArr = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "metaArr", pMetaArr); + for (int i = 0; i < pMsg->dataCount; ++i) { + cJSON* pMeta = cJSON_CreateObject(); + cJSON_AddNumberToObject(pMeta, "offset", metaArr[i].offset); + cJSON_AddNumberToObject(pMeta, "contLen", metaArr[i].contLen); + cJSON_AddItemToArray(pMetaArr, pMeta); + } + + cJSON* pMsgArr = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "msgArr", pMsgArr); + for (int i = 0; i < pMsg->dataCount; ++i) { + cJSON* pRpcMsgJson = cJSON_CreateObject(); + cJSON_AddNumberToObject(pRpcMsgJson, "code", msgArr[i].code); + cJSON_AddNumberToObject(pRpcMsgJson, "contLen", msgArr[i].contLen); + cJSON_AddNumberToObject(pRpcMsgJson, "msgType", msgArr[i].msgType); + cJSON_AddItemToArray(pMsgArr, pRpcMsgJson); + } + + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + taosMemoryFree(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + taosMemoryFree(s); + } + + cJSON* pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SyncAppendEntriesBatch", pRoot); + return pJson; +} + +char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg) { + cJSON* pJson = syncAppendEntriesBatch2Json(pMsg); + char* serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + +void syncAppendEntriesBatch2RpcMsgArray(SyncAppendEntriesBatch* pSyncMsg, SRpcMsg* rpcMsgArr, int32_t maxArrSize, + int32_t* pRetArrSize) { + if (pRetArrSize != NULL) { + *pRetArrSize = pSyncMsg->dataCount; + } + + int32_t arrSize = pSyncMsg->dataCount; + if (arrSize > maxArrSize) { + arrSize = maxArrSize; + } + + int32_t metaArrayLen = sizeof(SOffsetAndContLen) * pSyncMsg->dataCount; // + int32_t rpcArrayLen = sizeof(SRpcMsg) * pSyncMsg->dataCount; // SRpcMsg + int32_t contArrayLen = pSyncMsg->dataLen - metaArrayLen - rpcArrayLen; + + SOffsetAndContLen* metaArr = (SOffsetAndContLen*)(pSyncMsg->data); + SRpcMsg* msgArr = (SRpcMsg*)(pSyncMsg->data + metaArrayLen); + void* pData = pSyncMsg->data + metaArrayLen + rpcArrayLen; + + for (int i = 0; i < arrSize; ++i) { + rpcMsgArr[i] = msgArr[i]; + rpcMsgArr[i].pCont = rpcMallocCont(msgArr[i].contLen); + void* pRpcCont = pSyncMsg->data + metaArr[i].offset; + memcpy(rpcMsgArr[i].pCont, pRpcCont, rpcMsgArr[i].contLen); + } +} + +// for debug ---------------------- +void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg) { + char* serialized = syncAppendEntriesBatch2Str(pMsg); + printf("syncAppendEntriesBatchPrint | len:%lu | %s \n", strlen(serialized), serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg) { + char* serialized = syncAppendEntriesBatch2Str(pMsg); + printf("syncAppendEntriesBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg) { + char* serialized = syncAppendEntriesBatch2Str(pMsg); + sTrace("syncAppendEntriesBatchLog | len:%lu | %s", strlen(serialized), serialized); + taosMemoryFree(serialized); +} + +void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg) { + if (gRaftDetailLog) { + char* serialized = syncAppendEntriesBatch2Str(pMsg); + sTraceLong("syncAppendEntriesBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + taosMemoryFree(serialized); + } +} + // ---- message process SyncAppendEntriesReply---- SyncAppendEntriesReply* syncAppendEntriesReplyBuild(int32_t vgId) { uint32_t bytes = sizeof(SyncAppendEntriesReply); diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index 43890c196c..ec3f18132d 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -101,7 +101,7 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) { char *syncCfg2Str(SSyncCfg *pSyncCfg) { cJSON *pJson = syncCfg2Json(pSyncCfg); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -109,7 +109,7 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) { char *syncCfg2SimpleStr(SSyncCfg *pSyncCfg) { if (pSyncCfg != NULL) { int32_t len = 512; - char *s = taosMemoryMalloc(len); + char * s = taosMemoryMalloc(len); memset(s, 0, len); snprintf(s, len, "{replica-num:%d, my-index:%d, ", pSyncCfg->replicaNum, pSyncCfg->myIndex); @@ -205,7 +205,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { char *raftCfg2Str(SRaftCfg *pRaftCfg) { cJSON *pJson = raftCfg2Json(pRaftCfg); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -280,7 +280,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) { (pRaftCfg->configIndexArr)[i] = atoll(pIndex->valuestring); } - cJSON *pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); + cJSON * pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); int32_t code = syncCfgFromJson(pJsonSyncCfg, &(pRaftCfg->cfg)); ASSERT(code == 0); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 46850758f1..4908822a3a 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -116,6 +116,73 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) { return ret; } +int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + return -1; + } + + int32_t ret = 0; + for (int i = 0; i < pSyncNode->peersNum; ++i) { + SRaftId* pDestId = &(pSyncNode->peersId[i]); + + // next index + SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); + + // pre index, pre term + SyncIndex preLogIndex = syncNodeGetPreIndex(pSyncNode, nextIndex); + SyncTerm preLogTerm = syncNodeGetPreTerm(pSyncNode, nextIndex); + if (preLogTerm == SYNC_TERM_INVALID) { + SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(pSyncNode, pDestId); + ASSERT(pSender != NULL); + ASSERT(!snapshotSenderIsStart(pSender)); + + SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; + syncIndexMgrSetIndex(pSyncNode->pNextIndex, pDestId, newNextIndex); + syncIndexMgrSetIndex(pSyncNode->pMatchIndex, pDestId, SYNC_INDEX_INVALID); + sError("vgId:%d sync get pre term error, nextIndex:%ld, update next-index:%ld, match-index:%d, raftid:%ld", + pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr); + + return -1; + } + + SRpcMsg rpcMsgArr[SYNC_MAX_BATCH_SIZE]; + memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + + int32_t getCount = 0; + for (int32_t i = 0; i < pSyncNode->batchSize; ++i) { + SSyncRaftEntry* pEntry; + int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, nextIndex, &pEntry); + if (code == 0) { + ASSERT(pEntry != NULL); + // get rpc msg [i] from entry + syncEntryDestory(pEntry); + getCount++; + } else { + break; + } + } + + SyncAppendEntriesBatch* pMsg = syncAppendEntriesBatchBuild(rpcMsgArr, getCount, pSyncNode->vgId); + ASSERT(pMsg != NULL); + + // prepare msg + pMsg->srcId = pSyncNode->myRaftId; + pMsg->destId = *pDestId; + pMsg->term = pSyncNode->pRaftStore->currentTerm; + pMsg->prevLogIndex = preLogIndex; + pMsg->prevLogTerm = preLogTerm; + pMsg->commitIndex = pSyncNode->commitIndex; + pMsg->privateTerm = 0; + pMsg->dataCount = getCount; + + // send msg + syncNodeAppendEntriesBatch(pSyncNode, pDestId, pMsg); + syncAppendEntriesBatchDestroy(pMsg); + } + + return 0; +} + int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_LEADER); @@ -234,4 +301,24 @@ int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, c syncAppendEntries2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg); return ret; +} + +int32_t syncNodeAppendEntriesBatch(SSyncNode* pSyncNode, const SRaftId* destRaftId, + const SyncAppendEntriesBatch* pMsg) { + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); + sDebug( + "vgId:%d, send sync-append-entries-batch to %s:%d, {term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, " + "commit:%ld, " + "datalen:%d, dataCount:%d}", + pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm, + pMsg->commitIndex, pMsg->dataLen, pMsg->dataCount); + } while (0); + + SRpcMsg rpcMsg; + syncAppendEntriesBatch2RpcMsg(pMsg, &rpcMsg); + syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg); + return 0; } \ No newline at end of file diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 70f3801e61..4466cccbbc 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -80,7 +80,7 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; } // begin send snapshot by snapshot, pReader -void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader) { +int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader) { ASSERT(!snapshotSenderIsStart(pSender)); // init snapshot and reader @@ -181,9 +181,11 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void syncNodeEventLog(pSender->pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); + + return 0; } -void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { +int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { // close reader if (pSender->pReader != NULL) { int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); @@ -208,6 +210,8 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { syncNodeEventLog(pSender->pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); + + return 0; } // when sender receive ack, call this function to send msg from seq @@ -471,7 +475,7 @@ static void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { // if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver // if already start, force close, start again -void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { +int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { if (!snapshotReceiverIsStart(pReceiver)) { // first start snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); @@ -486,9 +490,11 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTer // start again snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); } + + return 0; } -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { +int32_t snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { if (pReceiver->pWriter != NULL) { int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); @@ -506,6 +512,8 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { syncNodeEventLog(pReceiver->pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); + + return 0; } static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index bc63462a9e..c549b78399 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -21,6 +21,7 @@ add_executable(syncEntryCacheTest "") add_executable(syncRequestVoteTest "") add_executable(syncRequestVoteReplyTest "") add_executable(syncAppendEntriesTest "") +add_executable(syncAppendEntriesBatchTest "") add_executable(syncAppendEntriesReplyTest "") add_executable(syncClientRequestTest "") add_executable(syncTimeoutTest "") @@ -146,6 +147,10 @@ target_sources(syncAppendEntriesTest PRIVATE "syncAppendEntriesTest.cpp" ) +target_sources(syncAppendEntriesBatchTest + PRIVATE + "syncAppendEntriesBatchTest.cpp" +) target_sources(syncAppendEntriesReplyTest PRIVATE "syncAppendEntriesReplyTest.cpp" @@ -387,6 +392,11 @@ target_include_directories(syncAppendEntriesTest "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncAppendEntriesBatchTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_include_directories(syncAppendEntriesReplyTest PUBLIC "${TD_SOURCE_DIR}/include/libs/sync" @@ -636,6 +646,10 @@ target_link_libraries(syncAppendEntriesTest sync gtest_main ) +target_link_libraries(syncAppendEntriesBatchTest + sync + gtest_main +) target_link_libraries(syncAppendEntriesReplyTest sync gtest_main diff --git a/source/libs/sync/test/syncAppendEntriesBatchTest.cpp b/source/libs/sync/test/syncAppendEntriesBatchTest.cpp new file mode 100644 index 0000000000..8784ddd637 --- /dev/null +++ b/source/libs/sync/test/syncAppendEntriesBatchTest.cpp @@ -0,0 +1,139 @@ +//#include +#include +#include "syncIO.h" +#include "syncInt.h" +#include "syncMessage.h" +#include "syncUtil.h" +#include "trpc.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"); +} + +SRpcMsg *createRpcMsg(int32_t i, int32_t dataLen) { + SRpcMsg *pRpcMsg = (SRpcMsg *)taosMemoryMalloc(sizeof(SRpcMsg)); + memset(pRpcMsg, 0, sizeof(SRpcMsg)); + + pRpcMsg->msgType = TDMT_SYNC_PING; + pRpcMsg->contLen = dataLen; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + pRpcMsg->code = 10 * i; + snprintf((char *)pRpcMsg->pCont, pRpcMsg->contLen, "value_%d", i); + + return pRpcMsg; +} + +SyncAppendEntriesBatch *createMsg() { + SRpcMsg rpcMsgArr[5]; + memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + + for (int32_t i = 0; i < 5; ++i) { + SRpcMsg *pRpcMsg = createRpcMsg(i, 20); + rpcMsgArr[i] = *pRpcMsg; + taosMemoryFree(pRpcMsg); + } + + SyncAppendEntriesBatch *pMsg = syncAppendEntriesBatchBuild(rpcMsgArr, 5, 1234); + 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->prevLogIndex = 11; + pMsg->prevLogTerm = 22; + pMsg->commitIndex = 33; + pMsg->privateTerm = 44; + return pMsg; +} + +void test1() { + SyncAppendEntriesBatch *pMsg = createMsg(); + syncAppendEntriesBatchLog2((char *)"test1:", pMsg); + + SRpcMsg rpcMsgArr[5]; + int32_t retArrSize; + syncAppendEntriesBatch2RpcMsgArray(pMsg, rpcMsgArr, 5, &retArrSize); + for (int i = 0; i < retArrSize; ++i) { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "==test1 decode rpc msg %d: msgType:%d, code:%d, contLen:%d, pCont:%s \n", i, + rpcMsgArr[i].msgType, rpcMsgArr[i].code, rpcMsgArr[i].contLen, (char *)rpcMsgArr[i].pCont); + sTrace("%s", logBuf); + } + + syncAppendEntriesBatchDestroy(pMsg); +} + +/* +void test2() { + SyncAppendEntries *pMsg = createMsg(); + uint32_t len = pMsg->bytes; + char * serialized = (char *)taosMemoryMalloc(len); + syncAppendEntriesSerialize(pMsg, serialized, len); + SyncAppendEntries *pMsg2 = syncAppendEntriesBuild(pMsg->dataLen, 1000); + syncAppendEntriesDeserialize(serialized, len, pMsg2); + syncAppendEntriesLog2((char *)"test2: syncAppendEntriesSerialize -> syncAppendEntriesDeserialize ", pMsg2); + + taosMemoryFree(serialized); + syncAppendEntriesDestroy(pMsg); + syncAppendEntriesDestroy(pMsg2); +} + +void test3() { + SyncAppendEntries *pMsg = createMsg(); + uint32_t len; + char * serialized = syncAppendEntriesSerialize2(pMsg, &len); + SyncAppendEntries *pMsg2 = syncAppendEntriesDeserialize2(serialized, len); + syncAppendEntriesLog2((char *)"test3: syncAppendEntriesSerialize3 -> syncAppendEntriesDeserialize2 ", pMsg2); + + taosMemoryFree(serialized); + syncAppendEntriesDestroy(pMsg); + syncAppendEntriesDestroy(pMsg2); +} + +void test4() { + SyncAppendEntries *pMsg = createMsg(); + SRpcMsg rpcMsg; + syncAppendEntries2RpcMsg(pMsg, &rpcMsg); + SyncAppendEntries *pMsg2 = (SyncAppendEntries *)taosMemoryMalloc(rpcMsg.contLen); + syncAppendEntriesFromRpcMsg(&rpcMsg, pMsg2); + syncAppendEntriesLog2((char *)"test4: syncAppendEntries2RpcMsg -> syncAppendEntriesFromRpcMsg ", pMsg2); + + rpcFreeCont(rpcMsg.pCont); + syncAppendEntriesDestroy(pMsg); + syncAppendEntriesDestroy(pMsg2); +} + +void test5() { + SyncAppendEntries *pMsg = createMsg(); + SRpcMsg rpcMsg; + syncAppendEntries2RpcMsg(pMsg, &rpcMsg); + SyncAppendEntries *pMsg2 = syncAppendEntriesFromRpcMsg2(&rpcMsg); + syncAppendEntriesLog2((char *)"test5: syncAppendEntries2RpcMsg -> syncAppendEntriesFromRpcMsg2 ", pMsg2); + + rpcFreeCont(rpcMsg.pCont); + syncAppendEntriesDestroy(pMsg); + syncAppendEntriesDestroy(pMsg2); +} +*/ + +int main() { + gRaftDetailLog = true; + tsAsyncLog = 0; + sDebugFlag = DEBUG_DEBUG + DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE; + logTest(); + + test1(); + + /* + test2(); + test3(); + test4(); + test5(); + */ + + return 0; +} diff --git a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp index b4f173ff02..2908dd5907 100644 --- a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp +++ b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp @@ -77,7 +77,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { return 0; } -int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void** ppReader) { +int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void *pParam, void** ppReader) { *ppReader = (void*)0xABCD; char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), "==callback== ==SnapshotStartRead== pFsm:%p, *ppReader:%p", pFsm, *ppReader); diff --git a/source/libs/sync/test/syncSnapshotSenderTest.cpp b/source/libs/sync/test/syncSnapshotSenderTest.cpp index 04a02460af..dc38cd3df5 100644 --- a/source/libs/sync/test/syncSnapshotSenderTest.cpp +++ b/source/libs/sync/test/syncSnapshotSenderTest.cpp @@ -25,7 +25,7 @@ void ReConfigCb(struct SSyncFSM* pFsm, SSyncCfg newCfg, SReConfigCbMeta cbMeta) int32_t GetSnapshot(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { return 0; } -int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void** ppReader) { return 0; } +int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void *pParam, void** ppReader) { return 0; } int32_t SnapshotStopRead(struct SSyncFSM* pFsm, void* pReader) { return 0; } int32_t SnapshotDoRead(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len) { return 0; } diff --git a/source/libs/sync/test/syncTestTool.cpp b/source/libs/sync/test/syncTestTool.cpp index 91a16cc033..4e84ff0f7e 100644 --- a/source/libs/sync/test/syncTestTool.cpp +++ b/source/libs/sync/test/syncTestTool.cpp @@ -74,7 +74,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { return 0; } -int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void** ppReader) { +int32_t SnapshotStartRead(struct SSyncFSM* pFsm, void *pParam, void** ppReader) { *ppReader = (void*)0xABCD; char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), "==callback== ==SnapshotStartRead== pFsm:%p, *ppReader:%p", pFsm, *ppReader); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2836bc2949..a239e6bbcb 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -329,7 +329,7 @@ void cliHandleResp(SCliConn* conn) { tDebug("%s conn %p construct ahandle %p by %s, persist: 1", CONN_GET_INST_LABEL(conn), conn, transMsg.info.ahandle, TMSG_INFO(transMsg.msgType)); if (!CONN_RELEASE_BY_SERVER(conn) && transMsg.info.ahandle == NULL) { - transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + transMsg.code = TSDB_CODE_RPC_BROKEN_LINK; transMsg.info.ahandle = transCtxDumpBrokenlinkVal(&conn->ctx, (int32_t*)&(transMsg.msgType)); tDebug("%s conn %p construct ahandle %p due brokenlink, persist: 1", CONN_GET_INST_LABEL(conn), conn, transMsg.info.ahandle); @@ -400,7 +400,7 @@ void cliHandleExcept(SCliConn* pConn) { STransConnCtx* pCtx = pMsg ? pMsg->ctx : NULL; STransMsg transMsg = {0}; - transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + transMsg.code = pConn->broken ? TSDB_CODE_RPC_BROKEN_LINK : TSDB_CODE_RPC_NETWORK_UNAVAIL; transMsg.msgType = pMsg ? pMsg->msg.msgType + 1 : 0; transMsg.info.ahandle = NULL; @@ -607,9 +607,10 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { if (clear) { if (!uv_is_closing((uv_handle_t*)conn->stream)) { uv_close((uv_handle_t*)conn->stream, cliDestroy); - } else { - cliDestroy((uv_handle_t*)conn->stream); } + //} else { + // cliDestroy((uv_handle_t*)conn->stream); + //} } } static void cliDestroy(uv_handle_t* handle) { @@ -1023,19 +1024,28 @@ void cliCompareAndSwap(int8_t* val, int8_t exp, int8_t newVal) { } bool cliTryToExtractEpSet(STransMsg* pResp, SEpSet* dst) { - if (pResp == NULL || pResp->info.hasEpSet == 0) { + if ((pResp == NULL || pResp->info.hasEpSet == 0)) { + return false; + } + // rebuild resp msg + SEpSet epset; + if (tDeserializeSEpSet(pResp->pCont, pResp->contLen, &epset) < 0) { return false; } - tDeserializeSEpSet(pResp->pCont, pResp->contLen, dst); int32_t tlen = tSerializeSEpSet(NULL, 0, dst); - int32_t bufLen = pResp->contLen - tlen; - char* buf = rpcMallocCont(bufLen); - - memcpy(buf, (char*)pResp->pCont + tlen, bufLen); + char* buf = NULL; + int32_t len = pResp->contLen - tlen; + if (len != 0) { + buf = rpcMallocCont(len); + memcpy(buf, (char*)pResp->pCont + tlen, len); + } + rpcFreeCont(pResp->pCont); pResp->pCont = buf; - pResp->contLen = bufLen; + pResp->contLen = len; + + *dst = epset; return true; } int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { @@ -1054,7 +1064,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { */ STransConnCtx* pCtx = pMsg->ctx; int32_t code = pResp->code; - if (pTransInst->retry != NULL && pTransInst->retry(code, pResp->msgType - 1)) { + bool retry = (pTransInst->retry != NULL && pTransInst->retry(code, pResp->msgType - 1)) ? true : false; + if (retry) { pMsg->sent = 0; pCtx->retryCnt += 1; if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { @@ -1083,11 +1094,13 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { STraceId* trace = &pResp->info.traceId; - if (cliTryToExtractEpSet(pResp, &pCtx->epSet)) { + bool hasEpSet = cliTryToExtractEpSet(pResp, &pCtx->epSet); + if (hasEpSet) { char tbuf[256] = {0}; EPSET_DEBUG_STR(&pCtx->epSet, tbuf); tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn); } + if (pCtx->pSem != NULL) { tGTrace("%s conn %p(sync) handle resp", CONN_GET_INST_LABEL(pConn), pConn); if (pCtx->pRsp == NULL) { @@ -1099,10 +1112,14 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pCtx->pRsp = NULL; } else { tGTrace("%s conn %p handle resp", CONN_GET_INST_LABEL(pConn), pConn); - if (!cliIsEpsetUpdated(code, pCtx)) { - pTransInst->cfp(pTransInst->parent, pResp, NULL); - } else { + if (retry == false && hasEpSet == true) { pTransInst->cfp(pTransInst->parent, pResp, &pCtx->epSet); + } else { + if (!cliIsEpsetUpdated(code, pCtx)) { + pTransInst->cfp(pTransInst->parent, pResp, NULL); + } else { + pTransInst->cfp(pTransInst->parent, pResp, &pCtx->epSet); + } } } return 0; diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index dfc6de6442..d32156dd0d 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -140,7 +140,6 @@ static void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd); static void (*transAsyncHandle[])(SSvrMsg* msg, SWorkThrd* thrd) = {uvHandleResp, uvHandleQuit, uvHandleRelease, uvHandleRegister, NULL}; - static void uvDestroyConn(uv_handle_t* handle); // server and worker thread @@ -777,9 +776,10 @@ static void destroyConn(SSvrConn* conn, bool clear) { if (!uv_is_closing((uv_handle_t*)conn->pTcp)) { tTrace("conn %p to be destroyed", conn); uv_close((uv_handle_t*)conn->pTcp, uvDestroyConn); - } else { - uvDestroyConn((uv_handle_t*)conn->pTcp); } + //} else { + // uvDestroyConn((uv_handle_t*)conn->pTcp); + //} } } static void destroyConnRegArg(SSvrConn* conn) { @@ -1116,4 +1116,6 @@ _return2: rpcFreeCont(msg->pCont); } +int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) { return -1; } + #endif diff --git a/source/libs/wal/inc/walInt.h b/source/libs/wal/inc/walInt.h index 7ca105ff2b..c23d0802c1 100644 --- a/source/libs/wal/inc/walInt.h +++ b/source/libs/wal/inc/walInt.h @@ -27,7 +27,7 @@ extern "C" { #endif // meta section begin -typedef struct WalFileInfo { +typedef struct { int64_t firstVer; int64_t lastVer; int64_t createTs; @@ -98,20 +98,20 @@ static inline int walBuildIdxName(SWal* pWal, int64_t fileFirstVer, char* buf) { return sprintf(buf, "%s/%020" PRId64 "." WAL_INDEX_SUFFIX, pWal->path, fileFirstVer); } -static inline int walValidHeadCksum(SWalHead* pHead) { - return taosCheckChecksum((uint8_t*)&pHead->head, sizeof(SWalReadHead), pHead->cksumHead); +static inline int walValidHeadCksum(SWalCkHead* pHead) { + return taosCheckChecksum((uint8_t*)&pHead->head, sizeof(SWalCont), pHead->cksumHead); } -static inline int walValidBodyCksum(SWalHead* pHead) { +static inline int walValidBodyCksum(SWalCkHead* pHead) { return taosCheckChecksum((uint8_t*)pHead->head.body, pHead->head.bodyLen, pHead->cksumBody); } -static inline int walValidCksum(SWalHead* pHead, void* body, int64_t bodyLen) { +static inline int walValidCksum(SWalCkHead* pHead, void* body, int64_t bodyLen) { return walValidHeadCksum(pHead) && walValidBodyCksum(pHead); } -static inline uint32_t walCalcHeadCksum(SWalHead* pHead) { - return taosCalcChecksum(0, (uint8_t*)&pHead->head, sizeof(SWalReadHead)); +static inline uint32_t walCalcHeadCksum(SWalCkHead* pHead) { + return taosCalcChecksum(0, (uint8_t*)&pHead->head, sizeof(SWalCont)); } static inline uint32_t walCalcBodyCksum(const void* body, uint32_t len) { diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 4150fe6d1b..313fd06c8e 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -16,9 +16,13 @@ #include "cJSON.h" #include "os.h" #include "taoserror.h" -#include "tref.h" +#include "tutil.h" #include "walInt.h" +bool FORCE_INLINE walLogExist(SWal* pWal, int64_t ver) { + return !walIsEmpty(pWal) && walGetFirstVer(pWal) <= ver && walGetLastVer(pWal) >= ver; +} + bool FORCE_INLINE walIsEmpty(SWal* pWal) { return pWal->vers.firstVer == -1; } int64_t FORCE_INLINE walGetFirstVer(SWal* pWal) { return pWal->vers.firstVer; } @@ -33,26 +37,9 @@ static FORCE_INLINE int walBuildMetaName(SWal* pWal, int metaVer, char* buf) { return sprintf(buf, "%s/meta-ver%d", pWal->path, metaVer); } -void* tmemmem(char* haystack, int hlen, char* needle, int nlen) { - char* limit; - - if (nlen == 0 || hlen < nlen) { - return NULL; - } - - limit = haystack + hlen - nlen + 1; - while ((haystack = (char*)memchr(haystack, needle[0], limit - haystack)) != NULL) { - if (memcmp(haystack, needle, nlen) == 0) { - return haystack; - } - haystack++; - } - return NULL; -} - static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { ASSERT(pWal->fileInfoSet != NULL); - int sz = taosArrayGetSize(pWal->fileInfoSet); + int32_t sz = taosArrayGetSize(pWal->fileInfoSet); ASSERT(sz > 0); #if 0 for (int i = 0; i < sz; i++) { @@ -97,14 +84,14 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { char* candidate; while ((candidate = tmemmem(haystack, readSize - (haystack - buf), (char*)&magic, sizeof(uint64_t))) != NULL) { // read and validate - SWalHead* logContent = (SWalHead*)candidate; + SWalCkHead* logContent = (SWalCkHead*)candidate; if (walValidHeadCksum(logContent) == 0 && walValidBodyCksum(logContent) == 0) { found = candidate; } haystack = candidate + 1; } if (found == buf) { - SWalHead* logContent = (SWalHead*)found; + SWalCkHead* logContent = (SWalCkHead*)found; if (walValidHeadCksum(logContent) != 0 || walValidBodyCksum(logContent) != 0) { // file has to be deleted taosMemoryFree(buf); @@ -114,7 +101,7 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { } } taosCloseFile(&pFile); - SWalHead* lastEntry = (SWalHead*)found; + SWalCkHead* lastEntry = (SWalCkHead*)found; return lastEntry->head.version; } diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 9505b02806..491b982968 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -117,8 +117,8 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { pWal->lastRollSeq = -1; // init write buffer - memset(&pWal->writeHead, 0, sizeof(SWalHead)); - pWal->writeHead.head.headVer = WAL_HEAD_VER; + memset(&pWal->writeHead, 0, sizeof(SWalCkHead)); + pWal->writeHead.head.protoVer = WAL_PROTO_VER; pWal->writeHead.magic = WAL_MAGIC; if (taosThreadMutexInit(&pWal->mutex, NULL) < 0) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 2de0fea9ac..e7f0b31ccc 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -33,7 +33,7 @@ SWalReadHandle *walOpenReadHandle(SWal *pWal) { taosThreadMutexInit(&pRead->mutex, NULL); - pRead->pHead = taosMemoryMalloc(sizeof(SWalHead)); + pRead->pHead = taosMemoryMalloc(sizeof(SWalCkHead)); if (pRead->pHead == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; taosMemoryFree(pRead); @@ -155,7 +155,7 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) { void walSetReaderCapacity(SWalReadHandle *pRead, int32_t capacity) { pRead->capacity = capacity; } -int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) { +int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalCkHead *pHead) { int64_t code; // TODO: valid ver @@ -170,8 +170,8 @@ int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) { ASSERT(taosValidFile(pRead->pReadLogTFile) == true); - code = taosReadFile(pRead->pReadLogTFile, pHead, sizeof(SWalHead)); - if (code != sizeof(SWalHead)) { + code = taosReadFile(pRead->pReadLogTFile, pHead, sizeof(SWalCkHead)); + if (code != sizeof(SWalCkHead)) { return -1; } @@ -186,7 +186,7 @@ int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) { return 0; } -int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalHead *pHead) { +int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalCkHead *pHead) { int64_t code; ASSERT(pRead->curVersion == pHead->head.version); @@ -203,12 +203,12 @@ int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalHead *pHead) { return 0; } -int32_t walFetchBody(SWalReadHandle *pRead, SWalHead **ppHead) { - SWalReadHead *pReadHead = &((*ppHead)->head); - int64_t ver = pReadHead->version; +int32_t walFetchBody(SWalReadHandle *pRead, SWalCkHead **ppHead) { + SWalCont *pReadHead = &((*ppHead)->head); + int64_t ver = pReadHead->version; if (pRead->capacity < pReadHead->bodyLen) { - void *ptr = taosMemoryRealloc(*ppHead, sizeof(SWalHead) + pReadHead->bodyLen); + void *ptr = taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen); if (ptr == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; return -1; @@ -241,18 +241,18 @@ int32_t walFetchBody(SWalReadHandle *pRead, SWalHead **ppHead) { return 0; } -int32_t walReadWithHandle_s(SWalReadHandle *pRead, int64_t ver, SWalReadHead **ppHead) { +int32_t walReadWithHandle_s(SWalReadHandle *pRead, int64_t ver, SWalCont **ppHead) { taosThreadMutexLock(&pRead->mutex); if (walReadWithHandle(pRead, ver) < 0) { taosThreadMutexUnlock(&pRead->mutex); return -1; } - *ppHead = taosMemoryMalloc(sizeof(SWalReadHead) + pRead->pHead->head.bodyLen); + *ppHead = taosMemoryMalloc(sizeof(SWalCont) + pRead->pHead->head.bodyLen); if (*ppHead == NULL) { taosThreadMutexUnlock(&pRead->mutex); return -1; } - memcpy(*ppHead, &pRead->pHead->head, sizeof(SWalReadHead) + pRead->pHead->head.bodyLen); + memcpy(*ppHead, &pRead->pHead->head, sizeof(SWalCont) + pRead->pHead->head.bodyLen); taosThreadMutexUnlock(&pRead->mutex); return 0; } @@ -282,8 +282,8 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { ASSERT(taosValidFile(pRead->pReadLogTFile) == true); - code = taosReadFile(pRead->pReadLogTFile, pRead->pHead, sizeof(SWalHead)); - if (code != sizeof(SWalHead)) { + code = taosReadFile(pRead->pReadLogTFile, pRead->pHead, sizeof(SWalCkHead)); + if (code != sizeof(SWalCkHead)) { if (code < 0) terrno = TAOS_SYSTEM_ERROR(errno); else { @@ -301,7 +301,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } if (pRead->capacity < pRead->pHead->head.bodyLen) { - void *ptr = taosMemoryRealloc(pRead->pHead, sizeof(SWalHead) + pRead->pHead->head.bodyLen); + void *ptr = taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pRead->pHead->head.bodyLen); if (ptr == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; return -1; diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index d1295667af..9245c03826 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -142,10 +142,10 @@ int32_t walRollback(SWal *pWal, int64_t ver) { return -1; } // validate offset - SWalHead head; + SWalCkHead head; ASSERT(taosValidFile(pLogTFile)); - int64_t size = taosReadFile(pLogTFile, &head, sizeof(SWalHead)); - if (size != sizeof(SWalHead)) { + int64_t size = taosReadFile(pLogTFile, &head, sizeof(SWalCkHead)); + if (size != sizeof(SWalCkHead)) { return -1; } code = walValidHeadCksum(&head); @@ -261,7 +261,7 @@ int32_t walEndSnapshot(SWal *pWal) { } int walRoll(SWal *pWal) { - int code = 0; + int32_t code = 0; if (pWal->pWriteIdxTFile != NULL) { code = taosCloseFile(&pWal->pWriteIdxTFile); if (code != 0) { @@ -321,12 +321,13 @@ static int walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { return 0; } -int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, +int32_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, int32_t bodyLen) { - int code = 0; + int32_t code = 0; // no wal if (pWal->cfg.level == TAOS_WAL_NOLOG) return 0; + if (bodyLen > TSDB_MAX_WAL_SIZE) { terrno = TSDB_CODE_WAL_SIZE_LIMIT; return -1; @@ -356,6 +357,7 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLog terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } + /*if (!tfValid(pWal->pWriteLogTFile)) return -1;*/ ASSERT(pWal->writeCur >= 0); @@ -380,7 +382,7 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLog pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead); pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen); - if (taosWriteFile(pWal->pWriteLogTFile, &pWal->writeHead, sizeof(SWalHead)) != sizeof(SWalHead)) { + if (taosWriteFile(pWal->pWriteLogTFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) { // TODO ftruncate terrno = TAOS_SYSTEM_ERROR(errno); wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal), @@ -405,19 +407,19 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLog // set status if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index; pWal->vers.lastVer = index; - pWal->totSize += sizeof(SWalHead) + bodyLen; + pWal->totSize += sizeof(SWalCkHead) + bodyLen; if (walGetCurFileInfo(pWal)->firstVer == -1) { walGetCurFileInfo(pWal)->firstVer = index; } walGetCurFileInfo(pWal)->lastVer = index; - walGetCurFileInfo(pWal)->fileSize += sizeof(SWalHead) + bodyLen; + walGetCurFileInfo(pWal)->fileSize += sizeof(SWalCkHead) + bodyLen; taosThreadMutexUnlock(&pWal->mutex); return 0; } -int64_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen) { +int32_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen) { SSyncLogMeta syncMeta = { .isWeek = -1, .seqNum = UINT64_MAX, @@ -435,27 +437,3 @@ void walFsync(SWal *pWal, bool forceFsync) { } } } - -/*static int walValidateOffset(SWal* pWal, int64_t ver) {*/ -/*int code = 0;*/ -/*SWalHead *pHead = NULL;*/ -/*code = (int)walRead(pWal, &pHead, ver);*/ -/*if(pHead->head.version != ver) {*/ -/*return -1;*/ -/*}*/ -/*return 0;*/ -/*}*/ - -/*static int64_t walGetOffset(SWal* pWal, int64_t ver) {*/ -/*int code = walSeekVer(pWal, ver);*/ -/*if(code != 0) {*/ -/*return -1;*/ -/*}*/ - -/*code = walValidateOffset(pWal, ver);*/ -/*if(code != 0) {*/ -/*return -1;*/ -/*}*/ - -/*return 0;*/ -/*}*/ diff --git a/source/libs/wal/test/walMetaTest.cpp b/source/libs/wal/test/walMetaTest.cpp index b1c673e87b..89c4fd9ef2 100644 --- a/source/libs/wal/test/walMetaTest.cpp +++ b/source/libs/wal/test/walMetaTest.cpp @@ -148,7 +148,7 @@ TEST_F(WalCleanEnv, createNew) { walRollFileInfo(pWal); ASSERT(pWal->fileInfoSet != NULL); ASSERT_EQ(pWal->fileInfoSet->size, 1); - WalFileInfo* pInfo = (WalFileInfo*)taosArrayGetLast(pWal->fileInfoSet); + SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet); ASSERT_EQ(pInfo->firstVer, 0); ASSERT_EQ(pInfo->lastVer, -1); ASSERT_EQ(pInfo->closeTs, -1); diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 291d38bdca..65471df0a9 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -300,16 +300,14 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { return pFile; } -int64_t taosCloseFile(TdFilePtr *ppFile) { +int32_t taosCloseFile(TdFilePtr *ppFile) { + int32_t code = 0; if (ppFile == NULL || *ppFile == NULL) { return 0; } #if FILE_WITH_LOCK taosThreadRwlockWrlock(&((*ppFile)->rwlock)); #endif - if (ppFile == NULL || *ppFile == NULL) { - return 0; - } if ((*ppFile)->fp != NULL) { fflush((*ppFile)->fp); fclose((*ppFile)->fp); @@ -320,9 +318,10 @@ int64_t taosCloseFile(TdFilePtr *ppFile) { HANDLE h = (HANDLE)_get_osfhandle((*ppFile)->fd); !FlushFileBuffers(h); #else - fsync((*ppFile)->fd); + // warning: never fsync silently in base lib + /*fsync((*ppFile)->fd);*/ #endif - close((*ppFile)->fd); + code = close((*ppFile)->fd); (*ppFile)->fd = -1; } (*ppFile)->refId = 0; @@ -332,7 +331,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile) { #endif taosMemoryFree(*ppFile); *ppFile = NULL; - return 0; + return code; } int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) { @@ -560,6 +559,8 @@ int32_t taosFsyncFile(TdFilePtr pFile) { return 0; } + // this implementation is WRONG + // fflush is not a replacement of fsync if (pFile->fp != NULL) return fflush(pFile->fp); if (pFile->fd >= 0) { #ifdef WINDOWS diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c new file mode 100644 index 0000000000..98cd63a831 --- /dev/null +++ b/source/os/src/osMath.c @@ -0,0 +1,47 @@ +/* + * 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 +#define _DEFAULT_SOURCE +#include "os.h" + +#ifdef WINDOWS +void swapStr(char* j, char* J, int width) { + int i; + char tmp; + for (i = 0; i < width; i++) { + tmp = *j; + *j = *J; + *J = tmp; + j++; + J++; + } +} +#endif + +void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar) { +#ifdef WINDOWS + int64_t i, j; + for (i = 0; i < sz - 1; i++) { + for (j = 0; j < sz - 1 - i; j++) { + if (compar((char*)arr + j * width, (char*)arr + (j + 1) * width) > 0.00) { + swapStr((char*)arr + j * width, (char*)arr + (j + 1) * width, width); + } + } + } +#else + qsort(arr, sz, width, compar); +#endif +} diff --git a/source/os/src/osString.c b/source/os/src/osString.c index da1fbd364f..e6904f1963 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -202,7 +202,7 @@ int32_t taosHexEncode(const char *src, char *dst, int32_t len) { } for (int32_t i = 0; i < len; ++i) { - sprintf(dst + i * 2, "%02x", src[i] & 0xff); + sprintf(dst + i * 2, "%02x", src[i]); } return 0; @@ -213,10 +213,10 @@ int32_t taosHexDecode(const char *src, char *dst, int32_t len) { return -1; } - uint16_t hn, ln, out; + uint8_t hn, ln, out; for (int i = 0, j = 0; i < len * 2; i += 2, ++j ) { - hn = src[i] > '9' ? src[i] - 'A' + 10 : src[i] - '0'; - ln = src[i + 1] > '9' ? src[i + 1] - 'A' + 10 : src[i + 1] - '0'; + hn = src[i] > '9' ? src[i] - 'a' + 10 : src[i] - '0'; + ln = src[i + 1] > '9' ? src[i + 1] - 'a' + 10 : src[i + 1] - '0'; out = (hn << 4) | ln; memcpy(dst + j, &out, 1); diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index ec90e5a9b9..23e79da948 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -373,7 +373,7 @@ void taosArraySort(SArray* pArray, __compar_fn_t compar) { assert(pArray != NULL); assert(compar != NULL); - qsort(pArray->pData, pArray->size, pArray->elemSize, compar); + taosSort(pArray->pData, pArray->size, pArray->elemSize, compar); } void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn, int32_t flags) { @@ -390,7 +390,7 @@ int32_t taosArraySearchIdx(const SArray* pArray, const void* key, __compar_fn_t void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) { assert(pArray != NULL); - qsort(pArray->pData, pArray->size, pArray->elemSize, comparFn); + taosSort(pArray->pData, pArray->size, pArray->elemSize, comparFn); } char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn, int32_t flags) { diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 56b113fd8f..a722cfeee2 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -124,7 +124,7 @@ void tdigestCompress(TDigest *t) { t->num_buffered_pts = 0; t->total_weight += unmerged_weight; - qsort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid); + taosSort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid); memset(&args, 0, sizeof(SMergeArgs)); args.centroids = (SCentroid*)taosMemoryMalloc((size_t)(sizeof(SCentroid) * t->size)); memset(args.centroids, 0, (size_t)(sizeof(SCentroid) * t->size)); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 96f0fb21ca..564751ad67 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -89,8 +89,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, "Ref is not there") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, "Redirect") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, "Authentication failure") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, "Unable to establish connection") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQDN") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_PORT_EADDRINUSE, "Port already in use") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_BROKEN_LINK, "Conn is broken") //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation") @@ -394,6 +394,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUPLICATTED_OPERATION, "Duplicatted operation TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_MSG_ERROR, "Task message error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JOB_FREED, "Job already freed") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_STATUS_ERROR, "Task status error") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_IN_ERROR, "Json not support in in/notin operator") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR, "Json not support in this place") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_IN_GROUP_ERROR, "Json not support in group/partition by") // grant TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired") @@ -429,6 +432,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NEW_CONFIG_ERROR, "Sync new config error TAOS_DEFINE_ERROR(TSDB_CODE_SYN_RECONFIG_NOT_READY, "Sync not ready for reconfig") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_PROPOSE_NOT_READY, "Sync not ready for propose") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_STANDBY_NOT_READY, "Sync not ready for standby") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BATCH_ERROR, "Sync batch error") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error") // wal @@ -586,6 +590,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_CACHE, "No tsma index in ca TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_STAT, "Invalid rsma state") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_QTASKINFO_CREATE, "Rsma qtaskinfo creation error") +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FILE_CORRUPTED, "Rsma file corrupted") + //tq TAOS_DEFINE_ERROR(TSDB_CODE_TQ_NO_COMMITTED_OFFSET, "No committed offset") @@ -614,7 +620,7 @@ static int32_t taosCompareTaosError(const void* a, const void* b) { static TdThreadOnce tsErrorInit = PTHREAD_ONCE_INIT; static void tsSortError(void) { - qsort(errors, sizeof(errors) / sizeof(errors[0]), sizeof(errors[0]), taosCompareTaosError); + taosSort(errors, sizeof(errors) / sizeof(errors[0]), sizeof(errors[0]), taosCompareTaosError); } const char* tstrerror(int32_t err) { diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index b034a6e73e..28e15dc9a3 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -16,24 +16,24 @@ #define _DEFAULT_SOURCE #include "tlrucache.h" #include "os.h" -#include "tdef.h" #include "taoserror.h" -#include "tlog.h" #include "tarray.h" +#include "tdef.h" +#include "tlog.h" -typedef struct SLRUEntry SLRUEntry; +typedef struct SLRUEntry SLRUEntry; typedef struct SLRUEntryTable SLRUEntryTable; typedef struct SLRUCacheShard SLRUCacheShard; -typedef struct SShardedCache SShardedCache; +typedef struct SShardedCache SShardedCache; enum { - TAOS_LRU_IN_CACHE = (1 << 0), // Whether this entry is referenced by the hash table. + 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_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_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). + TAOS_LRU_HAS_HIT = (1 << 3), // Whether this entry has had any lookups (hits). }; struct SLRUEntry { @@ -50,18 +50,39 @@ struct SLRUEntry { char keyData[1]; }; -#define TAOS_LRU_ENTRY_IN_CACHE(h) ((h)->flags & TAOS_LRU_IN_CACHE) +#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_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_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) +#define TAOS_LRU_ENTRY_REF(h) (++(h)->refs) static bool taosLRUEntryUnref(SLRUEntry *entry) { assert(entry->refs > 0); @@ -90,7 +111,7 @@ struct SLRUEntryTable { static int taosLRUEntryTableInit(SLRUEntryTable *table, int maxUpperHashBits) { table->lengthBits = 4; - table->list = taosMemoryCalloc(1 << table->lengthBits, sizeof(SLRUEntry*)); + table->list = taosMemoryCalloc(1 << table->lengthBits, sizeof(SLRUEntry *)); if (!table->list) { return -1; } @@ -125,7 +146,7 @@ static void taosLRUEntryTableCleanup(SLRUEntryTable *table) { taosMemoryFree(table->list); } -static SLRUEntry **taosLRUEntryTableFindPtr(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { +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; @@ -134,7 +155,7 @@ static SLRUEntry **taosLRUEntryTableFindPtr(SLRUEntryTable * table, const void * return entry; } -static void taosLRUEntryTableResize(SLRUEntryTable * table) { +static void taosLRUEntryTableResize(SLRUEntryTable *table) { int lengthBits = table->lengthBits; if (lengthBits >= table->maxLengthBits) { return; @@ -144,9 +165,9 @@ static void taosLRUEntryTableResize(SLRUEntryTable * table) { return; } - uint32_t oldLength = 1 << lengthBits; - int newLengthBits = lengthBits + 1; - SLRUEntry **newList = taosMemoryCalloc(1 << newLengthBits, sizeof(SLRUEntry*)); + uint32_t oldLength = 1 << lengthBits; + int newLengthBits = lengthBits + 1; + SLRUEntry **newList = taosMemoryCalloc(1 << newLengthBits, sizeof(SLRUEntry *)); if (!newList) { return; } @@ -154,8 +175,8 @@ static void taosLRUEntryTableResize(SLRUEntryTable * table) { 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 *next = entry->nextHash; + uint32_t hash = entry->hash; SLRUEntry **ptr = &newList[hash >> (32 - newLengthBits)]; entry->nextHash = *ptr; *ptr = entry; @@ -170,13 +191,13 @@ static void taosLRUEntryTableResize(SLRUEntryTable * table) { table->lengthBits = newLengthBits; } -static SLRUEntry *taosLRUEntryTableLookup(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { +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) { +static SLRUEntry *taosLRUEntryTableInsert(SLRUEntryTable *table, SLRUEntry *entry) { SLRUEntry **ptr = taosLRUEntryTableFindPtr(table, entry->keyData, entry->keyLength, entry->hash); - SLRUEntry *old = *ptr; + SLRUEntry *old = *ptr; entry->nextHash = (old == NULL) ? NULL : old->nextHash; *ptr = entry; if (old == NULL) { @@ -189,9 +210,9 @@ static SLRUEntry *taosLRUEntryTableInsert(SLRUEntryTable * table, SLRUEntry *ent return old; } -static SLRUEntry *taosLRUEntryTableRemove(SLRUEntryTable * table, const void *key, size_t keyLen, uint32_t hash) { +static SLRUEntry *taosLRUEntryTableRemove(SLRUEntryTable *table, const void *key, size_t keyLen, uint32_t hash) { SLRUEntry **entry = taosLRUEntryTableFindPtr(table, key, keyLen, hash); - SLRUEntry *result = *entry; + SLRUEntry *result = *entry; if (result) { *entry = result->nextHash; --table->elems; @@ -201,17 +222,17 @@ static SLRUEntry *taosLRUEntryTableRemove(SLRUEntryTable * table, const void *ke } 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; + 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))) @@ -231,8 +252,7 @@ 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))) { + 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; @@ -248,7 +268,7 @@ static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) { e->prev->next = e; e->next->prev = e; - + TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(e, false); shard->lruLowPri = e; } @@ -304,13 +324,13 @@ static void taosLRUCacheShardSetCapacity(SLRUCacheShard *shard, size_t capacity) for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); - taosLRUEntryFree(entry); + taosLRUEntryFree(entry); } taosArrayDestroy(lastReferenceList); } -static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool strict, - double highPriPoolRatio, int maxUpperHashBits) { +static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool strict, double highPriPoolRatio, + int maxUpperHashBits) { if (taosLRUEntryTableInit(&shard->table, maxUpperHashBits) < 0) { return -1; } @@ -341,23 +361,24 @@ static void taosLRUCacheShardCleanup(SLRUCacheShard *shard) { taosLRUEntryTableCleanup(&shard->table); } -static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *e, LRUHandle **handle, bool freeOnFail) { +static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *e, LRUHandle **handle, + bool freeOnFail) { LRUStatus status = TAOS_LRU_STATUS_OK; - SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES); + 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); + taosMemoryFree(e); - *handle = NULL; + *handle = NULL; } status = TAOS_LRU_STATUS_INCOMPLETE; @@ -371,21 +392,21 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry * 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; + taosLRUCacheShardLRURemove(shard, old); + assert(shard->usage >= old->totalCharge); + shard->usage -= old->totalCharge; - taosArrayPush(lastReferenceList, &old); + taosArrayPush(lastReferenceList, &old); } } if (handle == NULL) { taosLRUCacheShardLRUInsert(shard, e); } else { if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { - TAOS_LRU_ENTRY_REF(e); + TAOS_LRU_ENTRY_REF(e); } - *handle = (LRUHandle*) e; + *handle = (LRUHandle *)e; } } @@ -394,7 +415,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry * for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); - taosLRUEntryFree(entry); + taosLRUEntryFree(entry); } taosArrayDestroy(lastReferenceList); @@ -402,8 +423,8 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry * } 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) { + 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; @@ -442,7 +463,7 @@ static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key taosThreadMutexUnlock(&shard->mutex); - return (LRUHandle *) e; + return (LRUHandle *)e; } static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash) { @@ -482,7 +503,7 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); assert(shard->usage >= old->totalCharge); shard->usage -= old->totalCharge; - + taosArrayPush(lastReferenceList, &old); } @@ -491,14 +512,14 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); - taosLRUEntryFree(entry); + taosLRUEntryFree(entry); } taosArrayDestroy(lastReferenceList); } static bool taosLRUCacheShardRef(SLRUCacheShard *shard, LRUHandle *handle) { - SLRUEntry *e = (SLRUEntry *) handle; + SLRUEntry *e = (SLRUEntry *)handle; taosThreadMutexLock(&shard->mutex); assert(TAOS_LRU_ENTRY_HAS_REFS(e)); @@ -514,8 +535,8 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b return false; } - SLRUEntry *e = (SLRUEntry *) handle; - bool lastReference = false; + SLRUEntry *e = (SLRUEntry *)handle; + bool lastReference = false; taosThreadMutexLock(&shard->mutex); @@ -537,7 +558,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b assert(shard->usage >= e->totalCharge); shard->usage -= e->totalCharge; } - + taosThreadMutexUnlock(&shard->mutex); if (lastReference) { @@ -549,7 +570,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) { size_t usage = 0; - + taosThreadMutexLock(&shard->mutex); usage = shard->usage; taosThreadMutexUnlock(&shard->mutex); @@ -559,7 +580,7 @@ static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) { static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) { size_t usage = 0; - + taosThreadMutexLock(&shard->mutex); assert(shard->usage >= shard->lruUsage); @@ -579,11 +600,11 @@ static void taosLRUCacheShardSetStrictCapacity(SLRUCacheShard *shard, bool stric } struct SShardedCache { - uint32_t shardMask; - TdThreadMutex capacityMutex; - size_t capacity; - bool strictCapacity; - uint64_t lastId; // atomic var for last id + uint32_t shardMask; + TdThreadMutex capacityMutex; + size_t capacity; + bool strictCapacity; + uint64_t lastId; // atomic var for last id }; struct SLRUCache { @@ -593,7 +614,7 @@ struct SLRUCache { }; static int getDefaultCacheShardBits(size_t capacity) { - int numShardBits = 0; + int numShardBits = 0; size_t minShardSize = 512 * 1024; size_t numShards = capacity / minShardSize; while (numShards >>= 1) { @@ -621,7 +642,7 @@ SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoo numShardBits = getDefaultCacheShardBits(capacity); } - int numShards = 1 << numShardBits; + int numShards = 1 << numShardBits; cache->shards = taosMemoryCalloc(numShards, sizeof(SLRUCacheShard)); if (!cache->shards) { taosMemoryFree(cache); @@ -629,7 +650,7 @@ SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoo return NULL; } - bool strictCapacity = 1; + 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); @@ -653,7 +674,7 @@ void taosLRUCacheCleanup(SLRUCache *cache) { int numShards = cache->numShards; assert(numShards > 0); for (int i = 0; i < numShards; ++i) { - taosLRUCacheShardCleanup(&cache->shards[i]); + taosLRUCacheShardCleanup(&cache->shards[i]); } taosMemoryFree(cache->shards); cache->shards = 0; @@ -666,11 +687,12 @@ 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) { + _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); + return taosLRUCacheShardInsert(&cache->shards[shardIndex], key, keyLen, hash, value, charge, deleter, handle, + priority); } LRUHandle *taosLRUCacheLookup(SLRUCache *cache, const void *key, size_t keyLen) { @@ -699,7 +721,7 @@ bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle) { return false; } - uint32_t hash = ((SLRUEntry *) handle)->hash; + uint32_t hash = ((SLRUEntry *)handle)->hash; uint32_t shardIndex = hash & cache->shardedCache.shardMask; return taosLRUCacheShardRef(&cache->shards[shardIndex], handle); @@ -710,15 +732,13 @@ bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRe return false; } - uint32_t hash = ((SLRUEntry *) handle)->hash; + 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; -} +void *taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle) { return ((SLRUEntry *)handle)->value; } size_t taosLRUCacheGetUsage(SLRUCache *cache) { size_t usage = 0; @@ -742,7 +762,7 @@ size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache) { void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity) { uint32_t numShards = cache->numShards; - size_t perShard = (capacity + (numShards = 1)) / numShards; + size_t perShard = (capacity + (numShards - 1)) / numShards; taosThreadMutexLock(&cache->shardedCache.capacityMutex); @@ -751,7 +771,7 @@ void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity) { } cache->shardedCache.capacity = capacity; - + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); } @@ -777,7 +797,7 @@ void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict) { } cache->shardedCache.strictCapacity = strict; - + taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); } diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index cdf2629671..d70c45b0f2 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -193,7 +193,9 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { char* pDataBuf = pg->pData; memset(pDataBuf, 0, getAllocPageSize(pBuf->pageSize)); - +#ifdef BUF_PAGE_DEBUG + uDebug("page_flush %p, pageId:%d, offset:%d", pDataBuf, pg->pageId, pg->offset); +#endif pg->length = size; // on disk size return pDataBuf; } @@ -440,6 +442,9 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t groupId, int32_t* pageId) { } ((void**)pi->pData)[0] = pi; +#ifdef BUF_PAGE_DEBUG + uDebug("page_getNewBufPage , pi->pData:%p, pageId:%d, offset:%"PRId64, pi->pData, pi->pageId, pi->offset); +#endif return (void*)(GET_DATA_PAYLOAD(pi)); } @@ -462,7 +467,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { lruListMoveToFront(pBuf->lruList, (*pi)); (*pi)->used = true; - +#ifdef BUF_PAGE_DEBUG + uDebug("page_getBufPage1 pageId:%d, offset:%"PRId64, (*pi)->pageId, (*pi)->offset); +#endif return (void*)(GET_DATA_PAYLOAD(*pi)); } else { // not in memory assert((*pi)->pData == NULL && (*pi)->pn == NULL && (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1))); @@ -494,7 +501,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { return NULL; } } - +#ifdef BUF_PAGE_DEBUG + uDebug("page_getBufPage2 pageId:%d, offset:%"PRId64, (*pi)->pageId, (*pi)->offset); +#endif return (void*)(GET_DATA_PAYLOAD(*pi)); } } @@ -506,8 +515,11 @@ void releaseBufPage(SDiskbasedBuf* pBuf, void* page) { } void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) { +#ifdef BUF_PAGE_DEBUG + uDebug("page_releaseBufPageInfo pageId:%d, used:%d, offset:%"PRId64, pi->pageId, pi->used, pi->offset); +#endif assert(pi->pData != NULL && pi->used == true); - +// assert(pi->pData != NULL); pi->used = false; pBuf->statis.releasePages += 1; } diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index 0534eb3462..addb9f55ba 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -16,6 +16,23 @@ #define _DEFAULT_SOURCE #include "tutil.h" +void *tmemmem(const char *haystack, int32_t hlen, const char *needle, int32_t nlen) { + const char *limit; + + if (nlen == 0 || hlen < nlen) { + return NULL; + } + + limit = haystack + hlen - nlen + 1; + while ((haystack = (char *)memchr(haystack, needle[0], limit - haystack)) != NULL) { + if (memcmp(haystack, needle, nlen) == 0) { + return (void *)haystack; + } + haystack++; + } + return NULL; +} + int32_t strdequote(char *z) { if (z == NULL) { return 0; diff --git a/tests/pytest/tools/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdumpTestNanoSupport.py index 0101a65407..e96de674d7 100644 --- a/tests/pytest/tools/taosdumpTestNanoSupport.py +++ b/tests/pytest/tools/taosdumpTestNanoSupport.py @@ -60,7 +60,7 @@ class TDTestCase: def build_db(precision, start_time): tdSql.execute("drop database if exists timedb1") tdSql.execute( - "create database timedb1 duration 10 keep 365 blocks 8 precision "+"\""+precision+"\"") + "create database timedb1 duration 10 keep 36500 blocks 8 precision "+"\""+precision+"\"") tdSql.execute("use timedb1") tdSql.execute( diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 6caf5624a4..94043ed01a 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -17,6 +17,7 @@ import string import requests import time import socket +import json from .boundary import DataBoundary import taos from util.log import * @@ -25,7 +26,7 @@ from util.cases import * from util.dnodes import * from util.common import * -class TDCom: +class TDCom: def __init__(self): self.sml_type = None self.env_setting = None @@ -206,12 +207,12 @@ class TDCom: """ generate long name mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": + """ + if mode == "numbers": chars = ''.join(random.choice(string.digits) for i in range(len)) - elif mode == "letters": + elif mode == "letters": chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) - elif mode == "letters_mixed": + elif mode == "letters_mixed": chars = ''.join(random.choice(string.ascii_letters.upper() + string.ascii_letters.lower()) for i in range(len)) else: chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len)) @@ -276,7 +277,7 @@ class TDCom: vgroups replica precision strict wal fsync comp cachelast single_stable buffer pagesize pages minrows maxrows duration keep retentions ''' sqlString = f'create database if not exists {dbName} ' - + dbParams = "" if len(kwargs) > 0: for param, value in kwargs.items(): @@ -306,7 +307,7 @@ class TDCom: # return # def create_ctables(self,tsql, dbName,stbName,ctbNum,tagDict): - # tsql.execute("use %s" %dbName) + # tsql.execute("use %s" %dbName) # tagsValues = '' # for i in range(tagDict['int']): # if i > 0: @@ -323,7 +324,7 @@ class TDCom: # sql = pre_create # if sql != pre_create: # tsql.execute(sql) - + # tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) # return @@ -352,7 +353,7 @@ class TDCom: # tsql.execute(sql) # tdLog.debug("insert data ............ [OK]") # return - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -367,7 +368,7 @@ class TDCom: if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] break - return buildPath + return buildPath def getClientCfgPath(self): buildPath = self.getBuildPath() @@ -398,7 +399,7 @@ class TDCom: return newTdSql ################################################################################################################ - # port from the common.py of new test frame + # port from the common.py of new test frame ################################################################################################################ def gen_default_tag_str(self): default_tag_str = "" @@ -527,13 +528,14 @@ class TDCom: tag_value_list.append(self.gen_random_type_value(tag_elm["type"], "", "", "", "")) else: continue - return tag_value_list + return tag_value_list - def gen_column_value_list(self, column_elm_list, ts_value=None): + def gen_column_value_list(self, column_elm_list, ts_value=None): if ts_value is None: ts_value = self.genTs()[0] column_value_list = list() + column_value_list.append(ts_value) if column_elm_list is None: column_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) else: @@ -550,11 +552,11 @@ class TDCom: column_value_list.append(self.gen_random_type_value(column_elm["type"], "", "", "", "")) else: continue - column_value_list = [self.ts_value] + self.column_value_list + # column_value_list = [self.ts_value] + self.column_value_list return column_value_list def create_stable(self, tsql, dbname=None, stbname="stb", column_elm_list=None, tag_elm_list=None, - count=1, default_stbname_prefix="stb", **kwargs): + count=1, default_stbname_prefix="stb", **kwargs): colname_prefix = 'c' tagname_prefix = 't' stbname_index_start_num = 1 @@ -589,20 +591,20 @@ class TDCom: tag_value_str += f'"{tag_value}", ' else: tag_value_str += f'{tag_value}, ' - tag_value_str = tag_value_str.rstrip()[:-1] - + tag_value_str = tag_value_str.rstrip()[:-1] + if int(count) <= 1: create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' tsql.execute(create_ctable_sql) else: for _ in range(count): create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' - ctbname_index_start_num += 1 + ctbname_index_start_num += 1 tdLog.info("create ctb sql: %s"%create_ctable_sql) tsql.execute(create_ctable_sql) - + def create_table(self, tsql, dbname=None, tbname="ntb", column_elm_list=None, count=1, **kwargs): - tbname_index_start_num = 1 + tbname_index_start_num = 1 tbname_prefix="ntb" tb_params = "" @@ -632,14 +634,23 @@ class TDCom: column_value_str += f'"{column_value}", ' else: column_value_str += f'{column_value}, ' - column_value_str = column_value_str.rstrip()[:-1] + column_value_str = column_value_str.rstrip()[:-1] if int(count) <= 1: insert_sql = f'insert into {self.tb_name} values ({column_value_str});' tsql.execute(insert_sql) else: for num in range(count): column_value_list = self.gen_column_value_list(column_ele_list, f'{start_ts_value}+{num}s') - column_value_str = ", ".join(str(v) for v in column_value_list) + # column_value_str = ", ".join(str(v) for v in column_value_list) + column_value_str = '' + idx = 0 + for column_value in column_value_list: + if isinstance(column_value, str) and idx != 0: + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + idx += 1 + column_value_str = column_value_str.rstrip()[:-1] insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});' tsql.execute(insert_sql) def getOneRow(self, location, containElm): @@ -651,4 +662,22 @@ class TDCom: return res_list else: tdLog.exit(f"getOneRow out of range: row_index={location} row_count={self.query_row}") + + def killProcessor(self, processorName): + if (platform.system().lower() == 'windows'): + os.system("TASKKILL /F /IM %s.exe"%processorName) + else: + os.system('pkill %s'%processorName) + + +def is_json(msg): + if isinstance(msg, str): + try: + json.loads(msg) + return True + except: + return False + else: + return False + tdCom = TDCom() diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index 807398f70f..83487da023 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -71,6 +71,34 @@ TAOS_KEYWORDS = [ "COPY", "IF", "NOW", "STABLES", "WHERE", ] +NUM_FUNC = [ + "ABS", "ACOS", "ASIN", "ATAN", "CEIL", "COS", "FLOOR", "LOG", "POW", "ROUND", "SIN", "SQRT", "TAN", +] + +STR_FUNC = [ + "CHAR_LENGTH", "CONCAT", "CONCAT_WS", "LENGTH", "LOWER","LTRIM", "RTRIM", "SUBSTR", "UPPER", +] + +CONVER_FUNC = ["CASR", "TO_ISO8601", "TO_JSON", "TP_UNIXTIMESTAMP"] + +SELECT_FUNC = [ + "APERCENTILE", "BOTTOM", "FIRST", "INTERP", "LAST", "MAX", "MIN", "PERCENTILE", "TAIL", "TOP", "UNIQUE", +] + +AGG_FUNC = [ + "AVG", "COUNT", "ELAPSED", "LEASTSQUARES", "MODE", "SPREAD", "STDDEV", "SUM", "HYPERLOGLOG", "HISTOGRAM", +] + +TS_FUNC = [ + "CSUM", "DERIVATIVE", "DIFF", "IRATE", "MAVG", "SAMPLE", "STATECOUNT", "STATEDURATION", "TWA" +] + +SYSINFO_FUCN = [ + "DATABASE", "CLIENT_VERSION", "SERVER_VERSION", "SERVER_STATUS", "CURRENT_USER", "USER" +] + + + # basic data type boundary TINYINT_MAX = 127 TINYINT_MIN = -128 @@ -84,16 +112,16 @@ SMALLINT_MIN = -32768 SMALLINT_UN_MAX = 65535 SMALLINT_UN_MIN = 0 -INT_MAX = 2147483647 -INT_MIN = -2147483648 +INT_MAX = 2_147_483_647 +INT_MIN = -2_147_483_648 -INT_UN_MAX = 4294967295 +INT_UN_MAX = 4_294_967_295 INT_UN_MIN = 0 -BIGINT_MAX = 9223372036854775807 -BIGINT_MIN = -9223372036854775808 +BIGINT_MAX = 9_223_372_036_854_775_807 +BIGINT_MIN = -9_223_372_036_854_775_808 -BIGINT_UN_MAX = 18446744073709551615 +BIGINT_UN_MAX = 18_446_744_073_709_551_615 BIGINT_UN_MIN = 0 FLOAT_MAX = 3.40E+38 @@ -131,13 +159,13 @@ COL_COUNT_MIN = 2 TAG_COL_COUNT_MAX = 4096 TAG_COL_COUNT_MIN = 3 -MNODE_SHM_SIZE_MAX = 2147483647 -MNODE_SHM_SIZE_MIN = 6292480 -MNODE_SHM_SIZE_DEFAULT = 6292480 +MNODE_SHM_SIZE_MAX = 2_147_483_647 +MNODE_SHM_SIZE_MIN = 6_292_480 +MNODE_SHM_SIZE_DEFAULT = 6_292_480 -VNODE_SHM_SIZE_MAX = 2147483647 -VNODE_SHM_SIZE_MIN = 6292480 -VNODE_SHM_SIZE_DEFAULT = 31458304 +VNODE_SHM_SIZE_MAX = 2_147_483_647 +VNODE_SHM_SIZE_MIN = 6_292_480 +VNODE_SHM_SIZE_DEFAULT = 31_458_304 # time_init TIME_MS = 1 @@ -160,6 +188,7 @@ INTERVAL_MIN = 1 * TIME_MS if PRECISION == PRECISION_DEFAULT else 1 * TIME_US # streams and related agg-function SMA_INDEX_FUNCTIONS = ["MIN", "MAX"] ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"] +BLOCK_FUNCTIONS = ["SUM", "MIN", "MAX"] SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] WATERMARK_MAX = 900000 WATERMARK_MIN = 0 diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index fe802dd9a3..585594e035 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -96,6 +96,15 @@ class TDSql: return self.queryResult return self.queryRows + def is_err_sql(self, sql): + err_flag = True + try: + self.cursor.execute(sql) + except BaseException: + err_flag = False + + return False if err_flag else True + def getVariable(self, search_attr): ''' get variable of search_attr access "show variables" @@ -249,7 +258,6 @@ class TDSql: raise Exception(repr(e)) return self.queryResult - def executeTimes(self, sql, times): for i in range(times): try: @@ -336,6 +344,38 @@ class TDSql: elif precision == "ns": return int(times*1000*1000) + def get_type(self, col): + if self.cursor.istype(col, "BOOL"): + return "BOOL" + if self.cursor.istype(col, "INT"): + return "INT" + if self.cursor.istype(col, "BIGINT"): + return "BIGINT" + if self.cursor.istype(col, "TINYINT"): + return "TINYINT" + if self.cursor.istype(col, "SMALLINT"): + return "SMALLINT" + if self.cursor.istype(col, "FLOAT"): + return "FLOAT" + if self.cursor.istype(col, "DOUBLE"): + return "DOUBLE" + if self.cursor.istype(col, "BINARY"): + return "BINARY" + if self.cursor.istype(col, "NCHAR"): + return "NCHAR" + if self.cursor.istype(col, "TIMESTAMP"): + return "TIMESTAMP" + if self.cursor.istype(col, "JSON"): + return "JSON" + if self.cursor.istype(col, "TINYINT UNSIGNED"): + return "TINYINT UNSIGNED" + if self.cursor.istype(col, "SMALLINT UNSIGNED"): + return "SMALLINT UNSIGNED" + if self.cursor.istype(col, "INT UNSIGNED"): + return "INT UNSIGNED" + if self.cursor.istype(col, "BIGINT UNSIGNED"): + return "BIGINT UNSIGNED" + def taosdStatus(self, state): tdLog.sleep(5) pstate = 0 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index cc114ac55f..cb432024b7 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -30,13 +30,6 @@ ./test.sh -f tsim/dnode/balance2.sim ./test.sh -f tsim/dnode/balance3.sim ./test.sh -f tsim/dnode/balancex.sim -#./test.sh -f tsim/dnode/cluster_alter.sim -#./test.sh -f tsim/dnode/cluster_balance1.sim -#./test.sh -f tsim/dnode/cluster_balance2.sim -#./test.sh -f tsim/dnode/cluster_balance3.sim -#./test.sh -f tsim/dnode/cluster_cache.sim -#./test.sh -f tsim/dnode/cluster_flowctrl.sim -#./test.sh -f tsim/dnode/cluster_vgroup100.sim ./test.sh -f tsim/dnode/create_dnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim @@ -129,6 +122,7 @@ ./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim ./test.sh -f tsim/tmq/topic.sim ./test.sh -f tsim/tmq/snapshot.sim +./test.sh -f tsim/tmq/snapshot1.sim # --- stable ./test.sh -f tsim/stable/disk.sim diff --git a/tests/script/tsim/dnode/cluster_alter.sim b/tests/script/tsim/dnode/cluster_alter.sim deleted file mode 100644 index 77e040c6cd..0000000000 --- a/tests/script/tsim/dnode/cluster_alter.sim +++ /dev/null @@ -1,174 +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/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c role -v 1 -system sh/cfg.sh -n dnode2 -c role -v 2 -system sh/cfg.sh -n dnode3 -c role -v 2 -system sh/cfg.sh -n dnode4 -c role -v 2 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/cfg.sh -n dnode2 -c wallevel -v 2 -system sh/cfg.sh -n dnode3 -c wallevel -v 2 -system sh/cfg.sh -n dnode4 -c wallevel -v 2 - -system sh/cfg.sh -n dnode1 -c balance -v 0 -system sh/cfg.sh -n dnode2 -c balance -v 0 -system sh/cfg.sh -n dnode3 -c balance -v 0 -system sh/cfg.sh -n dnode4 -c balance -v 0 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sleep 2000 - -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sleep 2000 - -print ========== step2 -sql create database d1 -sql create table d1.t1 (t timestamp, i int) -sql insert into d1.t1 values(now+1s, 15) -sql insert into d1.t1 values(now+2s, 14) -sql insert into d1.t1 values(now+3s, 13) -sql insert into d1.t1 values(now+4s, 12) -sql insert into d1.t1 values(now+5s, 11) - -print ========== step3 -sleep 2000 -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 1 then - return -1 -endi -if $data2_3 != 0 then - return -1 -endi -if $data2_4 != 0 then - return -1 -endi - -print ========== step4 -sql alter dnode 2 balance "vnode:2-dnode:3" - -$x = 0 -show4: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_2 != 0 then - goto show4 -endi -if $data2_3 != 1 then - goto show4 -endi -if $data2_4 != 0 then - goto show4 -endi - -print ========== step5 -sql alter dnode 3 balance "vnode:2-dnode:4" - -$x = 0 -show5: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_2 != 0 then - goto show5 -endi -if $data2_3 != 0 then - goto show5 -endi -if $data2_4 != 1 then - goto show5 -endi - -print ========== step6 -sql alter dnode 4 balance "vnode:2-dnode:2" - -$x = 0 -show6: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_2 != 1 then - goto show6 -endi -if $data2_3 != 0 then - goto show6 -endi -if $data2_4 != 0 then - goto show6 -endi - -print ========== step7 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -print ========== step8 -sql_error sql alter dnode 4 balance "vnode:2-dnode:5" - -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 -system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/cluster_balance1.sim b/tests/script/tsim/dnode/cluster_balance1.sim deleted file mode 100644 index c98687a81c..0000000000 --- a/tests/script/tsim/dnode/cluster_balance1.sim +++ /dev/null @@ -1,590 +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/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 -system sh/deploy.sh -n dnode6 -i 6 -system sh/deploy.sh -n dnode7 -i 7 -system sh/deploy.sh -n dnode8 -i 8 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 -system sh/cfg.sh -n dnode5 -c wallevel -v 1 -system sh/cfg.sh -n dnode6 -c wallevel -v 1 -system sh/cfg.sh -n dnode7 -c wallevel -v 1 -system sh/cfg.sh -n dnode8 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4 - - -print ============== step1 -print ========= start dnode1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create database c_b1_d1 -sql use c_b1_d1 - -sql create table c_b1_t1 (t timestamp, i int) -sql insert into c_b1_t1 values(1520000020015, 15) -sql insert into c_b1_t1 values(1520000021014, 14) -sql insert into c_b1_t1 values(1520000022013, 13) -sql insert into c_b1_t1 values(1520000023012, 12) -sql insert into c_b1_t1 values(1520000024011, 11) - -sql create database c_b1_d2 -sql use c_b1_d2 -sql create table c_b1_t2 (t timestamp, i int) -sql insert into c_b1_t2 values(1520000020025, 25) -sql insert into c_b1_t2 values(1520000021024, 24) -sql insert into c_b1_t2 values(1520000022023, 23) -sql insert into c_b1_t2 values(1520000023022, 22) -sql insert into c_b1_t2 values(1520000024021, 21) - -sql show dnodes -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes - -if $dnode1Vnodes != 2 then - return -1 -endi -if $dnode2Vnodes != null then - return -1 -endi - -print ============================== step2 -print ========= start dnode2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -show2: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show2 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes - -if $dnode1Vnodes != 1 then - goto show2 -endi -if $dnode2Vnodes != 1 then - goto show2 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -print dnode1 ==> $dnode1Role -print dnode2 ==> $dnode2Role - -print ============================== step3 -print ========= add db3 -sql create database c_b1_d3 -sql use c_b1_d3 -sql create table c_b1_t3 (t timestamp, i int) -sql insert into c_b1_t3 values(1520000020035, 35) -sql insert into c_b1_t3 values(1520000021034, 34) -sql insert into c_b1_t3 values(1520000022033, 33) -sql insert into c_b1_t3 values(1520000023032, 32) -sql insert into c_b1_t3 values(1520000024031, 31) - -print ============================== step4 -print ========= drop dnode2 -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show4 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes - -if $dnode1Vnodes != 3 then - goto show4 -endi -if $dnode2Vnodes != null then - goto show4 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode2 ==> $dnode2Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -print ============================== step5 -print ========= add dnode2 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname3 - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show5 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode3Vnodes = $data2_3 -print dnode2 $dnode3Vnodes - -if $dnode1Vnodes != 2 then - goto show5 -endi -if $dnode3Vnodes != 1 then - goto show5 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -if $dnode1Role != master then - return -1 -endi -if $dnode3Role != slave then - return -1 -endi - -print ============================== step6 -sql_error drop dnode $hostname1 - -print ============================== step7 -sql_error create dnode $hostname1 - -print ============================== step8 -sql drop dnode $hostname3 - -$x = 0 -show8: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show8 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 3 then - goto show8 -endi -if $dnode3Vnodes != null then - goto show8 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -if $dnode1Role != master then - return -1 -endi - -if $dnode3Role != null then - return -1 -endi - -print ============================== step9 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show9: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show9 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode1Vnodes != 2 then - goto show9 -endi -if $dnode4Vnodes != 1 then - goto show9 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode4 ==> $dnode4Role - -if $dnode1Role != master then - return -1 -endi - -if $dnode4Role != slave then - return -1 -endi - -print ============================== step10 -sql create database c_b1_d4 -sql use c_b1_d4 -sql create table c_b1_t4 (t timestamp, i int) -sql insert into c_b1_t4 values(1520000020045, 45) -sql insert into c_b1_t4 values(1520000021044, 44) -sql insert into c_b1_t4 values(1520000022043, 43) -sql insert into c_b1_t4 values(1520000023042, 42) -sql insert into c_b1_t4 values(1520000024041, 41) - -$x = 0 -show10: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show10 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode1Vnodes != 2 then - goto show10 -endi -if $dnode4Vnodes != 2 then - goto show10 -endi - -sql reset query cache - -sql use c_b1_d3 -sql insert into c_b1_t3 values(1520000025036, 36) - -sql use c_b1_d2 -sql insert into c_b1_t2 values(1520000025026, 26) - -print ============================== step12 -sql create database c_b1_d5 -sql use c_b1_d5 -sql_error create table c_b1_t5 (t timestamp, i int) -x error3 - -print ============================== step13 -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start -$x = 0 -step13: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 -print dnode5 $data4_5 - -if $data4_5 != ready then - goto step13 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode4Role = $data2_4 -$dnode5Role = $data2_5 -print dnode1 ==> $dnode1Role -print dnode4 ==> $dnode4Role -print dnode5 ==> $dnode5Role - -sql use c_b1_d5; -sql create table c_b1_t5 (t timestamp, i int) -sql insert into c_b1_t5 values(1520000020055, 55) -sql insert into c_b1_t5 values(1520000021054, 54) -sql insert into c_b1_t5 values(1520000022053, 53) -sql insert into c_b1_t5 values(1520000023052, 52) -sql insert into c_b1_t5 values(1520000024051, 51) - -sql create database c_b1_d6 -sql use c_b1_d6 -sql create table c_b1_t6 (t timestamp, i int) -sql insert into c_b1_t6 values(1520000020065, 65) -sql insert into c_b1_t6 values(1520000021064, 64) -sql insert into c_b1_t6 values(1520000022063, 63) -sql insert into c_b1_t6 values(1520000023062, 62) -sql insert into c_b1_t6 values(1520000024061, 61) - -sql show dnodes -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode2Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode2Vnodes - -if $dnode1Vnodes != 2 then - goto step13 -endi -if $dnode4Vnodes != 2 then - goto step13 -endi -if $dnode5Vnodes != 2 then - goto step13 -endi - -print ============================== step14 -sql create dnode $hostname6 -system sh/exec.sh -n dnode6 -s start -$x = 0 -step14: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 -print dnode4 $data4_5 - -if $data4_6 != ready then - goto step14 -endi - -sql create database c_b1_d7 -sql use c_b1_d7 -sql create table c_b1_t7 (t timestamp, i int) -sql insert into c_b1_t7 values(1520000020075, 75) -sql insert into c_b1_t7 values(1520000021074, 74) -sql insert into c_b1_t7 values(1520000022073, 73) -sql insert into c_b1_t7 values(1520000023072, 72) -sql insert into c_b1_t7 values(1520000024071, 71) - -sql create database c_b1_d8 -sql use c_b1_d8 -sql create table c_b1_t8 (t timestamp, i int) -sql insert into c_b1_t8 values(1520000020085, 85) -sql insert into c_b1_t8 values(1520000021084, 84) -sql insert into c_b1_t8 values(1520000022083, 83) -sql insert into c_b1_t8 values(1520000023082, 82) -sql insert into c_b1_t8 values(1520000024081, 81) - -$x = 0 -show14: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi -sql show dnodes -x show14 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes - -if $dnode1Vnodes != 2 then - goto show14 -endi -if $dnode4Vnodes != 2 then - goto show14 -endi -if $dnode5Vnodes != 2 then - goto show14 -endi -if $dnode6Vnodes != 2 then - goto show14 -endi - -sql reset query cache -sleep 1000 - -print ============================== step17 -print ========= check data - -sql reset query cache -sleep 100 - -sql use c_b1_d1 -sql select * from c_b1_d1.c_b1_t1 -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $rows != 5 then - return -1 -endi - -sql use c_b1_d2 -sql select * from c_b1_d2.c_b1_t2 -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $rows != 6 then - return -1 -endi - -sql use c_b1_d3 -sql select * from c_b1_d3.c_b1_t3 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $rows != 6 then - return -1 -endi -if $data01 != 36 then - return -1 -endi - -sql use c_b1_d4 -sql select * from c_b1_d4.c_b1_t4 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 - -sql use c_b1_d5 -sql select * from c_b1_d5.c_b1_t5 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 51 then - return -1 -endi -if $data11 != 52 then - return -1 -endi -if $data21 != 53 then - return -1 -endi -if $data31 != 54 then - return -1 -endi -if $data41 != 55 then - return -1 -endi - -sql use c_b1_d6 -sql select * from c_b1_d6.c_b1_t6 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 61 then - return -1 -endi -if $data11 != 62 then - return -1 -endi -if $data21 != 63 then - return -1 -endi -if $data31 != 64 then - return -1 -endi -if $data41 != 65 then - return -1 -endi - -sql use c_b1_d7 -sql select * from c_b1_d7.c_b1_t7 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 71 then - return -1 -endi -if $data11 != 72 then - return -1 -endi -if $data21 != 73 then - return -1 -endi -if $data31 != 74 then - return -1 -endi -if $data41 != 75 then - return -1 -endi - -sql use c_b1_d8 -sql select * from c_b1_d8.c_b1_t8 order by t desc -print $rows -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 81 then - return -1 -endi -if $data11 != 82 then - return -1 -endi -if $data21 != 83 then - return -1 -endi -if $data31 != 84 then - return -1 -endi -if $data41 != 85 then - return -1 -endi - -print ============================================ over= -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 -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/cluster_balance2.sim b/tests/script/tsim/dnode/cluster_balance2.sim deleted file mode 100644 index 0b80acbe6c..0000000000 --- a/tests/script/tsim/dnode/cluster_balance2.sim +++ /dev/null @@ -1,479 +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/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 -system sh/deploy.sh -n dnode6 -i 6 -system sh/deploy.sh -n dnode7 -i 7 -system sh/deploy.sh -n dnode8 -i 8 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 -system sh/cfg.sh -n dnode5 -c wallevel -v 1 -system sh/cfg.sh -n dnode6 -c wallevel -v 1 -system sh/cfg.sh -n dnode7 -c wallevel -v 1 -system sh/cfg.sh -n dnode8 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4 - - -print ============== step1 -print ========= start dnode1 -system sh/exec.sh -n dnode1 -s start - -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 -endi -if $data2_2 != slave then - goto step1 -endi -if $data2_3 != slave then - goto step1 -endi - - -sql create database c_b2_d1 replica 2 -sql use c_b2_d1 -sql create table c_b2_t1 (t timestamp, i int) -sql insert into c_b2_t1 values(1520000020015, 15) -sql insert into c_b2_t1 values(1520000021014, 14) -sql insert into c_b2_t1 values(1520000022013, 13) -sql insert into c_b2_t1 values(1520000023012, 12) -sql insert into c_b2_t1 values(1520000024011, 11) - -sql create database c_b2_d2 replica 2 -sql use c_b2_d2 -sql create table c_b2_t2 (t timestamp, i int) -sql insert into c_b2_t2 values(1520000020025, 25) -sql insert into c_b2_t2 values(1520000021024, 24) -sql insert into c_b2_t2 values(1520000022023, 23) -sql insert into c_b2_t2 values(1520000023022, 22) -sql insert into c_b2_t2 values(1520000024021, 21) - -sql create database c_b2_d3 replica 2 -sql use c_b2_d3 -sql create table c_b2_t3 (t timestamp, i int) -sql insert into c_b2_t3 values(1520000020035, 35) -sql insert into c_b2_t3 values(1520000021034, 34) -sql insert into c_b2_t3 values(1520000022033, 33) -sql insert into c_b2_t3 values(1520000023032, 32) -sql insert into c_b2_t3 values(1520000024031, 31) - -$x = 0 -show1: - $x = $x + 1 - sleep 3000 - if $x == 20 then - return -1 - endi -sql show dnodes -x show1 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 2 then - goto show1 -endi -if $dnode2Vnodes != 2 then - goto show1 -endi -if $dnode3Vnodes != 2 then - goto show1 -endi - -print ============================== step2 -print ========= drop dnode2 -sql drop dnode $hostname2 - -$x = 0 -show2: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi -sql show dnodes -x show2 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 3 then - goto show2 -endi -if $dnode2Vnodes != null then - goto show2 -endi -if $dnode3Vnodes != 3 then - goto show2 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode2 ==> $dnode2Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -print ============================== step3 -print ========= start dnode4 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi -sql show dnodes -x show3 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 2 then - goto show3 -endi -if $dnode4Vnodes != 2 then - goto show3 -endi -if $dnode3Vnodes != 2 then - goto show3 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode2 ==> $dnode2Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -if $dnode1Role != master then - return -1 -endi -if $dnode2Role != null then - return -1 -endi -if $dnode3Role != slave then - return -1 -endi - -if $dnode4Role != slave then - return -1 -endi - -print ============================== step4 -print ========= drop dnode3 -sql drop dnode $hostname3 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show4 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 3 then - goto show4 -endi -if $dnode4Vnodes != 3 then - goto show4 -endi -if $dnode3Vnodes != null then - goto show4 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 -$dnode4Role = $data2_4 -print dnode1 ==> $dnode1Role -print dnode2 ==> $dnode2Role -print dnode3 ==> $dnode3Role -print dnode4 ==> $dnode4Role - -if $dnode1Role != master then - return -1 -endi -if $dnode2Role != null then - return -1 -endi -if $dnode3Role != null then - return -1 -endi - -if $dnode4Role != slave then - return -1 -endi - -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -print ============================== step5 -print ========= start dnode3 -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi -sql show dnodes -x show5 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes - -if $dnode1Vnodes != 2 then - goto show5 -endi -if $dnode4Vnodes != 2 then - goto show5 -endi -if $dnode5Vnodes != 2 then - goto show5 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode4Role = $data2_4 -$dnode5Role = $data2_5 -print dnode1 ==> $dnode1Role -print dnode4 ==> $dnode4Role -print dnode5 ==> $dnode5Role - -print ============================== step6 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -print stop dnode1 and sleep 3000 -sleep 3000 - -sql show mnodes -$dnode1Role = $data2_1 -$dnode4Role = $data2_4 -$dnode5Role = $data2_5 -print dnode1 ==> $dnode1Role -print dnode4 ==> $dnode4Role -print dnode5 ==> $dnode5Role - -if $dnode1Role != offline then - return -1 -endi - -print ============================== step6.1 -system sh/exec.sh -n dnode1 -s start - -$x = 0 -step6.1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 - -if $data4_1 != ready then - goto step6.1 -endi - -sql drop dnode $hostname1 -print drop dnode1 and sleep 9000 -sleep 9000 - -$x = 0 -show6: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi -sql show dnodes -x show6 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes - -if $dnode1Vnodes != null then - goto show6 -endi -if $dnode4Vnodes != 3 then - goto show6 -endi -if $dnode5Vnodes != 3 then - goto show6 -endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode4Role = $data2_4 -$dnode5Role = $data2_5 -print dnode1 ==> $dnode1Role -print dnode4 ==> $dnode4Role -print dnode5 ==> $dnode5Role - -#system sh/exec.sh -n dnode1 -s stop -x SIGINT - -print ============================== step12 -print ========= check data - -sql reset query cache -sleep 100 - -sql select * from c_b2_d1.c_b2_t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from c_b2_d2.c_b2_t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 - -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from c_b2_d3.c_b2_t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -print ============================================ over -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 -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGKILL -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/cluster_balance3.sim b/tests/script/tsim/dnode/cluster_balance3.sim deleted file mode 100644 index c2e9a84514..0000000000 --- a/tests/script/tsim/dnode/cluster_balance3.sim +++ /dev/null @@ -1,643 +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/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 -system sh/deploy.sh -n dnode6 -i 6 -system sh/deploy.sh -n dnode7 -i 7 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 -system sh/cfg.sh -n dnode5 -c wallevel -v 1 -system sh/cfg.sh -n dnode6 -c wallevel -v 1 -system sh/cfg.sh -n dnode7 -c wallevel -v 1 - -print ============== step1 -print ========= start dnode1 -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 -endi -if $data2_2 != slave then - goto step1 -endi -if $data2_3 != slave then - goto step1 -endi - -sql create database c_b3_d1 replica 3 -sql use c_b3_d1 -sql create table c_b3_t1 (t timestamp, i int) -sql insert into c_b3_t1 values(1520000020015, 15) -sql insert into c_b3_t1 values(1520000021014, 14) -sql insert into c_b3_t1 values(1520000022013, 13) -sql insert into c_b3_t1 values(1520000023012, 12) -sql insert into c_b3_t1 values(1520000024011, 11) - -sql create database c_b3_d2 replica 3 -sql use c_b3_d2 -sql create table c_b3_t2 (t timestamp, i int) -sql insert into c_b3_t2 values(1520000020025, 25) -sql insert into c_b3_t2 values(1520000021024, 24) -sql insert into c_b3_t2 values(1520000022023, 23) -sql insert into c_b3_t2 values(1520000023022, 22) -sql insert into c_b3_t2 values(1520000024021, 21) - -sql create database c_b3_d3 replica 3 -sql use c_b3_d3 -sql create table c_b3_t3 (t timestamp, i int) -sql insert into c_b3_t3 values(1520000020035, 35) -sql insert into c_b3_t3 values(1520000021034, 34) -sql insert into c_b3_t3 values(1520000022033, 33) -sql insert into c_b3_t3 values(1520000023032, 32) -sql insert into c_b3_t3 values(1520000024031, 31) - -$x = 0 -show1: - $x = $x + 1 - sleep 2000 - if $x == 20 then - return -1 - endi -sql show dnodes -x show1 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes - -if $dnode1Vnodes != 3 then - goto show1 -endi -if $dnode2Vnodes != 3 then - goto show1 -endi -if $dnode3Vnodes != 3 then - goto show1 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 - -print ============================== step2 -print ========= start dnode4 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show2: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show2 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode4Vnodes != 2 then - goto show2 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 - -print ============================== step3 -print ========= drop dnode2 -sql drop dnode $hostname2 - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show3 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data2_2 -print dnode2 $dnode2Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode1Vnodes != 3 then - goto show3 -endi -if $dnode2Vnodes != null then - goto show3 -endi -if $dnode3Vnodes != 3 then - goto show3 -endi -if $dnode4Vnodes != 3 then - goto show3 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 - -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -print ============================== step4 -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -x show4 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode5Vnodes != 2 then - goto show4 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 - -if $data2_4 != slave then - goto show4 -endi - -print ============================== step5 -print ========= drop dnode3 -sql drop dnode $hostname3 -sleep 9000 - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show5 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode3Vnodes = $data2_3 -print dnode3 $dnode3Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes - -if $dnode1Vnodes != 3 then - goto show5 -endi -if $dnode5Vnodes != 3 then - goto show5 -endi -if $dnode3Vnodes != null then - goto show5 -endi -if $dnode4Vnodes != 3 then - goto show5 -endi - -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -if $data2_5 != slave then - goto show5 -endi - -print ============================== step6 -sql create dnode $hostname6 -system sh/exec.sh -n dnode6 -s start - -$x = 0 -show6: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show6 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes - -if $dnode1Vnodes != 2 then - goto show6 -endi -if $dnode4Vnodes != 2 then - goto show6 -endi -if $dnode5Vnodes != 3 then - goto show6 -endi -if $dnode6Vnodes != 2 then - goto show6 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -print ============================== step7 -print ========= drop dnode4 -sql drop dnode $hostname4 - -$x = 0 -show7: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show7 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode4Vnodes = $data2_4 -print dnode4 $dnode4Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes - -if $dnode1Vnodes != 3 then - goto show7 -endi -if $dnode5Vnodes != 3 then - goto show7 -endi -if $dnode6Vnodes != 3 then - goto show7 -endi -if $dnode4Vnodes != null then - goto show7 -endi - -system sh/exec.sh -n dnode4 -s stop -x SIGINT -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -if $data2_6 != slave then - goto show7 -endi - -print ============================== step8 -sql create dnode $hostname7 -system sh/exec.sh -n dnode7 -s start - -$x = 0 -show8: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show8 -$dnode1Vnodes = $data2_1 -print dnode1 $dnode1Vnodes -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes -$dnode7Vnodes = $data2_7 -print dnode7 $dnode7Vnodes - -if $dnode1Vnodes != 2 then - goto show8 -endi -if $dnode5Vnodes != 2 then - goto show8 -endi -if $dnode6Vnodes != 3 then - goto show8 -endi -if $dnode7Vnodes != 2 then - goto show8 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -print ============================== step9 -system sh/exec.sh -n dnode1 -s stop -x SIGINT - -$x = 0 -show9: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show mnodes -x show9 - -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -if $data2_1 != offline then - goto show9 -endi -if $data2_5 != master then - goto show9 -endi -if $data2_6 != slave then - goto show9 -endi - -print ============================== step10 -sql drop dnode $hostname1 -$x = 0 -show10: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show mnodes -x show10 - -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -if $data2_1 != null then - goto show10 -endi -if $data2_5 != master then - goto show10 -endi -if $data2_6 != slave then - goto show10 -endi -if $data2_7 != slave then - goto show10 -endi - -print ============================== step11 -system sh/exec.sh -n dnode1 -s start - -$x = 0 -show11: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -x show11 -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes -$dnode7Vnodes = $data2_7 -print dnode7 $dnode7Vnodes - -if $dnode5Vnodes != 3 then - goto show11 -endi -if $dnode6Vnodes != 3 then - goto show11 -endi -if $dnode7Vnodes != 3 then - goto show11 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -print dnode4 ==> $data2_4 -print dnode5 ==> $data2_5 -print dnode6 ==> $data2_6 -print dnode7 ==> $data2_7 - -print ============================== step12 -sql create database c_b3_d4 replica 3 -sql use c_b3_d4 -$x = 0 -create4: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table c_b3_t4 (t timestamp, i int) -x create4 -sql insert into c_b3_t4 values(1520000020045, 45) -sql insert into c_b3_t4 values(1520000021044, 44) -sql insert into c_b3_t4 values(1520000022043, 43) -sql insert into c_b3_t4 values(1520000023042, 42) -sql insert into c_b3_t4 values(1520000024041, 41) - -$x = 0 -show12: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show dnodes -x show12 -$dnode5Vnodes = $data2_5 -print dnode5 $dnode5Vnodes -$dnode6Vnodes = $data2_6 -print dnode6 $dnode6Vnodes -$dnode7Vnodes = $data2_7 -print dnode7 $dnode7Vnodes - -if $dnode5Vnodes != 4 then - goto show12 -endi -if $dnode6Vnodes != 4 then - goto show12 -endi -if $dnode7Vnodes != 4 then - goto show12 -endi - -print ============================== step13 -sql reset query cache -sleep 200 - -print ========= check data - -sql select * from c_b3_d1.c_b3_t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from c_b3_d2.c_b3_t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 - -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from c_b3_d3.c_b3_t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -print ============================================ over -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 -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/cluster_cache.sim b/tests/script/tsim/dnode/cluster_cache.sim deleted file mode 100644 index 740eddfb0d..0000000000 --- a/tests/script/tsim/dnode/cluster_cache.sim +++ /dev/null @@ -1,65 +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/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode2 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 2 -system sh/cfg.sh -n dnode2 -c httpMaxThreads -v 2 -system sh/cfg.sh -n dnode1 -c monitor -v 1 -system sh/cfg.sh -n dnode1 -c monitor -v 2 -system sh/cfg.sh -n dnode2 -c http -v 1 -system sh/cfg.sh -n dnode1 -c enableHttp -v 1 -system sh/cfg.sh -n dnode2 -c monitor -v 1 -system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 -system sh/cfg.sh -n dnode2 -c monitorInterval -v 1 - -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -sql create database testdb -sql use testdb -sql create table meter1 (ts timestamp, val int) - -$x = 0 -$v = -100 -while $x < 30 - $v = $v + 1 - $ms = $v . m - sql insert into meter1 values (now $ms , $x ) - $x = $x + 1 -endw - -sleep 2000 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname2 - - -sleep 10000 - -sql show log.tables; -if $rows > 6 then - return -1 -endi - -sql select * from log.dn1 -print ===>rows $rows -print $data00 $data01 $data02 -print $data10 $data11 $data12 -print $data20 $data21 $data22 -if $rows < 10 then - return -1 -endi - -#sql create table sys.st as select avg(taosd), avg(system) from sys.cpu interval(30s) - -sql show log.vgroups -if $data05 != master then - return -1 -endi -if $data15 != master then - return -1 -endi diff --git a/tests/script/tsim/dnode/cluster_flowctrl.sim b/tests/script/tsim/dnode/cluster_flowctrl.sim deleted file mode 100644 index 700fa0a3f1..0000000000 --- a/tests/script/tsim/dnode/cluster_flowctrl.sim +++ /dev/null @@ -1,131 +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/deploy.sh -n dnode3 -i 3 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c http -v 0 -system sh/cfg.sh -n dnode2 -c http -v 0 -system sh/cfg.sh -n dnode3 -c http -v 0 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000 - -system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20 -system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20 -system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20 - -system sh/cfg.sh -n dnode1 -c replica -v 3 -system sh/cfg.sh -n dnode2 -c replica -v 3 -system sh/cfg.sh -n dnode3 -c replica -v 3 - -print ============== deploy - -system sh/exec.sh -n dnode1 -s start -sleep 5001 -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -print =============== step1 -$x = 0 -show1: - $x = $x + 1 - sleep 2000 - if $x == 5 then - return -1 - endi -sql show mnodes -x show1 -$mnode1Role = $data2_1 -print mnode1Role $mnode1Role -$mnode2Role = $data2_2 -print mnode2Role $mnode2Role -$mnode3Role = $data2_3 -print mnode3Role $mnode3Role - -if $mnode1Role != master then - goto show1 -endi -if $mnode2Role != slave then - goto show1 -endi -if $mnode3Role != slave then - goto show1 -endi - -print =============== step2 - -sql create database db replica 3 -sql use db -sql create table tb (ts timestamp, test int) - -$x = 0 -while $x < 100 - $ms = $x . s - sql insert into tb values (now + $ms , $x ) - $x = $x + 1 -endw - -print =============== step3 -sleep 2000 - -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 - -print =============== step4 -sleep 3000 -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -print =============== step5 -sleep 8000 -while $x < 200 - $ms = $x . s - sql insert into tb values (now + $ms , $x ) - $x = $x + 1 -endw - -print =============== step6 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 2000 -while $x < 300 - $ms = $x . s - sql insert into tb values (now + $ms , $x ) - $x = $x + 1 -endw - -system sh/exec.sh -n dnode2 -s start - -sleep 6000 -print =============== step7 -while $x < 400 - $ms = $x . s - sql insert into tb values (now + $ms , $x ) - $x = $x + 1 - sleep 1 -endw - -print =============== step8 -sql select * from tb -print rows $rows -if $rows != 400 then - return -1 -endi - -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 \ No newline at end of file diff --git a/tests/script/tsim/dnode/cluster_vgroup100.sim b/tests/script/tsim/dnode/cluster_vgroup100.sim deleted file mode 100644 index 656ed2ec44..0000000000 --- a/tests/script/tsim/dnode/cluster_vgroup100.sim +++ /dev/null @@ -1,146 +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/deploy.sh -n dnode3 -i 3 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c maxTables -v 4 -system sh/cfg.sh -n dnode2 -c maxTables -v 4 -system sh/cfg.sh -n dnode3 -c maxTables -v 4 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 - -print ============================== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print ============================== step2 -print ========= start dnode2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start - -$maxNum = 102 -$maxNum = 12 - -$x = 0 -show2: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show mnodes -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 - -print $dnode1Role -print $dnode2Role -print $dnode3Role - -if $dnode1Role != master then - goto show2 -endi -if $dnode2Role != slave then - goto show2 -endi -if $dnode3Role != slave then - goto show2 -endi - -print ============================== step3 -$count = 2 -while $count < $maxNum - $db = d . $count - $tb = $db . .t - $tb2 = $db . .t2 - sql create database $db replica 3 cache 1 blocks 3 - sql create table $tb (ts timestamp, i int) - sql insert into $tb values(now, 1) - sql create table $tb2 as select count(*) from $tb interval(10s) - $count = $count + 1 - print insert into $tb values(now, 1) ==> finished -endw - -print ============================== step4 - -$count = 2 -while $count < $maxNum - $db = d . $count - $tb = $db . .t - sql select * from $tb - if $rows != 1 then - print select * from $tb - return -1 - endi - $count = $count + 1 - print select * from $tb ==> rows: $rows -endw - -print ============================== step5 -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 - -print ============================== step6 -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -print ============================== step7 - -$x = 0 -show7: - $x = $x + 1 - sleep 2000 - if $x == 50 then - return -1 - endi - -sql show mnodes -x show7 -$dnode1Role = $data2_1 -$dnode2Role = $data2_2 -$dnode3Role = $data2_3 -if $dnode1Role != master then - goto show7 -endi -if $dnode2Role != slave then - goto show7 -endi -if $dnode2Role != slave then - goto show7 -endi - -print ============================== step8 -$x = 0 -show8: - $x = $x + 1 - sleep 2000 - if $x == 20 then - return -1 - endi - -$count = 2 -while $count < $maxNum - $db = d . $count - $tb = $db . .t - sql select * from $tb - if $rows != 1 then - print select * from $tb - goto show8 - endi - $count = $count + 1 - print select * from $tb ==> rows: $rows -endw - -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 \ No newline at end of file diff --git a/tests/script/tsim/sma/drop_sma.sim b/tests/script/tsim/sma/drop_sma.sim new file mode 100644 index 0000000000..17f19f5df3 --- /dev/null +++ b/tests/script/tsim/sma/drop_sma.sim @@ -0,0 +1,75 @@ +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/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== step2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step2: + $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 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi + +print ========== step3 +sql create database d1 vgroups 1 +sql use d1; + +print --> create stb +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned); + +print --> create sma +sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) interval(6m,10s) sliding(6m); + +print --> drop stb +sql drop table stb; + +print ========== step4 repeat + +print --> create stb +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned); + +print --> create sma +sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) interval(6m,10s) sliding(6m); + +print --> drop stb +sql drop table stb; + + +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 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/tmq/snapshot.sim b/tests/script/tsim/tmq/snapshot.sim index 5683aaa559..de0468e6f2 100644 --- a/tests/script/tsim/tmq/snapshot.sim +++ b/tests/script/tsim/tmq/snapshot.sim @@ -111,7 +111,7 @@ endi $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb -$expectmsgcnt = 1 +$expectmsgcnt = 1000000 $expectrowcnt = 100 sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) @@ -131,9 +131,6 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $expectmsgcnt then - return -1 -endi if $data[0][3] != $expectrowcnt then return -1 endi @@ -183,7 +180,7 @@ endi $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb -$expectmsgcnt = 1 +$expectmsgcnt = 1000000 sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb @@ -254,7 +251,7 @@ endi $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfNtb +$expectmsgcnt = 1000000 sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb diff --git a/tests/script/tsim/tmq/snapshot1.sim b/tests/script/tsim/tmq/snapshot1.sim new file mode 100644 index 0000000000..58541b725d --- /dev/null +++ b/tests/script/tsim/tmq/snapshot1.sim @@ -0,0 +1,310 @@ +#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406 +#basic1Of2Cons.sim: vgroups=1, one topic for 2 consumers, firstly insert data, then start consume. Include six topics +#basic2Of2ConsOverlap.sim: vgroups=1, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics +#basic3Of2Cons.sim: vgroups=4, one topic for 2 consumers, firstly insert data, then start consume. Include six topics +#basic4Of2Cons.sim: vgroups=4, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics + +# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN +# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5; +# +# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval). +# + +run tsim/tmq/prepareBasicEnv-1vgrp.sim + +#---- global parameters start ----# +$dbName = db +$vgroups = 1 +$stbPrefix = stb +$ctbPrefix = ctb +$ntbPrefix = ntb +$stbNum = 1 +$ctbNum = 10 +$ntbNum = 10 +$rowsPerCtb = 10 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 +#---- global parameters end ----# + +$pullDelay = 2 +$ifcheckdata = 1 +$ifmanualcommit = 1 +$showMsg = 1 +$showRow = 0 + +sql connect +sql use $dbName + +print == create topics from super table +sql create topic topic_stb_column as select ts, c3 from stb +sql create topic topic_stb_all as select ts, c1, c2, c3 from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb + +print == create topics from child table +sql create topic topic_ctb_column as select ts, c3 from ctb0 +sql create topic topic_ctb_all as select * from ctb0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0 + +print == create topics from normal table +sql create topic topic_ntb_column as select ts, c3 from ntb0 +sql create topic topic_ntb_all as select * from ntb0 +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0 + +#sql show topics +#if $rows != 9 then +# return -1 +#endi + +#'group.id:cgrp1,enable.auto.commit:false,auto.commit.interval.ms:6000,auto.offset.reset:earliest' +$keyList = ' . group.id:cgrp1 +$keyList = $keyList . , +$keyList = $keyList . enable.auto.commit:false +#$keyList = $keyList . , +#$keyList = $keyList . auto.commit.interval.ms:6000 +#$keyList = $keyList . , +#$keyList = $keyList . auto.offset.reset:earliest +$keyList = $keyList . ' +print ========== key list: $keyList + +$topicNum = 2 + +#=============================== start consume =============================# + + +print ================ test consume from stb +print == overlap toipcs: topic_stb_column + topic_stb_all, topic_stb_function + topic_stb_all +$topicList = ' . topic_stb_column +$topicList = $topicList . , +$topicList = $topicList . topic_stb_all +$topicList = $topicList . ' + +$consumerId = 0 +$totalMsgOfOneTopic = $ctbNum * $rowsPerCtb +$totalMsgOfStb = $totalMsgOfOneTopic * $topicNum +$expectmsgcnt = 1000000 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + + +$topicList = ' . topic_stb_all +$topicList = $topicList . , +$topicList = $topicList . topic_stb_function +$topicList = $topicList . ' +$consumerId = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + +print == start consumer to pull msgs from stb +print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start -e 1 +system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start -e 1 + +print == check consume result +wait_consumer_end_from_stb: +sql select * from consumeresult +print ==> rows: $rows +print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] +print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6] +if $rows != 2 then + sleep 1000 + goto wait_consumer_end_from_stb +endi +if $data[0][1] == 0 then + if $data[1][1] != 1 then + return -1 + endi +endi +if $data[0][1] == 1 then + if $data[1][1] != 0 then + return -1 + endi +endi + +# $data[0][3]/$data[1][3] should be between $totalMsgOfOneTopic and $totalMsgOfStb. +if $data[0][3] < $totalMsgOfOneTopic then + return -1 +endi +if $data[0][3] > $totalMsgOfStb then + return -1 +endi +if $data[1][3] < $totalMsgOfOneTopic then + return -1 +endi +if $data[1][3] > $totalMsgOfStb then + return -1 +endi + +$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb +$sumOfRows = $data[0][3] + $data[1][3] +if $sumOfRows != $totalMsgCons then + print actual: $sumOfRows + print expect: $totalMsgCons + return -1 +endi + +####################################################################################### +# clear consume info and consume result +#run tsim/tmq/clearConsume.sim +# because drop table function no stable, so by create new db for consume info and result. Modify it later +$cdbName = cdb1 +sql create database $cdbName vgroups 1 +sleep 500 +sql use $cdbName + +print == create consume info table and consume result table for ctb +sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) +sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) + +sql show tables +if $rows != 2 then + return -1 +endi +####################################################################################### + + +print ================ test consume from ctb +print == overlap toipcs: topic_ctb_column + topic_ctb_all, topic_ctb_function + topic_ctb_all +$topicList = ' . topic_ctb_column +$topicList = $topicList . , +$topicList = $topicList . topic_ctb_all +$topicList = $topicList . ' +$consumerId = 0 + +$totalMsgOfOneTopic = $rowsPerCtb +$totalMsgOfCtb = $totalMsgOfOneTopic * $topicNum +$expectmsgcnt = 1000000 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + +$topicList = ' . topic_ctb_function +$topicList = $topicList . , +$topicList = $topicList . topic_ctb_all +$topicList = $topicList . ' +$consumerId = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + +print == start consumer to pull msgs from ctb +print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start -e 1 +system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start -e 1 + +print == check consume result +wait_consumer_end_from_ctb: +sql select * from consumeresult +print ==> rows: $rows +print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] +print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6] +if $rows != 2 then + sleep 1000 + goto wait_consumer_end_from_ctb +endi +if $data[0][1] == 0 then + if $data[1][1] != 1 then + return -1 + endi +endi +if $data[0][1] == 1 then + if $data[1][1] != 0 then + return -1 + endi +endi + +if $data[0][3] == $totalMsgOfOneTopic then + if $data[1][3] == $totalMsgOfCtb then + goto check_ok_1 + endi +elif $data[1][3] == $totalMsgOfOneTopic then + if $data[0][3] == $totalMsgOfCtb then + goto check_ok_1 + endi +endi +return -1 +check_ok_1: + +####################################################################################### +# clear consume info and consume result +#run tsim/tmq/clearConsume.sim +# because drop table function no stable, so by create new db for consume info and result. Modify it later +$cdbName = cdb2 +sql create database $cdbName vgroups 1 +sleep 500 +sql use $cdbName + +print == create consume info table and consume result table for ntb +sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) +sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) + +sql show tables +if $rows != 2 then + return -1 +endi +####################################################################################### + + +print ================ test consume from ntb +print == overlap toipcs: topic_ntb_column + topic_ntb_all, topic_ntb_function + topic_ntb_all +$topicList = ' . topic_ntb_column +$topicList = $topicList . , +$topicList = $topicList . topic_ntb_all +$topicList = $topicList . ' + +$consumerId = 0 +$totalMsgOfOneTopic = $rowsPerCtb +$totalMsgOfNtb = $totalMsgOfOneTopic * $topicNum +$expectmsgcnt = 1000000 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + + +$topicList = ' . topic_ntb_function +$topicList = $topicList . , +$topicList = $topicList . topic_ntb_all +$topicList = $topicList . ' +$consumerId = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) + +print == start consumer to pull msgs from ntb +print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start -e 1 +system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start -e 1 + +print == check consume result from ntb +wait_consumer_end_from_ntb: +sql select * from consumeresult +print ==> rows: $rows +print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] +print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6] +if $rows != 2 then + sleep 1000 + goto wait_consumer_end_from_ntb +endi +if $data[0][1] == 0 then + if $data[1][1] != 1 then + return -1 + endi +endi +if $data[0][1] == 1 then + if $data[1][1] != 0 then + return -1 + endi +endi + + +if $data[0][3] == $totalMsgOfOneTopic then + if $data[1][3] == $totalMsgOfNtb then + goto check_ok_3 + endi +elif $data[1][3] == $totalMsgOfOneTopic then + if $data[0][3] == $totalMsgOfNtb then + goto check_ok_3 + endi +endi +return -1 +check_ok_3: + +sql select * from performance_schema.`consumers` +if $rows != 0 then + return -1 +endi + +#sql select * from performance_schema.`subscriptions` +#if $rows != 0 then +# return -1 +#endi + +#------ not need stop consumer, because it exit after pull msg overthan expect msg +#system tsim/tmq/consume.sh -s stop -x SIGINT + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/0-others/udfTest.py b/tests/system-test/0-others/udfTest.py index 375b7a6272..40f803432a 100644 --- a/tests/system-test/0-others/udfTest.py +++ b/tests/system-test/0-others/udfTest.py @@ -32,7 +32,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -58,7 +58,7 @@ class TDTestCase: def prepare_data(self): - + tdSql.execute("drop database if exists db ") tdSql.execute("create database if not exists db duration 300") tdSql.execute("use db") @@ -68,7 +68,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -150,7 +150,7 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: @@ -175,14 +175,14 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: tdLog.info("create two udf functions success ") - + def basic_udf_query(self): - + # scalar functions tdSql.execute("use db ") @@ -256,7 +256,7 @@ class TDTestCase: tdSql.checkData(0,1,165.247614504) tdSql.checkData(0,2,2551.470164435) tdSql.checkData(0,3,2.652476145) - + # # bug for crash when query sub table tdSql.query("select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from ct1") tdSql.checkData(0,0,378.215547010) @@ -281,7 +281,7 @@ class TDTestCase: tdSql.error("select udf1(num1) , stddev(num1) from tb;") tdSql.error("select udf1(num1) , mode(num1) from tb;") tdSql.error("select udf1(num1) , HYPERLOGLOG(num1) from tb;") - # stable + # stable tdSql.error("select udf1(c1) , count(c1) from stb1;") tdSql.error("select udf1(c1) , avg(c1) from stb1;") tdSql.error("select udf1(c1) , twa(c1) from stb1;") @@ -302,23 +302,25 @@ class TDTestCase: tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , first(num1) from tb;") - + tdSql.query("select abs(num1) , first(num1) from tb;") - + tdSql.query("select udf1(num1) , last(num1) from tb;") - + tdSql.query("select round(num1) , last(num1) from tb;") - + tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , bottom(num1,1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , last_row(num1) from tb;") - - tdSql.error("select round(num1) , last_row(num1) from tb;") - - - # stable + tdSql.query("select udf1(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + tdSql.query("select round(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + + # stable tdSql.query("select udf1(c1) , max(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , max(c1) from stb1;") @@ -328,9 +330,9 @@ class TDTestCase: tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select udf1(c1) , first(c1) from stb1;") - + tdSql.query("select udf1(c1) , last(c1) from stb1;") - + tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , top(c1 ,1) from stb1;") @@ -340,9 +342,11 @@ class TDTestCase: tdSql.query("select ceil(c1) , bottom(c1,1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , last_row(c1) from stb1;") - tdSql.error("select ceil(c1) , last_row(c1) from stb1;") - + tdSql.query("select udf1(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + tdSql.query("select ceil(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + # regular table with compute functions tdSql.query("select udf1(num1) , abs(num1) from tb;") @@ -350,7 +354,7 @@ class TDTestCase: tdSql.query("select floor(num1) , abs(num1) from tb;") tdSql.checkRows(12) - # # bug need fix + # # bug need fix #tdSql.query("select udf1(num1) , csum(num1) from tb;") #tdSql.checkRows(9) @@ -382,8 +386,8 @@ class TDTestCase: tdSql.checkData(1,0,88) tdSql.checkData(1,1,7) - # bug fix for crash - # order by udf function result + # bug fix for crash + # order by udf function result for _ in range(50): tdSql.query("select udf2(c1) from stb1 group by 1-udf1(c1)") print(tdSql.queryResult) @@ -401,7 +405,7 @@ class TDTestCase: tdSql.checkData(0,1,88) tdSql.checkData(0,2,-99.990000000) tdSql.checkData(0,3,88) - + tdSql.query("select sub1.c1, sub2.c2 from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,0) tdSql.checkData(0,1,0) @@ -429,7 +433,7 @@ class TDTestCase: tdSql.checkData(0,1,168.819430161) tdSql.error("select sub1.c1 , udf2(sub1.c1), sub2.c2 ,udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") - # udf functions with group by + # udf functions with group by tdSql.query("select udf1(c1) from ct1 group by c1") tdSql.checkRows(10) tdSql.query("select udf1(c1) from stb1 group by c1") @@ -452,7 +456,7 @@ class TDTestCase: tdSql.query("select udf2(c1) from stb1 group by floor(c1)") tdSql.checkRows(11) - # udf mix with order by + # udf mix with order by tdSql.query("select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)") tdSql.checkRows(11) @@ -481,7 +485,7 @@ class TDTestCase: tdSql.checkData(0,1,169.661427555) def try_query_sql(self): - udf1_sqls = [ + udf1_sqls = [ "select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb" , "select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1" , "select udf1(num1) , max(num1) from tb;" , @@ -525,7 +529,7 @@ class TDTestCase: "select udf2(c1) from stb1 group by udf1(c1)" , "select udf2(c1) from stb1 group by floor(c1)" , "select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)" , - + "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , @@ -551,7 +555,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - # create function without aggregate + # create function without aggregate tdLog.info(" create function with out aggregate ") tdSql.query("drop function udf1 ") @@ -575,8 +579,8 @@ class TDTestCase: tdSql.error(" select test(c1) from stb1 ") tdSql.error(" select test(c1,c6), test(c6) from stb1 ") tdSql.error(" select test(num1,num2), test(num1) from tb ") - - + + def loop_kill_udfd(self): @@ -585,7 +589,7 @@ class TDTestCase: tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - + cfgPath = buildPath + "/../sim/dnode1/cfg" udfdPath = buildPath +'/build/bin/udfd' @@ -596,19 +600,19 @@ class TDTestCase: tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # stop udfd cmds + # stop udfd cmds get_processID = "ps -ef | grep -w udfd | grep -v grep| grep -v defunct | awk '{print $2}'" processID = subprocess.check_output(get_processID, shell=True).decode("utf-8") stop_udfd = " kill -9 %s" % processID os.system(stop_udfd) time.sleep(2) - + tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # # start udfd cmds + # # start udfd cmds # start_udfd = "nohup " + udfdPath +'-c' +cfgPath +" > /dev/null 2>&1 &" # tdLog.info("start udfd : %s " % start_udfd) @@ -643,11 +647,11 @@ class TDTestCase: tdDnodes.stop(1) tdDnodes.start(1) time.sleep(2) - - + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring - - print(" env is ok for all ") + + print(" env is ok for all ") self.prepare_udf_so() self.prepare_data() self.create_udf_function() @@ -659,7 +663,7 @@ class TDTestCase: time.sleep(2) self.basic_udf_query() self.test_function_name() - + def stop(self): tdSql.close() diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index 5f3ab2e863..63650d6edc 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -34,7 +34,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -60,7 +60,7 @@ class TDTestCase: def prepare_data(self): - + tdSql.execute("drop database if exists db ") tdSql.execute("create database if not exists db duration 300") tdSql.execute("use db") @@ -70,7 +70,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -152,7 +152,7 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: @@ -177,14 +177,14 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: tdLog.info("create two udf functions success ") - + def basic_udf_query(self): - + # scalar functions tdSql.execute("use db ") @@ -258,7 +258,7 @@ class TDTestCase: tdSql.checkData(0,1,165.247614504) tdSql.checkData(0,2,2551.470164435) tdSql.checkData(0,3,2.652476145) - + # # bug for crash when query sub table tdSql.query("select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from ct1") tdSql.checkData(0,0,378.215547010) @@ -283,7 +283,7 @@ class TDTestCase: tdSql.error("select udf1(num1) , stddev(num1) from tb;") tdSql.error("select udf1(num1) , mode(num1) from tb;") tdSql.error("select udf1(num1) , HYPERLOGLOG(num1) from tb;") - # stable + # stable tdSql.error("select udf1(c1) , count(c1) from stb1;") tdSql.error("select udf1(c1) , avg(c1) from stb1;") tdSql.error("select udf1(c1) , twa(c1) from stb1;") @@ -304,23 +304,25 @@ class TDTestCase: tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , first(num1) from tb;") - + tdSql.query("select abs(num1) , first(num1) from tb;") - + tdSql.query("select udf1(num1) , last(num1) from tb;") - + tdSql.query("select round(num1) , last(num1) from tb;") - + tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , bottom(num1,1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , last_row(num1) from tb;") - - tdSql.error("select round(num1) , last_row(num1) from tb;") - - - # stable + tdSql.query("select udf1(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + tdSql.query("select round(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + + # stable tdSql.query("select udf1(c1) , max(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , max(c1) from stb1;") @@ -330,9 +332,9 @@ class TDTestCase: tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select udf1(c1) , first(c1) from stb1;") - + tdSql.query("select udf1(c1) , last(c1) from stb1;") - + tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , top(c1 ,1) from stb1;") @@ -342,9 +344,11 @@ class TDTestCase: tdSql.query("select ceil(c1) , bottom(c1,1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , last_row(c1) from stb1;") - tdSql.error("select ceil(c1) , last_row(c1) from stb1;") - + tdSql.query("select udf1(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + tdSql.query("select ceil(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + # regular table with compute functions tdSql.query("select udf1(num1) , abs(num1) from tb;") @@ -352,7 +356,7 @@ class TDTestCase: tdSql.query("select floor(num1) , abs(num1) from tb;") tdSql.checkRows(12) - # # bug need fix + # # bug need fix #tdSql.query("select udf1(num1) , csum(num1) from tb;") #tdSql.checkRows(9) @@ -384,8 +388,8 @@ class TDTestCase: tdSql.checkData(1,0,88) tdSql.checkData(1,1,7) - # bug fix for crash - # order by udf function result + # bug fix for crash + # order by udf function result for _ in range(50): tdSql.query("select udf2(c1) from stb1 group by 1-udf1(c1)") print(tdSql.queryResult) @@ -403,7 +407,7 @@ class TDTestCase: tdSql.checkData(0,1,88) tdSql.checkData(0,2,-99.990000000) tdSql.checkData(0,3,88) - + tdSql.query("select sub1.c1, sub2.c2 from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,0) tdSql.checkData(0,1,0) @@ -431,7 +435,7 @@ class TDTestCase: tdSql.checkData(0,1,168.819430161) tdSql.error("select sub1.c1 , udf2(sub1.c1), sub2.c2 ,udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") - # udf functions with group by + # udf functions with group by tdSql.query("select udf1(c1) from ct1 group by c1") tdSql.checkRows(10) tdSql.query("select udf1(c1) from stb1 group by c1") @@ -454,7 +458,7 @@ class TDTestCase: tdSql.query("select udf2(c1) from stb1 group by floor(c1)") tdSql.checkRows(11) - # udf mix with order by + # udf mix with order by tdSql.query("select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)") tdSql.checkRows(11) @@ -483,7 +487,7 @@ class TDTestCase: tdSql.checkData(0,1,169.661427555) def try_query_sql(self): - udf1_sqls = [ + udf1_sqls = [ "select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb" , "select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1" , "select udf1(num1) , max(num1) from tb;" , @@ -527,7 +531,7 @@ class TDTestCase: "select udf2(c1) from stb1 group by udf1(c1)" , "select udf2(c1) from stb1 group by floor(c1)" , "select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)" , - + "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , @@ -563,7 +567,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - # create function without aggregate + # create function without aggregate tdLog.info(" create function with out aggregate ") tdSql.query("drop function udf1 ") @@ -587,8 +591,8 @@ class TDTestCase: tdSql.error(" select test(c1) from stb1 ") tdSql.error(" select test(c1,c6), test(c6) from stb1 ") tdSql.error(" select test(num1,num2), test(num1) from tb ") - - + + def loop_kill_udfd(self): @@ -597,7 +601,7 @@ class TDTestCase: tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - + cfgPath = buildPath + "/../sim/dnode1/cfg" udfdPath = buildPath +'/build/bin/udfd' @@ -608,19 +612,19 @@ class TDTestCase: tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # stop udfd cmds + # stop udfd cmds get_processID = "ps -ef | grep -w udfd | grep -v grep| grep -v defunct | awk '{print $2}'" processID = subprocess.check_output(get_processID, shell=True).decode("utf-8") stop_udfd = " kill -9 %s" % processID os.system(stop_udfd) time.sleep(2) - + tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # # start udfd cmds + # # start udfd cmds # start_udfd = "nohup " + udfdPath +'-c' +cfgPath +" > /dev/null 2>&1 &" # tdLog.info("start udfd : %s " % start_udfd) @@ -655,17 +659,17 @@ class TDTestCase: tdDnodes.stop(1) tdDnodes.start(1) time.sleep(2) - - + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring - - print(" env is ok for all ") + + print(" env is ok for all ") self.prepare_udf_so() self.prepare_data() self.create_udf_function() self.basic_udf_query() self.unexpected_create() - + def stop(self): tdSql.close() diff --git a/tests/system-test/0-others/udf_restart_taosd.py b/tests/system-test/0-others/udf_restart_taosd.py index 857921e32c..c318980b67 100644 --- a/tests/system-test/0-others/udf_restart_taosd.py +++ b/tests/system-test/0-others/udf_restart_taosd.py @@ -31,7 +31,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -57,7 +57,7 @@ class TDTestCase: def prepare_data(self): - + tdSql.execute("drop database if exists db ") tdSql.execute("create database if not exists db duration 300") tdSql.execute("use db") @@ -67,7 +67,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -149,7 +149,7 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: @@ -174,14 +174,14 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '%s' outputtype double bufSize 8;"%self.libudf2) - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: tdLog.info("create two udf functions success ") - + def basic_udf_query(self): - + # scalar functions tdSql.execute("use db ") @@ -255,7 +255,7 @@ class TDTestCase: tdSql.checkData(0,1,165.247614504) tdSql.checkData(0,2,2551.470164435) tdSql.checkData(0,3,2.652476145) - + # # bug for crash when query sub table tdSql.query("select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from ct1") tdSql.checkData(0,0,378.215547010) @@ -280,7 +280,7 @@ class TDTestCase: tdSql.error("select udf1(num1) , stddev(num1) from tb;") tdSql.error("select udf1(num1) , mode(num1) from tb;") tdSql.error("select udf1(num1) , HYPERLOGLOG(num1) from tb;") - # stable + # stable tdSql.error("select udf1(c1) , count(c1) from stb1;") tdSql.error("select udf1(c1) , avg(c1) from stb1;") tdSql.error("select udf1(c1) , twa(c1) from stb1;") @@ -301,23 +301,25 @@ class TDTestCase: tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , first(num1) from tb;") - + tdSql.query("select abs(num1) , first(num1) from tb;") - + tdSql.query("select udf1(num1) , last(num1) from tb;") - + tdSql.query("select round(num1) , last(num1) from tb;") - + tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) tdSql.query("select udf1(num1) , bottom(num1,1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , last_row(num1) from tb;") - - tdSql.error("select round(num1) , last_row(num1) from tb;") - - - # stable + tdSql.query("select udf1(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + tdSql.query("select round(num1) , last_row(num1) from tb;") + tdSql.checkRows(1) + + + # stable tdSql.query("select udf1(c1) , max(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , max(c1) from stb1;") @@ -327,9 +329,9 @@ class TDTestCase: tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) tdSql.query("select udf1(c1) , first(c1) from stb1;") - + tdSql.query("select udf1(c1) , last(c1) from stb1;") - + tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) tdSql.query("select abs(c1) , top(c1 ,1) from stb1;") @@ -339,9 +341,11 @@ class TDTestCase: tdSql.query("select ceil(c1) , bottom(c1,1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , last_row(c1) from stb1;") - tdSql.error("select ceil(c1) , last_row(c1) from stb1;") - + tdSql.query("select udf1(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + tdSql.query("select ceil(c1) , last_row(c1) from stb1;") + tdSql.checkRows(1) + # regular table with compute functions tdSql.query("select udf1(num1) , abs(num1) from tb;") @@ -349,7 +353,7 @@ class TDTestCase: tdSql.query("select floor(num1) , abs(num1) from tb;") tdSql.checkRows(12) - # # bug need fix + # # bug need fix #tdSql.query("select udf1(num1) , csum(num1) from tb;") #tdSql.checkRows(9) @@ -381,8 +385,8 @@ class TDTestCase: tdSql.checkData(1,0,88) tdSql.checkData(1,1,7) - # bug fix for crash - # order by udf function result + # bug fix for crash + # order by udf function result for _ in range(50): tdSql.query("select udf2(c1) from stb1 group by 1-udf1(c1)") print(tdSql.queryResult) @@ -400,7 +404,7 @@ class TDTestCase: tdSql.checkData(0,1,88) tdSql.checkData(0,2,-99.990000000) tdSql.checkData(0,3,88) - + tdSql.query("select sub1.c1, sub2.c2 from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,0) tdSql.checkData(0,1,0) @@ -428,7 +432,7 @@ class TDTestCase: tdSql.checkData(0,1,168.819430161) tdSql.error("select sub1.c1 , udf2(sub1.c1), sub2.c2 ,udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") - # udf functions with group by + # udf functions with group by tdSql.query("select udf1(c1) from ct1 group by c1") tdSql.checkRows(10) tdSql.query("select udf1(c1) from stb1 group by c1") @@ -451,7 +455,7 @@ class TDTestCase: tdSql.query("select udf2(c1) from stb1 group by floor(c1)") tdSql.checkRows(11) - # udf mix with order by + # udf mix with order by tdSql.query("select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)") tdSql.checkRows(11) @@ -480,7 +484,7 @@ class TDTestCase: tdSql.checkData(0,1,169.661427555) def try_query_sql(self): - udf1_sqls = [ + udf1_sqls = [ "select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb" , "select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1" , "select udf1(num1) , max(num1) from tb;" , @@ -507,7 +511,7 @@ class TDTestCase: "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" , - "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" + "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" ] udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(c1) from stb1 group by 1-udf1(c1)" , @@ -524,7 +528,7 @@ class TDTestCase: "select udf2(c1) from stb1 group by udf1(c1)" , "select udf2(c1) from stb1 group by floor(c1)" , "select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)" , - + "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , @@ -550,7 +554,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - # create function without aggregate + # create function without aggregate tdLog.info(" create function with out aggregate ") tdSql.query("drop function udf1 ") @@ -574,8 +578,8 @@ class TDTestCase: tdSql.error(" select test(c1) from stb1 ") tdSql.error(" select test(c1,c6), test(c6) from stb1 ") tdSql.error(" select test(num1,num2), test(num1) from tb ") - - + + def loop_kill_udfd(self): @@ -584,7 +588,7 @@ class TDTestCase: tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - + cfgPath = buildPath + "/../sim/dnode1/cfg" udfdPath = buildPath +'/build/bin/udfd' @@ -595,19 +599,19 @@ class TDTestCase: tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # stop udfd cmds + # stop udfd cmds get_processID = "ps -ef | grep -w udfd | grep -v grep| grep -v defunct | awk '{print $2}'" processID = subprocess.check_output(get_processID, shell=True).decode("utf-8") stop_udfd = " kill -9 %s" % processID os.system(stop_udfd) time.sleep(2) - + tdSql.query("select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null") tdSql.checkData(0,0,169.661427555) tdSql.checkData(0,1,169.661427555) - # # start udfd cmds + # # start udfd cmds # start_udfd = "nohup " + udfdPath +'-c' +cfgPath +" > /dev/null 2>&1 &" # tdLog.info("start udfd : %s " % start_udfd) @@ -640,19 +644,19 @@ class TDTestCase: tdDnodes.stop(1) tdDnodes.start(1) time.sleep(2) - - + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring - - print(" env is ok for all ") + + print(" env is ok for all ") self.prepare_udf_so() self.prepare_data() self.create_udf_function() self.basic_udf_query() self.multi_cols_udf() self.restart_taosd_query_udf() - - + + def stop(self): tdSql.close() diff --git a/tests/system-test/1-insert/insertWithMoreVgroup.py b/tests/system-test/1-insert/insertWithMoreVgroup.py index e3a20cebf8..80468509ee 100644 --- a/tests/system-test/1-insert/insertWithMoreVgroup.py +++ b/tests/system-test/1-insert/insertWithMoreVgroup.py @@ -355,40 +355,6 @@ class TDTestCase: return - def test_case4(self): - self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10) - tdSql.execute("use db1;") - tdSql.query("show dnodes;") - dnodeId=tdSql.getData(0,0) - print(dnodeId) - tdSql.execute("create qnode on dnode %s"%dnodeId) - tdSql.query("select max(c1) from stb10;") - maxQnode=tdSql.getData(0,0) - tdSql.query("select min(c1) from stb11;") - minQnode=tdSql.getData(0,0) - tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") - unionQnode=tdSql.queryResult - tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") - unionallQnode=tdSql.queryResult - - # tdSql.query("show qnodes;") - # qnodeId=tdSql.getData(0,0) - tdSql.execute("drop qnode on dnode %s"%dnodeId) - tdSql.execute("reset query cache") - tdSql.query("select max(c1) from stb10;") - tdSql.checkData(0, 0, "%s"%maxQnode) - tdSql.query("select min(c1) from stb11;") - tdSql.checkData(0, 0, "%s"%minQnode) - tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") - unionVnode=tdSql.queryResult - assert unionQnode == unionVnode - tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") - unionallVnode=tdSql.queryResult - assert unionallQnode == unionallVnode - - - # tdSql.execute("create qnode on dnode %s"%dnodeId) - # run case def run(self): diff --git a/tests/system-test/1-insert/test_stmt_insert_query_ex.py b/tests/system-test/1-insert/test_stmt_insert_query_ex.py index 6d49f6065a..2a64c09ff4 100644 --- a/tests/system-test/1-insert/test_stmt_insert_query_ex.py +++ b/tests/system-test/1-insert/test_stmt_insert_query_ex.py @@ -82,7 +82,7 @@ class TDTestCase: return con def test_stmt_set_tbname_tag(self,conn): - dbname = "stmt_set_tbname_tag" + dbname = "stmt_tag" try: conn.execute("drop database if exists %s" % dbname) @@ -184,43 +184,43 @@ class TDTestCase: #query: string Functions - querystmt3=conn.statement("select CHAR_LENGTH(?) from log ") - queryparam3=new_bind_params(1) - print(type(queryparam3)) - queryparam3[0].binary('中文字符') - querystmt3.bind_param(queryparam3) - querystmt3.execute() - result3=querystmt3.use_result() - rows3=result3.fetch_all() - print("4",rows3) - assert rows3[0][0] == 12, 'fourth case is failed' - assert rows3[1][0] == 12, 'fourth case is failed' + querystmt9=conn.statement("select CHAR_LENGTH(?) from log ") + queryparam9=new_bind_params(1) + print(type(queryparam9)) + queryparam9[0].binary('中文字符') + querystmt9.bind_param(queryparam9) + querystmt9.execute() + result9=querystmt9.use_result() + rows9=result9.fetch_all() + print("9",rows9) + assert rows9[0][0] == 12, 'fourth case is failed' + assert rows9[1][0] == 12, 'fourth case is failed' - # #query: conversion Functions + #query: conversion Functions - # querystmt4=conn.statement("select cast( ? as bigint) from log ") - # queryparam4=new_bind_params(1) - # print(type(queryparam4)) - # queryparam4[0].binary('1232a') - # querystmt4.bind_param(queryparam4) - # querystmt4.execute() - # result4=querystmt4.use_result() - # rows4=result4.fetch_all() - # print("5",rows4) - # assert rows4[0][0] == 1232 - # assert rows4[1][0] == 1232 + querystmt4=conn.statement("select cast( ? as bigint) from log ") + queryparam4=new_bind_params(1) + print(type(queryparam4)) + queryparam4[0].binary('1232a') + querystmt4.bind_param(queryparam4) + querystmt4.execute() + result4=querystmt4.use_result() + rows4=result4.fetch_all() + print("5",rows4) + assert rows4[0][0] == 1232 + assert rows4[1][0] == 1232 - # querystmt4=conn.statement("select cast( ? as binary(10)) from log ") - # queryparam4=new_bind_params(1) - # print(type(queryparam4)) - # queryparam4[0].int(123) - # querystmt4.bind_param(queryparam4) - # querystmt4.execute() - # result4=querystmt4.use_result() - # rows4=result4.fetch_all() - # print("6",rows4) - # assert rows4[0][0] == '123' - # assert rows4[1][0] == '123' + querystmt4=conn.statement("select cast( ? as binary(10)) from log ") + queryparam4=new_bind_params(1) + print(type(queryparam4)) + queryparam4[0].int(123) + querystmt4.bind_param(queryparam4) + querystmt4.execute() + result4=querystmt4.use_result() + rows4=result4.fetch_all() + print("6",rows4) + assert rows4[0][0] == '123' + assert rows4[1][0] == '123' # #query: datatime Functions @@ -259,4 +259,4 @@ class TDTestCase: # add case with filename # tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/test_stmt_muti_insert_query.py b/tests/system-test/1-insert/test_stmt_muti_insert_query.py index 971be6c85f..de10b2f6b9 100644 --- a/tests/system-test/1-insert/test_stmt_muti_insert_query.py +++ b/tests/system-test/1-insert/test_stmt_muti_insert_query.py @@ -84,21 +84,21 @@ class TDTestCase: def test_stmt_insert_multi(self,conn): # type: (TaosConnection) -> None - dbname = "pytest_taos_stmt_multi" + dbname = "db_stmt" try: conn.execute("drop database if exists %s" % dbname) conn.execute("create database if not exists %s" % dbname) conn.select_db(dbname) conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ + "create table if not exists stb1(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", ) # conn.load_table_info("log") start = datetime.now() - stmt = conn.statement("insert into log values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") + stmt = conn.statement("insert into stb1 values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") params = new_multi_binds(16) params[0].timestamp((1626861392589, 1626861392590, 1626861392591)) @@ -125,7 +125,7 @@ class TDTestCase: assert stmt.affected_rows == 3 #query 1 - querystmt=conn.statement("select ?,bu from log") + querystmt=conn.statement("select ?,bu from stb1") queryparam=new_bind_params(1) print(type(queryparam)) queryparam[0].binary("ts") @@ -135,7 +135,7 @@ class TDTestCase: # rows=result.fetch_all() # print( querystmt.use_result()) - # result = conn.query("select * from log") + # result = conn.query("select * from stb1") rows=result.fetch_all() # rows=result.fetch_all() print(rows) @@ -144,7 +144,7 @@ class TDTestCase: assert rows[2][1] == None #query 2 - querystmt1=conn.statement("select * from log where bu < ?") + querystmt1=conn.statement("select * from stb1 where bu < ?") queryparam1=new_bind_params(1) print(type(queryparam1)) queryparam1[0].int(4) diff --git a/tests/system-test/2-query/elapsed.py b/tests/system-test/2-query/elapsed.py index 1553e06914..154d79ff01 100644 --- a/tests/system-test/2-query/elapsed.py +++ b/tests/system-test/2-query/elapsed.py @@ -1397,9 +1397,9 @@ class TDTestCase: tdSql.error(sql2) tdSql.error(sql3) - tdSql.error("select elapsed(ts,10s) from (select ts,tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);") + tdSql.query("select elapsed(ts,10s) from (select ts,tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);") - tdSql.error("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);") + tdSql.query("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);") # ===============================================inner nest============================================ @@ -1486,9 +1486,9 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0,0,9) - tdSql.error('select elapsed(ts,10s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ') + tdSql.query('select elapsed(ts,10s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ') - tdSql.error('select elapsed(ts,10s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ') + tdSql.query('select elapsed(ts,10s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ') tdSql.error('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(20s) fill (next) session(ts,1w) ; ') diff --git a/tests/system-test/2-query/explain.py b/tests/system-test/2-query/explain.py index d440144841..f2c6cb7771 100644 --- a/tests/system-test/2-query/explain.py +++ b/tests/system-test/2-query/explain.py @@ -163,38 +163,6 @@ class TDTestCase: # return filter(None, sqls) return list(filter(None, sqls)) - def __get_type(self, col): - if tdSql.cursor.istype(col, "BOOL"): - return "BOOL" - if tdSql.cursor.istype(col, "INT"): - return "INT" - if tdSql.cursor.istype(col, "BIGINT"): - return "BIGINT" - if tdSql.cursor.istype(col, "TINYINT"): - return "TINYINT" - if tdSql.cursor.istype(col, "SMALLINT"): - return "SMALLINT" - if tdSql.cursor.istype(col, "FLOAT"): - return "FLOAT" - if tdSql.cursor.istype(col, "DOUBLE"): - return "DOUBLE" - if tdSql.cursor.istype(col, "BINARY"): - return "BINARY" - if tdSql.cursor.istype(col, "NCHAR"): - return "NCHAR" - if tdSql.cursor.istype(col, "TIMESTAMP"): - return "TIMESTAMP" - if tdSql.cursor.istype(col, "JSON"): - return "JSON" - if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): - return "TINYINT UNSIGNED" - if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): - return "SMALLINT UNSIGNED" - if tdSql.cursor.istype(col, "INT UNSIGNED"): - return "INT UNSIGNED" - if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): - return "BIGINT UNSIGNED" - def explain_check(self): sqls = self.sql_list() tdLog.printNoPrefix("===step 1: curent case, must return query OK") diff --git a/tests/system-test/2-query/hyperloglog.py b/tests/system-test/2-query/hyperloglog.py index 8dd6bd2dda..6ab971173a 100644 --- a/tests/system-test/2-query/hyperloglog.py +++ b/tests/system-test/2-query/hyperloglog.py @@ -116,37 +116,6 @@ class TDTestCase: # return filter(None, sqls) return list(filter(None, sqls)) - def __get_type(self, col): - if tdSql.cursor.istype(col, "BOOL"): - return "BOOL" - if tdSql.cursor.istype(col, "INT"): - return "INT" - if tdSql.cursor.istype(col, "BIGINT"): - return "BIGINT" - if tdSql.cursor.istype(col, "TINYINT"): - return "TINYINT" - if tdSql.cursor.istype(col, "SMALLINT"): - return "SMALLINT" - if tdSql.cursor.istype(col, "FLOAT"): - return "FLOAT" - if tdSql.cursor.istype(col, "DOUBLE"): - return "DOUBLE" - if tdSql.cursor.istype(col, "BINARY"): - return "BINARY" - if tdSql.cursor.istype(col, "NCHAR"): - return "NCHAR" - if tdSql.cursor.istype(col, "TIMESTAMP"): - return "TIMESTAMP" - if tdSql.cursor.istype(col, "JSON"): - return "JSON" - if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): - return "TINYINT UNSIGNED" - if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): - return "SMALLINT UNSIGNED" - if tdSql.cursor.istype(col, "INT UNSIGNED"): - return "INT UNSIGNED" - if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): - return "BIGINT UNSIGNED" def hyperloglog_check(self): sqls = self.sql_list() @@ -228,10 +197,10 @@ class TDTestCase: tag_sql += f"{k} {v}," tdSql.execute(f'create table if not exists {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') - def __insert_data(self): + def __insert_data(self): pass - + def __hyperloglog_check_distribute(self): dbname = "dbtest" stbname = "stb" @@ -286,7 +255,7 @@ class TDTestCase: tdSql.query(f"select hyperloglog({k}) from {stbname} group by {k}") tdSql.execute(f'drop database {dbname}') - + def __insert_data(self, rows): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py index 3a451d069c..238924d851 100644 --- a/tests/system-test/2-query/irate.py +++ b/tests/system-test/2-query/irate.py @@ -58,8 +58,8 @@ class TDTestCase: for coltype in coltypes: colname = coltype[0] if coltype[1] in support_types and coltype[-1] != "TAG" : - irate_sql = "select irate({}) from (select * from {} order by tbname ) ".format(colname, tbname) - origin_sql = "select ts , {} , cast(ts as bigint) from (select ts , {} from {} order by ts desc limit 2 offset 0 ) order by ts".format(colname,colname, tbname) + irate_sql = "select irate({}) from {}".format(colname, tbname) + origin_sql = "select tail({}, 2), cast(ts as bigint) from {} order by ts".format(colname, tbname) tdSql.query(irate_sql) irate_result = tdSql.queryResult @@ -68,10 +68,10 @@ class TDTestCase: irate_value = irate_result[0][0] if origin_result[1][-1] - origin_result[0][-1] == 0: comput_irate_value = 0 - elif (origin_result[1][1] - origin_result[0][1])<0: - comput_irate_value = origin_result[1][1]*1000/( origin_result[1][-1] - origin_result[0][-1]) + elif (origin_result[1][0] - origin_result[0][0])<0: + comput_irate_value = origin_result[1][0]*1000/( origin_result[1][-1] - origin_result[0][-1]) else: - comput_irate_value = (origin_result[1][1] - origin_result[0][1])*1000/( origin_result[1][-1] - origin_result[0][-1]) + comput_irate_value = (origin_result[1][0] - origin_result[0][0])*1000/( origin_result[1][-1] - origin_result[0][-1]) if comput_irate_value ==irate_value: tdLog.info(" irate work as expected , sql is %s "% irate_sql) else: diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 53dfc57458..d03ed5e03a 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -38,7 +38,10 @@ class TDTestCase: tdSql.init(conn.cursor(), logSql) def run(self): - tdSql.prepare() + # tdSql.prepare() + tdSql.execute('drop database if exists db') + tdSql.execute('create database db vgroups 1') + tdSql.execute('use db') print("============== STEP 1 ===== prepare data & validate json string") tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json, tagint int)") tdSql.error("create table if not exists jsons1(ts timestamp, data json) tags(tagint int)") @@ -56,6 +59,22 @@ class TDTestCase: tdSql.query("select jtag from jsons1_8") tdSql.checkData(0, 0, '{" ":90,"1tag$":2,"tag1":null}') + tdSql.query("select ts,jtag from jsons1 order by ts limit 2,3") + tdSql.checkData(0, 0, '2020-06-02 09:17:08.000') + tdSql.checkData(0, 1, '{"tag1":5,"tag2":"beijing"}') + tdSql.checkData(1, 0, '2020-06-02 09:17:48.000') + tdSql.checkData(1, 1, '{"tag1":false,"tag2":"beijing"}') + tdSql.checkData(2, 0, '2020-06-02 09:18:48.000') + tdSql.checkData(2, 1, '{"tag1":null,"tag2":"shanghai","tag3":"hello"}') + + tdSql.query("select ts,jtag->'tag1' from jsons1 order by ts limit 2,3") + tdSql.checkData(0, 0, '2020-06-02 09:17:08.000') + tdSql.checkData(0, 1, '5.000000000') + tdSql.checkData(1, 0, '2020-06-02 09:17:48.000') + tdSql.checkData(1, 1, 'false') + tdSql.checkData(2, 0, '2020-06-02 09:18:48.000') + tdSql.checkData(2, 1, 'null') + # test empty json string, save as jtag is NULL tdSql.execute("insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '你就会', '2sdw')") tdSql.execute("CREATE TABLE if not exists jsons1_10 using jsons1 tags('')") @@ -218,9 +237,19 @@ class TDTestCase: # test where with json tag tdSql.query("select * from jsons1_1 where jtag is not null") - # tdSql.query("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'") + tdSql.error("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'") tdSql.error("select * from jsons1 where jtag->'tag1'={}") + # test json error + tdSql.error("select jtag + 1 from jsons1") + tdSql.error("select jtag > 1 from jsons1") + tdSql.error("select jtag like \"1\" from jsons1") + tdSql.error("select jtag in (\"1\") from jsons1") + tdSql.error("select jtag from jsons1 where jtag > 1") + tdSql.error("select jtag from jsons1 where jtag like 'fsss'") + tdSql.error("select jtag from jsons1 where jtag in (1)") + + # where json value is string tdSql.query("select * from jsons1 where jtag->'tag2'='beijing'") tdSql.checkRows(2) @@ -369,7 +398,7 @@ class TDTestCase: tdSql.checkRows(2) # test where condition in no support in - # tdSql.error("select * from jsons1 where jtag->'tag1' in ('beijing')") + tdSql.error("select * from jsons1 where jtag->'tag1' in ('beijing')") # test where condition match/nmath tdSql.query("select * from jsons1 where jtag->'tag1' match 'ma'") @@ -387,8 +416,8 @@ class TDTestCase: tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')") tdSql.query("select distinct jtag->'tag1' from jsons1") tdSql.checkRows(8) - tdSql.query("select distinct jtag from jsons1") - tdSql.checkRows(9) + # tdSql.query("select distinct jtag from jsons1") + # tdSql.checkRows(9) #test dumplicate key with normal colomn tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")") @@ -424,62 +453,56 @@ class TDTestCase: tdSql.checkData(7, 1, "false") - # tdSql.error("select count(*) from jsons1 group by jtag") - # tdSql.error("select count(*) from jsons1 partition by jtag") - # tdSql.error("select count(*) from jsons1 group by jtag order by jtag") + tdSql.error("select count(*) from jsons1 group by jtag") + tdSql.error("select count(*) from jsons1 partition by jtag") + tdSql.error("select count(*) from jsons1 group by jtag order by jtag") tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'") tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag") - # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") - # tdSql.checkRows(8) - # tdSql.checkData(0, 0, 2) - # tdSql.checkData(0, 1, '"femail"') - # tdSql.checkData(1, 0, 2) - # tdSql.checkData(1, 1, '"收到货"') - # tdSql.checkData(2, 0, 1) - # tdSql.checkData(2, 1, "11.000000000") - # tdSql.checkData(5, 0, 1) - # tdSql.checkData(5, 1, "false") - # tdSql.checkData(6, 0, 1) - # tdSql.checkData(6, 1, "null") - # tdSql.checkData(7, 0, 2) - # tdSql.checkData(7, 1, None) + tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") + tdSql.checkRows(8) + tdSql.checkData(0, 0, 2) + tdSql.checkData(0, 1, '"femail"') + tdSql.checkData(1, 0, 2) + tdSql.checkData(1, 1, '"收到货"') + tdSql.checkData(2, 0, 1) + tdSql.checkData(2, 1, "11.000000000") + tdSql.checkData(5, 0, 1) + tdSql.checkData(5, 1, "false") + + tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc") + tdSql.checkRows(8) + tdSql.checkData(0, 1, None) + tdSql.checkData(2, 0, 1) + tdSql.checkData(2, 1, "false") + tdSql.checkData(5, 0, 1) + tdSql.checkData(5, 1, "11.000000000") + tdSql.checkData(7, 0, 2) + tdSql.checkData(7, 1, '"femail"') - # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc") - # tdSql.checkRows(8) - # tdSql.checkData(0, 0, 2) - # tdSql.checkData(0, 1, None) - # tdSql.checkData(2, 0, 1) - # tdSql.checkData(2, 1, "false") - # tdSql.checkData(5, 0, 1) - # tdSql.checkData(5, 1, "11.000000000") - # tdSql.checkData(7, 0, 2) - # tdSql.checkData(7, 1, '"femail"') - # # test stddev with group by json tag - # tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") - # tdSql.checkRows(8) - # tdSql.checkData(0, 0, 10) - # tdSql.checkData(0, 1, None) - # tdSql.checkData(4, 0, 0) - # tdSql.checkData(4, 1, "5.000000000") - # tdSql.checkData(7, 0, 11) - # tdSql.checkData(7, 1, '"femail"') - # - # res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'") - # cname_list = [] - # cname_list.append("stddev(dataint)") - # cname_list.append("jsons1.jtag->'tag1'") - # tdSql.checkColNameList(res, cname_list) + tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") + tdSql.checkRows(8) + tdSql.checkData(0, 1, None) + tdSql.checkData(4, 0, 0) + tdSql.checkData(4, 1, "5.000000000") + tdSql.checkData(7, 0, 11) + tdSql.checkData(7, 1, '"femail"') + + res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'") + cname_list = [] + cname_list.append("stddev(dataint)") + cname_list.append("jsons1.jtag->'tag1'") + tdSql.checkColNameList(res, cname_list) # test top/bottom with group by json tag - # tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") - # tdSql.checkRows(11) - # tdSql.checkData(0, 1, None) - # tdSql.checkData(2, 0, 4) - # tdSql.checkData(3, 0, 3) - # tdSql.checkData(3, 1, "false") - # tdSql.checkData(8, 0, 2) - # tdSql.checkData(10, 1, '"femail"') + tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") + tdSql.checkRows(11) + tdSql.checkData(0, 1, None) + tdSql.checkData(2, 0, 4) + tdSql.checkData(3, 0, 3) + tdSql.checkData(3, 1, "false") + tdSql.checkData(8, 0, 2) + tdSql.checkData(10, 1, '"femail"') # test having # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1") @@ -492,6 +515,7 @@ class TDTestCase: tdSql.checkData(5, 0, '{"tag1":false,"tag2":"beijing"}') tdSql.error("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)") + tdSql.error("select t->'tag1' from (select jtag->'tag1' as t, dataint from jsons1)") # tdSql.query("select ts,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)") # tdSql.checkRows(11) # tdSql.checkData(1, 1, "jsons1_1") @@ -519,9 +543,10 @@ class TDTestCase: tdSql.checkData(0, 0, 10) tdSql.query("select avg(dataint) from jsons1 where jtag is not null") tdSql.checkData(0, 0, 5.3) - # tdSql.query("select twa(dataint) from jsons1 where jtag is not null") - # tdSql.checkData(0, 0, 36) - # tdSql.error("select irate(dataint) from jsons1 where jtag is not null") + tdSql.query("select twa(dataint) from jsons1 where jtag is not null") + tdSql.checkData(0, 0, 28.386363636363637) + tdSql.query("select irate(dataint) from jsons1 where jtag is not null") + tdSql.query("select sum(dataint) from jsons1 where jtag->'tag1' is not null") tdSql.checkData(0, 0, 45) tdSql.query("select stddev(dataint) from jsons1 where jtag->'tag1'>1") @@ -549,9 +574,9 @@ class TDTestCase: #test calculation function:diff/derivative/spread/ceil/floor/round/ tdSql.query("select diff(dataint) from jsons1 where jtag->'tag1'>1") - # tdSql.checkRows(2) - # tdSql.checkData(0, 0, -1) - # tdSql.checkData(1, 0, 10) + tdSql.checkRows(2) + tdSql.checkData(0, 0, -1) + tdSql.checkData(1, 0, 10) tdSql.query("select derivative(dataint, 10m, 0) from jsons1 where jtag->'tag1'>1") tdSql.checkData(0, 0, -2) tdSql.query("select spread(dataint) from jsons1 where jtag->'tag1'>1") @@ -608,14 +633,14 @@ class TDTestCase: tdSql.checkRows(1) # function not ready - # tdSql.query("select tail(dataint,1) from jsons1 where jtag->'tag1'>1;") - # tdSql.checkRows(3) - # tdSql.query("select unique(dataint) from jsons1 where jtag->'tag1'>1;") - # tdSql.checkRows(3) - # tdSql.query("select mode(dataint) from jsons1 where jtag->'tag1'>1;") - # tdSql.checkRows(3) - # tdSql.query("select irate(dataint) from jsons1 where jtag->'tag1'>1;") - # tdSql.checkRows(1) + tdSql.query("select tail(dataint,1) from jsons1 where jtag->'tag1'>1;") + tdSql.checkRows(1) + tdSql.query("select unique(dataint) from jsons1 where jtag->'tag1'>1;") + tdSql.checkRows(3) + tdSql.query("select mode(dataint) from jsons1 where jtag->'tag1'>1;") + tdSql.checkRows(1) + tdSql.query("select irate(dataint) from jsons1 where jtag->'tag1'>1;") + tdSql.checkRows(1) #str function tdSql.query("select upper(dataStr) from jsons1 where jtag->'tag1'>1;") @@ -659,13 +684,26 @@ class TDTestCase: tdSql.query("select ELAPSED(ts,1h) from jsons1 where jtag->'tag1'>1;") tdSql.checkRows(1) - # - # #test TD-12077 + # to_json() + tdSql.query("select to_json('{\"abc\":123}') from jsons1_1") + tdSql.checkRows(2) + # tdSql.checkData(0, 0, '{"abc":123}') + # tdSql.checkData(1, 0, '{"abc":123}') + tdSql.query("select to_json('null') from jsons1_1") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 'null') + tdSql.checkData(1, 0, 'null') + tdSql.query("select to_json('{\"key\"}') from jsons1_1") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 'null') + tdSql.checkData(1, 0, 'null') + + #test TD-12077 tdSql.execute("insert into jsons1_16 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":-2.111}') values(1591062628000, 2, NULL, '你就会', 'dws')") tdSql.query("select jtag->'tag3' from jsons1_16") tdSql.checkData(0, 0, '-2.111000000') - # # test TD-12452 + # test TD-12452 tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag=NULL") tdSql.query("select jtag from jsons1_1") tdSql.checkData(0, 0, None) diff --git a/tests/system-test/2-query/leastsquares.py b/tests/system-test/2-query/leastsquares.py index e8fa32e8b3..3bab509942 100644 --- a/tests/system-test/2-query/leastsquares.py +++ b/tests/system-test/2-query/leastsquares.py @@ -195,38 +195,6 @@ class TDTestCase: # return filter(None, sqls) return list(filter(None, current_sqls)), list(filter(None, err_sqls)) - def __get_type(self, col): - if tdSql.cursor.istype(col, "BOOL"): - return "BOOL" - if tdSql.cursor.istype(col, "INT"): - return "INT" - if tdSql.cursor.istype(col, "BIGINT"): - return "BIGINT" - if tdSql.cursor.istype(col, "TINYINT"): - return "TINYINT" - if tdSql.cursor.istype(col, "SMALLINT"): - return "SMALLINT" - if tdSql.cursor.istype(col, "FLOAT"): - return "FLOAT" - if tdSql.cursor.istype(col, "DOUBLE"): - return "DOUBLE" - if tdSql.cursor.istype(col, "BINARY"): - return "BINARY" - if tdSql.cursor.istype(col, "NCHAR"): - return "NCHAR" - if tdSql.cursor.istype(col, "TIMESTAMP"): - return "TIMESTAMP" - if tdSql.cursor.istype(col, "JSON"): - return "JSON" - if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): - return "TINYINT UNSIGNED" - if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): - return "SMALLINT UNSIGNED" - if tdSql.cursor.istype(col, "INT UNSIGNED"): - return "INT UNSIGNED" - if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): - return "BIGINT UNSIGNED" - def leastsquares_check(self): current_sqls, err_sqls = self.sql_list() for i in range(len(err_sqls)): diff --git a/tests/system-test/2-query/queryQnode.py b/tests/system-test/2-query/queryQnode.py index 15b643f5d7..0011fe248f 100644 --- a/tests/system-test/2-query/queryQnode.py +++ b/tests/system-test/2-query/queryQnode.py @@ -17,6 +17,8 @@ import threading as thd import multiprocessing as mp from numpy.lib.function_base import insert import taos +from util.dnodes import TDDnode +from util.dnodes import * from util.log import * from util.cases import * from util.sql import * @@ -30,9 +32,9 @@ class TDTestCase: # # --------------- main frame ------------------- # - clientCfgDict = {'queryproxy': '1','debugFlag': 135} - clientCfgDict["queryproxy"] = '2' - clientCfgDict["debugFlag"] = 143 + clientCfgDict = {'queryPolicy': '1','debugFlag': 135} + clientCfgDict["queryPolicy"] = '1' + clientCfgDict["debugFlag"] = 131 updatecfgDict = {'clientCfg': {}} updatecfgDict = {'debugFlag': 143} @@ -62,7 +64,7 @@ class TDTestCase: return buildPath # init - def init(self, conn, logSql): + def init(self, conn, logSql=True): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) # tdSql.prepare() @@ -292,12 +294,13 @@ class TDTestCase: tdLog.debug("-----create database and muti-thread create tables test------- ") - def test_case4(self): + def test_case1(self): self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10) tdSql.execute("use db1;") tdSql.query("show dnodes;") dnodeId=tdSql.getData(0,0) print(dnodeId) + tdLog.debug("create qnode on dnode %s"%dnodeId) tdSql.execute("create qnode on dnode %s"%dnodeId) tdSql.query("select max(c1) from stb10;") maxQnode=tdSql.getData(0,0) @@ -310,6 +313,7 @@ class TDTestCase: # tdSql.query("show qnodes;") # qnodeId=tdSql.getData(0,0) + tdLog.debug("drop qnode on dnode %s"%dnodeId) tdSql.execute("drop qnode on dnode %s"%dnodeId) tdSql.execute("reset query cache") tdSql.query("select max(c1) from stb10;") @@ -323,15 +327,156 @@ class TDTestCase: unionallVnode=tdSql.queryResult assert unionallQnode == unionallVnode + queryPolicy=2 + simClientCfg="%s/taos.cfg"%tdDnodes.getSimCfgPath() + cmd='sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'%simClientCfg + os.system(cmd) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("reset query cache") + tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + tdSql.query("show local variables;") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "queryPolicy" : + if int(tdSql.queryResult[i][1]) == int(queryPolicy): + tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) + else : + tdLog.debug(tdSql.queryResult) + tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) + tdSql.execute("reset query cache") + + tdSql.execute("use db1;") + tdSql.query("show dnodes;") + dnodeId=tdSql.getData(0,0) + tdLog.debug("create qnode on dnode %s"%dnodeId) + + tdSql.execute("create qnode on dnode %s"%dnodeId) + tdSql.query("select max(c1) from stb10;") + assert maxQnode==tdSql.getData(0,0) + tdSql.query("select min(c1) from stb11;") + assert minQnode==tdSql.getData(0,0) + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + assert unionQnode==tdSql.queryResult + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") + assert unionallQnode==tdSql.queryResult + + # tdSql.query("show qnodes;") + # qnodeId=tdSql.getData(0,0) + tdLog.debug("drop qnode on dnode %s"%dnodeId) + tdSql.execute("drop qnode on dnode %s"%dnodeId) + tdSql.execute("reset query cache") + tdSql.query("select max(c1) from stb10;") + assert maxQnode==tdSql.getData(0,0) + tdSql.query("select min(c1) from stb11;") + assert minQnode==tdSql.getData(0,0) + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") # tdSql.execute("create qnode on dnode %s"%dnodeId) + queryPolicy=3 + simClientCfg="%s/taos.cfg"%tdDnodes.getSimCfgPath() + cmd='sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'%simClientCfg + os.system(cmd) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("reset query cache") + tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + tdSql.query("show local variables;") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "queryPolicy" : + if int(tdSql.queryResult[i][1]) == int(queryPolicy): + tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) + else : + tdLog.debug(tdSql.queryResult) + tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) + tdSql.execute("reset query cache") + + tdSql.execute("use db1;") + tdSql.query("show dnodes;") + dnodeId=tdSql.getData(0,0) + tdLog.debug("create qnode on dnode %s"%dnodeId) + + tdSql.execute("create qnode on dnode %s"%dnodeId) + tdSql.query("select max(c1) from stb10;") + assert maxQnode==tdSql.getData(0,0) + tdSql.query("select min(c1) from stb11;") + assert minQnode==tdSql.getData(0,0) + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + assert unionQnode==tdSql.queryResult + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") + assert unionallQnode==tdSql.queryResult + + def test_case2(self): + self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 10, 2, 1*10) + tdSql.query("show qnodes") + if tdSql.queryRows == 1 : + tdLog.debug("drop qnode on dnode 1") + tdSql.execute("drop qnode on dnode 1") + queryPolicy=2 + simClientCfg="%s/taos.cfg"%tdDnodes.getSimCfgPath() + cmd='sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'%simClientCfg + os.system(cmd) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("reset query cache") + tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + tdSql.query("show local variables;") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "queryPolicy" : + if int(tdSql.queryResult[i][1]) == int(queryPolicy): + tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) + else : + tdLog.debug(tdSql.queryResult) + tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) + tdSql.execute("use db1;") + tdSql.error("select max(c1) from stb10;") + tdSql.error("select min(c1) from stb11;") + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") + + tdSql.query("select max(c1) from stb10_0;") + tdSql.query("select min(c1) from stb11_0;") + + def test_case3(self): + + tdSql.execute('alter local "queryPolicy" "3"') + tdLog.debug("create qnode on dnode 1") + tdSql.execute("create qnode on dnode 1") + tdSql.execute("use db1;") + tdSql.query("show dnodes;") + dnodeId=tdSql.getData(0,0) + print(dnodeId) + + tdSql.query("select max(c1) from stb10;") + maxQnode=tdSql.getData(0,0) + tdSql.query("select min(c1) from stb11;") + minQnode=tdSql.getData(0,0) + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + unionQnode=tdSql.queryResult + tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") + unionallQnode=tdSql.queryResult + + # tdSql.query("show qnodes;") + # qnodeId=tdSql.getData(0,0) + tdLog.debug("drop qnode on dnode %s"%dnodeId) + + tdSql.execute("drop qnode on dnode %s"%dnodeId) + tdSql.execute("reset query cache") + + tdSql.error("select max(c1) from stb10;") + tdSql.error("select min(c1) from stb11;") + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") + tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") + # run case def run(self): - # test qnode - self.test_case4() - tdLog.debug(" LIMIT test_case3 ............ [OK]") + self.test_case1() + self.test_case2() + + self.test_case3() + # tdLog.debug(" LIMIT test_case3 ............ [OK]") return diff --git a/tests/system-test/2-query/spread.py b/tests/system-test/2-query/spread.py index d2dbbd03ed..51c569e565 100644 --- a/tests/system-test/2-query/spread.py +++ b/tests/system-test/2-query/spread.py @@ -159,38 +159,6 @@ class TDTestCase: # return filter(None, sqls) return list(filter(None, sqls)) - def __get_type(self, col): - if tdSql.cursor.istype(col, "BOOL"): - return "BOOL" - if tdSql.cursor.istype(col, "INT"): - return "INT" - if tdSql.cursor.istype(col, "BIGINT"): - return "BIGINT" - if tdSql.cursor.istype(col, "TINYINT"): - return "TINYINT" - if tdSql.cursor.istype(col, "SMALLINT"): - return "SMALLINT" - if tdSql.cursor.istype(col, "FLOAT"): - return "FLOAT" - if tdSql.cursor.istype(col, "DOUBLE"): - return "DOUBLE" - if tdSql.cursor.istype(col, "BINARY"): - return "BINARY" - if tdSql.cursor.istype(col, "NCHAR"): - return "NCHAR" - if tdSql.cursor.istype(col, "TIMESTAMP"): - return "TIMESTAMP" - if tdSql.cursor.istype(col, "JSON"): - return "JSON" - if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): - return "TINYINT UNSIGNED" - if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): - return "SMALLINT UNSIGNED" - if tdSql.cursor.istype(col, "INT UNSIGNED"): - return "INT UNSIGNED" - if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): - return "BIGINT UNSIGNED" - def spread_check(self): sqls = self.sql_list() tdLog.printNoPrefix("===step 1: curent case, must return query OK") diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index a4c85cc5ed..c03f4e03db 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -92,8 +92,6 @@ class TDTestCase: "select tail(c1,1) , min(c1) from t1", "select tail(c1,1) , spread(c1) from t1", "select tail(c1,1) , diff(c1) from t1", - "select tail(c1,1) , abs(c1) from t1", - "select tail(c1,1) , c1 from t1", "select tail from stb1 partition by tbname", "select tail(123--123)==1 from stb1 partition by tbname", "select tail(123,123) from stb1 partition by tbname", @@ -115,10 +113,7 @@ class TDTestCase: "select tail(c1,1) , avg(c1) from stb1 partition by tbname", "select tail(c1,1) , min(c1) from stb1 partition by tbname", "select tail(c1,1) , spread(c1) from stb1 partition by tbname", - "select tail(c1,1) , diff(c1) from stb1 partition by tbname", - "select tail(c1,1) , abs(c1) from stb1 partition by tbname", - "select tail(c1,1) , c1 from stb1 partition by tbname" - + "select tail(c1,1) , diff(c1) from stb1 partition by tbname", ] for error_sql in error_sql_lists: tdSql.error(error_sql) @@ -266,17 +261,17 @@ class TDTestCase: tdSql.query("select tail(c1,10,10) from ct1") tdSql.checkRows(3) - tdSql.error("select tail(c1,10,10),tbname from ct1") - tdSql.error("select tail(c1,10,10),t1 from ct1") + tdSql.query("select tail(c1,10,10),tbname from ct1") + tdSql.query("select tail(c1,10,10),t1 from ct1") # tail with common col - tdSql.error("select tail(c1,10,10) ,ts from ct1") - tdSql.error("select tail(c1,10,10) ,c1 from ct1") + tdSql.query("select tail(c1,10,10) ,ts from ct1") + tdSql.query("select tail(c1,10,10) ,c1 from ct1") # tail with scalar function - tdSql.error("select tail(c1,10,10) ,abs(c1) from ct1") + tdSql.query("select tail(c1,10,10) ,abs(c1) from ct1") tdSql.error("select tail(c1,10,10) , tail(c2,10,10) from ct1") - tdSql.error("select tail(c1,10,10) , abs(c2)+2 from ct1") + tdSql.query("select tail(c1,10,10) , abs(c2)+2 from ct1") # bug need fix for scalar value or compute again # tdSql.error(" select tail(c1,10,10) , 123 from ct1") diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py index e7353b0f13..80508979c5 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py @@ -65,31 +65,6 @@ class TDTestCase: self._async_raise(thread.ident, SystemExit) - def insertData(self,countstart,countstop): - # fisrt add data : db\stable\childtable\general table - - for couti in range(countstart,countstop): - tdLog.debug("drop database if exists db%d" %couti) - tdSql.execute("drop database if exists db%d" %couti) - print("create database if not exists db%d replica 1 duration 300" %couti) - tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti) - tdSql.execute("use db%d" %couti) - 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 (t1 int) - ''' - ) - 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 ( {i+1} )') - - def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'db', @@ -143,7 +118,8 @@ class TDTestCase: threads=[] for i in range(restartNumbers): dbNameIndex = '%s%d'%(paraDict["dbName"],i) - threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(tdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']))) + newTdSql=tdCom.newTdSql() + threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(newTdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']))) for tr in threads: tr.start() diff --git a/tests/system-test/6-cluster/clusterCommonCheck.py b/tests/system-test/6-cluster/clusterCommonCheck.py index 2d378e623d..cde09b4c58 100644 --- a/tests/system-test/6-cluster/clusterCommonCheck.py +++ b/tests/system-test/6-cluster/clusterCommonCheck.py @@ -39,6 +39,7 @@ class ClusterComCheck: def checkDnodes(self,dnodeNumbers): count=0 + # print(tdSql) while count < 5: tdSql.query("show dnodes") # tdLog.debug(tdSql.queryResult) @@ -85,7 +86,7 @@ class ClusterComCheck: tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j)) else: continue - print(query_status) + # print(query_status) count+=1 if query_status == dbNumbers: tdLog.success("we find cluster with %d dnode and check all databases are ready within 5s! " %dbNumbers) diff --git a/tests/system-test/6-cluster/clusterCommonCreate.py b/tests/system-test/6-cluster/clusterCommonCreate.py index 78aac309a0..9d3f74a2e3 100644 --- a/tests/system-test/6-cluster/clusterCommonCreate.py +++ b/tests/system-test/6-cluster/clusterCommonCreate.py @@ -125,7 +125,6 @@ class ClusterComCreate: def create_databases(self,tsql,dbNameIndex,dbNumbers,dropFlag=1,vgroups=4,replica=1): for i in range(dbNumbers): - print(dbNumbers) if dropFlag == 1: tsql.execute("drop database if exists %s_%d"%(dbNameIndex,i)) tsql.execute("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,i, vgroups, replica)) diff --git a/tests/system-test/7-tmq/stbFilter.py b/tests/system-test/7-tmq/stbFilter.py index 542894574b..7383d5b692 100644 --- a/tests/system-test/7-tmq/stbFilter.py +++ b/tests/system-test/7-tmq/stbFilter.py @@ -122,9 +122,9 @@ class TDTestCase: tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - # if expectRowsList[2] != resultList[0]: - # tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) - # tdLog.exit("2 tmq consume rows error!") + if expectRowsList[2] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) + tdLog.exit("2 tmq consume rows error!") time.sleep(10) for i in range(len(topicNameList)): diff --git a/tests/system-test/7-tmq/subscribeDb2.py b/tests/system-test/7-tmq/subscribeDb2.py index af31e802b3..78aaa2634c 100644 --- a/tests/system-test/7-tmq/subscribeDb2.py +++ b/tests/system-test/7-tmq/subscribeDb2.py @@ -5,6 +5,7 @@ import time import socket import os import threading +import math from util.log import * from util.sql import * @@ -127,10 +128,14 @@ class TDTestCase: #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) + batchRows = 0 for j in range(rowsPerTbl): sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) - if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + batchRows += 1 + # if (j > 0) and ((j%(batchNum-1) == 0) or (j == rowsPerTbl - 1)): + if (j > 0) and ((batchRows == batchNum) or (j == rowsPerTbl - 1)): tsql.execute(sql) + batchRows = 0 if j < rowsPerTbl - 1: sql = "insert into %s_%d values " %(stbName,i) else: @@ -171,8 +176,8 @@ class TDTestCase: 'dbName': 'db8', \ 'vgroups': 4, \ 'stbName': 'stb', \ - 'ctbNum': 10, \ - 'rowsPerTbl': 10000, \ + 'ctbNum': 1, \ + 'rowsPerTbl': 1000, \ 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath @@ -189,7 +194,7 @@ class TDTestCase: tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 - expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2 + expectrowcnt = math.ceil(parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2) topicList = topicName1 ifcheckdata = 0 ifManualCommit = 0 @@ -217,7 +222,7 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt: + if not (totalConsumeRows >= expectrowcnt): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -267,7 +272,7 @@ class TDTestCase: tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 - expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2 + expectrowcnt = math.ceil(parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2) topicList = topicName1 ifcheckdata = 0 ifManualCommit = 1 diff --git a/tests/system-test/7-tmq/subscribeDb4.py b/tests/system-test/7-tmq/subscribeDb4.py index de475803fe..b99704b602 100644 --- a/tests/system-test/7-tmq/subscribeDb4.py +++ b/tests/system-test/7-tmq/subscribeDb4.py @@ -14,19 +14,24 @@ sys.path.append("./7-tmq") from tmqCommon import * class TDTestCase: - paraDict = {'dbName': 'db12', - 'dropFlag':1, - 'vgroups': 4, - 'precision': 'ms', - 'stbName': 'stb0', - 'ctbNum': 10, + paraDict = {'dbName': 'db12', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb0', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':16, 'count':1}, {'type': 'timestamp','count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 10, 'rowsPerTbl': 10000, - 'batchNum': 10, - 'startTs': 0, # 1640966400000 ----> 2022-01-01 00:00:00.000 - 'event':'', - 'columnDict': {'int':2}, - 'tagDict': {'int':1} - } + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 20, + 'showMsg': 1, + 'showRow': 1} cdbName = 'cdb' # some parameter to consumer processor @@ -57,17 +62,18 @@ class TDTestCase: tmqCom.initConsumerTable(self.cdbName) - tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"], self.paraDict['precision']) + tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) self.paraDict["stbName"] = 'stb1' - tdCom.create_stable(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["columnDict"],self.paraDict["tagDict"]) - tdCom.create_ctables(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["ctbNum"],self.paraDict["tagDict"]) - tdCom.insert_data(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"]) + tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) + tdCom.create_ctable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],tag_elm_list=self.paraDict['tagSchema'],count=self.paraDict["ctbNum"],default_ctbname_prefix=self.paraDict["ctbPrefix"]) + tmqCom.insert_data_2(tdSql,self.paraDict["dbName"],self.paraDict["ctbPrefix"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"],self.paraDict["startTs"],self.paraDict["ctbStartIdx"]) self.paraDict["stbName"] = 'stb2' - tdCom.create_stable(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["columnDict"],self.paraDict["tagDict"]) - tdCom.create_ctables(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["ctbNum"],self.paraDict["tagDict"]) - tdCom.insert_data(tdSql,self.paraDict["dbName"],self.paraDict["stbName"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"]) + self.paraDict["ctbPrefix"] = 'newctb' + tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) + tdCom.create_ctable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],tag_elm_list=self.paraDict['tagSchema'],count=self.paraDict["ctbNum"],default_ctbname_prefix=self.paraDict["ctbPrefix"]) + tmqCom.insert_data_2(tdSql,self.paraDict["dbName"],self.paraDict["ctbPrefix"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"],self.paraDict["startTs"],self.paraDict["ctbStartIdx"]) tdLog.info("create topics from db") topicName1 = 'topic_%s'%(self.paraDict['dbName']) @@ -97,7 +103,7 @@ class TDTestCase: tdLog.info("act consume rows: %d, expect consume rows: between %d and %d"%(totalConsumeRows, self.expectrowcnt/2, self.expectrowcnt)) tdLog.exit("tmq consume rows error!") - time.sleep(15) + time.sleep(10) tdSql.query("drop topic %s"%topicName1) tdLog.printNoPrefix("======== test case 12 end ...... ") diff --git a/tests/system-test/7-tmq/tmqAlterSchema.py b/tests/system-test/7-tmq/tmqAlterSchema.py new file mode 100644 index 0000000000..a2e20990d9 --- /dev/null +++ b/tests/system-test/7-tmq/tmqAlterSchema.py @@ -0,0 +1,259 @@ + +from ntpath import join +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +from util.cluster import * + +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.dnodes = 5 + self.mnodes = 3 + self.idIndex = 0 + self.roleIndex = 2 + self.mnodeStatusIndex = 3 + self.mnodeEpIndex = 1 + self.dnodeStatusIndex = 4 + self.mnodeCheckCnt = 10 + self.host = socket.gethostname() + self.startPort = 6030 + self.portStep = 100 + self.dnodeOfLeader = 0 + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: topic: select * from stb, while consume, add column int-A/bianry-B/float-C, and then modify B, drop C") + tdLog.printNoPrefix("add tag int-A/bianry-B/float-C, and then rename A, modify B, drop C, set t2") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}, {'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1'] + expectRowsList = [] + queryStringList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + # tdLog.info("async insert data") + # pThread = tmqCom.asyncInsertData(paraDict) + tmqCom.insert_data_2(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"],paraDict["ctbStartIdx"]) + + tdLog.info("create topics from stb with filter") + queryStringList.append("select * from %s.%s" %(paraDict['dbName'], paraDict['stbName'])) + sqlString = "create topic %s as %s" %(topicNameList[0], queryStringList[0]) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + dstFile = tmqCom.getResultFileByTaosShell(consumerId, queryStringList[0]) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the notify info of start consume, then alter schema") + tmqCom.getStartConsumeNotifyFromTmqsim() + + # add column double-A/bianry-B/double-C, and then modify B, drop C + sqlString = "alter table %s.%s add column newc1 double"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add column newc2 binary(16)"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add column newc3 double"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s modify column newc2 binary(32)"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s drop column newc3"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + # add tag double-A/bianry-B/double-C, and then rename A, modify B, drop C, set t1 + sqlString = "alter table %s.%s add tag newt1 double"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add tag newt2 binary(16)"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add tag newt3 double"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s rename tag newt1 newt1n"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s modify tag newt2 binary(32)"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s drop tag newt3"%(paraDict["dbName"],paraDict['stbName']) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s0 set tag newt2='new tag'"%(paraDict["dbName"],paraDict['ctbPrefix']) + tdSql.execute(sqlString) + + tdLog.info("check the consume result") + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + tdLog.info("expect consume rows: %d"%(expectRowsList[0])) + tdLog.info("act consume rows: %d"%(resultList[0])) + + if expectRowsList[0] != resultList[0]: + tdLog.exit("0 tmq consume rows error!") + + tmqCom.checkTmqConsumeFileContent(consumerId, dstFile) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self): + tdLog.printNoPrefix("======== test case 2: topic: select * from ntb, while consume, add column int-A/bianry-B/float-C, and then rename A, modify B, drop C") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':2}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + ntbName = 'ntb' + + topicNameList = ['topic1'] + expectRowsList = [] + queryStringList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ntb") + tdCom.create_table(tdSql, dbname=paraDict["dbName"],tbname=ntbName,column_elm_list=paraDict['colSchema'],count=1) + tdLog.info("start insert data ....") + # pThread = tmqCom.asyncInsertData(paraDict) + tdCom.insert_rows(tdSql, dbname=paraDict["dbName"], tbname=ntbName, column_ele_list=paraDict['colSchema'], start_ts_value=paraDict["startTs"], count=paraDict["rowsPerTbl"]) + tdLog.info("insert data end") + + tdLog.info("create topics from ntb with filter") + queryStringList.append("select * from %s.%s" %(paraDict['dbName'], ntbName)) + sqlString = "create topic %s as %s" %(topicNameList[0], queryStringList[0]) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + dstFile = tmqCom.getResultFileByTaosShell(consumerId, queryStringList[0]) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the notify info of start consume, then alter schema") + tmqCom.getStartConsumeNotifyFromTmqsim() + + # add column double-A/bianry-B/double-C, and then rename A, modify B, drop C + sqlString = "alter table %s.%s add column newc1 double"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add column newc2 binary(16)"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s add column newc3 double"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s rename column newc1 newc1n"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s modify column newc2 binary(32)"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + sqlString = "alter table %s.%s drop column newc3"%(paraDict["dbName"],ntbName) + tdSql.execute(sqlString) + + tdLog.info("check the consume result") + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + tdLog.info("expect consume rows: %d"%(expectRowsList[0])) + tdLog.info("act consume rows: %d"%(resultList[0])) + + if expectRowsList[0] != resultList[0]: + tdLog.exit("0 tmq consume rows error!") + + tmqCom.checkTmqConsumeFileContent(consumerId, dstFile) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def run(self): + self.tmqCase1() + self.tmqCase2() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 9254f57c40..f8488aee49 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -76,8 +76,24 @@ class TMQCom: resultList.append(tdSql.getData(i , 3)) return resultList + + def selectConsumeMsgResult(self,expectRows,cdbName='cdb'): + resultList=[] + while 1: + tdSql.query("select * from %s.consumeresult"%cdbName) + #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) + if tdSql.getRows() == expectRows: + break + else: + time.sleep(5) + + for i in range(expectRows): + tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) + resultList.append(tdSql.getData(i , 2)) + + return resultList - def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0,alias=0): + def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0,alias=0,snapshot=0): buildPath = tdCom.getBuildPath() cfgPath = tdCom.getClientCfgPath() if valgrind == 1: @@ -93,7 +109,7 @@ class TMQCom: os.system(shellCmd) processorName = processorNameNew shellCmd = 'mintty -h never ' + processorName + ' -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) shellCmd += "> nul 2>&1 &" else: processorName = buildPath + '/build/bin/tmq_sim' @@ -103,7 +119,7 @@ class TMQCom: os.system(shellCmd) processorName = processorNameNew shellCmd = 'nohup ' + processorName + ' -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -367,6 +383,69 @@ class TMQCom: pThread.start() return pThread + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + lines = 0 + while True: + dst = queryFile.readline() + src = consumeFile.readline() + lines += 1 + if dst: + if dst != src: + tdLog.info("src row: %s"%src) + tdLog.info("dst row: %s"%dst) + tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines)) + else: + break + return + + def getResultFileByTaosShell(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + return dstFile + + def checkTmqConsumeFileContent(self, consumerId, dstFile): + cfgPath = tdCom.getClientCfgPath() + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + lines = 0 + while True: + dst = queryFile.readline() + src = consumeFile.readline() + lines += 1 + if dst: + if dst != src: + tdLog.info("src row: %s"%src) + tdLog.info("dst row: %s"%dst) + tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines)) + else: + break + return + def close(self): self.cursor.close() diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb.py b/tests/system-test/7-tmq/tmqConsFromTsdb.py new file mode 100644 index 0000000000..64f09f4a17 --- /dev/null +++ b/tests/system-test/7-tmq/tmqConsFromTsdb.py @@ -0,0 +1,393 @@ + +import taos +import sys +import time +import socket +import os +import threading +import math + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.vgroups = 1 + self.ctbNum = 10 + self.rowsPerTbl = 10000 + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 3, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("insert data") + tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info("create topics from stb with filter") + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + tmqCom.checkFileContent(consumerId, queryString) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self): + tdLog.printNoPrefix("======== test case 2: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 3, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + # tdLog.info("create stb") + # tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + # tdLog.info("create ctb") + # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + # tdLog.info("insert data") + # tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + # tdDnodes.stop(1) + # tdDnodes.start(1) + + tdLog.info("create topics from stb with filter") + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + totalRowsInserted = expectRowsList[0] + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 1 + expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] / 3) + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 0") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): + tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + firstConsumeRows = resultList[0] + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 2 + expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 1") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + actConsumeTotalRows = firstConsumeRows + resultList[0] + + if not (expectrowcnt >= resultList[0] and totalRowsInserted == actConsumeTotalRows): + tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) + tdLog.info("and sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def tmqCase3(self): + tdLog.printNoPrefix("======== test case 3: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + # tdLog.info("create stb") + # tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + # tdLog.info("create ctb") + # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + # tdLog.info("insert data") + # tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + # tdDnodes.stop(1) + # tdDnodes.start(1) + + tdLog.info("create topics from stb with filter") + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + totalRowsInserted = expectRowsList[0] + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 3 + expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] / 3) + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + consumerId = 4 + expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 0") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + expectRows = 2 + resultList = tmqCom.selectConsumeResult(expectRows) + actConsumeTotalRows = resultList[0] + resultList[1] + + if not (totalRowsInserted == actConsumeTotalRows): + tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 3 end ...... ") + + def tmqCase4(self): + tdLog.printNoPrefix("======== test case 4: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + # tdLog.info("create stb") + # tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + # tdLog.info("create ctb") + # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + # tdLog.info("insert data") + # tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + # tdDnodes.stop(1) + # tdDnodes.start(1) + + tdLog.info("create topics from stb with filter") + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + totalRowsInserted = expectRowsList[0] + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 5 + expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 0") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + tdLog.info("wait commit notify") + tmqCom.getStartCommitNotifyFromTmqsim() + + tdLog.info("pkill consume processor") + tdCom.killProcessor("tmq_sim") + + # time.sleep(10) + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 6 + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 1") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + actConsumeTotalRows = resultList[0] + + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 4 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + self.tmqCase2() + self.tmqCase3() + self.tmqCase4() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index f6dfe95f45..957ee17e0b 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -121,7 +121,7 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 -# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3 @@ -136,6 +136,7 @@ python3 ./test.py -f 7-tmq/subscribeDb0.py python3 ./test.py -f 7-tmq/subscribeDb1.py python3 ./test.py -f 7-tmq/subscribeDb2.py python3 ./test.py -f 7-tmq/subscribeDb3.py +#python3 ./test.py -f 7-tmq/subscribeDb4.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 @@ -152,3 +153,4 @@ python3 ./test.py -f 7-tmq/tmqUdf.py #python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 python3 ./test.py -f 7-tmq/tmqConsumerGroup.py python3 ./test.py -f 7-tmq/tmqShow.py +python3 ./test.py -f 7-tmq/tmqAlterSchema.py diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 81fa72d15a..a333e6ea5e 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -36,7 +36,12 @@ #define MAX_CONSUMER_THREAD_CNT (16) #define MAX_VGROUP_CNT (32) -typedef enum { NOTIFY_CMD_START_CONSUM, NOTIFY_CMD_START_COMMIT, NOTIFY_CMD_ID_BUTT } NOTIFY_CMD_ID; +int64_t now; +typedef enum { + NOTIFY_CMD_START_CONSUM, + NOTIFY_CMD_START_COMMIT, + NOTIFY_CMD_ID_BUTT, +} NOTIFY_CMD_ID; typedef struct { TdThread thread; @@ -124,15 +129,13 @@ char* getCurrentTimeString(char* timeString) { return timeString; } -static void tmqStop(int signum, void *info, void *ctx) { +static void tmqStop(int signum, void* info, void* ctx) { running = 0; char tmpString[128]; - taosFprintfFile(g_fp, "%s tmqStop() receive stop signal[%d]\n", getCurrentTimeString(tmpString), signum); + taosFprintfFile(g_fp, "%s tmqStop() receive stop signal[%d]\n", getCurrentTimeString(tmpString), signum); } -static void tmqSetSignalHandle() { - taosSetSignal(SIGINT, tmqStop); -} +static void tmqSetSignalHandle() { taosSetSignal(SIGINT, tmqStop); } void initLogFile() { char filename[256]; @@ -433,7 +436,7 @@ static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields int32_t precision) { for (int32_t i = 0; i < num_fields; i++) { if (i > 0) { - taosFprintfFile(pFile, "\n"); + taosFprintfFile(pFile, ","); } shellDumpFieldToFile(pFile, (const char*)row[i], fields + i, length[i], precision); } @@ -463,16 +466,16 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex) int32_t precision = taos_result_precision(msg); const char* tbName = tmq_get_table_name(msg); - #if 0 +#if 0 // get schema //============================== stub =================================================// for (int32_t i = 0; i < numOfFields; i++) { taosFprintfFile(g_fp, "%02d: name: %s, type: %d, len: %d\n", i, fields[i].name, fields[i].type, fields[i].bytes); } //============================== stub =================================================// - #endif +#endif - dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); + dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); taos_print_row(buf, row, fields, numOfFields); @@ -529,7 +532,7 @@ static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { g_once_commit_flag = 1; notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); } - + char tmpString[128]; taosFprintfFile(g_fp, "%s tmq_commit_cb_print() be called\n", getCurrentTimeString(tmpString)); } @@ -565,7 +568,7 @@ void build_consumer(SThreadInfo* pInfo) { // tmq_conf_set(conf, "auto.offset.reset", "latest"); // if (g_stConfInfo.useSnapshot) { - tmq_conf_set(conf, "experiment.use.snapshot", "true"); + tmq_conf_set(conf, "experimental.snapshot.enable", "true"); } pInfo->tmq = tmq_consumer_new(conf, NULL, 0); @@ -586,12 +589,10 @@ void build_topic_list(SThreadInfo* pInfo) { int32_t saveConsumeResult(SThreadInfo* pInfo) { char sqlStr[1024] = {0}; - - int64_t now = taosGetTimestampMs(); - // schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int sprintf(sqlStr, "insert into %s.consumeresult values (%" PRId64 ", %d, %" PRId64 ", %" PRId64 ", %d)", - g_stConfInfo.cdbName, now, pInfo->consumerId, pInfo->consumeMsgCnt, pInfo->consumeRowCnt, pInfo->checkresult); + g_stConfInfo.cdbName, atomic_fetch_add_64(&now, 1), pInfo->consumerId, pInfo->consumeMsgCnt, + pInfo->consumeRowCnt, pInfo->checkresult); char tmpString[128]; taosFprintfFile(g_fp, "%s, consume id %d result: %s\n", getCurrentTimeString(tmpString), pInfo->consumerId, sqlStr); @@ -635,6 +636,10 @@ void loop_consume(SThreadInfo* pInfo) { } } + int64_t lastTotalMsgs = 0; + uint64_t lastPrintTime = taosGetTimestampMs(); + uint64_t startTs = taosGetTimestampMs(); + int32_t consumeDelay = g_stConfInfo.consumeDelay == -1 ? -1 : (g_stConfInfo.consumeDelay * 1000); while (running) { TAOS_RES* tmqMsg = tmq_consumer_poll(pInfo->tmq, consumeDelay); @@ -647,12 +652,21 @@ void loop_consume(SThreadInfo* pInfo) { totalMsgs++; + int64_t currentPrintTime = taosGetTimestampMs(); + if (currentPrintTime - lastPrintTime > 10 * 1000) { + taosFprintfFile( + g_fp, "consumer id %d has currently poll total msgs: %" PRId64 ", period rate: %.3f msgs/second\n", + pInfo->consumerId, totalMsgs, (totalMsgs - lastTotalMsgs) * 1000.0 / (currentPrintTime - lastPrintTime)); + lastPrintTime = currentPrintTime; + lastTotalMsgs = totalMsgs; + } + if (0 == once_flag) { once_flag = 1; notifyMainScript(pInfo, NOTIFY_CMD_START_CONSUM); } - if (totalRows >= pInfo->expectMsgCnt) { + if ((totalRows >= pInfo->expectMsgCnt) || (totalMsgs >= pInfo->expectMsgCnt)) { char tmpString[128]; taosFprintfFile(g_fp, "%s over than expect rows, so break consume\n", getCurrentTimeString(tmpString)); break; @@ -676,20 +690,19 @@ void loop_consume(SThreadInfo* pInfo) { } void* consumeThreadFunc(void* param) { - int32_t totalMsgs = 0; - SThreadInfo* pInfo = (SThreadInfo*)param; pInfo->taos = taos_connect(NULL, "root", "taosdata", NULL, 0); if (pInfo->taos == NULL) { taosFprintfFile(g_fp, "taos_connect() fail, can not notify and save consume result to main scripte\n"); - return NULL; + ASSERT(0); + return NULL; } build_consumer(pInfo); build_topic_list(pInfo); if ((NULL == pInfo->tmq) || (NULL == pInfo->topicList)) { - taosFprintfFile(g_fp, "create consumer fail! tmq is null or topicList is null\n"); + taosFprintfFile(g_fp, "create consumer fail! tmq is null or topicList is null\n"); assert(0); return NULL; } @@ -697,7 +710,7 @@ void* consumeThreadFunc(void* param) { int32_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList); if (err != 0) { pError("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err)); - taosFprintfFile(g_fp, "tmq_subscribe() fail! reason: %s\n", tmq_err2str(err)); + taosFprintfFile(g_fp, "tmq_subscribe() fail! reason: %s\n", tmq_err2str(err)); assert(0); return NULL; } @@ -718,13 +731,13 @@ void* consumeThreadFunc(void* param) { err = tmq_unsubscribe(pInfo->tmq); if (err != 0) { pError("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err)); - taosFprintfFile(g_fp, "tmq_unsubscribe()! reason: %s\n", tmq_err2str(err)); + taosFprintfFile(g_fp, "tmq_unsubscribe()! reason: %s\n", tmq_err2str(err)); } err = tmq_consumer_close(pInfo->tmq); if (err != 0) { pError("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err)); - taosFprintfFile(g_fp, "tmq_consumer_close()! reason: %s\n", tmq_err2str(err)); + taosFprintfFile(g_fp, "tmq_consumer_close()! reason: %s\n", tmq_err2str(err)); } pInfo->tmq = NULL; @@ -842,6 +855,8 @@ int32_t getConsumeInfo() { } int main(int32_t argc, char* argv[]) { + now = taosGetTimestampMs(); + parseArgument(argc, argv); getConsumeInfo(); saveConfigToLogFile(); @@ -859,16 +874,30 @@ int main(int32_t argc, char* argv[]) { (void*)(&(g_stConfInfo.stThreads[i]))); } + int64_t start = taosGetTimestampUs(); + for (int32_t i = 0; i < g_stConfInfo.numOfThread; i++) { taosThreadJoin(g_stConfInfo.stThreads[i].thread, NULL); taosThreadClear(&g_stConfInfo.stThreads[i].thread); } - // printf("consumer: %d, cosumer1: %d\n", totalMsgs, pInfo->consumeMsgCnt); + int64_t end = taosGetTimestampUs(); + + int64_t totalMsgs = 0; + for (int32_t i = 0; i < g_stConfInfo.numOfThread; i++) { + totalMsgs += g_stConfInfo.stThreads[i].consumeMsgCnt; + } + + int64_t t = end - start; + if (0 == t) t = 1; + + double tInMs = (double)t / 1000000.0; + taosFprintfFile(g_fp, + "Spent %.3f seconds to poll msgs: %" PRIu64 " with %d thread(s), throughput: %.3f msgs/second\n\n", + tInMs, totalMsgs, g_stConfInfo.numOfThread, (double)(totalMsgs / tInMs)); taosFprintfFile(g_fp, "==== close tmqlog ====\n"); taosCloseFile(&g_fp); return 0; } - diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index 9cb3541017..cc1171b3df 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -482,6 +482,7 @@ int32_t shellReadCommand(char *command) { #endif break; case 4: // EOF or Ctrl+D + taosResetTerminalMode(); printf("\n"); return -1; case 5: // ctrl E diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 7b275c5a15..96d017ec7a 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -364,7 +364,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) { int32_t *length = taos_fetch_lengths(tres); for (int32_t i = 0; i < num_fields; i++) { if (i > 0) { - taosFprintfFile(pFile, "\n"); + taosFprintfFile(pFile, ","); } shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision); } @@ -394,9 +394,9 @@ void shellPrintNChar(const char *str, int32_t length, int32_t width) { break; } int w = 0; - if(*(str + pos) == '\t' || *(str + pos) == '\n' || *(str + pos) == '\r'){ + if (*(str + pos) == '\t' || *(str + pos) == '\n' || *(str + pos) == '\r') { w = bytes; - }else{ + } else { w = taosWcharWidth(wc); } pos += bytes; @@ -513,7 +513,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t } bool shellIsLimitQuery(const char *sql) { - //todo refactor + // todo refactor if (taosStrCaseStr(sql, " limit ") != NULL) { return true; } @@ -522,7 +522,7 @@ bool shellIsLimitQuery(const char *sql) { } bool shellIsShowQuery(const char *sql) { - //todo refactor + // todo refactor if (taosStrCaseStr(sql, "show ") != NULL) { return true; } @@ -530,7 +530,6 @@ bool shellIsShowQuery(const char *sql) { return false; } - int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) { TAOS_ROW row = taos_fetch_row(tres); if (row == NULL) { diff --git a/tools/taos-tools b/tools/taos-tools index 7105027650..5fdd694621 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit 7105027650b51e701cfa1dac11b8fb42d447dd01 +Subproject commit 5fdd694621fbb7bd2d6102ff4feaec92a7001038