diff --git a/cmake/cmake.version b/cmake/cmake.version index 42de285c8ee..5150ee3b75e 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.3.1") + SET(TD_VER_NUMBER "3.0.3.2") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 1c401ae80e0..b2f335e1f7b 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG d8059ff + GIT_TAG cb1e89c SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 40fa48b8154..0110b27b325 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 2864326 + GIT_TAG 149ac34 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/07-develop/07-tmq.mdx b/docs/en/07-develop/07-tmq.mdx index c85109d3c5b..dc0f07d3d51 100644 --- a/docs/en/07-develop/07-tmq.mdx +++ b/docs/en/07-develop/07-tmq.mdx @@ -293,7 +293,6 @@ You configure the following parameters when creating a consumer: | `auto.offset.reset` | enum | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) | | `enable.auto.commit` | boolean | Commit automatically | Specify `true` or `false`. | | `auto.commit.interval.ms` | integer | Interval for automatic commits, in milliseconds | -| `enable.heartbeat.background` | boolean | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | | | `experimental.snapshot.enable` | boolean | Specify whether to consume messages from the WAL or from TSBS | | | `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages | @@ -368,7 +367,6 @@ conf := &tmq.ConfigMap{ "td.connect.port": "6030", "client.id": "test_tmq_c", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", } @@ -418,7 +416,6 @@ Python programs use the following parameters: | `auto.commit.interval.ms` | string | Interval for automatic commits, in milliseconds | | | `auto.offset.reset` | string | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) | | `experimental.snapshot.enable` | string | Specify whether to consume messages from the WAL or from TSDB | Specify `true` or `false` | -| `enable.heartbeat.background` | string | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | Specify `true` or `false` | diff --git a/docs/examples/go/sub/main.go b/docs/examples/go/sub/main.go index 1f7218936fb..334b8f290bd 100644 --- a/docs/examples/go/sub/main.go +++ b/docs/examples/go/sub/main.go @@ -35,7 +35,6 @@ func main() { "td.connect.port": "6030", "client.id": "test_tmq_client", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", }) diff --git a/docs/zh/07-develop/07-tmq.mdx b/docs/zh/07-develop/07-tmq.mdx index fb171042d97..5771e5053aa 100644 --- a/docs/zh/07-develop/07-tmq.mdx +++ b/docs/zh/07-develop/07-tmq.mdx @@ -291,7 +291,6 @@ CREATE TOPIC topic_name AS DATABASE db_name; | `auto.offset.reset` | enum | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` | | `enable.auto.commit` | boolean | 是否启用消费位点自动提交 | 合法值:`true`, `false`。 | | `auto.commit.interval.ms` | integer | 以毫秒为单位的消费记录自动提交消费位点时间间 | 默认 5000 m | -| `enable.heartbeat.background` | boolean | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 默认开启 | | `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据 | 实验功能,默认关闭 | | `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) | | @@ -366,7 +365,6 @@ conf := &tmq.ConfigMap{ "td.connect.port": "6030", "client.id": "test_tmq_c", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", } @@ -418,7 +416,6 @@ consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"}) | `auto.commit.interval.ms` | string | 以毫秒为单位的自动提交时间间隔 | 默认值:5000 ms | | `auto.offset.reset` | string | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` | | `experimental.snapshot.enable` | string | 是否允许从 TSDB 消费数据 | 合法值:`true`, `false` | -| `enable.heartbeat.background` | string | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 合法值:`true`, `false` | diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 9e928a79ac7..a97c68be492 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -185,7 +185,7 @@ typedef struct SBlockID { typedef struct SDataBlockInfo { STimeWindow window; int32_t rowSize; - int32_t rows; // todo hide this attribute + int64_t rows; // todo hide this attribute uint32_t capacity; SBlockID id; int16_t hasVarCol; @@ -208,15 +208,12 @@ typedef struct SSDataBlock { } SSDataBlock; enum { - FETCH_TYPE__DATA = 1, - FETCH_TYPE__META, - FETCH_TYPE__SEP, + FETCH_TYPE__DATA = 0, FETCH_TYPE__NONE, }; typedef struct { int8_t fetchType; - STqOffsetVal offset; union { SSDataBlock data; void* meta; diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 84d696e518c..99fffa2cf1d 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -178,7 +178,7 @@ int32_t getJsonValueLen(const char* data); int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull); int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull); -int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows); +int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue); int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource, int32_t numOfRow2); int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows, diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index eca8740d286..9b709272b2f 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -34,7 +34,7 @@ typedef enum { WRITE_QUEUE, APPLY_QUEUE, SYNC_QUEUE, - SYNC_CTRL_QUEUE, + SYNC_RD_QUEUE, STREAM_QUEUE, QUEUE_MAX, } EQueueType; diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 46ca814e50a..96d18d1abc6 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -259,7 +259,7 @@ enum { TD_NEW_MSG_SEG(TDMT_SYNC_MSG) TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL) // no longer used + TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT_ELECTION, "sync-elect", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL) // no longer used 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) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 2e4a135f549..57af6ad9272 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -127,24 +127,24 @@ #define TK_NK_EQ 109 #define TK_USING 110 #define TK_TAGS 111 -#define TK_COMMENT 112 -#define TK_BOOL 113 -#define TK_TINYINT 114 -#define TK_SMALLINT 115 -#define TK_INT 116 -#define TK_INTEGER 117 -#define TK_BIGINT 118 -#define TK_FLOAT 119 -#define TK_DOUBLE 120 -#define TK_BINARY 121 -#define TK_NCHAR 122 -#define TK_UNSIGNED 123 -#define TK_JSON 124 -#define TK_VARCHAR 125 -#define TK_MEDIUMBLOB 126 -#define TK_BLOB 127 -#define TK_VARBINARY 128 -#define TK_DECIMAL 129 +#define TK_BOOL 112 +#define TK_TINYINT 113 +#define TK_SMALLINT 114 +#define TK_INT 115 +#define TK_INTEGER 116 +#define TK_BIGINT 117 +#define TK_FLOAT 118 +#define TK_DOUBLE 119 +#define TK_BINARY 120 +#define TK_NCHAR 121 +#define TK_UNSIGNED 122 +#define TK_JSON 123 +#define TK_VARCHAR 124 +#define TK_MEDIUMBLOB 125 +#define TK_BLOB 126 +#define TK_VARBINARY 127 +#define TK_DECIMAL 128 +#define TK_COMMENT 129 #define TK_MAX_DELAY 130 #define TK_WATERMARK 131 #define TK_ROLLUP 132 diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 19a6407b777..33172a4f868 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -78,7 +78,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v * @param SReadHandle * @return */ -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, SSchemaWrapper** pSchema); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, uint64_t id); /** * set the task Id, usually used by message queue process @@ -89,6 +89,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3 void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId); int32_t qSetStreamOpOpen(qTaskInfo_t tinfo); + /** * Set multiple input data blocks for the stream scan. * @param tinfo @@ -197,11 +198,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT // int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit); -int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); +void qStreamSetOpen(qTaskInfo_t tinfo); -SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); +void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); -int64_t qStreamExtractPrepareUid(qTaskInfo_t tinfo); +SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); const SSchemaWrapper* qExtractSchemaFromTask(qTaskInfo_t tinfo); diff --git a/include/libs/function/function.h b/include/libs/function/function.h index fb6ef26a8ac..aa5c78195af 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -112,7 +112,7 @@ typedef struct SResultDataInfo { typedef struct SInputColumnInfoData { int32_t totalRows; // total rows in current columnar data int32_t startRowIndex; // handle started row index - int32_t numOfRows; // the number of rows needs to be handled + int64_t numOfRows; // the number of rows needs to be handled int32_t numOfInputCols; // PTS is not included bool colDataSMAIsSet; // if agg is set or not SColumnInfoData *pPTS; // primary timestamp column diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 1a9700907ef..480912a8cfd 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -298,6 +298,7 @@ typedef struct SSelectStmt { bool hasUniqueFunc; bool hasTailFunc; bool hasInterpFunc; + bool hasInterpPseudoColFunc; bool hasLastRowFunc; bool hasLastFunc; bool hasTimeLineFunc; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index cb547ee6b37..b6ada5a0c7c 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -33,6 +33,7 @@ typedef enum { JOB_TASK_STATUS_INIT, JOB_TASK_STATUS_EXEC, JOB_TASK_STATUS_PART_SUCC, + JOB_TASK_STATUS_FETCH, JOB_TASK_STATUS_SUCC, JOB_TASK_STATUS_FAIL, JOB_TASK_STATUS_DROP, diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index 6b09bf4899b..fd5cec29316 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -23,20 +23,19 @@ extern "C" { #ifndef _STREAM_STATE_H_ #define _STREAM_STATE_H_ -typedef struct SStreamTask SStreamTask; - typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2); typedef struct STdbState { - SStreamTask* pOwner; - TDB* db; - TTB* pStateDb; - TTB* pFuncStateDb; - TTB* pFillStateDb; // todo refactor - TTB* pSessionStateDb; - TTB* pParNameDb; - TTB* pParTagDb; - TXN* txn; + struct SStreamTask* pOwner; + + TDB* db; + TTB* pStateDb; + TTB* pFuncStateDb; + TTB* pFillStateDb; // todo refactor + TTB* pSessionStateDb; + TTB* pParNameDb; + TTB* pParTagDb; + TXN* txn; } STdbState; // incremental state storage @@ -45,7 +44,7 @@ typedef struct { int32_t number; } SStreamState; -SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages); +SStreamState* streamStateOpen(char* path, struct SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages); void streamStateClose(SStreamState* pState); int32_t streamStateBegin(SStreamState* pState); int32_t streamStateCommit(SStreamState* pState); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 1d301623b1c..5b1d1fa1bcd 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -223,27 +223,12 @@ static FORCE_INLINE void* streamQueueCurItem(SStreamQueue* queue) { return queue->qItem; } -static FORCE_INLINE void* streamQueueNextItem(SStreamQueue* queue) { - int8_t dequeueFlag = atomic_exchange_8(&queue->status, STREAM_QUEUE__PROCESSING); - if (dequeueFlag == STREAM_QUEUE__FAILED) { - ASSERT(queue->qItem != NULL); - return streamQueueCurItem(queue); - } else { - queue->qItem = NULL; - taosGetQitem(queue->qall, &queue->qItem); - if (queue->qItem == NULL) { - taosReadAllQitems(queue->queue, queue->qall); - taosGetQitem(queue->qall, &queue->qItem); - } - return streamQueueCurItem(queue); - } -} +void* streamQueueNextItem(SStreamQueue* queue); SStreamDataSubmit2* streamDataSubmitNew(SPackedData submit); +void streamDataSubmitDestroy(SStreamDataSubmit2* pDataSubmit); -void streamDataSubmitRefDec(SStreamDataSubmit2* pDataSubmit); - -SStreamDataSubmit2* streamSubmitRefClone(SStreamDataSubmit2* pSubmit); +SStreamDataSubmit2* streamSubmitBlockClone(SStreamDataSubmit2* pSubmit); typedef struct { char* qmsg; @@ -295,7 +280,7 @@ typedef struct { SEpSet epSet; } SStreamChildEpInfo; -typedef struct SStreamTask { +struct SStreamTask { int64_t streamId; int32_t taskId; int32_t totalLevel; @@ -362,8 +347,7 @@ typedef struct SStreamTask { int64_t checkpointingId; int32_t checkpointAlignCnt; - -} SStreamTask; +}; int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo); int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo); @@ -372,43 +356,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId); int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask); int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask); void tFreeSStreamTask(SStreamTask* pTask); - -static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) { - int8_t type = pItem->type; - if (type == STREAM_INPUT__DATA_SUBMIT) { - SStreamDataSubmit2* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit2*)pItem); - if (pSubmitClone == NULL) { - qDebug("task %d %p submit enqueue failed since out of memory", pTask->taskId, pTask); - terrno = TSDB_CODE_OUT_OF_MEMORY; - atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED); - return -1; - } - qDebug("task %d %p submit enqueue %p %p %p %d %" PRId64, pTask->taskId, pTask, pItem, pSubmitClone, - pSubmitClone->submit.msgStr, pSubmitClone->submit.msgLen, pSubmitClone->submit.ver); - taosWriteQitem(pTask->inputQueue->queue, pSubmitClone); - // qStreamInput(pTask->exec.executor, pSubmitClone); - } else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE || - type == STREAM_INPUT__REF_DATA_BLOCK) { - taosWriteQitem(pTask->inputQueue->queue, pItem); - // qStreamInput(pTask->exec.executor, pItem); - } else if (type == STREAM_INPUT__CHECKPOINT) { - taosWriteQitem(pTask->inputQueue->queue, pItem); - // qStreamInput(pTask->exec.executor, pItem); - } else if (type == STREAM_INPUT__GET_RES) { - taosWriteQitem(pTask->inputQueue->queue, pItem); - // qStreamInput(pTask->exec.executor, pItem); - } - - if (type != STREAM_INPUT__GET_RES && type != STREAM_INPUT__CHECKPOINT && pTask->triggerParam != 0) { - atomic_val_compare_exchange_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__INACTIVE, TASK_TRIGGER_STATUS__ACTIVE); - } - -#if 0 - // TODO: back pressure - atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL); -#endif - return 0; -} +int32_t tAppendDataForStream(SStreamTask* pTask, SStreamQueueItem* pItem); static FORCE_INLINE void streamTaskInputFail(SStreamTask* pTask) { atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED); @@ -587,7 +535,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code); int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg); -int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); +// int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); int32_t streamTryExec(SStreamTask* pTask); int32_t streamSchedExec(SStreamTask* pTask); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 014ed518a39..ccbc53fa5d0 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -146,8 +146,8 @@ typedef struct { int64_t curFileFirstVer; int64_t curVersion; int64_t capacity; - int8_t curInvalid; - int8_t curStopped; +// int8_t curInvalid; +// int8_t curStopped; TdThreadMutex mutex; SWalFilterCond cond; // TODO remove it diff --git a/include/os/osDir.h b/include/os/osDir.h index 73871602c5e..55c7a15764c 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -31,21 +31,49 @@ extern "C" { #endif +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #ifdef WINDOWS + #define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\" +#ifdef CUS_NAME +#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\" +#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\" +#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\" +#else #define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\" #define TD_DATA_DIR_PATH "C:\\TDengine\\data\\" #define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" +#endif // CUS_NAME + #elif defined(_TD_DARWIN_64) + +#ifdef CUS_PROMPT +#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/" +#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/" +#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/" +#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/" +#else #define TD_TMP_DIR_PATH "/tmp/taosd/" #define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/" +#endif // CUS_PROMPT + #else + #define TD_TMP_DIR_PATH "/tmp/" +#ifdef CUS_PROMPT +#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/" +#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/" +#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/" +#else #define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/" +#endif // CUS_PROMPT #endif typedef struct TdDir *TdDirPtr; diff --git a/include/util/cus_name.h b/include/util/cus_name.h new file mode 100644 index 00000000000..16f677f855b --- /dev/null +++ b/include/util/cus_name.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _CUS_NAME_H_ +#define _CUS_NAME_H_ + +#ifndef CUS_NAME +#define CUS_NAME "TDengine" +#endif + +#ifndef CUS_PROMPT +#define CUS_PROMPT "taos" +#endif + +#ifndef CUS_EMAIL +#define CUS_EMAIL "" +#endif + +#endif // _CUS_NAME_H_ diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 56290547204..e5d63de031d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -759,6 +759,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TMQ_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x4000) #define TSDB_CODE_TMQ_CONSUMER_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x4001) #define TSDB_CODE_TMQ_CONSUMER_CLOSED TAOS_DEF_ERROR_CODE(0, 0x4002) +#define TSDB_CODE_TMQ_CONSUMER_ERROR TAOS_DEF_ERROR_CODE(0, 0x4003) // stream #define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100) diff --git a/include/util/tqueue.h b/include/util/tqueue.h index 1f6b205cdf8..d05b5418b37 100644 --- a/include/util/tqueue.h +++ b/include/util/tqueue.h @@ -61,7 +61,7 @@ typedef void (*FItems)(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfItems); typedef struct STaosQnode STaosQnode; -typedef struct STaosQnode { +struct STaosQnode { STaosQnode *next; STaosQueue *queue; int64_t timestamp; @@ -70,9 +70,9 @@ typedef struct STaosQnode { int8_t itype; int8_t reserved[3]; char item[]; -} STaosQnode; +}; -typedef struct STaosQueue { +struct STaosQueue { STaosQnode *head; STaosQnode *tail; STaosQueue *next; // for queue set @@ -84,22 +84,22 @@ typedef struct STaosQueue { int64_t memOfItems; int32_t numOfItems; int64_t threadId; -} STaosQueue; +}; -typedef struct STaosQset { +struct STaosQset { STaosQueue *head; STaosQueue *current; TdThreadMutex mutex; tsem_t sem; int32_t numOfQueues; int32_t numOfItems; -} STaosQset; +}; -typedef struct STaosQall { +struct STaosQall { STaosQnode *current; STaosQnode *start; int32_t numOfItems; -} STaosQall; +}; STaosQueue *taosOpenQueue(); void taosCloseQueue(STaosQueue *queue); diff --git a/include/util/tsimplehash.h b/include/util/tsimplehash.h index c9df9114763..987a9fe2a84 100644 --- a/include/util/tsimplehash.h +++ b/include/util/tsimplehash.h @@ -48,6 +48,13 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn); */ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj); +/** + * set the free function pointer + * @param pHashObj + * @param freeFp + */ +void tSimpleHashSetFreeFp(SSHashObj* pHashObj, _hash_free_fn_t freeFp); + int32_t tSimpleHashPrint(const SSHashObj *pHashObj); /** diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index a98dc5a2365..2159899aa27 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -1,7 +1,6 @@ ######################################################## # # # Configuration # -# Any questions, please email support@taosdata.com # # # ######################################################## @@ -13,7 +12,7 @@ ############### 1. Cluster End point ############################ -# The end point of the first dnode in the cluster to be connected to when this dnode or a CLI `taos` is started +# The end point of the first dnode in the cluster to be connected to when this dnode or the CLI utility is started # firstEp hostname:6030 # The end point of the second dnode to be connected to if the firstEp is not available @@ -25,7 +24,7 @@ # The FQDN of the host on which this dnode will be started. It can be IP address # fqdn hostname -# The port for external access after this dnode is started +# The port for external access after this dnode is started # serverPort 6030 # The maximum number of connections a dnode can accept @@ -96,7 +95,7 @@ # if free disk space is less than this value, this dnode will fail to start # minimalDataDirGB 2.0 -# enable/disable system monitor +# enable/disable system monitor # monitor 1 # The following parameter is used to limit the maximum number of lines in log files. @@ -114,8 +113,8 @@ # The following parameters are used for debug purpose only by this dnode. # debugFlag is a 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR -# Available debug levels are: -# 131: output warning and error +# Available debug levels are: +# 131: output warning and error # 135: output debug, warning and error # 143: output trace, debug, warning and error to log # 199: output debug, warning and error to both screen and file @@ -130,7 +129,7 @@ # debug flag for util # uDebugFlag 131 -# debug flag for rpc +# debug flag for rpc # rpcDebugFlag 131 # debug flag for jni @@ -139,7 +138,7 @@ # debug flag for query # qDebugFlag 131 -# debug flag for taosc driver +# debug flag for client driver # cDebugFlag 131 # debug flag for dnode messages diff --git a/packaging/cfg/taosd.service b/packaging/cfg/taosd.service index fff4b74e62a..52c4b1d1e2d 100644 --- a/packaging/cfg/taosd.service +++ b/packaging/cfg/taosd.service @@ -1,5 +1,5 @@ [Unit] -Description=TDengine server service +Description=server service After=network-online.target Wants=network-online.target diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index e9d86219cb6..c21063e6a42 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -90,45 +90,33 @@ cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepat cp -r %{_compiledir}/../examples/* %{buildroot}%{homepath}/examples if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then - mkdir -p %{buildroot}%{userlocalpath}/bin - mkdir -p %{buildroot}%{userlocalpath}/lib - mkdir -p %{buildroot}%{userlocalpath}/lib/pkgconfig - mkdir -p %{buildroot}%{userlocalpath}/include - mkdir -p %{buildroot}%{userlocalpath}/include/jemalloc - mkdir -p %{buildroot}%{userlocalpath}/share - mkdir -p %{buildroot}%{userlocalpath}/share/doc - mkdir -p %{buildroot}%{userlocalpath}/share/doc/jemalloc - mkdir -p %{buildroot}%{userlocalpath}/share/man - mkdir -p %{buildroot}%{userlocalpath}/share/man/man3 - - cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{userlocalpath}/bin/ + mkdir -p %{buildroot}%{homepath}/jemalloc/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/include/jemalloc/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/lib/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/lib/pkgconfig ||: + + cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{homepath}/jemalloc/bin if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then - cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{userlocalpath}/bin/ + cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{homepath}/jemalloc/bin fi if [ -f %{_compiledir}/build/bin/jeprof ]; then - cp %{_compiledir}/build/bin/jeprof %{buildroot}%{userlocalpath}/bin/ + cp %{_compiledir}/build/bin/jeprof %{buildroot}%{homepath}/jemalloc/bin fi if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then - cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{userlocalpath}/include/jemalloc/ + cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{homepath}/jemalloc/include/jemalloc/ fi if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then - cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/ - ln -sf libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/libjemalloc.so + cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib + ln -sf libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib/libjemalloc.so fi if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then - cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{userlocalpath}/lib/ + cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{homepath}/jemalloc/lib fi if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then - cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{userlocalpath}/lib/ + cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{homepath}/jemalloc/lib fi if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then - cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{userlocalpath}/lib/pkgconfig/ - fi - if [ -f %{_compiledir}/build/share/doc/jemalloc/jemalloc.html ]; then - cp %{_compiledir}/build/share/doc/jemalloc/jemalloc.html %{buildroot}%{userlocalpath}/share/doc/jemalloc/ - fi - if [ -f %{_compiledir}/build/share/man/man3/jemalloc.3 ]; then - cp %{_compiledir}/build/share/man/man3/jemalloc.3 %{buildroot}%{userlocalpath}/share/man/man3/ + cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig fi fi diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index a3f8b53d33d..63ea55cf828 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -4,7 +4,7 @@ # is required to use systemd to manage services at boot set -e -#set -x +# set -x verMode=edge pagMode=full @@ -34,21 +34,25 @@ benchmarkName="taosBenchmark" dumpName="taosdump" demoName="taosdemo" xname="taosx" -explorerName="${clientName}-explorer" clientName2="taos" -serverName2="taosd" +serverName2="${clientName2}d" +configFile2="${clientName2}.cfg" productName2="TDengine" emailName2="taosdata.com" +xname2="${clientName2}x" +adapterName2="${clientName2}adapter" +explorerName="${clientName2}-explorer" benchmarkName2="${clientName2}Benchmark" +demoName2="${clientName2}demo" dumpName2="${clientName2}dump" uninstallScript2="rm${clientName2}" historyFile="${clientName2}_history" logDir="/var/log/${clientName2}" configDir="/etc/${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" data_dir=${dataDir} log_dir=${logDir} @@ -206,15 +210,15 @@ function install_main_path() { function install_bin() { # Remove links - ${csudo}rm -f ${bin_link_dir}/${clientName} || : - ${csudo}rm -f ${bin_link_dir}/${serverName} || : + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${serverName2} || : ${csudo}rm -f ${bin_link_dir}/${udfdName} || : ${csudo}rm -f ${bin_link_dir}/${adapterName} || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : - ${csudo}rm -f ${bin_link_dir}/${demoName} || : - ${csudo}rm -f ${bin_link_dir}/${benchmarkName} || : - ${csudo}rm -f ${bin_link_dir}/${dumpName} || : - ${csudo}rm -f ${bin_link_dir}/${xname} || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${csudo}rm -f ${bin_link_dir}/${xname2} || : ${csudo}rm -f ${bin_link_dir}/${explorerName} || : ${csudo}rm -f ${bin_link_dir}/set_core || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : @@ -222,24 +226,23 @@ function install_bin() { ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : - [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : + [ -x ${install_main_dir}/bin/${clientName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName2} ${bin_link_dir}/${clientName2} || : + [ -x ${install_main_dir}/bin/${serverName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${serverName2} ${bin_link_dir}/${serverName2} || : [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : - [ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : - [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || : - [ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname} ${bin_link_dir}/${xname} || : + [ -x ${install_main_dir}/bin/${adapterName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${adapterName2} ${bin_link_dir}/${adapterName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${demoName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${benchmarkName2} || : + [ -x ${install_main_dir}/bin/${dumpName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName2} ${bin_link_dir}/${dumpName2} || : + [ -x ${install_main_dir}/bin/${xname2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname2} ${bin_link_dir}/${xname2} || : [ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || : [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + if [ "$clientName2" == "${clientName}" ]; then + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : + fi + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName2} || : - [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName2} || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : fi } @@ -399,7 +402,7 @@ function set_hostname() { ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || : fi - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile2} serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -433,7 +436,7 @@ function set_ipAsFqdn() { echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" localFqdn="127.0.0.1" # Write the local FQDN to configuration file - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} serverFqdn=$localFqdn echo return @@ -455,7 +458,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} serverFqdn=$localFqdn break fi @@ -519,15 +522,15 @@ function install_adapter_config() { function install_config() { - if [ ! -f "${cfg_install_dir}/${configFile}" ]; then + if [ ! -f "${cfg_install_dir}/${configFile2}" ]; then ${csudo}mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/${configFile} ] && ${csudo}cp ${script_dir}/cfg/${configFile} ${cfg_install_dir} + [ -f ${script_dir}/cfg/${configFile2} ] && ${csudo}cp ${script_dir}/cfg/${configFile2} ${cfg_install_dir} ${csudo}chmod 644 ${cfg_install_dir}/* else - ${csudo}cp -f ${script_dir}/cfg/${configFile} ${cfg_install_dir}/${configFile}.new + ${csudo}cp -f ${script_dir}/cfg/${configFile2} ${cfg_install_dir}/${configFile2}.new fi - ${csudo}ln -sf ${cfg_install_dir}/${configFile} ${install_main_dir}/cfg + ${csudo}ln -sf ${cfg_install_dir}/${configFile2} ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -548,7 +551,7 @@ function install_config() { read firstEp while true; do if [ ! -z "$firstEp" ]; then - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile2} break else break @@ -569,6 +572,20 @@ function install_config() { done } +function install_share_etc() { + for c in `ls ${script_dir}/share/etc/`; do + if [ -e /etc/$c ]; then + out=/etc/$c.new.`date +%F` + echo -e -n "${RED} /etc/$c exists, save a new cfg file as $out" + ${csudo}cp -f ${script_dir}/share/etc/$c $out + else + ${csudo}cp -f ${script_dir}/share/etc/$c /etc/$c + fi + done + + ${csudo} cp ${script_dir}/share/srv/* ${service_config_dir} +} + function install_log() { ${csudo}rm -rf ${log_dir} || : ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} @@ -600,8 +617,8 @@ function install_web() { function clean_service_on_sysvinit() { - if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then - ${csudo}service ${serverName} stop || : + if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then + ${csudo}service ${serverName2} stop || : fi if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then @@ -609,30 +626,30 @@ function clean_service_on_sysvinit() { fi if ((${initd_mod} == 1)); then - if [ -e ${service_config_dir}/${serverName} ]; then - ${csudo}chkconfig --del ${serverName} || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}chkconfig --del ${serverName2} || : 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} || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}insserv -r ${serverName2} || : 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 || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}update-rc.d -f ${serverName2} 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}/${serverName2} || : ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &>/dev/null); then @@ -653,24 +670,24 @@ function install_service_on_sysvinit() { fi if ((${initd_mod} == 1)); then - ${csudo}chkconfig --add ${serverName} || : - ${csudo}chkconfig --level 2345 ${serverName} on || : + ${csudo}chkconfig --add ${serverName2} || : + ${csudo}chkconfig --level 2345 ${serverName2} on || : elif ((${initd_mod} == 2)); then - ${csudo}insserv ${serverName} || : - ${csudo}insserv -d ${serverName} || : + ${csudo}insserv ${serverName2} || : + ${csudo}insserv -d ${serverName2} || : elif ((${initd_mod} == 3)); then - ${csudo}update-rc.d ${serverName} defaults || : + ${csudo}update-rc.d ${serverName2} defaults || : fi } function clean_service_on_systemd() { - taosd_service_config="${service_config_dir}/${serverName}.service" - if systemctl is-active --quiet ${serverName}; then + service_config="${service_config_dir}/${serverName2}.service" + if systemctl is-active --quiet ${serverName2}; then echo "${productName} is running, stopping it..." - ${csudo}systemctl stop ${serverName} &>/dev/null || echo &>/dev/null + ${csudo}systemctl stop ${serverName2} &>/dev/null || echo &>/dev/null fi - ${csudo}systemctl disable ${serverName} &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${taosd_service_config} + ${csudo}systemctl disable ${serverName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${service_config} tarbitratord_service_config="${service_config_dir}/tarbitratord.service" if systemctl is-active --quiet tarbitratord; then @@ -682,24 +699,46 @@ function clean_service_on_systemd() { # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then # ${csudo}rm -f ${service_config_dir}/${serverName2}.service # fi + x_service_config="${service_config_dir}/${xName2}.service" + if [ -e "$x_service_config" ]; then + if systemctl is-active --quiet ${xName2}; then + echo "${productName2} ${xName2} is running, stopping it..." + ${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${x_service_config} + fi + + explorer_service_config="${service_config_dir}/${explorerName2}.service" + if [ -e "$explorer_service_config" ]; then + if systemctl is-active --quiet ${explorerName2}; then + echo "${productName2} ${explorerName2} is running, stopping it..." + ${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${explorer_service_config} + ${csudo}rm -f /etc/${clientName2}/explorer.toml + fi } function install_service_on_systemd() { clean_service_on_systemd - [ -f ${script_dir}/cfg/${serverName}.service ] && - ${csudo}cp ${script_dir}/cfg/${serverName}.service \ + install_share_etc + + [ -f ${script_dir}/cfg/${serverName2}.service ] && + ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ ${service_config_dir}/ || : # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - # [ -f ${script_dir}/cfg/${serverName}.service ] && - # ${csudo}cp ${script_dir}/cfg/${serverName}.service \ + # [ -f ${script_dir}/cfg/${serverName2}.service ] && + # ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ # ${service_config_dir}/${serverName2}.service || : # fi ${csudo}systemctl daemon-reload - ${csudo}systemctl enable ${serverName} + ${csudo}systemctl enable ${serverName2} ${csudo}systemctl daemon-reload } @@ -719,7 +758,7 @@ function install_service() { elif ((${service_mod} == 1)); then install_service_on_sysvinit else - kill_process ${serverName} + kill_process ${serverName2} fi } @@ -756,10 +795,10 @@ function is_version_compatible() { if [ -f ${script_dir}/driver/vercomp.txt ]; then min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt) else - min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5) + min_compatible_version=$(${script_dir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 5) fi - exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3) + exist_version=$(${installDir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 3) vercomp $exist_version "3.0.0.0" case $? in 2) @@ -829,13 +868,13 @@ function updateProduct() { echo -e "${GREEN}Start to update ${productName2}...${NC}" # Stop the service if running - if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then + if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then if ((${service_mod} == 0)); then - ${csudo}systemctl stop ${serverName} || : + ${csudo}systemctl stop ${serverName2} || : elif ((${service_mod} == 1)); then - ${csudo}service ${serverName} stop || : + ${csudo}service ${serverName2} stop || : else - kill_process ${serverName} + kill_process ${serverName2} fi sleep 1 fi @@ -862,21 +901,21 @@ function updateProduct() { openresty_work=false echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile}" - [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}" + [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml" if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName}${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName} start${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ./${serverName}${NC}" - [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ./${serverName2}${NC}" + [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${clientName2}adapter &${NC}" fi if [ ${openresty_work} = 'true' ]; then @@ -887,7 +926,7 @@ function updateProduct() { if ((${prompt_force} == 1)); then echo "" - echo -e "${RED}Please run '${serverName} --force-keep-file' at first time for the exist ${productName2} $exist_version!${NC}" + echo -e "${RED}Please run '${serverName2} --force-keep-file' at first time for the exist ${productName2} $exist_version!${NC}" fi echo echo -e "\033[44;32;1m${productName2} is updated successfully!${NC}" @@ -899,7 +938,7 @@ function updateProduct() { echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" fi - rm -rf $(tar -tf ${tarName} | grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function installProduct() { @@ -944,21 +983,21 @@ function installProduct() { # Ask if to start the service echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile}" - [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}" + [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml" if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName}${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName} start${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${serverName}${NC}" - [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${serverName2}${NC}" + [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${clientName2}adapter &${NC}" fi if [ ! -z "$firstEp" ]; then @@ -991,7 +1030,7 @@ function installProduct() { fi touch ~/.${historyFile} - rm -rf $(tar -tf ${tarName} | grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } ## ==============================Main program starts from here============================ @@ -1002,7 +1041,7 @@ if [ "$verType" == "server" ]; then echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m" else # Install server and client - if [ -x ${bin_dir}/${serverName} ]; then + if [ -x ${bin_dir}/${serverName2} ]; then update_flag=1 updateProduct else @@ -1012,7 +1051,7 @@ if [ "$verType" == "server" ]; then elif [ "$verType" == "client" ]; then interactiveFqdn=no # Only install client - if [ -x ${bin_dir}/${clientName} ]; then + if [ -x ${bin_dir}/${clientName2} ]; then update_flag=1 updateProduct client else diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index f46de0f94b6..9413f55d51d 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -23,9 +23,12 @@ clientName2="${12}" productName="TDengine" clientName="taos" +benchmarkName="taosBenchmark" configFile="taos.cfg" tarName="package.tar.gz" +benchmarkName2="${clientName2}Benchmark" + if [ "$osType" != "Darwin" ]; then script_dir="$(dirname $(readlink -f $0))" top_dir="$(readlink -f ${script_dir}/../..)" @@ -53,11 +56,12 @@ fi # Directories and files. -if [ "$verMode" == "cluster" ]; then - sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh -fi +#if [ "$verMode" == "cluster" ]; then +# sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh +# sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh +# sed -i "s/configFile2=\"taos\"/configFile2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh +# sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh +#fi if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then @@ -66,6 +70,7 @@ if [ "$osType" != "Darwin" ]; then ${script_dir}/remove_client.sh" else bin_files="${build_dir}/bin/${clientName} \ + ${build_dir}/bin/${benchmarkName} \ ${script_dir}/remove_client.sh \ ${script_dir}/set_core.sh \ ${script_dir}/get_client.sh" @@ -153,6 +158,7 @@ if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_client_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_client_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_client_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_client_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_client_temp.sh sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_client_temp.sh diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 29160238ce2..12e215c62ba 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -51,9 +51,9 @@ fi if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then cd ${top_dir}/tools/taos-tools/packaging/deb - [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" taostools_ver=$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags|grep -v taos | tail -1) + [ -z "$taostools_ver" ] && taostools_ver="0.1.0" taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}" cd ${curr_dir} @@ -96,7 +96,7 @@ else ${taostools_bin_files} \ ${taosx_bin} \ ${explorer_bin_files} \ - ${build_dir}/bin/taosadapter \ + ${build_dir}/bin/${clientName}adapter \ ${build_dir}/bin/udfd \ ${script_dir}/remove.sh \ ${script_dir}/set_core.sh \ @@ -135,12 +135,12 @@ mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile} -if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then - cp ${compile_dir}/test/cfg/taosadapter.toml ${install_dir}/cfg || : +if [ -f "${compile_dir}/test/cfg/${clientName}adapter.toml" ]; then + cp ${compile_dir}/test/cfg/${clientName}adapter.toml ${install_dir}/cfg || : fi -if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then - cp ${compile_dir}/test/cfg/taosadapter.service ${install_dir}/cfg || : +if [ -f "${compile_dir}/test/cfg/${clientName}adapter.service" ]; then + cp ${compile_dir}/test/cfg/${clientName}adapter.service ${install_dir}/cfg || : fi if [ -f "${cfg_dir}/${serverName}.service" ]; then @@ -150,18 +150,19 @@ 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}/share && cp -rf ${build_dir}/share/{etc,srv} ${install_dir}/share if [ $adapterName != "taosadapter" ]; then - mv ${install_dir}/cfg/taosadapter.toml ${install_dir}/cfg/$adapterName.toml + mv ${install_dir}/cfg/${clientName2}adapter.toml ${install_dir}/cfg/$adapterName.toml sed -i "s/path = \"\/var\/log\/taos\"/path = \"\/var\/log\/${productName}\"/g" ${install_dir}/cfg/$adapterName.toml sed -i "s/password = \"taosdata\"/password = \"${defaultPasswd}\"/g" ${install_dir}/cfg/$adapterName.toml - mv ${install_dir}/cfg/taosadapter.service ${install_dir}/cfg/$adapterName.service + mv ${install_dir}/cfg/${clientName2}adapter.service ${install_dir}/cfg/$adapterName.service sed -i "s/TDengine/${productName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosAdapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service - mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName} + mv ${install_dir}/bin/${clientName2}adapter ${install_dir}/bin/${adapterName} mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb fi @@ -233,8 +234,10 @@ if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" remove_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" remove_temp.sh + cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh fi if [ "$verMode" == "cloud" ]; then @@ -262,8 +265,10 @@ if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_temp.sh + cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$verMode" == "cloud" ]; then diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index c9fab51b286..35c28feb6ad 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -145,6 +145,59 @@ function install_include() { log_print "install include success" } +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 install_lib() { log_print "start install lib from ${lib_dir} to ${lib_link_dir}" ${csudo}rm -f ${lib_link_dir}/libtaos* || : @@ -663,6 +716,7 @@ function install_TDengine() { # Install include, lib, binary and service install_include && install_lib && + install_jemalloc install_bin if [[ "$?" != 0 ]];then diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 2479e48670b..6c671473bfb 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -40,11 +40,16 @@ serverName2="taosd" clientName2="taos" productName2="TDengine" +adapterName2="${clientName2}adapter" +demoName2="${clientName2}demo" benchmarkName2="${clientName2}Benchmark" dumpName2="${clientName2}dump" +keeperName2="${clientName2}keeper" +xName2="${clientName2}x" +explorerName2="${clientName2}-explorer" uninstallScript2="rm${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" #install main path install_main_dir=${installDir} @@ -55,8 +60,8 @@ local_bin_link_dir="/usr/local/bin" service_config_dir="/etc/systemd/system" -taos_service_name=${serverName} -taosadapter_service_name="taosadapter" +taos_service_name=${serverName2} +taosadapter_service_name="${clientName2}adapter" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo >/dev/null; then @@ -84,14 +89,14 @@ else fi function kill_taosadapter() { - pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') + pid=$(ps -ef | grep "${adapterName2}" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then ${csudo}kill -9 $pid || : fi } function kill_taosd() { - pid=$(ps -ef | grep ${serverName} | grep -v "grep" | awk '{print $2}') + pid=$(ps -ef | grep ${serverName2} | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then ${csudo}kill -9 $pid || : fi @@ -109,17 +114,17 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/${clientName} || : ${csudo}rm -f ${bin_link_dir}/${serverName} || : ${csudo}rm -f ${bin_link_dir}/udfd || : - ${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}/${adapterName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${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 || : - ${csudo}rm -f ${bin_link_dir}/taoskeeper || : - ${csudo}rm -f ${bin_link_dir}/taosx || : - ${csudo}rm -f ${bin_link_dir}/taos-explorer || : + ${csudo}rm -f ${bin_link_dir}/${keeperName2} || : + ${csudo}rm -f ${bin_link_dir}/${xName2} || : + ${csudo}rm -f ${bin_link_dir}/${explorerName2} || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then ${csudo}rm -f ${bin_link_dir}/${clientName2} || : @@ -130,8 +135,8 @@ function clean_bin() { } function clean_local_bin() { - ${csudo}rm -f ${local_bin_link_dir}/taosBenchmark || : - ${csudo}rm -f ${local_bin_link_dir}/taosdemo || : + ${csudo}rm -f ${local_bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${local_bin_link_dir}/${demoName2} || : } function clean_lib() { @@ -173,7 +178,7 @@ function clean_service_on_systemd() { ${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" + taosadapter_service_config="${service_config_dir}/${clientName2}adapter.service" if systemctl is-active --quiet ${taosadapter_service_name}; then echo "${productName2} ${clientName2}Adapter is running, stopping it..." ${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null @@ -187,7 +192,27 @@ function clean_service_on_systemd() { ${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} + + x_service_config="${service_config_dir}/${xName2}.service" + if [ -e "$x_service_config" ]; then + if systemctl is-active --quiet ${xName2}; then + echo "${productName2} ${xName2} is running, stopping it..." + ${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${x_service_config} + fi + + explorer_service_config="${service_config_dir}/${explorerName2}.service" + if [ -e "$explorer_service_config" ]; then + if systemctl is-active --quiet ${explorerName2}; then + echo "${productName2} ${explorerName2} is running, stopping it..." + ${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${explorer_service_config} + ${csudo}rm -f /etc/${clientName2}/explorer.toml + fi } function clean_service_on_sysvinit() { @@ -235,8 +260,8 @@ function clean_service_on_sysvinit() { function clean_service_on_launchctl() { ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : ${csudo}rm /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : - ${csudo}rm /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : + ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || : + ${csudo}rm /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || : } function clean_service() { diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index 10a0fb5e02a..2bdb56fac21 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -15,11 +15,12 @@ uninstallScript="rmtaos" clientName2="taos" productName2="TDengine" -benchmarkName2="${clientName}Benchmark" -dumpName2="${clientName}dump" -uninstallScript2="rm${clientName}" +benchmarkName2="${clientName2}Benchmark" +demoName2="${clientName2}demo" +dumpName2="${clientName2}dump" +uninstallScript2="rm${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" #install main path install_main_dir=${installDir} @@ -44,14 +45,17 @@ function kill_client() { function clean_bin() { # Remove link - ${csudo}rm -f ${bin_link_dir}/${clientName} || : - ${csudo}rm -f ${bin_link_dir}/taosdemo || : - ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}rm -f ${bin_link_dir}/set_core || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : fi diff --git a/source/client/inc/clientLog.h b/source/client/inc/clientLog.h index c29f495201d..908e4708305 100644 --- a/source/client/inc/clientLog.h +++ b/source/client/inc/clientLog.h @@ -26,6 +26,7 @@ extern "C" { #define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0) #define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0) #define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0) +#define tscWarnL(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLongString("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0) #define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0) #define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0) #define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0) diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h index 2b42de93e3f..0c9696f1c81 100644 --- a/source/client/inc/clientStmt.h +++ b/source/client/inc/clientStmt.h @@ -102,6 +102,7 @@ typedef struct STscStmt { SStmtBindInfo bInfo; int64_t reqid; + int32_t errCode; } STscStmt; extern char *gStmtStatusStr[]; @@ -121,6 +122,7 @@ extern char *gStmtStatusStr[]; int32_t _code = c; \ if (_code != TSDB_CODE_SUCCESS) { \ terrno = _code; \ + pStmt->errCode = _code; \ return _code; \ } \ } while (0) @@ -129,6 +131,7 @@ extern char *gStmtStatusStr[]; int32_t _code = c; \ if (_code != TSDB_CODE_SUCCESS) { \ terrno = _code; \ + pStmt->errCode = _code; \ } \ return _code; \ } while (0) @@ -137,6 +140,7 @@ extern char *gStmtStatusStr[]; code = c; \ if (code != TSDB_CODE_SUCCESS) { \ terrno = code; \ + pStmt->errCode = code; \ goto _return; \ } \ } while (0) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index de08ba66cc7..418103f2a6f 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -30,6 +30,10 @@ #include "tsched.h" #include "ttime.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 @@ -103,6 +107,7 @@ static void deregisterRequest(SRequestObj *pRequest) { if (duration >= SLOW_QUERY_INTERVAL) { atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1); + tscWarnL("slow query: %s, duration:%" PRId64, pRequest->sqlstr, duration); } releaseTscObj(pTscObj->id); @@ -541,9 +546,15 @@ void taos_init_imp(void) { deltaToUtcInitOnce(); - if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { + char logDirName[64] = {0}; +#ifdef CUS_PROMPT + snprintf(logDirName, 64, "%slog", CUS_PROMPT); +#else + snprintf(logDirName, 64, "taoslog"); +#endif + if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { // ignore create log failed, only print - printf(" WARING: Create taoslog failed:%s. configDir=%s\n", strerror(errno), configDir); + printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir); } if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) { diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 21590022b13..a0146cfa39f 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -76,7 +76,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { goto End; } - if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 2)) != 0) { + if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) { setErrno(pRequest, code); tsem_post(&pRequest->body.rspSem); goto End; @@ -506,7 +506,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true); } - if(code != 0){ + if (code != 0) { taosMemoryFree(pRes); } tFreeSShowVariablesRsp(&rsp); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 17197598225..4c28ee76c37 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -174,6 +174,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName) { if (childTableNameLen == tag->keyLen && strncmp(tag->key, tsSmlChildTableName, tag->keyLen) == 0) { memset(childTableName, 0, TSDB_TABLE_NAME_LEN); strncpy(childTableName, tag->value, (tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN)); + taosArrayRemove(tags, i); break; } } @@ -257,19 +258,14 @@ SSmlSTableMeta *smlBuildSTableMeta(bool isDataFormat) { kvVal->f = (float)result; #define SET_BIGINT \ - if (smlDoubleToInt64OverFlow(result)) { \ - errno = 0; \ - int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \ - if (errno == ERANGE) { \ - smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \ - return false; \ - } \ - kvVal->type = TSDB_DATA_TYPE_BIGINT; \ - kvVal->i = tmp; \ - return true; \ - } \ - kvVal->type = TSDB_DATA_TYPE_BIGINT; \ - kvVal->i = (int64_t)result; + errno = 0; \ + int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \ + if (errno == ERANGE) { \ + smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \ + return false; \ + } \ + kvVal->type = TSDB_DATA_TYPE_BIGINT; \ + kvVal->i = tmp; #define SET_INT \ if (!IS_VALID_INT(result)) { \ @@ -288,19 +284,14 @@ SSmlSTableMeta *smlBuildSTableMeta(bool isDataFormat) { kvVal->i = result; #define SET_UBIGINT \ - if (result >= (double)UINT64_MAX || result < 0) { \ - errno = 0; \ - uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \ - if (errno == ERANGE || result < 0) { \ - smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \ - return false; \ - } \ - kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ - kvVal->u = tmp; \ - return true; \ - } \ - kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ - kvVal->u = result; + errno = 0; \ + uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \ + if (errno == ERANGE || result < 0) { \ + smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \ + return false; \ + } \ + kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ + kvVal->u = tmp; #define SET_UINT \ if (!IS_VALID_UINT(result)) { \ @@ -543,8 +534,7 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm uint16_t *index = colHash ? (uint16_t *)taosHashGet(colHash, kv->key, kv->keyLen) : NULL; if (index) { if (colField[*index].type != kv->type) { - uError("SML:0x%" PRIx64 " point type and db type mismatch. key: %s. point type: %d, db type: %d", info->id, - kv->key, colField[*index].type, kv->type); + uError("SML:0x%" PRIx64 " point type and db type mismatch. point type: %d, db type: %d, key: %s", info->id, colField[*index].type, kv->type, kv->key); return TSDB_CODE_TSC_INVALID_VALUE; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 3ed157efef1..71a41c68e71 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -32,8 +32,14 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) { STMT_LOG_SEQ(newStatus); } + if (pStmt->errCode && newStatus != STMT_PREPARE) { + STMT_DLOG("stmt already failed with err: %s", tstrerror(pStmt->errCode)); + return pStmt->errCode; + } + switch (newStatus) { case STMT_PREPARE: + pStmt->errCode = 0; break; case STMT_SETTBNAME: if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND) || STMT_STATUS_EQ(BIND_COL)) { @@ -197,7 +203,10 @@ int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHa STscStmt* pStmt = (STscStmt*)stmt; *pVgHash = pStmt->sql.pVgHash; + pStmt->sql.pVgHash = NULL; + *pBlockHash = pStmt->exec.pBlockHash; + pStmt->exec.pBlockHash = NULL; return TSDB_CODE_SUCCESS; } @@ -325,6 +334,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) { } int32_t stmtCleanSQLInfo(STscStmt* pStmt) { + STMT_DLOG_E("start to free SQL info"); + taosMemoryFree(pStmt->sql.queryRes.fields); taosMemoryFree(pStmt->sql.queryRes.userFields); taosMemoryFree(pStmt->sql.sqlStr); @@ -351,6 +362,8 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) { memset(&pStmt->sql, 0, sizeof(pStmt->sql)); + STMT_DLOG_E("end to free SQL info"); + return TSDB_CODE_SUCCESS; } @@ -441,11 +454,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { .mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)}; int32_t code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta); if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) { - STMT_ERR_RET(stmtCleanBindInfo(pStmt)); - tscDebug("tb %s not exist", pStmt->bInfo.tbFName); + stmtCleanBindInfo(pStmt); - return TSDB_CODE_SUCCESS; + STMT_ERR_RET(code); } STMT_ERR_RET(code); @@ -922,9 +934,13 @@ int stmtExec(TAOS_STMT* stmt) { int stmtClose(TAOS_STMT* stmt) { STscStmt* pStmt = (STscStmt*)stmt; + STMT_DLOG_E("start to free stmt"); + stmtCleanSQLInfo(pStmt); taosMemoryFree(stmt); + STMT_DLOG_E("stmt freed"); + return TSDB_CODE_SUCCESS; } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 111ca28cdc4..befcb00ac79 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -27,6 +27,8 @@ #define EMPTY_BLOCK_POLL_IDLE_DURATION 10 #define DEFAULT_AUTO_COMMIT_INTERVAL 5000 +typedef void (*__tmq_askep_fn_t)(tmq_t* pTmq, int32_t code, SDataBuf* pBuf, void* pParam); + struct SMqMgmt { int8_t inited; tmr_h timer; @@ -105,10 +107,14 @@ struct tmq_t { STaosQueue* mqueue; // queue of rsp STaosQall* qall; STaosQueue* delayedTask; // delayed task queue for heartbeat and auto commit - TdThreadMutex lock; // used to protect the operation on each topic, when updating the epsets. tsem_t rspSem; }; +typedef struct SAskEpInfo { + int32_t code; + tsem_t sem; +} SAskEpInfo; + enum { TMQ_VG_STATUS__IDLE = 0, TMQ_VG_STATUS__WAIT, @@ -169,11 +175,10 @@ typedef struct { } SMqSubscribeCbParam; typedef struct { - int64_t refId; - int32_t epoch; - int32_t code; - int32_t async; - tsem_t rspSem; + int64_t refId; + int32_t epoch; + void* pParam; + __tmq_askep_fn_t pUserFn; } SMqAskEpCbParam; typedef struct { @@ -182,23 +187,19 @@ typedef struct { SMqClientVg* pVg; SMqClientTopic* pTopic; int32_t vgId; - tsem_t rspSem; uint64_t requestId; // request id for debug purpose } SMqPollCbParam; typedef struct { int64_t refId; int32_t epoch; - int8_t automatic; - int8_t async; int32_t waitingRspNum; int32_t totalRspNum; - int32_t rspErr; - tmq_commit_cb* userCb; + int32_t code; + tmq_commit_cb* callbackFn; /*SArray* successfulOffsets;*/ /*SArray* failedOffsets;*/ - void* userParam; - tsem_t rspSem; + void* userParam; } SMqCommitCbParamSet; typedef struct { @@ -209,12 +210,14 @@ typedef struct { tmq_t* pTmq; } SMqCommitCbParam; -static int32_t tmqAskEp(tmq_t* tmq, bool async); +static int32_t doAskEp(tmq_t* tmq); static int32_t makeTopicVgroupKey(char* dst, const char* topicName, int32_t vg); static int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet); static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicName, SMqCommitCbParamSet* pParamSet, int32_t index, int32_t totalVgroups); -static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId); +static void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId); +static void asyncAskEp(tmq_t* pTmq, __tmq_askep_fn_t askEpFn, void* param); +static void addToQueueCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param); tmq_conf_t* tmq_conf_new() { tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t)); @@ -320,15 +323,16 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value } if (strcasecmp(key, "enable.heartbeat.background") == 0) { - if (strcasecmp(value, "true") == 0) { - conf->hbBgEnable = true; - return TMQ_CONF_OK; - } else if (strcasecmp(value, "false") == 0) { - conf->hbBgEnable = false; - return TMQ_CONF_OK; - } else { +// if (strcasecmp(value, "true") == 0) { +// conf->hbBgEnable = true; +// return TMQ_CONF_OK; +// } else if (strcasecmp(value, "false") == 0) { +// conf->hbBgEnable = false; +// return TMQ_CONF_OK; +// } else { + tscError("the default value of enable.heartbeat.background is true, can not be seted"); return TMQ_CONF_INVALID; - } +// } } if (strcasecmp(key, "td.connect.ip") == 0) { @@ -443,7 +447,7 @@ static int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) { // taosMemoryFree(pBuf->pData); // taosMemoryFree(pBuf->pEpSet); // -// tmqCommitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); +// commitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); // return 0; // } // @@ -453,7 +457,7 @@ static int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) { taosMemoryFree(pBuf->pData); taosMemoryFree(pBuf->pEpSet); - tmqCommitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); + commitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); return 0; } @@ -461,8 +465,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN int32_t index, int32_t totalVgroups) { STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); if (pOffset == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pOffset->val = pVg->currentOffset; @@ -476,13 +479,13 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN int32_t code = 0; tEncodeSize(tEncodeSTqOffset, pOffset, len, code); if (code < 0) { - return -1; + return TSDB_CODE_INVALID_PARA; } void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); if (buf == NULL) { taosMemoryFree(pOffset); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); @@ -499,7 +502,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN if (pParam == NULL) { taosMemoryFree(pOffset); taosMemoryFree(buf); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pParam->params = pParamSet; @@ -515,7 +518,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN taosMemoryFree(pOffset); taosMemoryFree(buf); taosMemoryFree(pParam); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pMsgSendInfo->msgInfo = (SDataBuf){ @@ -535,136 +538,128 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN atomic_add_fetch_32(&pParamSet->totalRspNum, 1); SEp* pEp = GET_ACTIVE_EP(&pVg->epSet); - tscDebug("consumer:0x%" PRIx64 " topic:%s on vgId:%d send offset:%" PRId64 " prev:%" PRId64 - ", ep:%s:%d, ordinal:%d/%d, req:0x%" PRIx64, - tmq->consumerId, pOffset->subKey, pVg->vgId, pOffset->val.version, pVg->committedOffset.version, pEp->fqdn, - pEp->port, index + 1, totalVgroups, pMsgSendInfo->requestId); + char offsetBuf[80] = {0}; + tFormatOffset(offsetBuf, tListLen(offsetBuf), &pOffset->val); + + char commitBuf[80] = {0}; + tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->committedOffset); + tscDebug("consumer:0x%" PRIx64 " topic:%s on vgId:%d send offset:%s prev:%s, ep:%s:%d, ordinal:%d/%d, req:0x%" PRIx64, + tmq->consumerId, pOffset->subKey, pVg->vgId, offsetBuf, commitBuf, pEp->fqdn, pEp->port, index + 1, + totalVgroups, pMsgSendInfo->requestId); int64_t transporterId = 0; asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo); - return 0; + + return TSDB_CODE_SUCCESS; } -static int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_commit_cb* userCb, void* userParam) { - char* topic; - int32_t vgId; - if (TD_RES_TMQ(msg)) { - SMqRspObj* pRspObj = (SMqRspObj*)msg; - topic = pRspObj->topic; +static void asyncCommitOffset(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* pCommitFp, void* userParam) { + char* pTopicName = NULL; + int32_t vgId = 0; + int32_t code = 0; + + if (pRes == NULL || tmq == NULL) { + pCommitFp(tmq, TSDB_CODE_INVALID_PARA, userParam); + return; + } + + if (TD_RES_TMQ(pRes)) { + SMqRspObj* pRspObj = (SMqRspObj*)pRes; + pTopicName = pRspObj->topic; vgId = pRspObj->vgId; - } else if (TD_RES_TMQ_META(msg)) { - SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; - topic = pMetaRspObj->topic; + } else if (TD_RES_TMQ_META(pRes)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)pRes; + pTopicName = pMetaRspObj->topic; vgId = pMetaRspObj->vgId; - } else if (TD_RES_TMQ_METADATA(msg)) { - SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)msg; - topic = pRspObj->topic; + } else if (TD_RES_TMQ_METADATA(pRes)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)pRes; + pTopicName = pRspObj->topic; vgId = pRspObj->vgId; } else { - return TSDB_CODE_TMQ_INVALID_MSG; + pCommitFp(tmq, TSDB_CODE_TMQ_INVALID_MSG, userParam); + return; } SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); if (pParamSet == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + pCommitFp(tmq, TSDB_CODE_OUT_OF_MEMORY, userParam); + return; } pParamSet->refId = tmq->refId; pParamSet->epoch = tmq->epoch; - pParamSet->automatic = 0; - pParamSet->async = async; - pParamSet->userCb = userCb; + pParamSet->callbackFn = pCommitFp; pParamSet->userParam = userParam; - tsem_init(&pParamSet->rspSem, 0, 0); - - int32_t code = -1; - taosThreadMutexLock(&tmq->lock); int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics); - tscDebug("consumer:0x%" PRIx64 " user invoked commit offset for %d", tmq->consumerId, numOfTopics); - for (int32_t i = 0; i < numOfTopics; i++) { + tscDebug("consumer:0x%" PRIx64 " do manual commit offset for %s, vgId:%d", tmq->consumerId, pTopicName, vgId); + + int32_t i = 0; + for (; i < numOfTopics; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (strcmp(pTopic->topicName, topic) != 0) { - continue; + if (strcmp(pTopic->topicName, pTopicName) == 0) { + break; } + } - int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); - for (int32_t j = 0; j < numOfVgroups; j++) { - SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - if (pVg->vgId != vgId) { - continue; - } + if (i == numOfTopics) { + tscWarn("consumer:0x%" PRIx64 " failed to find the specified topic:%s, total topics:%d", tmq->consumerId, pTopicName, + numOfTopics); + taosMemoryFree(pParamSet); + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; + } - if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { - if (doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups) < 0) { - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); - goto FAIL; - } - goto HANDLE_RSP; - } + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + + int32_t j = 0; + int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); + for (j = 0; j < numOfVgroups; j++) { + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->vgId == vgId) { + break; } } -HANDLE_RSP: - if (pParamSet->totalRspNum == 0) { - tsem_destroy(&pParamSet->rspSem); + if (j == numOfVgroups) { + tscWarn("consumer:0x%" PRIx64 " failed to find the specified vgId:%d, total Vgs:%d, topic:%s", tmq->consumerId, vgId, + numOfVgroups, pTopicName); taosMemoryFree(pParamSet); - taosThreadMutexUnlock(&tmq->lock); - return 0; + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; } - if (!async) { - taosThreadMutexUnlock(&tmq->lock); - tsem_wait(&pParamSet->rspSem); - code = pParamSet->rspErr; - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); - return code; - } else { - code = 0; - } + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { + code = doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups); -FAIL: - taosThreadMutexUnlock(&tmq->lock); - if (code != 0 && async) { - userCb(tmq, code, userParam); + // failed to commit, callback user function directly. + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(pParamSet); + pCommitFp(tmq, code, userParam); + } + } else { // do not perform commit, callback user function directly. + taosMemoryFree(pParamSet); + pCommitFp(tmq, code, userParam); } - - return 0; } -static int32_t doAutoCommit(tmq_t* tmq, int8_t automatic, int8_t async, tmq_commit_cb* userCb, void* userParam) { - int32_t code = -1; - +static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam) { SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); if (pParamSet == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - if (async) { - if (automatic) { - tmq->commitCb(tmq, code, tmq->commitCbUserParam); - } else { - userCb(tmq, code, userParam); - } - } - return -1; + pCommitFp(tmq, TSDB_CODE_OUT_OF_MEMORY, userParam); + return; } pParamSet->refId = tmq->refId; pParamSet->epoch = tmq->epoch; - - pParamSet->automatic = automatic; - pParamSet->async = async; - pParamSet->userCb = userCb; + pParamSet->callbackFn = pCommitFp; pParamSet->userParam = userParam; - tsem_init(&pParamSet->rspSem, 0, 0); // init as 1 to prevent concurrency issue pParamSet->waitingRspNum = 1; - taosThreadMutexLock(&tmq->lock); int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics); tscDebug("consumer:0x%" PRIx64 " start to commit offset for %d topics", tmq->consumerId, numOfTopics); @@ -678,7 +673,7 @@ static int32_t doAutoCommit(tmq_t* tmq, int8_t automatic, int8_t async, tmq_comm SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { - code = doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups); + int32_t code = doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups); if (code != TSDB_CODE_SUCCESS) { tscError("consumer:0x%" PRIx64 " topic:%s vgId:%d offset:%" PRId64 " failed, code:%s ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->committedOffset.version, tstrerror(terrno), @@ -689,7 +684,7 @@ static int32_t doAutoCommit(tmq_t* tmq, int8_t automatic, int8_t async, tmq_comm // update the offset value. pVg->committedOffset = pVg->currentOffset; } else { - tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d, no commit, current:%" PRId64 ", ordinal:%d/%d", + tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d, not commit, current:%" PRId64 ", ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->currentOffset.version, j + 1, numOfVgroups); } } @@ -697,39 +692,16 @@ static int32_t doAutoCommit(tmq_t* tmq, int8_t automatic, int8_t async, tmq_comm tscDebug("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, numOfTopics); - taosThreadMutexUnlock(&tmq->lock); // no request is sent if (pParamSet->totalRspNum == 0) { - tsem_destroy(&pParamSet->rspSem); taosMemoryFree(pParamSet); - return 0; + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; } // count down since waiting rsp num init as 1 - tmqCommitRspCountDown(pParamSet, tmq->consumerId, "", 0); - - if (!async) { - tsem_wait(&pParamSet->rspSem); - code = pParamSet->rspErr; - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); -#if 0 - taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); - taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); -#endif - } - - return code; -} - -static int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb, - void* userParam) { - if (msg) { // user invoked commit - return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam); - } else { // this for auto commit - return doAutoCommit(tmq, automatic, async, userCb, userParam); - } + commitRspCountDown(pParamSet, tmq->consumerId, "", 0); } static void generateTimedTask(int64_t refId, int32_t type) { @@ -836,6 +808,12 @@ void tmqSendHbReq(void* param, void* tmrId) { taosReleaseRef(tmqMgmt.rsetId, refId); } +static void defaultCommitCbFn(tmq_t* pTmq, int32_t code, void* param) { + if (code != 0) { + tscDebug("consumer:0x%"PRIx64", failed to commit offset, code:%s", pTmq->consumerId, tstrerror(code)); + } +} + int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { STaosQall* qall = taosAllocateQall(); taosReadAllQitems(pTmq->delayedTask, qall); @@ -851,7 +829,7 @@ int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { while (pTaskType != NULL) { if (*pTaskType == TMQ_DELAYED_TASK__ASK_EP) { - tmqAskEp(pTmq, true); + asyncAskEp(pTmq, addToQueueCallbackFn, NULL); int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t)); *pRefId = pTmq->refId; @@ -859,12 +837,13 @@ int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { tscDebug("consumer:0x%" PRIx64 " retrieve ep from mnode in 1s", pTmq->consumerId); taosTmrReset(tmqAssignAskEpTask, 1000, pRefId, tmqMgmt.timer, &pTmq->epTimer); } else if (*pTaskType == TMQ_DELAYED_TASK__COMMIT) { - tmqCommitInner(pTmq, NULL, 1, 1, pTmq->commitCb, pTmq->commitCbUserParam); + tmq_commit_cb* pCallbackFn = pTmq->commitCb? pTmq->commitCb:defaultCommitCbFn; + asyncCommitAllOffsets(pTmq, pCallbackFn, pTmq->commitCbUserParam); int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t)); *pRefId = pTmq->refId; - tscDebug("consumer:0x%" PRIx64 " commit to vnode(s) in %.2fs", pTmq->consumerId, + tscDebug("consumer:0x%" PRIx64 " next commit to vnode(s) in %.2fs", pTmq->consumerId, pTmq->autoCommitInterval / 1000.0); taosTmrReset(tmqAssignDelayedCommitTask, pTmq->autoCommitInterval, pRefId, tmqMgmt.timer, &pTmq->commitTimer); } else if (*pTaskType == TMQ_DELAYED_TASK__REPORT) { @@ -998,7 +977,6 @@ void tmqFreeImpl(void* handle) { taosFreeQall(tmq->qall); tsem_destroy(&tmq->rspSem); - taosThreadMutexDestroy(&tmq->lock); taosArrayDestroyEx(tmq->clientTopics, freeClientVgImpl); taos_close_internal(tmq->pTscObj); @@ -1043,7 +1021,6 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->delayedTask = taosOpenQueue(); pTmq->qall = taosAllocateQall(); - taosThreadMutexInit(&pTmq->lock, NULL); if (pTmq->clientTopics == NULL || pTmq->mqueue == NULL || pTmq->qall == NULL || pTmq->delayedTask == NULL || conf->groupId[0] == 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -1056,8 +1033,6 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->status = TMQ_CONSUMER_STATUS__INIT; pTmq->pollCnt = 0; pTmq->epoch = 0; - /*pTmq->epStatus = 0;*/ - /*pTmq->epSkipCnt = 0;*/ // set conf strcpy(pTmq->clientId, conf->clientId); @@ -1209,7 +1184,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { } int32_t retryCnt = 0; - while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) { + while (TSDB_CODE_MND_CONSUMER_NOT_READY == doAskEp(tmq)) { if (retryCnt++ > MAX_RETRY_COUNT) { goto FAIL; } @@ -1254,7 +1229,6 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq == NULL) { - tsem_destroy(&pParam->rspSem); taosMemoryFree(pParam); taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); @@ -1290,6 +1264,8 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { pRspWrapper->tmqRspType = TMQ_MSG_TYPE__END_RSP; taosWriteQitem(tmq->mqueue, pRspWrapper); + }else if(code == TSDB_CODE_WAL_LOG_NOT_EXIST){ //poll data while insert + taosMsleep(500); } goto CREATE_MSG_FAIL; @@ -1343,7 +1319,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { char buf[80]; tFormatOffset(buf, 80, &pRspWrapper->dataRsp.rspOffset); - tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64, + tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64, tmq->consumerId, vgId, pRspWrapper->dataRsp.reqOffset.version, buf, rspType, requestId); } else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) { SDecoder decoder; @@ -1364,8 +1340,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pData); taosWriteQitem(tmq->mqueue, pRspWrapper); + int32_t total = taosQueueItemSize(tmq->mqueue); tscDebug("consumer:0x%" PRIx64 " put poll res into mqueue, type:%d, vgId:%d, total in queue:%d, reqId:0x%" PRIx64, - tmq->consumerId, rspType, vgId, tmq->mqueue->numOfItems, requestId); + tmq->consumerId, rspType, vgId, total, requestId); tsem_post(&tmq->rspSem); taosReleaseRef(tmqMgmt.rsetId, refId); @@ -1440,7 +1417,7 @@ static void freeClientVgInfo(void* param) { taosArrayDestroy(pTopic->vgs); } -static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { +static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { bool set = false; int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); @@ -1449,6 +1426,9 @@ static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { char vgKey[TSDB_TOPIC_FNAME_LEN + 22]; tscDebug("consumer:0x%" PRIx64 " update ep epoch from %d to epoch %d, incoming topics:%d, existed topics:%d", tmq->consumerId, tmq->epoch, epoch, topicNumGet, topicNumCur); + if (epoch <= tmq->epoch) { + return false; + } SArray* newTopics = taosArrayInit(topicNumGet, sizeof(SMqClientTopic)); if (newTopics == NULL) { @@ -1492,14 +1472,11 @@ static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { taosHashCleanup(pVgOffsetHashMap); - taosThreadMutexLock(&tmq->lock); // destroy current buffered existed topics info if (tmq->clientTopics) { taosArrayDestroyEx(tmq->clientTopics, freeClientVgInfo); } - tmq->clientTopics = newTopics; - taosThreadMutexUnlock(&tmq->lock); int8_t flag = (topicNumGet == 0)? TMQ_CONSUMER_STATUS__NO_TOPIC:TMQ_CONSUMER_STATUS__READY; atomic_store_8(&tmq->status, flag); @@ -1509,28 +1486,30 @@ static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { return set; } -static int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { +int32_t askEpCallbackFn(void* param, SDataBuf* pMsg, int32_t code) { SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param; - int8_t async = pParam->async; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId); + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId); if (tmq == NULL) { - if (!async) { - tsem_destroy(&pParam->rspSem); - } else { - taosMemoryFree(pParam); - } + terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; + pParam->pUserFn(tmq, terrno, NULL, pParam->pParam); + taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); - terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; - return -1; + taosMemoryFree(pParam); + return terrno; } - pParam->code = code; if (code != TSDB_CODE_SUCCESS) { - tscError("consumer:0x%" PRIx64 ", get topic endpoint error, async:%d, code:%s", tmq->consumerId, pParam->async, - tstrerror(code)); - goto END; + tscError("consumer:0x%" PRIx64 ", get topic endpoint error, code:%s", tmq->consumerId, tstrerror(code)); + pParam->pUserFn(tmq, code, NULL, pParam->pParam); + + taosReleaseRef(tmqMgmt.rsetId, pParam->refId); + + taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); + taosMemoryFree(pParam); + return code; } // tmq's epoch is monotonically increase, @@ -1541,6 +1520,7 @@ static int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { if (head->epoch <= epoch) { tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, no need to update local ep", tmq->consumerId, head->epoch, epoch); + if (tmq->status == TMQ_CONSUMER_STATUS__RECOVER) { SMqAskEpRsp rsp; tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); @@ -1549,45 +1529,17 @@ static int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { tDeleteSMqAskEpRsp(&rsp); } - goto END; - } - - tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, update local ep", tmq->consumerId, - head->epoch, epoch); - - if (!async) { - SMqAskEpRsp rsp; - tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); - tmqUpdateEp(tmq, head->epoch, &rsp); - tDeleteSMqAskEpRsp(&rsp); } else { - SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0); - if (pWrapper == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = -1; - goto END; - } - - pWrapper->tmqRspType = TMQ_MSG_TYPE__EP_RSP; - pWrapper->epoch = head->epoch; - memcpy(&pWrapper->msg, pMsg->pData, sizeof(SMqRspHead)); - tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pWrapper->msg); - - taosWriteQitem(tmq->mqueue, pWrapper); - tsem_post(&tmq->rspSem); + tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, update local ep", tmq->consumerId, + head->epoch, epoch); } + pParam->pUserFn(tmq, code, pMsg, pParam->pParam); -END: taosReleaseRef(tmqMgmt.rsetId, pParam->refId); - if (!async) { - tsem_post(&pParam->rspSem); - } else { - taosMemoryFree(pParam); - } - taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); + taosMemoryFree(pParam); return code; } @@ -1788,7 +1740,7 @@ static int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* p if (rspWrapper->epoch > atomic_load_32(&tmq->epoch)) { SMqAskEpRspWrapper* pEpRspWrapper = (SMqAskEpRspWrapper*)rspWrapper; SMqAskEpRsp* rspMsg = &pEpRspWrapper->msg; - tmqUpdateEp(tmq, rspWrapper->epoch, rspMsg); + doUpdateLocalEp(tmq, rspWrapper->epoch, rspMsg); /*tmqClearUnhandleMsg(tmq);*/ tDeleteSMqAskEpRsp(rspMsg); *pReset = true; @@ -1976,7 +1928,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { while (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { int32_t retryCnt = 0; - while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) { + while (TSDB_CODE_MND_CONSUMER_NOT_READY == doAskEp(tmq)) { if (retryCnt++ > 40) { return NULL; } @@ -2158,96 +2110,162 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } -void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { - tmqCommitInner(tmq, msg, 0, 1, cb, param); +void tmq_commit_async(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* cb, void* param) { + if (pRes == NULL) { // here needs to commit all offsets. + asyncCommitAllOffsets(tmq, cb, param); + } else { // only commit one offset + asyncCommitOffset(tmq, pRes, cb, param); + } } -int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* msg) { - return tmqCommitInner(tmq, msg, 0, 0, NULL, NULL); +typedef struct SSyncCommitInfo { + tsem_t sem; + int32_t code; +} SSyncCommitInfo; + +static void commitCallBackFn(tmq_t *pTmq, int32_t code, void* param) { + SSyncCommitInfo* pInfo = (SSyncCommitInfo*) param; + pInfo->code = code; + tsem_post(&pInfo->sem); } -int32_t tmqAskEp(tmq_t* tmq, bool async) { - int32_t code = TSDB_CODE_SUCCESS; -#if 0 - int8_t epStatus = atomic_val_compare_exchange_8(&tmq->epStatus, 0, 1); - if (epStatus == 1) { - int32_t epSkipCnt = atomic_add_fetch_32(&tmq->epSkipCnt, 1); - tscTrace("consumer:0x%" PRIx64 ", skip ask ep cnt %d", tmq->consumerId, epSkipCnt); - if (epSkipCnt < 5000) return 0; +int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) { + int32_t code = 0; + + SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo)); + tsem_init(&pInfo->sem, 0, 0); + pInfo->code = 0; + + if (pRes == NULL) { + asyncCommitAllOffsets(tmq, commitCallBackFn, pInfo); + } else { + asyncCommitOffset(tmq, pRes, commitCallBackFn, pInfo); } - atomic_store_32(&tmq->epSkipCnt, 0); -#endif + tsem_wait(&pInfo->sem); + code = pInfo->code; + + tsem_destroy(&pInfo->sem); + taosMemoryFree(pInfo); + + tscDebug("consumer:0x%"PRIx64" sync commit done, code:%s", tmq->consumerId, tstrerror(code)); + return code; +} + +void updateEpCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param) { + SAskEpInfo* pInfo = param; + pInfo->code = code; + + if (code == TSDB_CODE_SUCCESS) { + SMqRspHead* head = pDataBuf->pData; + + SMqAskEpRsp rsp; + tDecodeSMqAskEpRsp(POINTER_SHIFT(pDataBuf->pData, sizeof(SMqRspHead)), &rsp); + doUpdateLocalEp(pTmq, head->epoch, &rsp); + tDeleteSMqAskEpRsp(&rsp); + } + + tsem_post(&pInfo->sem); +} + +void addToQueueCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param) { + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return; + } + + SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0); + if (pWrapper == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return; + } + + SMqRspHead* head = pDataBuf->pData; + + pWrapper->tmqRspType = TMQ_MSG_TYPE__EP_RSP; + pWrapper->epoch = head->epoch; + memcpy(&pWrapper->msg, pDataBuf->pData, sizeof(SMqRspHead)); + tDecodeSMqAskEpRsp(POINTER_SHIFT(pDataBuf->pData, sizeof(SMqRspHead)), &pWrapper->msg); + + taosWriteQitem(pTmq->mqueue, pWrapper); +} + +int32_t doAskEp(tmq_t* pTmq) { + SAskEpInfo* pInfo = taosMemoryMalloc(sizeof(SAskEpInfo)); + tsem_init(&pInfo->sem, 0, 0); + + asyncAskEp(pTmq, updateEpCallbackFn, pInfo); + tsem_wait(&pInfo->sem); + + int32_t code = pInfo->code; + tsem_destroy(&pInfo->sem); + taosMemoryFree(pInfo); + return code; +} + +void asyncAskEp(tmq_t* pTmq, __tmq_askep_fn_t askEpFn, void* param) { SMqAskEpReq req = {0}; - req.consumerId = tmq->consumerId; - req.epoch = tmq->epoch; - strcpy(req.cgroup, tmq->groupId); + req.consumerId = pTmq->consumerId; + req.epoch = pTmq->epoch; + strcpy(req.cgroup, pTmq->groupId); int32_t tlen = tSerializeSMqAskEpReq(NULL, 0, &req); if (tlen < 0) { - tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq failed", tmq->consumerId); - return -1; + tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq failed", pTmq->consumerId); + askEpFn(pTmq, TSDB_CODE_INVALID_PARA, NULL, param); + return; } void* pReq = taosMemoryCalloc(1, tlen); if (pReq == NULL) { - tscError("consumer:0x%" PRIx64 ", failed to malloc askEpReq msg, size:%d", tmq->consumerId, tlen); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + tscError("consumer:0x%" PRIx64 ", failed to malloc askEpReq msg, size:%d", pTmq->consumerId, tlen); + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; } if (tSerializeSMqAskEpReq(pReq, tlen, &req) < 0) { - tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq %d failed", tmq->consumerId, tlen); + tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq %d failed", pTmq->consumerId, tlen); taosMemoryFree(pReq); - return -1; + + askEpFn(pTmq, TSDB_CODE_INVALID_PARA, NULL, param); + return; } SMqAskEpCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqAskEpCbParam)); if (pParam == NULL) { - tscError("consumer:0x%" PRIx64 ", failed to malloc subscribe param", tmq->consumerId); + tscError("consumer:0x%" PRIx64 ", failed to malloc subscribe param", pTmq->consumerId); taosMemoryFree(pReq); - return -1; + + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; } - pParam->refId = tmq->refId; - pParam->epoch = tmq->epoch; - pParam->async = async; - tsem_init(&pParam->rspSem, 0, 0); + pParam->refId = pTmq->refId; + pParam->epoch = pTmq->epoch; + pParam->pUserFn = askEpFn; + pParam->pParam = param; SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (sendInfo == NULL) { - tsem_destroy(&pParam->rspSem); taosMemoryFree(pParam); taosMemoryFree(pReq); - return -1; + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; } - sendInfo->msgInfo = (SDataBuf){ - .pData = pReq, - .len = tlen, - .handle = NULL, - }; + sendInfo->msgInfo = (SDataBuf){ .pData = pReq, .len = tlen, .handle = NULL }; sendInfo->requestId = generateRequestId(); sendInfo->requestObjRefId = 0; sendInfo->param = pParam; - sendInfo->fp = tmqAskEpCb; + sendInfo->fp = askEpCallbackFn; sendInfo->msgType = TDMT_MND_TMQ_ASK_EP; - SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); - tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, async:%d, reqId:0x%" PRIx64, tmq->consumerId, async, - sendInfo->requestId); + SEpSet epSet = getEpSet_s(&pTmq->pTscObj->pAppInfo->mgmtEp); + tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, reqId:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId); int64_t transporterId = 0; - asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); - - if (!async) { - tsem_wait(&pParam->rspSem); - code = pParam->code; - taosMemoryFree(pParam); - } - - return code; + asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); } int32_t makeTopicVgroupKey(char* dst, const char* topicName, int32_t vg) { @@ -2259,38 +2277,20 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) { tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq == NULL) { - if (!pParamSet->async) { - tsem_destroy(&pParamSet->rspSem); - } taosMemoryFree(pParamSet); terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; return -1; } // if no more waiting rsp - if (pParamSet->async) { - // call async cb func - if (pParamSet->automatic && tmq->commitCb) { - tmq->commitCb(tmq, pParamSet->rspErr, tmq->commitCbUserParam); - } else if (!pParamSet->automatic && pParamSet->userCb) { // sem post - pParamSet->userCb(tmq, pParamSet->rspErr, pParamSet->userParam); - } - - taosMemoryFree(pParamSet); - } else { - tsem_post(&pParamSet->rspSem); - } - -#if 0 - taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); - taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); -#endif + pParamSet->callbackFn(tmq, pParamSet->code, pParamSet->userParam); + taosMemoryFree(pParamSet); taosReleaseRef(tmqMgmt.rsetId, refId); return 0; } -void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId) { +void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId) { int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); if (waitingRspNum == 0) { tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d all commit-rsp received, commit completed", consumerId, pTopic, diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 5523e1f7772..84e34242648 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -161,10 +161,10 @@ void *queryThread(void *arg) { return NULL; } -static int32_t numOfThreads = 1; +int32_t numOfThreads = 1; void tmq_commit_cb_print(tmq_t *pTmq, int32_t code, void *param) { - printf("success, code:%d\n", code); + printf("auto commit success, code:%d\n\n\n\n", code); } void* doConsumeData(void* param) { @@ -173,7 +173,7 @@ void* doConsumeData(void* param) { tmq_conf_t* conf = tmq_conf_new(); tmq_conf_set(conf, "enable.auto.commit", "true"); tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpName12"); + tmq_conf_set(conf, "group.id", "cgrpName41"); tmq_conf_set(conf, "td.connect.user", "root"); tmq_conf_set(conf, "td.connect.pass", "taosdata"); tmq_conf_set(conf, "auto.offset.reset", "earliest"); @@ -998,7 +998,8 @@ TEST(clientCase, sub_db_test) { // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "topic_db1"); + tmq_list_append(topicList, "topic_t1"); + tmq_list_append(topicList, "topic_s2"); // 启动订阅 tmq_subscribe(tmq, topicList); @@ -1059,7 +1060,7 @@ TEST(clientCase, sub_tb_test) { tmq_conf_t* conf = tmq_conf_new(); tmq_conf_set(conf, "enable.auto.commit", "true"); tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpName27"); + tmq_conf_set(conf, "group.id", "cgrpName45"); tmq_conf_set(conf, "td.connect.user", "root"); tmq_conf_set(conf, "td.connect.pass", "taosdata"); tmq_conf_set(conf, "auto.offset.reset", "earliest"); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 3c8d394b439..0dd8cb9b0c1 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -147,9 +147,17 @@ int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) { return TSDB_CODE_SUCCESS; } -static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, - int32_t itemLen, int32_t numOfRows) { - ASSERT(pColumnInfoData->info.bytes >= itemLen); +static int32_t doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, + int32_t itemLen, int32_t numOfRows, bool trimValue) { + if (pColumnInfoData->info.bytes < itemLen) { + uWarn("column/tag actual data len %d is bigger than schema len %d, trim it:%d", itemLen, pColumnInfoData->info.bytes, trimValue); + if (trimValue) { + itemLen = pColumnInfoData->info.bytes; + } else { + return TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + } + } + size_t start = 1; // the first item @@ -178,10 +186,12 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren pColumnInfoData->varmeta.length += numOfRows * itemLen; } + + return TSDB_CODE_SUCCESS; } int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, - uint32_t numOfRows) { + uint32_t numOfRows, bool trimValue) { int32_t len = pColumnInfoData->info.bytes; if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { len = varDataTLen(pData); @@ -193,8 +203,7 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, } } - doCopyNItems(pColumnInfoData, currentRow, pData, len, numOfRows); - return TSDB_CODE_SUCCESS; + return doCopyNItems(pColumnInfoData, currentRow, pData, len, numOfRows, trimValue); } static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, const SColumnInfoData* pSource, @@ -973,7 +982,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { 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); + uDebug("blockDataSort easy cost:%" PRId64 ", rows:%" PRId64 "\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -1026,6 +1035,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { return TSDB_CODE_SUCCESS; } +#if 0 typedef struct SHelper { int32_t index; union { @@ -1074,59 +1084,20 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock* int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) { const SSDataBlockSortHelper* pHelper = (const SSDataBlockSortHelper*)param; - // SSDataBlock* pDataBlock = pHelper->pDataBlock; - SHelper* left = (SHelper*)p1; SHelper* right = (SHelper*)p2; SArray* pInfo = pHelper->orderInfo; int32_t offset = 0; - // for(int32_t i = 0; i < pInfo->size; ++i) { - // SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, 0); - // SColumnInfoData* pColInfoData = pOrder->pColData;//TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex); - - // if (pColInfoData->hasNull) { - // bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, pDataBlock->pBlockAgg); - // bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, pDataBlock->pBlockAgg); - // if (leftNull && rightNull) { - // continue; // continue to next slot - // } - // - // if (rightNull) { - // return pHelper->nullFirst? 1:-1; - // } - // - // if (leftNull) { - // return pHelper->nullFirst? -1:1; - // } - // } - - // void* left1 = colDataGetData(pColInfoData, left); - // void* right1 = colDataGetData(pColInfoData, right); - - // switch(pColInfoData->info.type) { - // case TSDB_DATA_TYPE_INT: { int32_t leftx = *(int32_t*)left->pData; //*(int32_t*)(left->pData + offset); int32_t rightx = *(int32_t*)right->pData; //*(int32_t*)(right->pData + offset); - // offset += pColInfoData->info.bytes; if (leftx == rightx) { - // break; return 0; } else { - // if (pOrder->order == TSDB_ORDER_ASC) { return (leftx < rightx) ? -1 : 1; - // } else { - // return (leftx < rightx)? 1:-1; - // } - } - // } - // default: - // assert(0); - // } - // } - + } return 0; } @@ -1170,6 +1141,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF // destroyTupleIndex(index); return 0; } +#endif void blockDataCleanup(SSDataBlock* pDataBlock) { blockDataEmpty(pDataBlock); @@ -1180,7 +1152,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) { void blockDataEmpty(SSDataBlock* pDataBlock) { SDataBlockInfo* pInfo = &pDataBlock->info; - if (pInfo->capacity == 0 || pInfo->rows > pDataBlock->info.capacity) { + if (pInfo->capacity == 0) { return; } @@ -1618,12 +1590,13 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) { i += 1; } } else if (n > 8) { - int32_t gap = len - newLen; + int32_t remain = (total % 8 != 0 && total % 8 <= tail) ? 1 : 0; + int32_t gap = len - newLen - remain; while (i < newLen) { uint8_t v = p[i + gap]; p[i] = (v << tail); - if (i < newLen - 1) { + if (i < newLen - 1 + remain) { uint8_t next = p[i + gap + 1]; p[i] |= (next >> (8 - tail)); } @@ -1739,14 +1712,14 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { int64_t tbUid = pBlock->info.id.uid; int16_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); int16_t hasVarCol = pBlock->info.hasVarCol; - int32_t rows = pBlock->info.rows; + int64_t rows = pBlock->info.rows; int32_t sz = taosArrayGetSize(pBlock->pDataBlock); int32_t tlen = 0; tlen += taosEncodeFixedI64(buf, tbUid); tlen += taosEncodeFixedI16(buf, numOfCols); tlen += taosEncodeFixedI16(buf, hasVarCol); - tlen += taosEncodeFixedI32(buf, rows); + tlen += taosEncodeFixedI64(buf, rows); tlen += taosEncodeFixedI32(buf, sz); for (int32_t i = 0; i < sz; i++) { SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); @@ -1777,7 +1750,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) { buf = taosDecodeFixedU64(buf, &pBlock->info.id.uid); buf = taosDecodeFixedI16(buf, &numOfCols); buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol); - buf = taosDecodeFixedI32(buf, &pBlock->info.rows); + buf = taosDecodeFixedI64(buf, &pBlock->info.rows); buf = taosDecodeFixedI32(buf, &sz); pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData)); for (int32_t i = 0; i < sz; i++) { @@ -1878,6 +1851,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { return buf; } +#if 0 void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag) { SArray* dataBlocks = taosArrayInit(1, sizeof(SSDataBlock*)); taosArrayPush(dataBlocks, &pBlock); @@ -1970,6 +1944,8 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { } } +#endif + // for debug char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) { int32_t size = 2048; @@ -1981,7 +1957,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t len = 0; len += snprintf(dumpBuf + len, size - len, "===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 - "|rows:%d|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", + "|rows:%" PRId64 "|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.id.groupId, pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version, pDataBlock->info.calWin.skey, pDataBlock->info.calWin.ekey, pDataBlock->info.parTbName); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 34808aa389b..d6ab974c6ce 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -2453,6 +2453,11 @@ int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t byt code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0); if (code) goto _exit; } else { + if(ASSERT(varDataTLen(data + offset) <= bytes)){ + uError("var data length invalid, varDataTLen(data + offset):%d <= bytes:%d", (int)varDataTLen(data + offset), bytes); + code = TSDB_CODE_INVALID_PARA; + goto _exit; + } code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, (uint8_t *)varDataVal(data + offset), varDataLen(data + offset)); } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index aeeec1d61ce..56e34da4ce3 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -20,6 +20,10 @@ #include "tlog.h" #include "tmisce.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + GRANT_CFG_DECLARE; SConfig *tsCfg = NULL; @@ -228,7 +232,11 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input taosExpandDir(inputCfgDir, cfgDir, PATH_MAX); if (taosIsDir(cfgDir)) { +#ifdef CUS_PROMPT + snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "%s.cfg", cfgDir, CUS_PROMPT); +#else snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir); +#endif } else { tstrncpy(cfgFile, cfgDir, sizeof(cfgDir)); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 7d517e3e1ec..0f10fc3561d 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -7305,6 +7305,7 @@ void tDestroySSubmitReq2(SSubmitReq2 *pReq, int32_t flag) { tDestroySSubmitTbData(&aSubmitTbData[i], flag); } taosArrayDestroy(pReq->aSubmitTbData); + pReq->aSubmitTbData = NULL; } int32_t tEncodeSSubmitRsp2(SEncoder *pCoder, const SSubmitRsp2 *pRsp) { diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 9a092e2df50..f0e020edfed 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -20,6 +20,21 @@ #include "tglobal.h" #include "version.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#else +#ifndef CUS_NAME + #define CUS_NAME "TDengine" +#endif + +#ifndef CUS_PROMPT + #define CUS_PROMPT "taos" +#endif + +#ifndef CUS_EMAIL + #define CUS_EMAIL "" +#endif +#endif // clang-format off #define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'." #define DM_CFG_DIR "Configuration directory." @@ -232,7 +247,7 @@ static void dmDumpCfg() { } static int32_t dmInitLog() { - return taosCreateLog("taosdlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0); + return taosCreateLog(CUS_PROMPT"dlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0); } static void taosCleanupArgs() { diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h index b47742b4ed8..24f75e3c8b0 100644 --- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h @@ -34,7 +34,7 @@ typedef struct SMnodeMgmt { SSingleWorker readWorker; SSingleWorker writeWorker; SSingleWorker syncWorker; - SSingleWorker syncCtrlWorker; + SSingleWorker syncRdWorker; bool stopped; int32_t refCount; TdThreadRwlock lock; @@ -54,7 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt); void mmStopWorker(SMnodeMgmt *pMgmt); int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutMsgToSyncCtrlQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToSyncRdQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index fe65c3dde96..c2c9e37c8cf 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -188,7 +188,8 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_INDEX_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DISABLE_WRITE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT_ELECTION, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; @@ -198,11 +199,12 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; + + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index b0810d528f7..0152e5d0b1a 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -111,8 +111,8 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg); } -int32_t mmPutMsgToSyncCtrlQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->syncCtrlWorker, pMsg); +int32_t mmPutMsgToSyncRdQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->syncRdWorker, pMsg); } int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { @@ -151,8 +151,8 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { case SYNC_QUEUE: pWorker = &pMgmt->syncWorker; break; - case SYNC_CTRL_QUEUE: - pWorker = &pMgmt->syncCtrlWorker; + case SYNC_RD_QUEUE: + pWorker = &pMgmt->syncRdWorker; break; default: terrno = TSDB_CODE_INVALID_PARA; @@ -238,12 +238,12 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { SSingleWorkerCfg scCfg = { .min = 1, .max = 1, - .name = "mnode-sync-ctrl", + .name = "mnode-sync-rd", .fp = (FItem)mmProcessSyncMsg, .param = pMgmt, }; - if (tSingleWorkerInit(&pMgmt->syncCtrlWorker, &scCfg) != 0) { - dError("failed to start mnode mnode-sync-ctrl worker since %s", terrstr()); + if (tSingleWorkerInit(&pMgmt->syncRdWorker, &scCfg) != 0) { + dError("failed to start mnode mnode-sync-rd worker since %s", terrstr()); return -1; } @@ -259,6 +259,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) { tSingleWorkerCleanup(&pMgmt->readWorker); tSingleWorkerCleanup(&pMgmt->writeWorker); tSingleWorkerCleanup(&pMgmt->syncWorker); - tSingleWorkerCleanup(&pMgmt->syncCtrlWorker); + tSingleWorkerCleanup(&pMgmt->syncRdWorker); dDebug("mnode workers are closed"); } diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h index e3fa2964b74..4374ae363cc 100644 --- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h +++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h @@ -59,7 +59,7 @@ typedef struct { SVnode *pImpl; SMultiWorker pWriteW; SMultiWorker pSyncW; - SMultiWorker pSyncCtrlW; + SMultiWorker pSyncRdW; SMultiWorker pApplyW; STaosQueue *pQueryQ; STaosQueue *pStreamQ; @@ -107,7 +107,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc); int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index d7f91b74a8d..28cb5d2058d 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -549,7 +549,8 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT_ELECTION, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; @@ -559,12 +560,12 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 0524e2713ab..4c5b1246e7f 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -98,9 +98,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) pVnode->pSyncW.queue->threadId); tMultiWorkerCleanup(&pVnode->pSyncW); - dInfo("vgId:%d, wait for vnode sync ctrl queue:%p is empty, thread:%08" PRId64, pVnode->vgId, - pVnode->pSyncCtrlW.queue, pVnode->pSyncCtrlW.queue->threadId); - tMultiWorkerCleanup(&pVnode->pSyncCtrlW); + dInfo("vgId:%d, wait for vnode sync rd queue:%p is empty, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncRdW.queue, + pVnode->pSyncRdW.queue->threadId); + tMultiWorkerCleanup(&pVnode->pSyncRdW); dInfo("vgId:%d, wait for vnode apply queue:%p is empty, thread:%08" PRId64, pVnode->vgId, pVnode->pApplyW.queue, pVnode->pApplyW.queue->threadId); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 7aa1c9f56ac..e4e0d608de4 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -216,9 +216,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp dGTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pSyncW.queue, pMsg); break; - case SYNC_CTRL_QUEUE: - dGTrace("vgId:%d, msg:%p put into vnode-sync-ctrl queue", pVnode->vgId, pMsg); - taosWriteQitem(pVnode->pSyncCtrlW.queue, pMsg); + case SYNC_RD_QUEUE: + dGTrace("vgId:%d, msg:%p put into vnode-sync-rd queue", pVnode->vgId, pMsg); + taosWriteQitem(pVnode->pSyncRdW.queue, pMsg); break; case APPLY_QUEUE: dGTrace("vgId:%d, msg:%p put into vnode-apply queue", pVnode->vgId, pMsg); @@ -234,9 +234,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp return code; } -int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return vmPutMsgToQueue(pMgmt, pMsg, SYNC_CTRL_QUEUE); -} +int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_RD_QUEUE); } int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); } @@ -327,18 +325,18 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) { int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { SMultiWorkerCfg wcfg = {.max = 1, .name = "vnode-write", .fp = (FItems)vnodeProposeWriteMsg, .param = pVnode->pImpl}; SMultiWorkerCfg scfg = {.max = 1, .name = "vnode-sync", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; - SMultiWorkerCfg sccfg = {.max = 1, .name = "vnode-sync-ctrl", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; + SMultiWorkerCfg sccfg = {.max = 1, .name = "vnode-sync-rd", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; SMultiWorkerCfg acfg = {.max = 1, .name = "vnode-apply", .fp = (FItems)vnodeApplyWriteMsg, .param = pVnode->pImpl}; (void)tMultiWorkerInit(&pVnode->pWriteW, &wcfg); (void)tMultiWorkerInit(&pVnode->pSyncW, &scfg); - (void)tMultiWorkerInit(&pVnode->pSyncCtrlW, &sccfg); + (void)tMultiWorkerInit(&pVnode->pSyncRdW, &sccfg); (void)tMultiWorkerInit(&pVnode->pApplyW, &acfg); pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue); pVnode->pStreamQ = tAutoQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue); pVnode->pFetchQ = tWWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItems)vmProcessFetchQueue); - if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncCtrlW.queue == NULL || + if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncRdW.queue == NULL || pVnode->pApplyW.queue == NULL || pVnode->pQueryQ == NULL || pVnode->pStreamQ == NULL || pVnode->pFetchQ == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -348,8 +346,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { pVnode->pWriteW.queue->threadId); dInfo("vgId:%d, sync-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncW.queue, pVnode->pSyncW.queue->threadId); - dInfo("vgId:%d, sync-ctrl-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncCtrlW.queue, - pVnode->pSyncCtrlW.queue->threadId); + dInfo("vgId:%d, sync-rd-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncRdW.queue, + pVnode->pSyncRdW.queue->threadId); dInfo("vgId:%d, apply-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pApplyW.queue, pVnode->pApplyW.queue->threadId); dInfo("vgId:%d, query-queue:%p is alloced", pVnode->vgId, pVnode->pQueryQ); diff --git a/source/dnode/mnode/impl/inc/mndConsumer.h b/source/dnode/mnode/impl/inc/mndConsumer.h index 99b0d06936e..aa38b94fd7d 100644 --- a/source/dnode/mnode/impl/inc/mndConsumer.h +++ b/source/dnode/mnode/impl/inc/mndConsumer.h @@ -24,10 +24,10 @@ extern "C" { enum { MQ_CONSUMER_STATUS__MODIFY = 1, - MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore +// MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS__READY, MQ_CONSUMER_STATUS__LOST, - MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore +// MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS__LOST_REBD, MQ_CONSUMER_STATUS__REMOVED, }; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 1b60c0a95e3..d8519a23285 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -394,7 +394,7 @@ typedef struct { } SSmaObj; typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; + char name[TSDB_INDEX_FNAME_LEN]; char stb[TSDB_TABLE_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; char dstTbName[TSDB_TABLE_FNAME_LEN]; diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 616f69cd5ba..0f3f862d6d6 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -247,6 +247,13 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebInfo; } +static void freeRebalanceItem(void* param) { + SMqRebInfo* pInfo = param; + taosArrayDestroy(pInfo->lostConsumers); + taosArrayDestroy(pInfo->newConsumers); + taosArrayDestroy(pInfo->removedConsumers); +} + static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SSdb *pSdb = pMnode->pSdb; @@ -262,8 +269,21 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { } SMqDoRebalanceMsg *pRebMsg = rpcMallocCont(sizeof(SMqDoRebalanceMsg)); + if (pRebMsg == NULL) { + mError("failed to create the rebalance msg, size:%d, quit mq timer", (int32_t) sizeof(SMqDoRebalanceMsg)); + mndRebEnd(); + return TSDB_CODE_OUT_OF_MEMORY; + } + pRebMsg->rebSubHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK); - // TODO set cleanfp + if (pRebMsg->rebSubHash == NULL) { + mError("failed to create rebalance hashmap"); + rpcFreeCont(pRebMsg); + mndRebEnd(); + return TSDB_CODE_OUT_OF_MEMORY; + } + + taosHashSetFreeFp(pRebMsg->rebSubHash, freeRebalanceItem); // iterate all consumers, find all modification while (1) { @@ -317,7 +337,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); } taosRUnLockLatch(&pConsumer->lock); - } else if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { + } else if (status == MQ_CONSUMER_STATUS__MODIFY) { taosRLockLatch(&pConsumer->lock); int32_t newTopicNum = taosArrayGetSize(pConsumer->rebNewTopics); @@ -356,7 +376,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { } else { taosHashCleanup(pRebMsg->rebSubHash); rpcFreeCont(pRebMsg); - mDebug("mq rebalance finished, no modification"); + mDebug("mq timer finished, no need to re-balance"); mndRebEnd(); } return 0; @@ -852,6 +872,47 @@ static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { return 0; } +static void updateConsumerStatus(SMqConsumerObj* pConsumer) { + int32_t status = pConsumer->status; + + if (taosArrayGetSize(pConsumer->rebNewTopics) == 0 && taosArrayGetSize(pConsumer->rebRemovedTopics) == 0) { + if (status == MQ_CONSUMER_STATUS__MODIFY) { + pConsumer->status = MQ_CONSUMER_STATUS__READY; + } else if (status == MQ_CONSUMER_STATUS__LOST) { + pConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; + } + } +} + +// remove from new topic +static void removeFromNewTopicList(SMqConsumerObj* pConsumer, const char* pTopic) { + int32_t size = taosArrayGetSize(pConsumer->rebNewTopics); + for (int32_t i = 0; i < taosArrayGetSize(pConsumer->rebNewTopics); i++) { + char *p = taosArrayGetP(pConsumer->rebNewTopics, i); + if (strcmp(pTopic, p) == 0) { + taosArrayRemove(pConsumer->rebNewTopics, i); + taosMemoryFree(p); + + mDebug("consumer:0x%" PRIx64 " remove new topic:%s in the topic list, remain newTopics:%d", pConsumer->consumerId, + pTopic, (int) taosArrayGetSize(pConsumer->rebNewTopics)); + break; + } + } +} + +// remove from removed topic +static void removeFromRemoveTopicList(SMqConsumerObj* pConsumer, const char* pTopic) { + int32_t size = taosArrayGetSize(pConsumer->rebRemovedTopics); + for (int32_t i = 0; i < size; i++) { + char *p = taosArrayGetP(pConsumer->rebRemovedTopics, i); + if (strcmp(pTopic, p) == 0) { + taosArrayRemove(pConsumer->rebRemovedTopics, i); + taosMemoryFree(p); + break; + } + } +} + static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { mDebug("consumer:0x%" PRIx64 " perform update action, update type:%d, subscribe-time:%" PRId64 ", uptime:%" PRId64, pOldConsumer->consumerId, pNewConsumer->updateType, pOldConsumer->subscribeTime, pOldConsumer->upTime); @@ -862,6 +923,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, /*A(taosArrayGetSize(pOldConsumer->rebNewTopics) == 0);*/ /*A(taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0);*/ + // this new consumer has identical topics with one existed consumers. if (taosArrayGetSize(pNewConsumer->rebNewTopics) == 0 && taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0) { pOldConsumer->status = MQ_CONSUMER_STATUS__READY; } else { @@ -878,7 +940,6 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pNewConsumer->assignedTopics = tmp; pOldConsumer->subscribeTime = pNewConsumer->upTime; - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY; } } else if (pNewConsumer->updateType == CONSUMER_UPDATE__LOST) { @@ -918,71 +979,48 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pOldConsumer->rebalanceTime = pNewConsumer->upTime; } else if (pNewConsumer->updateType == CONSUMER_UPDATE__ADD) { - /*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1);*/ - /*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0);*/ + ASSERT(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1 && taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0); + char *pNewTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); - char *addedTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); // not exist in current topic - - bool existing = false; -#if 1 + bool existing = false; int32_t numOfExistedTopics = taosArrayGetSize(pOldConsumer->currentTopics); for (int32_t i = 0; i < numOfExistedTopics; i++) { char *topic = taosArrayGetP(pOldConsumer->currentTopics, i); - if (strcmp(topic, addedTopic) == 0) { + if (strcmp(topic, pNewTopic) == 0) { existing = true; } } -#endif - // remove from new topic - for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebNewTopics); i++) { - char *topic = taosArrayGetP(pOldConsumer->rebNewTopics, i); - if (strcmp(addedTopic, topic) == 0) { - taosArrayRemove(pOldConsumer->rebNewTopics, i); - taosMemoryFree(topic); - break; - } - } + removeFromNewTopicList(pOldConsumer, pNewTopic); // add to current topic if (!existing) { - taosArrayPush(pOldConsumer->currentTopics, &addedTopic); + taosArrayPush(pOldConsumer->currentTopics, &pNewTopic); taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); } else { - taosMemoryFree(addedTopic); + taosMemoryFree(pNewTopic); } // set status int32_t status = pOldConsumer->status; - if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__READY; - } else if (status == MQ_CONSUMER_STATUS__LOST_IN_REB || status == MQ_CONSUMER_STATUS__LOST) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; - } - } else { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY_IN_REB; - } else if (status == MQ_CONSUMER_STATUS__LOST || status == MQ_CONSUMER_STATUS__LOST_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_IN_REB; - } - } + updateConsumerStatus(pOldConsumer); // the re-balance is triggered when the new consumer is launched. pOldConsumer->rebalanceTime = pNewConsumer->upTime; atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 ", current topics:%d", + mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), - pOldConsumer->epoch, pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->currentTopics)); + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + } else if (pNewConsumer->updateType == CONSUMER_UPDATE__REMOVE) { /*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 0);*/ /*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 1);*/ char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); - - // not exist in new topic #if 0 for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebNewTopics); i++) { char *topic = taosArrayGetP(pOldConsumer->rebNewTopics, i); @@ -991,14 +1029,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, #endif // remove from removed topic - for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebRemovedTopics); i++) { - char *topic = taosArrayGetP(pOldConsumer->rebRemovedTopics, i); - if (strcmp(removedTopic, topic) == 0) { - taosArrayRemove(pOldConsumer->rebRemovedTopics, i); - taosMemoryFree(topic); - break; - } - } + removeFromRemoveTopicList(pOldConsumer, removedTopic); // remove from current topic int32_t i = 0; @@ -1011,32 +1042,20 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, break; } } - // must find the topic - /*A(i < sz);*/ // set status int32_t status = pOldConsumer->status; - if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__READY; - } else if (status == MQ_CONSUMER_STATUS__LOST_IN_REB || status == MQ_CONSUMER_STATUS__LOST) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; - } - } else { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY_IN_REB; - } else if (status == MQ_CONSUMER_STATUS__LOST || status == MQ_CONSUMER_STATUS__LOST_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_IN_REB; - } - } + updateConsumerStatus(pOldConsumer); pOldConsumer->rebalanceTime = pNewConsumer->upTime; atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mDebug("consumer:0x%" PRIx64 " state %d(%s) -> %d(%s), new epoch:%d, reb-time:%" PRId64 ", current topics:%d", + mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), - pOldConsumer->epoch, pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->currentTopics)); + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } taosWUnLockLatch(&pOldConsumer->lock); @@ -1170,10 +1189,8 @@ static const char *mndConsumerStatusName(int status) { return "ready"; case MQ_CONSUMER_STATUS__LOST: case MQ_CONSUMER_STATUS__LOST_REBD: - case MQ_CONSUMER_STATUS__LOST_IN_REB: return "lost"; case MQ_CONSUMER_STATUS__MODIFY: - case MQ_CONSUMER_STATUS__MODIFY_IN_REB: return "rebalancing"; default: return "unknown"; diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index 8782fd823f3..83172acf641 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -138,7 +138,7 @@ static void *mndBuildDropIdxReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStbOb mInfo("idx: %s start to build drop index req", pIdx->name); len = tSerializeSDropIdxReq(NULL, 0, &req); - if (ret < 0) { + if (len < 0) { goto _err; } @@ -672,7 +672,7 @@ int32_t mndAddIndexImpl(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pSt static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *req, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; SIdxObj idxObj = {0}; - memcpy(idxObj.name, req->idxName, TSDB_TABLE_FNAME_LEN); + memcpy(idxObj.name, req->idxName, TSDB_INDEX_FNAME_LEN); memcpy(idxObj.stb, pStb->name, TSDB_TABLE_FNAME_LEN); memcpy(idxObj.db, pDb->name, TSDB_DB_FNAME_LEN); memcpy(idxObj.colName, req->colName, TSDB_COL_NAME_LEN); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 41dea507314..50e502f4ab9 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -226,7 +226,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { goto _OVER; } - if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, version, 2)) != 0) { + if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, version, 3)) != 0) { terrno = code; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 924216bcbf8..64a3170d471 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -197,24 +197,20 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebSub; } -static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { - int32_t totalVgNum = pOutput->pSub->vgNum; - const char *sub = pOutput->pSub->key; - mInfo("sub:%s mq re-balance %d vgroups", sub, pOutput->pSub->vgNum); - - // 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg - SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); +static void doRemoveExistedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + const char *pSubKey = pOutput->pSub->key; - // 2. check and get actual removed consumers, put their vg into hash - int32_t removedNum = taosArrayGetSize(pInput->pRebInfo->removedConsumers); int32_t actualRemoved = 0; - for (int32_t i = 0; i < removedNum; i++) { + for (int32_t i = 0; i < numOfRemoved; i++) { uint64_t consumerId = *(uint64_t *)taosArrayGet(pInput->pRebInfo->removedConsumers, i); SMqConsumerEp *pConsumerEp = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + // consumer exists till now if (pConsumerEp) { actualRemoved++; + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); for (int32_t j = 0; j < consumerVgNum; j++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); @@ -223,52 +219,66 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .newConsumerId = -1, .pVgEp = pVgEp, }; + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from consumer:0x%" PRIx64, sub, pVgEp->vgId, consumerId); + mInfo("sub:%s mq re-balance remove vgId:%d from consumer:%" PRIx64, pSubKey, pVgEp->vgId, consumerId); } + taosArrayDestroy(pConsumerEp->vgs); taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + // put into removed taosArrayPush(pOutput->removedConsumers, &consumerId); } } - if (removedNum != actualRemoved) { - mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", sub, removedNum, actualRemoved); + if (numOfRemoved != actualRemoved) { + mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", pSubKey, numOfRemoved, actualRemoved); + } else { + mInfo("sub:%s removed %d consumers", pSubKey, numOfRemoved); } +} - // if previously no consumer, there are vgs not assigned - { - int32_t consumerVgNum = taosArrayGetSize(pOutput->pSub->unassignedVgs); - for (int32_t i = 0; i < consumerVgNum; i++) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); - SMqRebOutputVg rebOutput = { - .oldConsumerId = -1, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from unassigned", sub, pVgEp->vgId); - } +static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { + int32_t numOfNewConsumers = taosArrayGetSize(pInput->pRebInfo->newConsumers); + const char *pSubKey = pOutput->pSub->key; + + for (int32_t i = 0; i < numOfNewConsumers; i++) { + int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); + + SMqConsumerEp newConsumerEp; + newConsumerEp.consumerId = consumerId; + newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); + + taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); + taosArrayPush(pOutput->newConsumers, &consumerId); + mInfo("sub:%s mq rebalance add new consumer:%" PRIx64, pSubKey, consumerId); } +} - // 3. calc vg number of each consumer - int32_t afterRebConsumerNum = pInput->oldConsumerNum + taosArrayGetSize(pInput->pRebInfo->newConsumers) - - taosArrayGetSize(pInput->pRebInfo->removedConsumers); - int32_t minVgCnt = 0; - int32_t imbConsumerNum = 0; - // calc num - if (afterRebConsumerNum) { - minVgCnt = totalVgNum / afterRebConsumerNum; - imbConsumerNum = totalVgNum % afterRebConsumerNum; +static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj* pHash) { + const char *pSubKey = pOutput->pSub->key; + int32_t numOfVgroups = taosArrayGetSize(pOutput->pSub->unassignedVgs); + + for (int32_t i = 0; i < numOfVgroups; i++) { + SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); + SMqRebOutputVg rebOutput = { + .oldConsumerId = -1, + .newConsumerId = -1, + .pVgEp = pVgEp, + }; + + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); + mInfo("sub:%s mq re-balance remove vgId:%d from unassigned", pSubKey, pVgEp->vgId); } +} - mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has more vgs", sub, - afterRebConsumerNum, minVgCnt, imbConsumerNum); +static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj* pHash, int32_t minVgCnt, int32_t imbConsumerNum) { + const char *pSubKey = pOutput->pSub->key; - // 4. first scan: remove consumer more than wanted, put to remove hash int32_t imbCnt = 0; void *pIter = NULL; + while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) { @@ -276,8 +286,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); // all old consumers still existing are touched // TODO optimize: touch only consumer whose vgs changed taosArrayPush(pOutput->touchedConsumers, &pConsumerEp->consumerId); @@ -296,13 +306,13 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", sub, pVgEp->vgId, + mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } imbCnt++; } } else { - // pop until equal minVg + // all the remain consumers should only have the number of vgroups, which is equalled to the value of minVg while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt) { SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); SMqRebOutputVg outputVg = { @@ -311,36 +321,67 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", sub, pVgEp->vgId, + mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } } } } +} - // 5. add new consumer into sub - { - int32_t consumerNum = taosArrayGetSize(pInput->pRebInfo->newConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); - - SMqConsumerEp newConsumerEp; - newConsumerEp.consumerId = consumerId; - newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); - taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); - taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("sub:%s mq rebalance add new consumer:0x%" PRIx64, sub, consumerId); - } +static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { + int32_t totalVgNum = pOutput->pSub->vgNum; + const char *pSubKey = pOutput->pSub->key; + + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); + mInfo("sub:%s mq re-balance %d vgroups, existed consumers:%d, added:%d, removed:%d", pSubKey, totalVgNum, + pInput->oldConsumerNum, numOfAdded, numOfRemoved); + + // 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg + SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + + // 2. check and get actual removed consumers, put their vg into hash + doRemoveExistedConsumers(pOutput, pHash, pInput); + + // 3. if previously no consumer, there are vgs not assigned + addUnassignedVgroups(pOutput, pHash); + + // 4. calc vg number of each consumer + int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; + + int32_t minVgCnt = 0; + int32_t imbConsumerNum = 0; + + // calc num + if (numOfFinal) { + minVgCnt = totalVgNum / numOfFinal; + imbConsumerNum = totalVgNum % numOfFinal; + mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has 1 more vgroups than avg value", + pSubKey, numOfFinal, minVgCnt, imbConsumerNum); + } else { + mInfo("sub:%s no consumer subscribe this topic", pSubKey); } - // 6. second scan: find consumer do not have enough vg, extract from temporary hash and assign to new consumer. + // 5. first scan: remove vgroups from te consumers, who have more vgroups than the threashold value that is + // minVgCnt, and then put them into the recycled hash list + transferVgroupsForConsumers(pOutput, pHash, minVgCnt, imbConsumerNum); + + // 6. add new consumer into sub + doAddNewConsumers(pOutput, pInput); + + // 7. second scan: find consumer do not have enough vgroups, extract from temporary hash and assign to them // All related vg should be put into rebVgs SMqRebOutputVg *pRebVg = NULL; void *pRemovedIter = NULL; - pIter = NULL; + void *pIter = NULL; + while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) break; + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; // push until equal minVg @@ -348,8 +389,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR // iter hash and find one vg pRemovedIter = taosHashIterate(pHash, pRemovedIter); if (pRemovedIter == NULL) { - mError("sub:%s removed iter is null", sub); - continue; + mError("sub:%s removed iter is null", pSubKey); + break; } pRebVg = (SMqRebOutputVg *)pRemovedIter; @@ -409,15 +450,15 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); taosArrayPush(pOutput->rebVgs, pRebOutput); - mInfo("sub:%s mq re-balance unassign vgId:%d (second scan)", sub, pRebOutput->pVgEp->vgId); + mInfo("sub:%s mq re-balance unassign vgId:%d (second scan)", pSubKey, pRebOutput->pVgEp->vgId); } } // 8. generate logs - mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", sub); + mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pSubKey); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, sub, + mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pSubKey, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } { @@ -427,10 +468,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", sub, pConsumerEp->consumerId, sz); + mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pSubKey, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, sub, pVgEp->vgId, + mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } } @@ -555,17 +596,23 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMqDoRebalanceMsg *pReq = pMsg->pCont; void *pIter = NULL; + bool rebalanceOnce = false; // to ensure only once. - mInfo("mq re-balance start"); + mInfo("mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(pReq->rebSubHash)); + // here we only handle one topic rebalance requirement to ensure the atomic execution of this transaction. while (1) { + if (rebalanceOnce) { + break; + } + pIter = taosHashIterate(pReq->rebSubHash, pIter); if (pIter == NULL) { break; } + // todo handle the malloc failure SMqRebInputObj rebInput = {0}; - SMqRebOutputObj rebOutput = {0}; rebOutput.newConsumers = taosArrayInit(0, sizeof(int64_t)); rebOutput.removedConsumers = taosArrayInit(0, sizeof(int64_t)); @@ -582,9 +629,10 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { char topic[TSDB_TOPIC_FNAME_LEN]; char cgroup[TSDB_CGROUP_LEN]; mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); if (pTopic == NULL) { - mError("mq re-balance %s ignored since topic %s not exist", pRebInfo->key, topic); + mError("mq re-balance %s ignored since topic %s doesn't exist", pRebInfo->key, topic); continue; } @@ -604,11 +652,13 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { mndReleaseTopic(pMnode, pTopic); rebInput.oldConsumerNum = 0; + mInfo("topic:%s has no consumers sub yet", topic); } else { taosRLockLatch(&pSub->lock); rebInput.oldConsumerNum = taosHashGetSize(pSub->consumerHash); rebOutput.pSub = tCloneSubscribeObj(pSub); taosRUnLockLatch(&pSub->lock); + mInfo("topic:%s has %d consumers sub till now", pRebInfo->key, rebInput.oldConsumerNum); mndReleaseSubscribe(pMnode, pSub); } @@ -623,16 +673,14 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { mError("mq re-balance persist output error, possibly vnode splitted or dropped"); } - taosArrayDestroy(pRebInfo->lostConsumers); - taosArrayDestroy(pRebInfo->newConsumers); - taosArrayDestroy(pRebInfo->removedConsumers); - taosArrayDestroy(rebOutput.newConsumers); taosArrayDestroy(rebOutput.touchedConsumers); taosArrayDestroy(rebOutput.removedConsumers); taosArrayDestroy(rebOutput.rebVgs); tDeleteSubscribeObj(rebOutput.pSub); taosMemoryFree(rebOutput.pSub); + + rebalanceOnce = true; } // reset flag diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 18548db56f0..4965d5c34a2 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -33,7 +33,7 @@ static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { return -1; } - int32_t code = tmsgPutToQueue(msgcb, SYNC_CTRL_QUEUE, pMsg); + int32_t code = tmsgPutToQueue(msgcb, SYNC_RD_QUEUE, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 39b4252618f..9d8a662b6b0 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1091,10 +1091,13 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { pAction->msgReceived = 1; pAction->errCode = pRsp->code; pTrans->lastErrorNo = pRsp->code; + + mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, + mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode); + } else { + mInfo("trans:%d, invalid action, index:%d, code:0x%x", transId, action, pRsp->code); } - mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage), - action, pRsp->code, pAction->acceptableCode, pAction->retryCode); mndTransExecute(pMnode, pTrans, true); _OVER: diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 8dc3f46ae3d..9911752f8e2 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -57,7 +57,7 @@ target_sources( # tq "src/tq/tq.c" - "src/tq/tqExec.c" + "src/tq/tqScan.c" "src/tq/tqMeta.c" "src/tq/tqRead.c" "src/tq/tqOffset.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 2d053d04aeb..a9e5fe628bb 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -178,11 +178,11 @@ typedef struct STsdbReader STsdbReader; int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num); int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables, - SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr); + SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr, bool countOnly); void tsdbReaderSetId(STsdbReader* pReader, const char* idstr); void tsdbReaderClose(STsdbReader *pReader); -bool tsdbNextDataBlock(STsdbReader *pReader); +int32_t tsdbNextDataBlock(STsdbReader *pReader, bool *hasNext); int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave); void tsdbReleaseDataBlock(STsdbReader *pReader); SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); @@ -228,19 +228,12 @@ typedef struct SSnapContext { SArray *idList; int32_t index; bool withMeta; - bool queryMetaOrData; // true-get meta, false-get data + bool queryMeta; // true-get meta, false-get data } SSnapContext; typedef struct STqReader { - // const SSubmitReq *pMsg; - // SSubmitBlk *pBlock; - // SSubmitMsgIter msgIter; - // SSubmitBlkIter blkIter; - - int64_t ver; SPackedData msg2; - int8_t setMsg; SSubmitReq2 submit; int32_t nextBlk; @@ -267,7 +260,7 @@ int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqSeekVer(STqReader *pReader, int64_t ver, const char *id); -int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret); +void tqNextBlock(STqReader *pReader, SFetchRet *ret); int32_t tqReaderSetSubmitReq2(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver); // int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 452b1f6c0b8..2a85b191a42 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -123,12 +123,12 @@ int32_t tsdbRowIterOpen(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) void tsdbRowClose(STSDBRowIter *pIter); SColVal *tsdbRowIterNext(STSDBRowIter *pIter); // SRowMerger -int32_t tsdbRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema); +int32_t tsdbRowMergerInit(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema); int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema); -int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema); -void tsdbRowMergerClear(SRowMerger *pMerger); -int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow); +// int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema); +void tsdbRowMergerClear(SRowMerger *pMerger); +// int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow); int32_t tsdbRowMergerGetRow(SRowMerger *pMerger, SRow **ppRow); // TABLEID int32_t tTABLEIDCmprFn(const void *p1, const void *p2); @@ -224,6 +224,8 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, void *tsdbTbDataIterDestroy(STbDataIter *pIter); void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter); bool tsdbTbDataIterNext(STbDataIter *pIter); +void tsdbMemTableCountRows(SMemTable *pMemTable, SHashObj *pTableMap, int64_t *rowsNum); + // STbData int32_t tsdbGetNRowsInTbData(STbData *pTbData); // tsdbFile.c ============================================================================================== diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 0fe7f9a7730..8b01ba237f2 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -193,7 +193,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode); void tqClose(STQ*); int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver); int tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest, SRpcMsg* pRpcMsg, SMqDataRsp* pDataRsp, int32_t type); -int tqRemovePushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer); +int tqUnregisterPushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer); int tqCommit(STQ*); int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 67ade457328..0126d29cc93 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -268,7 +268,7 @@ int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t ctx->snapVersion = snapVersion; ctx->suid = suid; ctx->subType = subType; - ctx->queryMetaOrData = withMeta; + ctx->queryMeta = withMeta; ctx->withMeta = withMeta; ctx->idVersion = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); if (ctx->idVersion == NULL) { @@ -475,7 +475,7 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in if (ctx->index >= taosArrayGetSize(ctx->idList)) { metaDebug("tmqsnap get meta end"); ctx->index = 0; - ctx->queryMetaOrData = false; // change to get data + ctx->queryMeta = false; // change to get data return 0; } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 3ed1b083e43..c75c675ec39 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -669,7 +669,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma #endif for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) { SSDataBlock *output = taosArrayGetP(pResList, i); - smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%d", output->info.id.uid, + smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%" PRId64, output->info.id.uid, output->info.id.groupId, output->info.rows); STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 7997a9eb1af..66e6ac4cd8c 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -223,19 +223,6 @@ static int32_t doSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqData int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { SMqDataRsp* pRsp = pPushEntry->pDataRsp; - -#if 0 - A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); - A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - - A(!pRsp->withSchema); - A(taosArrayGetSize(pRsp->blockSchema) == 0); - - if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { - A(pRsp->rspOffset.version > pRsp->reqOffset.version); - } -#endif - SMqRspHead* pHeader = &pPushEntry->pDataRsp->head; doSendDataRsp(&pPushEntry->info, pRsp, pHeader->epoch, pHeader->consumerId, pHeader->mqMsgType); @@ -249,21 +236,6 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { } int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type) { -#if 0 - A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); - A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - - A(!pRsp->withSchema); - A(taosArrayGetSize(pRsp->blockSchema) == 0); - - if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { - if (pRsp->blockNum > 0) { - A(pRsp->rspOffset.version > pRsp->reqOffset.version); - } else { - A(pRsp->rspOffset.version >= pRsp->reqOffset.version); - } - } -#endif doSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type); char buf1[80] = {0}; @@ -365,17 +337,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su } pRsp->withTbName = 0; -#if 0 - pRsp->withTbName = pReq->withTbName; - if (pRsp->withTbName) { - pRsp->blockTbName = taosArrayInit(0, sizeof(void*)); - if (pRsp->blockTbName == NULL) { - // TODO free - return -1; - } - } -#endif - pRsp->withSchema = false; return 0; } @@ -412,8 +373,8 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand char formatBuf[80]; tFormatOffset(formatBuf, 80, pOffsetVal); - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue.", - consumerId, pHandle->subKey, vgId, formatBuf); + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue. reqId:0x%"PRIx64, + consumerId, pHandle->subKey, vgId, formatBuf, pRequest->reqId); return 0; } else { // no poll occurs in this vnode for this topic, let's seek to the right offset value. @@ -434,6 +395,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand return -1; } + // offset set to previous version when init tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer - 1); } } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { @@ -474,7 +436,6 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg, STqOffsetVal* pOffset) { - int32_t code = 0; uint64_t consumerId = pRequest->consumerId; int32_t vgId = TD_VID(pTq->pVnode); @@ -485,7 +446,10 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, taosWLockLatch(&pTq->lock); qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId); - code = tqScanData(pTq, pHandle, &dataRsp, pOffset); + int code = tqScanData(pTq, pHandle, &dataRsp, pOffset); + if(code != 0) { + goto end; + } // till now, all data has been transferred to consumer, new data needs to push client once arrived. if (dataRsp.blockNum == 0 && dataRsp.reqOffset.type == TMQ_OFFSET__LOG && @@ -495,89 +459,60 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, return code; } - taosWUnLockLatch(&pTq->lock); + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_RSP); // NOTE: this pHandle->consumerId may have been changed already. - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, offset type:%d, uid/version:%" PRId64 - ", ts:%" PRId64 ", reqId:0x%" PRIx64, - consumerId, pHandle->subKey, vgId, dataRsp.blockNum, dataRsp.rspOffset.type, dataRsp.rspOffset.uid, - dataRsp.rspOffset.ts, pRequest->reqId); - tDeleteSMqDataRsp(&dataRsp); +end: + { + char buf[80] = {0}; + tFormatOffset(buf, 80, &dataRsp.rspOffset); + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%" PRIx64 " code:%d", + consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId, code); + taosWUnLockLatch(&pTq->lock); + tDeleteSMqDataRsp(&dataRsp); + } return code; } -static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg) { - int32_t code = -1; - STqOffsetVal offset = {0}; - SWalCkHead* pCkHead = NULL; - int32_t vgId = TD_VID(pTq->pVnode); - - STqOffsetVal reqOffset = pRequest->reqOffset; - uint64_t consumerId = pRequest->consumerId; - // 1. reset the offset if needed - if (IS_OFFSET_RESET_TYPE(reqOffset.type)) { - // handle the reset offset cases, according to the consumer's choice. - bool blockReturned = false; - code = extractResetOffsetVal(&offset, pTq, pHandle, pRequest, pMsg, &blockReturned); - if (code != 0) { - return code; - } - - // empty block returned, quit - if (blockReturned) { - return 0; - } - } else { // use the consumer specified offset - // the offset value can not be monotonious increase?? - offset = reqOffset; - } - - // this is a normal subscribe requirement - if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { - return extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &offset); - } - - // todo handle the case where re-balance occurs. - // for taosx +static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg, STqOffsetVal *offset) { + int code = 0; + int32_t vgId = TD_VID(pTq->pVnode); + SWalCkHead* pCkHead = NULL; SMqMetaRsp metaRsp = {0}; STaosxRsp taosxRsp = {0}; tqInitTaosxRsp(&taosxRsp, pRequest); - if (offset.type != TMQ_OFFSET__LOG) { - if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, &offset) < 0) { + if (offset->type != TMQ_OFFSET__LOG) { + if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, offset) < 0) { return -1; } if (metaRsp.metaRspLen > 0) { code = tqSendMetaPollRsp(pTq, pMsg, pRequest, &metaRsp); - tqDebug("tmq poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send meta offset type:%d,uid:%" PRId64 - ",ts:%" PRId64, - consumerId, pHandle->subKey, vgId, metaRsp.rspOffset.type, metaRsp.rspOffset.uid, - metaRsp.rspOffset.ts); + tqDebug("tmq poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send meta offset type:%d,uid:%" PRId64 ",ts:%" PRId64, + pRequest->consumerId, pHandle->subKey, vgId, metaRsp.rspOffset.type, metaRsp.rspOffset.uid, metaRsp.rspOffset.ts); taosMemoryFree(metaRsp.metaRsp); tDeleteSTaosxRsp(&taosxRsp); return code; } + tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64 + ",ts:%" PRId64,pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type, taosxRsp.rspOffset.uid,taosxRsp.rspOffset.ts); if (taosxRsp.blockNum > 0) { code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); tDeleteSTaosxRsp(&taosxRsp); return code; - } else { - offset = taosxRsp.rspOffset; + }else { + *offset = taosxRsp.rspOffset; } - - tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64 - ",version:%" PRId64, - consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type, taosxRsp.rspOffset.uid, - taosxRsp.rspOffset.version); } - if (offset.type == TMQ_OFFSET__LOG) { - int64_t fetchVer = offset.version + 1; + + if (offset->type == TMQ_OFFSET__LOG) { + int64_t fetchVer = offset->version + 1; pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); if (pCkHead == NULL) { tDeleteSTaosxRsp(&taosxRsp); @@ -587,12 +522,10 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p walSetReaderCapacity(pHandle->pWalReader, 2048); int totalRows = 0; while (1) { - // todo refactor: this is not correct. int32_t savedEpoch = atomic_load_32(&pHandle->epoch); if (savedEpoch > pRequest->epoch) { tqWarn("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey:%s vgId:%d offset %" PRId64 - ", found new consumer epoch %d, discard req epoch %d", - consumerId, pRequest->epoch, pHandle->subKey, vgId, fetchVer, savedEpoch, pRequest->epoch); + ", found new consumer epoch %d, discard req epoch %d", pRequest->consumerId, pRequest->epoch, pHandle->subKey, vgId, fetchVer, savedEpoch, pRequest->epoch); break; } @@ -605,7 +538,7 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p } SWalCont* pHead = &pCkHead->head; - tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d", consumerId, + tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d", pRequest->consumerId, pRequest->epoch, vgId, fetchVer, pHead->msgType); // process meta @@ -643,7 +576,7 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p }; if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp, &totalRows) < 0) { - tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", consumerId, vgId, + tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId, pRequest->subKey); taosMemoryFreeClear(pCkHead); tDeleteSTaosxRsp(&taosxRsp); @@ -667,6 +600,39 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p return 0; } +static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg) { + int32_t code = -1; + STqOffsetVal offset = {0}; + STqOffsetVal reqOffset = pRequest->reqOffset; + + // 1. reset the offset if needed + if (IS_OFFSET_RESET_TYPE(reqOffset.type)) { + // handle the reset offset cases, according to the consumer's choice. + bool blockReturned = false; + code = extractResetOffsetVal(&offset, pTq, pHandle, pRequest, pMsg, &blockReturned); + if (code != 0) { + return code; + } + + // empty block returned, quit + if (blockReturned) { + return 0; + } + } else { // use the consumer specified offset + // the offset value can not be monotonious increase?? + offset = reqOffset; + } + + // this is a normal subscribe requirement + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + return extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &offset); + } + + // todo handle the case where re-balance occurs. + // for taosx + return extractDataAndRspForDbStbSubscribe(pTq, pHandle, pRequest, pMsg, &offset); +} + int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { SMqPollReq req = {0}; if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) { @@ -808,7 +774,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg STqHandle tqHandle = {0}; pHandle = &tqHandle; - /*taosInitRWLatch(&pExec->lock);*/ uint64_t oldConsumerId = pHandle->consumerId; memcpy(pHandle->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN); @@ -829,13 +794,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg pHandle->pRef = pRef; SReadHandle handle = { - .meta = pVnode->pMeta, - .vnode = pVnode, - .initTableReader = true, - .initTqReader = true, - .version = ver, - }; - + .meta = pVnode->pMeta, .vnode = pVnode, .initTableReader = true, .initTqReader = true, .version = ver}; pHandle->snapshotVer = ver; if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { @@ -843,7 +802,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg req.qmsg = NULL; pHandle->execHandle.task = - qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, vgId, &pHandle->execHandle.numOfCols, NULL); + qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, vgId, &pHandle->execHandle.numOfCols, req.newConsumerId); void* scanner = NULL; qExtractStreamScanner(pHandle->execHandle.task, &scanner); pHandle->execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner); @@ -856,7 +815,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg buildSnapContext(handle.meta, handle.version, 0, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext**)(&handle.sContext)); - pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId); } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { pHandle->pWalReader = walOpenReader(pVnode->pWal, NULL); pHandle->execHandle.execTb.suid = req.suid; @@ -874,7 +833,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg buildSnapContext(handle.meta, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext**)(&handle.sContext)); - pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId); } taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle)); @@ -905,7 +864,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg atomic_store_32(&pHandle->epoch, -1); // remove if it has been register in the push manager, and return one empty block to consumer - tqRemovePushEntry(pTq, req.subKey, (int32_t)strlen(req.subKey), pHandle->consumerId, true); + tqUnregisterPushEntry(pTq, req.subKey, (int32_t)strlen(req.subKey), pHandle->consumerId, true); atomic_store_64(&pHandle->consumerId, req.newConsumerId); atomic_add_fetch_32(&pHandle->epoch, 1); @@ -1348,7 +1307,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { pRefBlock->dataRef = pRef; atomic_add_fetch_32(pRefBlock->dataRef, 1); - if (streamTaskInput(pTask, (SStreamQueueItem*)pRefBlock) < 0) { + if (tAppendDataForStream(pTask, (SStreamQueueItem*)pRefBlock) < 0) { qError("stream task input del failed, task id %d", pTask->taskId); atomic_sub_fetch_32(pRef, 1); @@ -1383,7 +1342,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { taosArrayPush(pStreamBlock->blocks, &block); if (!failed) { - if (streamTaskInput(pTask, (SStreamQueueItem*)pStreamBlock) < 0) { + if (tAppendDataForStream(pTask, (SStreamQueueItem*)pStreamBlock) < 0) { qError("stream task input del failed, task id %d", pTask->taskId); continue; } @@ -1403,15 +1362,14 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { } int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) { - void* pIter = NULL; - bool failed = false; - SStreamDataSubmit2* pSubmit = NULL; + void* pIter = NULL; + bool succ = true; - pSubmit = streamDataSubmitNew(submit); + SStreamDataSubmit2* pSubmit = streamDataSubmitNew(submit); if (pSubmit == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; tqError("failed to create data submit for stream since out of memory"); - failed = true; + succ = false; } while (1) { @@ -1421,22 +1379,27 @@ int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) { } SStreamTask* pTask = *(SStreamTask**)pIter; - if (pTask->taskLevel != TASK_LEVEL__SOURCE) continue; + if (pTask->taskLevel != TASK_LEVEL__SOURCE) { + continue; + } + if (pTask->taskStatus == TASK_STATUS__RECOVER_PREPARE || pTask->taskStatus == TASK_STATUS__WAIT_DOWNSTREAM) { - tqDebug("skip push task %d, task status %d", pTask->taskId, pTask->taskStatus); + tqDebug("stream task:%d skip push data, not ready for processing, status %d", pTask->taskId, pTask->taskStatus); continue; } - tqDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, submit.ver); + tqDebug("data submit enqueue stream task:%d, ver: %" PRId64, pTask->taskId, submit.ver); + if (succ) { + int32_t code = tAppendDataForStream(pTask, (SStreamQueueItem*)pSubmit); + if (code < 0) { + // let's handle the back pressure - if (!failed) { - if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) { - tqError("stream task input failed, task id %d", pTask->taskId); + tqError("stream task:%d failed to put into queue for, too many", pTask->taskId); continue; } if (streamSchedExec(pTask) < 0) { - tqError("stream task launch failed, task id %d", pTask->taskId); + tqError("stream task:%d launch failed, code:%s", pTask->taskId, tstrerror(terrno)); continue; } } else { @@ -1444,12 +1407,12 @@ int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) { } } - if (pSubmit) { - streamDataSubmitRefDec(pSubmit); + if (pSubmit != NULL) { + streamDataSubmitDestroy(pSubmit); taosFreeQitem(pSubmit); } - return failed ? -1 : 0; + return succ ? 0 : -1; } int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { @@ -1569,6 +1532,8 @@ int32_t vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) { rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); return 0; + } else { + tDeleteStreamDispatchReq(&req); } code = TSDB_CODE_STREAM_TASK_NOT_EXIST; diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index b6bca1e4ca7..a273f2edec4 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -307,7 +307,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { if (handle.execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { handle.execHandle.task = - qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, vgId, &handle.execHandle.numOfCols, NULL); + qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, vgId, &handle.execHandle.numOfCols, 0); if (handle.execHandle.task == NULL) { tqError("cannot create exec task for %s", handle.subKey); code = -1; @@ -332,7 +332,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext**)(&reader.sContext)); - handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, NULL); + handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0); } else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) { handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); @@ -341,7 +341,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid); for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i); - tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid); + tqDebug("vgId:%d, idx %d, uid:%" PRId64, vgId, i, tbUid); } handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode); tqReaderSetTbUidList(handle.execHandle.pExecReader, tbUidList); @@ -349,9 +349,9 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType, handle.fetchMeta, (SSnapContext**)(&reader.sContext)); - handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, NULL); + handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0); } - tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode)); + tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, vgId); taosHashPut(pTq->pHandle, pKey, kLen, &handle, sizeof(STqHandle)); } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 797aeb3f043..9dfcf43e4d5 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -30,7 +30,7 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm // update processed atomic_store_64(&pHandle->pushHandle.processedVer, pSubmit->ver); streamQueueProcessSuccess(&pHandle->pushHandle.inputQ); - streamDataSubmitRefDec(pSubmit); + streamDataSubmitDestroy(pSubmit); if (pRsp->blockNum > 0) { *ppSubmit = pSubmit; return 0; @@ -58,7 +58,7 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) { } while (pHandle->pushHandle.processedVer > pSubmit->ver + 1) { streamQueueProcessSuccess(&pHandle->pushHandle.inputQ); - streamDataSubmitRefDec(pSubmit); + streamDataSubmitDestroy(pSubmit); pSubmit = streamQueueNextItem(&pHandle->pushHandle.inputQ); if (pSubmit == NULL) break; } @@ -120,7 +120,7 @@ int32_t tqPreparePush(STQ* pTq, STqHandle* pHandle, int64_t reqId, const SRpcHan int32_t tqEnqueue(STqHandle* pHandle, SStreamDataSubmit* pSubmit) { int8_t inputStatus = atomic_load_8(&pHandle->pushHandle.inputStatus); if (inputStatus == TASK_INPUT_STATUS__NORMAL) { - SStreamDataSubmit* pSubmitClone = streamSubmitRefClone(pSubmit); + SStreamDataSubmit* pSubmitClone = streamSubmitBlockClone(pSubmit); if (pSubmitClone == NULL) { return -1; } @@ -206,7 +206,69 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ } #endif -int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { +typedef struct { + void* pKey; + int64_t keyLen; +} SItem; + +static void recordPushedEntry(SArray* cachedKey, void* pIter); +static void doRemovePushedEntry(SArray* pCachedKeys, STQ* pTq); + +static void freeItem(void* param) { + SItem* p = (SItem*) param; + taosMemoryFree(p->pKey); +} + +static void doPushDataForEntry(void* pIter, STqExecHandle* pExec, STQ* pTq, int64_t ver, int32_t vgId, char* pData, + int32_t dataLen, SArray* pCachedKey) { + STqPushEntry* pPushEntry = *(STqPushEntry**)pIter; + + SMqDataRsp* pRsp = pPushEntry->pDataRsp; + if (pRsp->reqOffset.version >= ver) { + tqDebug("vgId:%d, push entry req version %" PRId64 ", while push version %" PRId64 ", skip", vgId, + pRsp->reqOffset.version, ver); + return; + } + + qTaskInfo_t pTaskInfo = pExec->task; + + // prepare scan mem data + SPackedData submit = {.msgStr = pData, .msgLen = dataLen, .ver = ver}; + + if (qStreamSetScanMemData(pTaskInfo, submit) != 0) { + return; + } + qStreamSetOpen(pTaskInfo); + // here start to scan submit block to extract the subscribed data + int32_t totalRows = 0; + + while (1) { + SSDataBlock* pDataBlock = NULL; + uint64_t ts = 0; + if (qExecTask(pTaskInfo, &pDataBlock, &ts) < 0) { + tqDebug("vgId:%d, tq exec error since %s", vgId, terrstr()); + } + + if (pDataBlock == NULL) { + break; + } + + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); + pRsp->blockNum++; + totalRows += pDataBlock->info.rows; + } + + tqDebug("vgId:%d, tq handle push, subkey:%s, block num:%d, rows:%d", vgId, pPushEntry->subKey, pRsp->blockNum, + totalRows); + + if (pRsp->blockNum > 0) { + tqOffsetResetToLog(&pRsp->rspOffset, ver); + tqPushDataRsp(pTq, pPushEntry); + recordPushedEntry(pCachedKey, pIter); + } +} + +int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { void* pReq = POINTER_SHIFT(msg, sizeof(SSubmitReq2Msg)); int32_t len = msgLen - sizeof(SSubmitReq2Msg); int32_t vgId = TD_VID(pTq->pVnode); @@ -220,24 +282,19 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) tqDebug("vgId:%d tq push msg version:%" PRId64 " type:%s, head:%p, body:%p len:%d, numOfPushed consumers:%d", vgId, ver, TMSG_INFO(msgType), msg, pReq, len, numOfRegisteredPush); - SArray* cachedKeys = taosArrayInit(0, sizeof(void*)); - SArray* cachedKeyLens = taosArrayInit(0, sizeof(size_t)); - - void* data = taosMemoryMalloc(len); + void* data = taosMemoryMalloc(len); if (data == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tqError("failed to copy data for stream since out of memory"); - taosArrayDestroyP(cachedKeys, (FDelete)taosMemoryFree); - taosArrayDestroy(cachedKeyLens); - - // unlock + tqError("failed to copy data for stream since out of memory, vgId:%d", vgId); taosWUnLockLatch(&pTq->lock); return -1; } memcpy(data, pReq, len); - void* pIter = NULL; + SArray* cachedKey = taosArrayInit(0, sizeof(SItem)); + void* pIter = NULL; + while (1) { pIter = taosHashIterate(pTq->pPushMgr, pIter); if (pIter == NULL) { @@ -248,96 +305,39 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) STqHandle* pHandle = taosHashGet(pTq->pHandle, pPushEntry->subKey, strlen(pPushEntry->subKey)); if (pHandle == NULL) { - tqDebug("vgId:%d, cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey); - continue; - } - - SMqDataRsp* pRsp = pPushEntry->pDataRsp; - if (pRsp->reqOffset.version >= ver) { - tqDebug("vgId:%d, push entry req version %" PRId64 ", while push version %" PRId64 ", skip", vgId, - pRsp->reqOffset.version, ver); + tqDebug("vgId:%d, failed to find handle %s in pushing data to consumer, ignore", pTq->pVnode->config.vgId, pPushEntry->subKey); continue; } STqExecHandle* pExec = &pHandle->execHandle; - qTaskInfo_t task = pExec->task; - - // prepare scan mem data - SPackedData submit = { - .msgStr = data, - .msgLen = len, - .ver = ver, - }; - if(qStreamSetScanMemData(task, submit) != 0){ - continue; - } - - // here start to scan submit block to extract the subscribed data - while (1) { - SSDataBlock* pDataBlock = NULL; - uint64_t ts = 0; - if (qExecTask(task, &pDataBlock, &ts) < 0) { - tqDebug("vgId:%d, tq exec error since %s", vgId, terrstr()); - } - - if (pDataBlock == NULL) { - break; - } - - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); - pRsp->blockNum++; - } - - tqDebug("vgId:%d, tq handle push, subkey:%s, block num:%d", vgId, pPushEntry->subKey, pRsp->blockNum); - if (pRsp->blockNum > 0) { - // set offset - tqOffsetResetToLog(&pRsp->rspOffset, ver); - - // remove from hash - size_t kLen; - void* key = taosHashGetKey(pIter, &kLen); - void* keyCopy = taosMemoryCalloc(1, kLen + 1); - memcpy(keyCopy, key, kLen); - - taosArrayPush(cachedKeys, &keyCopy); - taosArrayPush(cachedKeyLens, &kLen); - - tqPushDataRsp(pTq, pPushEntry); - } + doPushDataForEntry(pIter, pExec, pTq, ver, vgId, data, len, cachedKey); } - // delete entry - for (int32_t i = 0; i < taosArrayGetSize(cachedKeys); i++) { - void* key = taosArrayGetP(cachedKeys, i); - size_t kLen = *(size_t*)taosArrayGet(cachedKeyLens, i); - if (taosHashRemove(pTq->pPushMgr, key, kLen) != 0) { - tqError("vgId:%d, tq push hash remove key error, key: %s", pTq->pVnode->config.vgId, (char*)key); - } - } - - taosArrayDestroyP(cachedKeys, (FDelete)taosMemoryFree); - taosArrayDestroy(cachedKeyLens); + doRemovePushedEntry(cachedKey, pTq); + taosArrayDestroyEx(cachedKey, freeItem); taosMemoryFree(data); } + // unlock taosWUnLockLatch(&pTq->lock); } + // push data for stream processing if (!tsDisableStream && vnodeIsRoleLeader(pTq->pVnode)) { - if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0; + if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) { + return 0; + } + if (msgType == TDMT_VND_SUBMIT) { void* data = taosMemoryMalloc(len); if (data == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tqError("failed to copy data for stream since out of memory"); + tqError("vgId:%d, failed to copy submit data for stream processing, since out of memory", vgId); return -1; } + memcpy(data, pReq, len); - SPackedData submit = { - .msgStr = data, - .msgLen = len, - .ver = ver, - }; + SPackedData submit = {.msgStr = data, .msgLen = len, .ver = ver}; tqDebug("tq copy write msg %p %d %" PRId64 " from %p", data, len, ver, pReq); tqProcessSubmitReq(pTq, submit); @@ -388,8 +388,8 @@ int32_t tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest, return 0; } -int32_t tqRemovePushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer) { - int32_t vgId = TD_VID(pTq->pVnode); +int32_t tqUnregisterPushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer) { + int32_t vgId = TD_VID(pTq->pVnode); STqPushEntry** pEntry = taosHashGet(pTq->pPushMgr, pKey, keyLen); if (pEntry != NULL) { @@ -408,3 +408,26 @@ int32_t tqRemovePushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t c return 0; } + +void recordPushedEntry(SArray* cachedKey, void* pIter) { + size_t kLen = 0; + void* key = taosHashGetKey(pIter, &kLen); + SItem item = {.pKey = strndup(key, kLen), .keyLen = kLen}; + taosArrayPush(cachedKey, &item); +} + +void doRemovePushedEntry(SArray* pCachedKeys, STQ* pTq) { + int32_t vgId = TD_VID(pTq->pVnode); + int32_t numOfKeys = (int32_t) taosArrayGetSize(pCachedKeys); + + for (int32_t i = 0; i < numOfKeys; i++) { + SItem* pItem = taosArrayGet(pCachedKeys, i); + if (taosHashRemove(pTq->pPushMgr, pItem->pKey, pItem->keyLen) != 0) { + tqError("vgId:%d, tq push hash remove key error, key: %s", vgId, (char*) pItem->pKey); + } + } + + if (numOfKeys > 0) { + tqDebug("vgId:%d, pushed %d items and remain:%d", vgId, numOfKeys, (int32_t)taosHashGetSize(pTq->pPushMgr)); + } +} diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 7f9563ae5f9..54e4e393ecf 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -263,7 +263,7 @@ STqReader* tqOpenReader(SVnode* pVnode) { pReader->pVnodeMeta = pVnode->pMeta; /*pReader->pMsg = NULL;*/ - pReader->ver = -1; +// pReader->ver = -1; pReader->pColIdList = NULL; pReader->cachedSchemaVer = 0; pReader->cachedSchemaSuid = 0; @@ -290,41 +290,26 @@ void tqCloseReader(STqReader* pReader) { } // free hash taosHashCleanup(pReader->tbIdHash); + tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE); taosMemoryFree(pReader); } int32_t tqSeekVer(STqReader* pReader, int64_t ver, const char* id) { - // todo set the correct vgId - tqDebug("tmq poll: wal seek to version:%"PRId64" %s", ver, id); if (walReadSeekVer(pReader->pWalReader, ver) < 0) { tqDebug("tmq poll: wal reader failed to seek to ver:%"PRId64" code:%s, %s", ver, tstrerror(terrno), id); return -1; - } else { - tqDebug("tmq poll: wal reader seek to ver:%"PRId64" %s", ver, id); - return 0; } + tqDebug("tmq poll: wal reader seek to ver:%"PRId64" %s", ver, id); + return 0; } -int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { - bool fromProcessedMsg = pReader->msg2.msgStr != NULL; - +void tqNextBlock(STqReader* pReader, SFetchRet* ret) { while (1) { - if (!fromProcessedMsg) { + if (pReader->msg2.msgStr == NULL) { if (walNextValidMsg(pReader->pWalReader) < 0) { -// pReader->ver = pReader->pWalReader->curVersion - pReader->pWalReader->curStopped; - if(pReader->pWalReader->curInvalid == 0){ - pReader->ver = pReader->pWalReader->curVersion - pReader->pWalReader->curStopped; - }else{ - pReader->ver = walGetLastVer(pReader->pWalReader->pWal); - } - ret->offset.type = TMQ_OFFSET__LOG; - - ret->offset.version = pReader->ver; ret->fetchType = FETCH_TYPE__NONE; - tqDebug("return offset %" PRId64 ", no more valid msg in wal", ret->offset.version); - return -1; + return; } - void* body = POINTER_SHIFT(pReader->pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg)); int32_t bodyLen = pReader->pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg); int64_t ver = pReader->pWalReader->pHead->head.version; @@ -333,109 +318,44 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { } while (tqNextDataBlock2(pReader)) { - // TODO mem free memset(&ret->data, 0, sizeof(SSDataBlock)); int32_t code = tqRetrieveDataBlock2(&ret->data, pReader, NULL); if (code != 0 || ret->data.info.rows == 0) { continue; } ret->fetchType = FETCH_TYPE__DATA; - tqDebug("return data rows %d", ret->data.info.rows); - return 0; - } - - if (fromProcessedMsg) { - ret->offset.type = TMQ_OFFSET__LOG; - ret->offset.version = pReader->ver; - ret->fetchType = FETCH_TYPE__SEP; - tqDebug("return offset %" PRId64 ", processed finish", ret->offset.version); - return 0; + return; } } } -#if 0 -int32_t tqReaderSetDataMsg(STqReader* pReader, const SSubmitReq* pMsg, int64_t ver) { - pReader->pMsg = pMsg; - -// if (tInitSubmitMsgIter(pMsg, &pReader->msgIter) < 0) return -1; -// while (true) { -// if (tGetSubmitMsgNext(&pReader->msgIter, &pReader->pBlock) < 0) return -1; -// tqDebug("submitnext vgId:%d, block:%p, dataLen:%d, len:%d, uid:%"PRId64, pWalReader->pWal->cfg.vgId, pReader->pBlock, pReader->msgIter.dataLen, -// pReader->msgIter.len, pReader->msgIter.uid); -// if (pReader->pBlock == NULL) break; -// } - - if (tInitSubmitMsgIter(pMsg, &pReader->msgIter) < 0) return -1; - pReader->ver = ver; - memset(&pReader->blkIter, 0, sizeof(SSubmitBlkIter)); - return 0; -} -#endif - int32_t tqReaderSetSubmitReq2(STqReader* pReader, void* msgStr, int32_t msgLen, int64_t ver) { - ASSERT(pReader->msg2.msgStr == NULL && msgStr && msgLen && (ver >= 0)); - pReader->msg2.msgStr = msgStr; pReader->msg2.msgLen = msgLen; pReader->msg2.ver = ver; - pReader->ver = ver; tqDebug("tq reader set msg %p %d", msgStr, msgLen); - - if (pReader->setMsg == 0) { - SDecoder decoder; - tDecoderInit(&decoder, pReader->msg2.msgStr, pReader->msg2.msgLen); - if (tDecodeSSubmitReq2(&decoder, &pReader->submit) < 0) { - ASSERT(0); - } + SDecoder decoder; + tDecoderInit(&decoder, pReader->msg2.msgStr, pReader->msg2.msgLen); + if (tDecodeSSubmitReq2(&decoder, &pReader->submit) < 0) { tDecoderClear(&decoder); - pReader->setMsg = 1; + tqError("DecodeSSubmitReq2 error, msgLen:%d, ver:%"PRId64, msgLen, ver); + return -1; } + tDecoderClear(&decoder); return 0; } -#if 0 -bool tqNextDataBlock(STqReader* pReader) { - if (pReader->pMsg == NULL) return false; - while (1) { - if (tGetSubmitMsgNext(&pReader->msgIter, &pReader->pBlock) < 0) { - return false; - } - if (pReader->pBlock == NULL) { - pReader->pMsg = NULL; - return false; - } - - if (pReader->tbIdHash == NULL) { - return true; - } - void* ret = taosHashGet(pReader->tbIdHash, &pReader->msgIter.uid, sizeof(int64_t)); - /*tqDebug("search uid %" PRId64, pHandle->msgIter.uid);*/ - if (ret != NULL) { - /*tqDebug("find uid %" PRId64, pHandle->msgIter.uid);*/ - return true; - } - } - return false; -} -#endif - bool tqNextDataBlock2(STqReader* pReader) { if (pReader->msg2.msgStr == NULL) { return false; } - ASSERT(pReader->setMsg == 1); - - tqDebug("tq reader next data block %p, %d %" PRId64 " %d", pReader->msg2.msgStr, pReader->msg2.msgLen, - pReader->msg2.ver, pReader->nextBlk); - int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData); while (pReader->nextBlk < blockSz) { + tqDebug("tq reader next data block %p, %d %" PRId64 " %d", pReader->msg2.msgStr, pReader->msg2.msgLen, + pReader->msg2.ver, pReader->nextBlk); SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk); - ASSERT(pSubmitTbData->uid); - if (pReader->tbIdHash == NULL) return true; void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t)); @@ -446,7 +366,6 @@ bool tqNextDataBlock2(STqReader* pReader) { } tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE); - pReader->setMsg = 0; pReader->nextBlk = 0; pReader->msg2.msgStr = NULL; @@ -455,7 +374,6 @@ bool tqNextDataBlock2(STqReader* pReader) { bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) { if (pReader->msg2.msgStr == NULL) return false; - ASSERT(pReader->setMsg == 1); int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData); while (pReader->nextBlk < blockSz) { @@ -470,7 +388,6 @@ bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) { } tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE); - pReader->setMsg = 0; pReader->nextBlk = 0; pReader->msg2.msgStr = NULL; @@ -506,63 +423,8 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap return 0; } -#if 0 -bool tqNextDataBlockFilterOut(STqReader* pHandle, SHashObj* filterOutUids) { - while (1) { - if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) { - return false; - } - if (pHandle->pBlock == NULL) return false; - - void* ret = taosHashGet(filterOutUids, &pHandle->msgIter.uid, sizeof(int64_t)); - if (ret == NULL) { - return true; - } - } - return false; -} - -int32_t tqScanSubmitSplit(SArray* pBlocks, SArray* schemas, STqReader* pReader) { - // - int32_t sversion = htonl(pReader->pBlock->sversion); - if (pReader->cachedSchemaSuid == 0 || pReader->cachedSchemaVer != sversion || - pReader->cachedSchemaSuid != pReader->msgIter.suid) { - taosMemoryFree(pReader->pSchema); - pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchema == NULL) { - tqWarn("vgId:%d, cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64 - "), version %d, possibly dropped table", - pWalReader->pWal->cfg.vgId, pReader->msgIter.uid, pReader->msgIter.suid, sversion); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - - tDeleteSSchemaWrapper(pReader->pSchemaWrapper); - pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchemaWrapper == NULL) { - tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table", - pWalReader->pWal->cfg.vgId, pReader->msgIter.uid, pReader->cachedSchemaVer); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - - STSchema* pTschema = pReader->pSchema; - SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper; - - int32_t colNumNeed = taosArrayGetSize(pReader->pColIdList); - } - return 0; -} -#endif - int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbData** pSubmitTbDataRet) { - int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData); - ASSERT(pReader->nextBlk < blockSz); - - tqDebug("tq reader retrieve data block %p, %d", pReader->msg2.msgStr, pReader->nextBlk); - + tqDebug("tq reader retrieve data block %p, index:%d", pReader->msg2.msgStr, pReader->nextBlk); SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk); pReader->nextBlk++; @@ -666,33 +528,27 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD int32_t targetIdx = 0; int32_t sourceIdx = 0; while (targetIdx < colActual) { - ASSERT(sourceIdx < numOfCols); - + if(sourceIdx >= numOfCols){ + tqError("tqRetrieveDataBlock2 sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols); + goto FAIL; + } SColData* pCol = taosArrayGet(pCols, sourceIdx); SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx); SColVal colVal; - ASSERT(pCol->nVal == numOfRows); + if(pCol->nVal != numOfRows){ + tqError("tqRetrieveDataBlock2 pCol->nVal:%d != numOfRows:%d", pCol->nVal, numOfRows); + goto FAIL; + } if (pCol->cid < pColData->info.colId) { sourceIdx++; } else if (pCol->cid == pColData->info.colId) { for (int32_t i = 0; i < pCol->nVal; i++) { tColDataGetValue(pCol, i, &colVal); -#if 0 - void* val = NULL; - if (IS_STR_DATA_TYPE(colVal.type)) { - val = colVal.value.pData; - } else { - val = &colVal.value.val; - } - if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) { - goto FAIL; - } -#endif if (IS_STR_DATA_TYPE(colVal.type)) { if (colVal.value.pData != NULL) { - char val[65535 + 2]; + char val[65535 + 2] = {0}; memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData); varDataSetLen(val, colVal.value.nData); if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) { @@ -726,8 +582,6 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD for (int32_t j = 0; j < colActual; j++) { SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j); while (1) { - ASSERT(sourceIdx < pTschema->numOfCols); - SColVal colVal; tRowGet(pRow, pTschema, sourceIdx, &colVal); if (colVal.cid < pColData->info.colId) { @@ -736,7 +590,7 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD } else if (colVal.cid == pColData->info.colId) { if (IS_STR_DATA_TYPE(colVal.type)) { if (colVal.value.pData != NULL) { - char val[65535 + 2]; + char val[65535 + 2] = {0}; memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData); varDataSetLen(val, colVal.value.nData); if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) { @@ -745,7 +599,6 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD } else { colDataSetNULL(pColData, i); } - /*val = colVal.value.pData;*/ } else { if (colDataAppend(pColData, i, (void*)&colVal.value.val, !COL_VAL_IS_VALUE(&colVal)) < 0) { goto FAIL; @@ -771,253 +624,6 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD return -1; } -#if 0 -int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) { - // TODO: cache multiple schema - int32_t sversion = htonl(pReader->pBlock->sversion); - if (pReader->cachedSchemaSuid == 0 || pReader->cachedSchemaVer != sversion || - pReader->cachedSchemaSuid != pReader->msgIter.suid) { - if (pReader->pSchema) taosMemoryFree(pReader->pSchema); - pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchema == NULL) { - tqWarn("cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64 "), version %d, possibly dropped table", - pReader->msgIter.uid, pReader->msgIter.suid, pReader->cachedSchemaVer); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - - if (pReader->pSchemaWrapper) tDeleteSSchemaWrapper(pReader->pSchemaWrapper); - pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchemaWrapper == NULL) { - tqWarn("cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table", - pReader->msgIter.uid, pReader->cachedSchemaVer); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - pReader->cachedSchemaVer = sversion; - pReader->cachedSchemaSuid = pReader->msgIter.suid; - } - - STSchema* pTschema = pReader->pSchema; - SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper; - - int32_t colNumNeed = taosArrayGetSize(pReader->pColIdList); - - if (colNumNeed == 0) { - int32_t colMeta = 0; - while (colMeta < pSchemaWrapper->nCols) { - SSchema* pColSchema = &pSchemaWrapper->pSchema[colMeta]; - SColumnInfoData colInfo = createColumnInfoData(pColSchema->type, pColSchema->bytes, pColSchema->colId); - int32_t code = blockDataAppendColInfo(pBlock, &colInfo); - if (code != TSDB_CODE_SUCCESS) { - goto FAIL; - } - colMeta++; - } - } else { - if (colNumNeed > pSchemaWrapper->nCols) { - colNumNeed = pSchemaWrapper->nCols; - } - - int32_t colMeta = 0; - int32_t colNeed = 0; - while (colMeta < pSchemaWrapper->nCols && colNeed < colNumNeed) { - SSchema* pColSchema = &pSchemaWrapper->pSchema[colMeta]; - col_id_t colIdSchema = pColSchema->colId; - col_id_t colIdNeed = *(col_id_t*)taosArrayGet(pReader->pColIdList, colNeed); - if (colIdSchema < colIdNeed) { - colMeta++; - } else if (colIdSchema > colIdNeed) { - colNeed++; - } else { - SColumnInfoData colInfo = createColumnInfoData(pColSchema->type, pColSchema->bytes, pColSchema->colId); - int32_t code = blockDataAppendColInfo(pBlock, &colInfo); - if (code != TSDB_CODE_SUCCESS) { - goto FAIL; - } - colMeta++; - colNeed++; - } - } - } - - if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto FAIL; - } - - int32_t colActual = blockDataGetNumOfCols(pBlock); - - STSRowIter iter = {0}; - tdSTSRowIterInit(&iter, pTschema); - STSRow* row; - int32_t curRow = 0; - - tInitSubmitBlkIter(&pReader->msgIter, pReader->pBlock, &pReader->blkIter); - - pBlock->info.id.uid = pReader->msgIter.uid; - pBlock->info.rows = pReader->msgIter.numOfRows; - pBlock->info.version = pReader->pMsg->version; - pBlock->info.dataLoad = 1; - - while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) { - tdSTSRowIterReset(&iter, row); - // get all wanted col of that block - for (int32_t i = 0; i < colActual; i++) { - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); - SCellVal sVal = {0}; - if (!tdSTSRowIterFetch(&iter, pColData->info.colId, pColData->info.type, &sVal)) { - break; - } - if (colDataSetVal(pColData, curRow, sVal.val, sVal.valType != TD_VTYPE_NORM) < 0) { - goto FAIL; - } - } - curRow++; - } - return 0; - -FAIL: - blockDataFreeRes(pBlock); - return -1; -} - -int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas) { - int32_t sversion = htonl(pReader->pBlock->sversion); - - if (pReader->cachedSchemaSuid == 0 || pReader->cachedSchemaVer != sversion || - pReader->cachedSchemaSuid != pReader->msgIter.suid) { - if (pReader->pSchema) taosMemoryFree(pReader->pSchema); - pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchema == NULL) { - tqWarn("cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64 "), version %d, possibly dropped table", - pReader->msgIter.uid, pReader->msgIter.suid, pReader->cachedSchemaVer); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - - if (pReader->pSchemaWrapper) tDeleteSSchemaWrapper(pReader->pSchemaWrapper); - pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1); - if (pReader->pSchemaWrapper == NULL) { - tqWarn("cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table", - pReader->msgIter.uid, pReader->cachedSchemaVer); - pReader->cachedSchemaSuid = 0; - terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; - return -1; - } - pReader->cachedSchemaVer = sversion; - pReader->cachedSchemaSuid = pReader->msgIter.suid; - } - - STSchema* pTschema = pReader->pSchema; - SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper; - - int32_t colAtMost = pSchemaWrapper->nCols; - - int32_t curRow = 0; - int32_t lastRow = 0; - - char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols); - if (assigned == NULL) return -1; - - tInitSubmitBlkIter(&pReader->msgIter, pReader->pBlock, &pReader->blkIter); - STSRowIter iter = {0}; - tdSTSRowIterInit(&iter, pTschema); - STSRow* row; - - while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) { - bool buildNew = false; - tdSTSRowIterReset(&iter, row); - - tqDebug("vgId:%d, row of block %d", pReader->pWalReader->pWal->cfg.vgId, curRow); - for (int32_t i = 0; i < colAtMost; i++) { - SCellVal sVal = {0}; - if (!tdSTSRowIterFetch(&iter, pSchemaWrapper->pSchema[i].colId, pSchemaWrapper->pSchema[i].type, &sVal)) { - break; - } - tqDebug("vgId:%d, %d col, type %d", pReader->pWalReader->pWal->cfg.vgId, i, sVal.valType); - if (curRow == 0) { - assigned[i] = sVal.valType != TD_VTYPE_NONE; - buildNew = true; - } else { - bool currentRowAssigned = sVal.valType != TD_VTYPE_NONE; - if (currentRowAssigned != assigned[i]) { - assigned[i] = currentRowAssigned; - buildNew = true; - } - } - } - - if (buildNew) { - if (taosArrayGetSize(blocks) > 0) { - SSDataBlock* pLastBlock = taosArrayGetLast(blocks); - pLastBlock->info.rows = curRow - lastRow; - lastRow = curRow; - } - SSDataBlock* pBlock = createDataBlock(); - SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper)); - if (tqMaskBlock(pSW, pBlock, pSchemaWrapper, assigned) < 0) { - blockDataDestroy(pBlock); - goto FAIL; - } - SSDataBlock block = {0}; - assignOneDataBlock(&block, pBlock); - blockDataDestroy(pBlock); - - tqDebug("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId, - (int32_t)taosArrayGetSize(block.pDataBlock)); - - taosArrayPush(blocks, &block); - taosArrayPush(schemas, &pSW); - } - - SSDataBlock* pBlock = taosArrayGetLast(blocks); - pBlock->info.id.uid = pReader->msgIter.uid; - pBlock->info.rows = 0; - pBlock->info.version = pReader->pMsg->version; - - tqDebug("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId, - (int32_t)taosArrayGetSize(blocks)); - - if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows - curRow) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto FAIL; - } - - tdSTSRowIterReset(&iter, row); - for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); i++) { - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); - SCellVal sVal = {0}; - - if (!tdSTSRowIterFetch(&iter, pColData->info.colId, pColData->info.type, &sVal)) { - break; - } - - ASSERT(sVal.valType != TD_VTYPE_NONE); - - if (colDataSetVal(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) { - goto FAIL; - } - tqDebug("vgId:%d, row %d col %d append %d", pReader->pWalReader->pWal->cfg.vgId, curRow, i, - sVal.valType == TD_VTYPE_NULL); - } - curRow++; - } - SSDataBlock* pLastBlock = taosArrayGetLast(blocks); - pLastBlock->info.rows = curRow - lastRow; - - taosMemoryFree(assigned); - return 0; - -FAIL: - taosMemoryFree(assigned); - return -1; -} -#endif - int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schemas, SSubmitTbData** pSubmitTbDataRet) { tqDebug("tq reader retrieve data block %p, %d", pReader->msg2.msgStr, pReader->nextBlk); diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqScan.c similarity index 77% rename from source/dnode/vnode/src/tq/tqExec.c rename to source/dnode/vnode/src/tq/tqScan.c index f23b5f8526a..a26f59f72be 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -18,7 +18,9 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); - if (buf == NULL) return -1; + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf; pRetrieve->useconds = 0; @@ -31,7 +33,8 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t actualLen += sizeof(SRetrieveTableRsp); taosArrayPush(pRsp->blockDataLen, &actualLen); taosArrayPush(pRsp->blockData, &buf); - return 0; + + return TSDB_CODE_SUCCESS; } static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp) { @@ -62,71 +65,50 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in } int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset) { - const STqExecHandle* pExec = &pHandle->execHandle; + const int32_t MAX_ROWS_TO_RETURN = 4096; + int32_t vgId = TD_VID(pTq->pVnode); + int32_t code = 0; + int32_t totalRows = 0; + const STqExecHandle* pExec = &pHandle->execHandle; qTaskInfo_t task = pExec->task; - int32_t vgId = TD_VID(pTq->pVnode); if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return, consumer:0x%"PRIx64, pHandle->consumerId); - if (pOffset->type == TMQ_OFFSET__LOG) { - pRsp->rspOffset = *pOffset; - return 0; - } else { - tqOffsetResetToLog(pOffset, pHandle->snapshotVer); - if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return, consumer:0x%"PRIx64, pHandle->consumerId); - pRsp->rspOffset = *pOffset; - return 0; - } - } + tqError("prepare scan failed, return"); + return -1; } - int32_t rowCnt = 0; while (1) { SSDataBlock* pDataBlock = NULL; uint64_t ts = 0; - - tqDebug("vgId:%d, tmq task start to execute, consumer:0x%"PRIx64, vgId, pHandle->consumerId); - if (qExecTask(task, &pDataBlock, &ts) < 0) { - tqError("vgId:%d, task exec error since %s, consumer:0x%" PRIx64, vgId, terrstr(), - pHandle->consumerId); + qStreamSetOpen(task); + tqDebug("consumer:0x%"PRIx64" vgId:%d, tmq one task start execute", pHandle->consumerId, vgId); + if (qExecTask(task, &pDataBlock, &ts) != TSDB_CODE_SUCCESS) { + tqError("consumer:0x%"PRIx64" vgId:%d, task exec error since %s", pHandle->consumerId, vgId, terrstr()); return -1; } - tqDebug("consumer:0x%"PRIx64" vgId:%d, tmq task executed, get %p", pHandle->consumerId, vgId, pDataBlock); - + tqDebug("consumer:0x%"PRIx64" vgId:%d tmq one task end executed, pDataBlock:%p", pHandle->consumerId, vgId, pDataBlock); // current scan should be stopped asap, since the rebalance occurs. if (pDataBlock == NULL) { break; } - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); - pRsp->blockNum++; - - if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - rowCnt += pDataBlock->info.rows; - if (rowCnt >= 4096) { - break; - } + code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); + if (code != TSDB_CODE_SUCCESS) { + tqError("vgId:%d, failed to add block to rsp msg", vgId); + return code; } - } - if (qStreamExtractOffset(task, &pRsp->rspOffset) < 0) { - return -1; - } - - if (pRsp->rspOffset.type == 0) { - tqError("vgId:%d, expected rsp offset: type %d %" PRId64 " %" PRId64 " %" PRId64, vgId, pRsp->rspOffset.type, - pRsp->rspOffset.ts, pRsp->rspOffset.uid, pRsp->rspOffset.version); - return -1; - } - - if (pRsp->withTbName || pRsp->withSchema) { - tqError("vgId:%d, get column should not with meta:%d,%d", vgId, pRsp->withTbName, pRsp->withSchema); - return -1; + pRsp->blockNum++; + totalRows += pDataBlock->info.rows; + if (totalRows >= MAX_ROWS_TO_RETURN) { + break; + } } + tqDebug("consumer:0x%"PRIx64" vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d", pHandle->consumerId, vgId, pRsp->blockNum, totalRows); + qStreamExtractOffset(task, &pRsp->rspOffset); return 0; } @@ -135,18 +117,8 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta qTaskInfo_t task = pExec->task; if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return"); - if (pOffset->type == TMQ_OFFSET__LOG) { - pRsp->rspOffset = *pOffset; - return 0; - } else { - tqOffsetResetToLog(pOffset, pHandle->snapshotVer); - if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return"); - pRsp->rspOffset = *pOffset; - return 0; - } - } + tqDebug("tqScanTaosx prepare scan failed, return"); + return -1; } int32_t rowCnt = 0; @@ -192,42 +164,31 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta } } - if (pDataBlock == NULL && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - if (qStreamExtractPrepareUid(task) != 0) { + // get meta + SMqMetaRsp* tmp = qStreamExtractMetaMsg(task); + if (tmp->metaRspLen > 0) { + qStreamExtractOffset(task, &tmp->rspOffset); + *pMetaRsp = *tmp; + + tqDebug("tmqsnap task get meta"); + break; + } + + if (pDataBlock == NULL) { + qStreamExtractOffset(task, pOffset); + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { continue; } - tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), - pHandle->snapshotVer + 1); + tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), pHandle->snapshotVer + 1); + qStreamExtractOffset(task, &pRsp->rspOffset); break; } if (pRsp->blockNum > 0) { tqDebug("tmqsnap task exec exited, get data"); + qStreamExtractOffset(task, &pRsp->rspOffset); break; } - - SMqMetaRsp* tmp = qStreamExtractMetaMsg(task); - if (tmp->rspOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { - tqOffsetResetToData(pOffset, tmp->rspOffset.uid, tmp->rspOffset.ts); - qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType); - tmp->rspOffset.type = TMQ_OFFSET__SNAPSHOT_META; - tqDebug("tmqsnap task exec change to get data"); - continue; - } - - *pMetaRsp = *tmp; - tqDebug("tmqsnap task exec exited, get meta"); - - tqDebug("task exec exited"); - break; - } - - qStreamExtractOffset(task, &pRsp->rspOffset); - - if (pRsp->rspOffset.type == 0) { - tqError("expected rsp offset: type %d %" PRId64 " %" PRId64 " %" PRId64, pRsp->rspOffset.type, pRsp->rspOffset.ts, - pRsp->rspOffset.uid, pRsp->rspOffset.version); - return -1; } return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index d34af9acae6..d0ff403bf70 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -282,6 +282,40 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return true; } +int64_t tsdbCountTbDataRows(STbData *pTbData) { + SMemSkipListNode *pNode = pTbData->sl.pHead; + int64_t rowsNum = 0; + + while (NULL != pNode) { + pNode = SL_GET_NODE_FORWARD(pNode, 0); + if (pNode == pTbData->sl.pTail) { + return rowsNum; + } + + rowsNum++; + } + + return rowsNum; +} + +void tsdbMemTableCountRows(SMemTable *pMemTable, SHashObj* pTableMap, int64_t *rowsNum) { + taosRLockLatch(&pMemTable->latch); + for (int32_t i = 0; i < pMemTable->nBucket; ++i) { + STbData *pTbData = pMemTable->aBucket[i]; + while (pTbData) { + void* p = taosHashGet(pTableMap, &pTbData->uid, sizeof(pTbData->uid)); + if (p == NULL) { + pTbData = pTbData->next; + continue; + } + + *rowsNum += tsdbCountTbDataRows(pTbData); + pTbData = pTbData->next; + } + } + taosRUnLockLatch(&pMemTable->latch); +} + static int32_t tsdbMemTableRehash(SMemTable *pMemTable) { int32_t code = 0; @@ -787,4 +821,4 @@ SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable) { _exit: return aTbDataP; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 96bce02b674..0cf28c1ed14 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -15,6 +15,7 @@ #include "osDef.h" #include "tsdb.h" +#include "tsimplehash.h" #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) @@ -24,6 +25,11 @@ typedef enum { EXTERNAL_ROWS_NEXT = 0x3, } EContentData; +typedef enum { + READ_MODE_COUNT_ONLY = 0x1, + READ_MODE_ALL, +} EReadMode; + typedef struct { STbDataIter* iter; int32_t index; @@ -167,6 +173,8 @@ struct STsdbReader { uint64_t suid; int16_t order; bool freeBlock; + EReadMode readMode; + uint64_t rowsNum; STimeWindow window; // the primary query time window that applies to all queries SSDataBlock* pResBlock; int32_t capacity; @@ -176,14 +184,15 @@ struct STsdbReader { SBlockLoadSuppInfo suppInfo; STsdbReadSnap* pReadSnap; SIOCostSummary cost; - STSchema* pSchema; // the newest version schema - STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times - SDataFReader* pFileReader; // the file reader - SDelFReader* pDelFReader; // the del file reader - SArray* pDelIdx; // del file block index; - SBlockInfoBuf blockInfoBuf; - int32_t step; - STsdbReader* innerReader[2]; + STSchema* pSchema; // the newest version schema + // STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times + SSHashObj* pSchemaMap; // keep the retrieved schema info, to avoid the overhead by repeatly load schema + SDataFReader* pFileReader; // the file reader + SDelFReader* pDelFReader; // the del file reader + SArray* pDelIdx; // del file block index; + SBlockInfoBuf blockInfoBuf; + int32_t step; + STsdbReader* innerReader[2]; }; static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); @@ -949,14 +958,18 @@ static void setBlockAllDumped(SFileBlockDumpInfo* pDumpInfo, int64_t maxKey, int pDumpInfo->lastKey = maxKey + step; } -static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_t colIndex, SColVal* pColVal, - SBlockLoadSuppInfo* pSup) { +static int32_t doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_t colIndex, SColVal* pColVal, + SBlockLoadSuppInfo* pSup) { if (IS_VAR_DATA_TYPE(pColVal->type)) { if (!COL_VAL_IS_VALUE(pColVal)) { colDataSetNULL(pColInfoData, rowIndex); } else { varDataSetLen(pSup->buildBuf[colIndex], pColVal->value.nData); - ASSERT(pColVal->value.nData <= pColInfoData->info.bytes); + if (pColVal->value.nData > pColInfoData->info.bytes) { + tsdbWarn("column cid:%d actual data len %d is bigger than schema len %d", pColVal->cid, pColVal->value.nData, + pColInfoData->info.bytes); + return TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + } if (pColVal->value.nData > 0) { // pData may be null, if nData is 0 memcpy(varDataVal(pSup->buildBuf[colIndex]), pColVal->value.pData, pColVal->value.nData); } @@ -966,6 +979,8 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_ } else { colDataSetVal(pColInfoData, rowIndex, (const char*)&pColVal->value, !COL_VAL_IS_VALUE(pColVal)); } + + return TSDB_CODE_SUCCESS; } static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { @@ -1167,6 +1182,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { SDataBlk* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; int32_t numOfOutputCols = pSupInfo->numOfCols; + int32_t code = TSDB_CODE_SUCCESS; SColVal cv = {0}; int64_t st = taosGetTimestampUs(); @@ -1244,7 +1260,10 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { } else { // varchar/nchar type for (int32_t j = pDumpInfo->rowIndex; rowIndex < dumpedRows; j += step) { tColDataGetValue(pData, j, &cv); - doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo); + code = doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo); + if (code) { + return code; + } } } } @@ -1766,7 +1785,7 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* setComposedBlockFlag(pReader, true); double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; - tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange:%" PRId64 + tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%" PRId64 ", brange:%" PRId64 " - %" PRId64 ", uid:%" PRIu64 ", %s", pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey, pBlockScanInfo->uid, pReader->idStr); @@ -1776,23 +1795,29 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* } static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pBlockData, int64_t key, - SFileBlockDumpInfo* pDumpInfo) { + SFileBlockDumpInfo* pDumpInfo, bool* copied) { // opt version // 1. it is not a border point // 2. the direct next point is not an duplicated timestamp + int32_t code = TSDB_CODE_SUCCESS; + + *copied = false; bool asc = (pReader->order == TSDB_ORDER_ASC); if ((pDumpInfo->rowIndex < pDumpInfo->totalRows - 1 && asc) || (pDumpInfo->rowIndex > 0 && (!asc))) { int32_t step = pReader->order == TSDB_ORDER_ASC ? 1 : -1; int64_t nextKey = pBlockData->aTSKEY[pDumpInfo->rowIndex + step]; if (nextKey != key) { // merge is not needed - doAppendRowFromFileBlock(pReader->pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); + if (code) { + return code; + } pDumpInfo->rowIndex += step; - return true; + *copied = true; } } - return false; + return code; } static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, @@ -1819,20 +1844,35 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc } static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SLastBlockReader* pLastBlockReader, - STableBlockScanInfo* pScanInfo, int64_t ts, STsdbReader* pReader) { + STableBlockScanInfo* pScanInfo, int64_t ts, STsdbReader* pReader, + bool* copied) { + int32_t code = TSDB_CODE_SUCCESS; + + *copied = false; + bool hasVal = nextRowFromLastBlocks(pLastBlockReader, pScanInfo, &pReader->verRange); if (hasVal) { int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader); if (next1 != ts) { - doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); - return true; + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); + if (code) { + return code; + } + + *copied = true; + return code; } } else { - doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); - return true; + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); + if (code) { + return code; + } + + *copied = true; + return code; } - return false; + return code; } static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid) { @@ -1858,28 +1898,23 @@ static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader* return pReader->pSchema; } - if (pReader->pMemSchema == NULL) { - int32_t code = - metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pMemSchema); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } else { - return pReader->pMemSchema; - } - } - - if (pReader->pMemSchema->version == sversion) { - return pReader->pMemSchema; + void** p = tSimpleHashGet(pReader->pSchemaMap, &sversion, sizeof(sversion)); + if (p != NULL) { + return *(STSchema**)p; } - taosMemoryFreeClear(pReader->pMemSchema); - int32_t code = metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pMemSchema); - if (code != TSDB_CODE_SUCCESS || pReader->pMemSchema == NULL) { + STSchema* ptr = NULL; + int32_t code = metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &ptr); + if (code != TSDB_CODE_SUCCESS) { terrno = code; return NULL; } else { - return pReader->pMemSchema; + code = tSimpleHashPut(pReader->pSchemaMap, &sversion, sizeof(sversion), &ptr, POINTER_BYTES); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return NULL; + } + return ptr; } } @@ -1934,7 +1969,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (pReader->order == TSDB_ORDER_ASC) { if (minKey == key) { init = true; - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1944,10 +1979,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); } else { init = true; - int32_t code = tsdbRowMergerInit(&merge, &fRow1, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow1, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1964,7 +1999,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* tsdbRowMergerAdd(&merge, pRow, pSchema); } else { init = true; - int32_t code = tsdbRowMergerInit(&merge, pRow, pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1978,7 +2013,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == k.ts) { init = true; STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); - int32_t code = tsdbRowMergerInit(&merge, pRow, pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1992,10 +2027,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); } else { init = true; - int32_t code = tsdbRowMergerInit(&merge, &fRow1, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow1, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2005,10 +2040,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == key) { if (init) { - tsdbRowMerge(&merge, &fRow); + tsdbRowMergerAdd(&merge, &fRow, NULL); } else { init = true; - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2022,11 +2057,12 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); - return TSDB_CODE_SUCCESS; + + return code; } static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, STsdbReader* pReader, @@ -2034,25 +2070,31 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, bool mergeBlockData) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; int64_t tsLastBlock = getCurrentKeyInLastBlock(pLastBlockReader); - - SRow* pTSRow = NULL; - SRowMerger merge = {0}; - TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); + bool copied = false; + int32_t code = TSDB_CODE_SUCCESS; + SRow* pTSRow = NULL; + SRowMerger merge = {0}; + TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); tsdbTrace("fRow ptr:%p, %d, uid:%" PRIu64 ", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr); // only last block exists if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) { - if (tryCopyDistinctRowFromSttBlock(&fRow, pLastBlockReader, pBlockScanInfo, tsLastBlock, pReader)) { + code = tryCopyDistinctRowFromSttBlock(&fRow, pLastBlockReader, pBlockScanInfo, tsLastBlock, pReader, &copied); + if (code) { + return code; + } + + if (copied) { pBlockScanInfo->lastKey = tsLastBlock; return TSDB_CODE_SUCCESS; } else { - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge, &pReader->verRange, pReader->idStr); code = tsdbRowMergerGetRow(&merge, &pTSRow); @@ -2060,13 +2102,17 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } else { // not merge block data - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2083,10 +2129,14 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } } return TSDB_CODE_SUCCESS; @@ -2114,7 +2164,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader SRow* pTSRow = NULL; SRowMerger merge = {0}; - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2122,7 +2172,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, ts, &merge, &pReader->verRange, pReader->idStr); @@ -2131,7 +2181,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); @@ -2213,7 +2263,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == key) { init = true; TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); - code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2224,10 +2274,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); } else { init = true; - code = tsdbRowMergerInit(&merge, &fRow1, pReader->pSchema); + code = tsdbRowMergerInit(&merge, NULL, &fRow1, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2238,7 +2288,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == ik.ts) { if (init) { - tsdbRowMerge(&merge, piRow); + tsdbRowMergerAdd(&merge, piRow, NULL); } else { init = true; STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(piRow), pReader, pBlockScanInfo->uid); @@ -2246,7 +2296,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - code = tsdbRowMergerInit(&merge, piRow, pSchema); + code = tsdbRowMergerInit(&merge, NULL, piRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2265,10 +2315,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - tsdbRowMerge(&merge, pRow); + tsdbRowMergerAdd(&merge, pRow, NULL); } else { STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); - code = tsdbRowMergerInit(&merge, pRow, pSchema); + code = tsdbRowMergerInit(&merge, NULL, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2283,7 +2333,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == k.ts) { init = true; STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); - code = tsdbRowMergerInit(&merge, pRow, pSchema); + code = tsdbRowMergerInit(&merge, NULL, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2297,11 +2347,11 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == ik.ts) { if (init) { - tsdbRowMerge(&merge, piRow); + tsdbRowMergerAdd(&merge, piRow, NULL); } else { init = true; STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(piRow), pReader, pBlockScanInfo->uid); - code = tsdbRowMergerInit(&merge, piRow, pSchema); + code = tsdbRowMergerInit(&merge, NULL, piRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2316,10 +2366,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { - tsdbRowMerge(&merge, &fRow1); + tsdbRowMergerAdd(&merge, &fRow1, NULL); } else { init = true; - code = tsdbRowMergerInit(&merge, &fRow1, pReader->pSchema); + code = tsdbRowMergerInit(&merge, NULL, &fRow1, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2330,7 +2380,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == key) { TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); if (!init) { - code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2338,7 +2388,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (merge.pTSchema == NULL) { return code; } - tsdbRowMerge(&merge, &fRow); + tsdbRowMergerAdd(&merge, &fRow, NULL); } doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); } @@ -2353,7 +2403,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); @@ -2508,7 +2558,13 @@ bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - if (tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo)) { + bool copied = false; + int32_t code = tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo, &copied); + if (code) { + return code; + } + + if (copied) { pBlockScanInfo->lastKey = key; return TSDB_CODE_SUCCESS; } else { @@ -2517,7 +2573,7 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc SRow* pTSRow = NULL; SRowMerger merge = {0}; - int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2528,11 +2584,11 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); - return TSDB_CODE_SUCCESS; + return code; } } @@ -2649,7 +2705,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) && pBlock->nRow <= pReader->capacity) { if (asc || ((!asc) && (!hasDataInLastBlock(pLastBlockReader)))) { - copyBlockDataToSDataBlock(pReader); + code = copyBlockDataToSDataBlock(pReader); + if (code) { + goto _end; + } // record the last key value pBlockScanInfo->lastKey = asc ? pBlock->maxKey.ts : pBlock->minKey.ts; @@ -2696,7 +2755,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader); + if (code) { + goto _end; + } // currently loaded file data block is consumed if ((pBlockData->nRow > 0) && (pDumpInfo->rowIndex >= pBlockData->nRow || pDumpInfo->rowIndex < 0)) { @@ -2715,8 +2777,8 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { updateComposedBlockInfo(pReader, el, pBlockScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); } @@ -2922,6 +2984,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader; STableUidList* pUidList = &pStatus->uidList; + int32_t code = TSDB_CODE_SUCCESS; if (taosHashGetSize(pStatus->pTableMap) == 0) { return TSDB_CODE_SUCCESS; @@ -2952,7 +3015,11 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + if (code) { + return code; + } + if (pResBlock->info.rows >= pReader->capacity) { break; } @@ -2962,8 +3029,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { updateComposedBlockInfo(pReader, el, pScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); return TSDB_CODE_SUCCESS; @@ -3032,7 +3099,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + if (code) { + return code; + } + if (pResBlock->info.rows >= pReader->capacity) { break; } @@ -3042,8 +3113,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { updateComposedBlockInfo(pReader, el, pScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); } @@ -3069,6 +3140,148 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { return code; } +static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReader) { + int64_t st = taosGetTimestampUs(); + LRUHandle* handle = NULL; + int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle); + if (code != TSDB_CODE_SUCCESS || handle == NULL) { + goto _end; + } + + int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap); + + SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle); + size_t num = taosArrayGetSize(aBlockIdx); + if (num == 0) { + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); + return TSDB_CODE_SUCCESS; + } + + SBlockIdx* pBlockIdx = NULL; + int32_t i = 0; + for (int32_t i = 0; i < num; ++i) { + pBlockIdx = (SBlockIdx*)taosArrayGet(aBlockIdx, i); + if (pBlockIdx->suid != pReader->suid) { + continue; + } + + STableBlockScanInfo** p = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(pBlockIdx->uid)); + if (p == NULL) { + continue; + } + + STableBlockScanInfo* pScanInfo = *p; + tMapDataReset(&pScanInfo->mapData); + tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData); + + SDataBlk block = {0}; + for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) { + tGetDataBlk(pScanInfo->mapData.pData + pScanInfo->mapData.aOffset[j], &block); + pReader->rowsNum += block.nRow; + } + } + +_end: + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); + return code; +} + +static int32_t doSumSttBlockRows(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader; + SSttBlockLoadInfo* pBlockLoadInfo = NULL; + + for (int32_t i = 0; i < pReader->pFileReader->pSet->nSttF; ++i) { // open all last file + pBlockLoadInfo = &pLastBlockReader->pInfo[i]; + + code = tsdbReadSttBlk(pReader->pFileReader, i, pBlockLoadInfo->aSttBlk); + if (code) { + return code; + } + + size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk); + if (size >= 1) { + SSttBlk* pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0); + SSttBlk* pEnd = taosArrayGet(pBlockLoadInfo->aSttBlk, size - 1); + + // all identical + if (pStart->suid == pEnd->suid) { + if (pStart->suid != pReader->suid) { + // no qualified stt block existed + taosArrayClear(pBlockLoadInfo->aSttBlk); + continue; + } + for (int32_t i = 0; i < size; ++i) { + SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, i); + pReader->rowsNum += p->nRow; + } + } else { + for (int32_t i = 0; i < size; ++i) { + SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, i); + uint64_t s = p->suid; + if (s < pReader->suid) { + continue; + } + + if (s == pReader->suid) { + pReader->rowsNum += p->nRow; + } else if (s > pReader->suid) { + break; + } + } + } + } + } + + return code; +} + +static int32_t readRowsCountFromFiles(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + + while (1) { + bool hasNext = false; + int32_t code = filesetIteratorNext(&pReader->status.fileIter, pReader, &hasNext); + if (code) { + return code; + } + + if (!hasNext) { // no data files on disk + break; + } + + code = doSumFileBlockRows(pReader, pReader->pFileReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = doSumSttBlockRows(pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + + pReader->status.loadFromFile = false; + + return code; +} + +static int32_t readRowsCountFromMem(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + int64_t memNum = 0, imemNum = 0; + if (pReader->pReadSnap->pMem != NULL) { + tsdbMemTableCountRows(pReader->pReadSnap->pMem, pReader->status.pTableMap, &memNum); + } + + if (pReader->pReadSnap->pIMem != NULL) { + tsdbMemTableCountRows(pReader->pReadSnap->pIMem, pReader->status.pTableMap, &imemNum); + } + + pReader->rowsNum += memNum + imemNum; + + return code; +} + static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; STableUidList* pUidList = &pStatus->uidList; @@ -3481,7 +3694,7 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe tsdbRowMergerAdd(pMerger, pRow, pTSchema); } else { // column format - tsdbRowMerge(pMerger, pRow); + tsdbRowMergerAdd(pMerger, pRow, NULL); } } @@ -3497,7 +3710,7 @@ static int32_t doMergeRowsInFileBlockImpl(SBlockData* pBlockData, int32_t rowInd } TSDBROW fRow = tsdbRowFromBlockData(pBlockData, rowIndex); - tsdbRowMerge(pMerger, &fRow); + tsdbRowMergerAdd(pMerger, &fRow, NULL); rowIndex += step; } @@ -3575,7 +3788,7 @@ int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockSc int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader); if (next1 == ts) { TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); - tsdbRowMerge(pMerger, &fRow1); + tsdbRowMergerAdd(pMerger, &fRow1, NULL); } else { tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid, pScanInfo->lastBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->lastKeyInStt, @@ -3631,7 +3844,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, pReader->pSchema = pTSchema; } - code = tsdbRowMergerInit2(&merge, pReader->pSchema, ¤t, pTSchema); + code = tsdbRowMergerInit(&merge, pReader->pSchema, ¤t, pTSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3643,12 +3856,12 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, tsdbRowMergerAdd(&merge, pNextRow, pTSchema1); } else { // let's merge rows in file block - code = tsdbRowMergerInit(&merge, ¤t, pReader->pSchema); + code = tsdbRowMergerInit(&merge, NULL, ¤t, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - tsdbRowMerge(&merge, pNextRow); + tsdbRowMergerAdd(&merge, pNextRow, NULL); } code = doMergeRowsInBuf(pIter, uid, TSDBROW_TS(¤t), pDelList, &merge, pReader); @@ -3672,13 +3885,13 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p SRow** pTSRow) { SRowMerger merge = {0}; - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + TSDBKEY k = TSDBROW_KEY(pRow); + TSDBKEY ik = TSDBROW_KEY(piRow); + STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); + STSchema* piSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(piRow), pReader, pBlockScanInfo->uid); if (ASCENDING_TRAVERSE(pReader->order)) { // ascending order imem --> mem - STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); - - int32_t code = tsdbRowMergerInit(&merge, piRow, pSchema); + int32_t code = tsdbRowMergerInit(&merge, pSchema, piRow, piSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3689,7 +3902,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p return code; } - tsdbRowMerge(&merge, pRow); + tsdbRowMergerAdd(&merge, pRow, pSchema); code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); if (code != TSDB_CODE_SUCCESS) { @@ -3697,9 +3910,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p } } else { - STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); - - int32_t code = tsdbRowMergerInit(&merge, pRow, pSchema); + int32_t code = tsdbRowMergerInit(&merge, NULL, pRow, pSchema); if (code != TSDB_CODE_SUCCESS || merge.pTSchema == NULL) { return code; } @@ -3710,7 +3921,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p return code; } - tsdbRowMerge(&merge, piRow); + tsdbRowMergerAdd(&merge, piRow, piSchema); code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, &merge, pReader); if (code != TSDB_CODE_SUCCESS) { @@ -3784,6 +3995,7 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pTSRow, STableBlockScanInfo* pScanInfo) { int32_t outputRowIndex = pBlock->info.rows; int64_t uid = pScanInfo->uid; + int32_t code = TSDB_CODE_SUCCESS; int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock); @@ -3806,7 +4018,10 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pT SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); tRowGet(pTSRow, pSchema, j, &colVal); - doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo); + code = doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo); + if (code) { + return code; + } i += 1; j += 1; } else if (colId < pSchema->columns[j].colId) { @@ -3836,6 +4051,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t rowIndex) { int32_t i = 0, j = 0; int32_t outputRowIndex = pResBlock->info.rows; + int32_t code = TSDB_CODE_SUCCESS; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; if (pReader->suppInfo.colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) { @@ -3858,7 +4074,10 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, pSupInfo->slotId[i]); if (pData->cid == pSupInfo->colId[i]) { tColDataGetValue(pData, rowIndex, &cv); - doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); + code = doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); + if (code) { + return code; + } j += 1; } else if (pData->cid > pCol->info.colId) { // the specified column does not exist in file block, fill with null data @@ -3882,6 +4101,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader) { SSDataBlock* pBlock = pReader->pResBlock; + int32_t code = TSDB_CODE_SUCCESS; do { // SRow* pTSRow = NULL; @@ -3893,13 +4113,20 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e } if (row.type == TSDBROW_ROW_FMT) { - doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); if (freeTSRow) { taosMemoryFree(row.pTSRow); } + + if (code) { + return code; + } } else { - doAppendRowFromFileBlock(pBlock, pReader, row.pBlockData, row.iRow); + code = doAppendRowFromFileBlock(pBlock, pReader, row.pBlockData, row.iRow); + if (code) { + break; + } } // no data in buffer, return immediately @@ -3912,7 +4139,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e } } while (1); - return TSDB_CODE_SUCCESS; + return code; } // TODO refactor: with createDataBlockScanInfo @@ -3929,8 +4156,13 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n if (code) { return code; } - pReader->status.uidList.tableUidList = - (uint64_t*)taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num); + + char* p1 = taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num); + if (p1 == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pReader->status.uidList.tableUidList = (uint64_t*)p1; } taosHashClear(pReader->status.pTableMap); @@ -3986,6 +4218,8 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { int32_t code = TSDB_CODE_SUCCESS; if (pStatus->fileIter.numOfFiles == 0) { pStatus->loadFromFile = false; + } else if (READ_MODE_COUNT_ONLY == pReader->readMode) { + // DO NOTHING } else { code = initForFirstBlockInFile(pReader, pBlockIter); } @@ -3997,14 +4231,15 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { return code; } +static void freeSchemaFunc(void* param) { + void* p = *(void**)param; + taosMemoryFree(p); +} + // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables, - SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr) { + SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr, bool countOnly) { STimeWindow window = pCond->twindows; - if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { - pCond->twindows.skey += 1; - pCond->twindows.ekey -= 1; - } int32_t capacity = pVnode->config.tsdbCfg.maxRows; if (pResBlock != NULL) { @@ -4027,11 +4262,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL // update the SQueryTableDataCond to create inner reader int32_t order = pCond->order; if (order == TSDB_ORDER_ASC) { - pCond->twindows.ekey = window.skey; + pCond->twindows.ekey = window.skey - 1; pCond->twindows.skey = INT64_MIN; pCond->order = TSDB_ORDER_DESC; } else { - pCond->twindows.skey = window.ekey; + pCond->twindows.skey = window.ekey + 1; pCond->twindows.ekey = INT64_MAX; pCond->order = TSDB_ORDER_ASC; } @@ -4043,11 +4278,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } if (order == TSDB_ORDER_ASC) { - pCond->twindows.skey = window.ekey; + pCond->twindows.skey = window.ekey + 1; pCond->twindows.ekey = INT64_MAX; } else { pCond->twindows.skey = INT64_MIN; - pCond->twindows.ekey = window.ekey; + pCond->twindows.ekey = window.ekey - 1; } pCond->order = order; @@ -4073,6 +4308,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } } + pReader->pSchemaMap = tSimpleHashInit(8, taosFastHash); + if (pReader->pSchemaMap == NULL) { + tsdbError("failed init schema hash for reader %s", pReader->idStr); + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + tSimpleHashSetFreeFp(pReader->pSchemaMap, freeSchemaFunc); if (pReader->pSchema != NULL) { code = updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo); if (code != TSDB_CODE_SUCCESS) { @@ -4091,6 +4334,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL pReader->suspended = true; + if (countOnly) { + pReader->readMode = READ_MODE_COUNT_ONLY; + } + tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr); return code; @@ -4115,7 +4362,7 @@ void tsdbReaderClose(STsdbReader* pReader) { p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; - p->pMemSchema = NULL; + p->pSchemaMap = NULL; p = pReader->innerReader[1]; @@ -4123,7 +4370,7 @@ void tsdbReaderClose(STsdbReader* pReader) { p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; - p->pMemSchema = NULL; + p->pSchemaMap = NULL; tsdbReaderClose(pReader->innerReader[0]); tsdbReaderClose(pReader->innerReader[1]); @@ -4203,10 +4450,7 @@ void tsdbReaderClose(STsdbReader* pReader) { taosMemoryFree(pReader->idStr); taosMemoryFree(pReader->pSchema); - if (pReader->pMemSchema != pReader->pSchema) { - taosMemoryFree(pReader->pMemSchema); - } - + tSimpleHashCleanup(pReader->pSchemaMap); taosMemoryFreeClear(pReader); } @@ -4366,14 +4610,14 @@ int32_t tsdbReaderResume(STsdbReader* pReader) { pPrevReader->status.pTableMap = pReader->status.pTableMap; pPrevReader->status.uidList = pReader->status.uidList; pPrevReader->pSchema = pReader->pSchema; - pPrevReader->pMemSchema = pReader->pMemSchema; + pPrevReader->pSchemaMap = pReader->pSchemaMap; pPrevReader->pReadSnap = pReader->pReadSnap; pNextReader->capacity = 1; pNextReader->status.pTableMap = pReader->status.pTableMap; pNextReader->status.uidList = pReader->status.uidList; pNextReader->pSchema = pReader->pSchema; - pNextReader->pMemSchema = pReader->pMemSchema; + pNextReader->pSchemaMap = pReader->pSchemaMap; pNextReader->pReadSnap = pReader->pReadSnap; code = doOpenReaderImpl(pPrevReader); @@ -4394,43 +4638,82 @@ int32_t tsdbReaderResume(STsdbReader* pReader) { return code; } -static bool doTsdbNextDataBlock(STsdbReader* pReader) { +static bool tsdbReadRowsCountOnly(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SSDataBlock* pBlock = pReader->pResBlock; + + if (pReader->status.loadFromFile == false) { + return false; + } + + code = readRowsCountFromFiles(pReader); + if (code != TSDB_CODE_SUCCESS) { + return false; + } + + code = readRowsCountFromMem(pReader); + if (code != TSDB_CODE_SUCCESS) { + return false; + } + + pBlock->info.rows = pReader->rowsNum; + pBlock->info.id.uid = 0; + pBlock->info.dataLoad = 0; + + pReader->rowsNum = 0; + + return pBlock->info.rows > 0; +} + +static int32_t doTsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) { + int32_t code = TSDB_CODE_SUCCESS; + // cleanup the data that belongs to the previous data block SSDataBlock* pBlock = pReader->pResBlock; blockDataCleanup(pBlock); + *hasNext = false; + SReaderStatus* pStatus = &pReader->status; if (taosHashGetSize(pStatus->pTableMap) == 0) { - return false; + return code; + } + + if (READ_MODE_COUNT_ONLY == pReader->readMode) { + return tsdbReadRowsCountOnly(pReader); } if (pStatus->loadFromFile) { - int32_t code = buildBlockFromFiles(pReader); + code = buildBlockFromFiles(pReader); if (code != TSDB_CODE_SUCCESS) { - return false; + return code; } - if (pBlock->info.rows > 0) { - return true; - } else { + if (pBlock->info.rows <= 0) { resetTableListIndex(&pReader->status); - buildBlockFromBufferSequentially(pReader); - return pBlock->info.rows > 0; + code = buildBlockFromBufferSequentially(pReader); } } else { // no data in files, let's try the buffer - buildBlockFromBufferSequentially(pReader); - return pBlock->info.rows > 0; + code = buildBlockFromBufferSequentially(pReader); } + + *hasNext = pBlock->info.rows > 0; + + return code; } -bool tsdbNextDataBlock(STsdbReader* pReader) { +int32_t tsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) { + int32_t code = TSDB_CODE_SUCCESS; + + *hasNext = false; + if (isEmptyQueryTimeWindow(&pReader->window) || pReader->step == EXTERNAL_ROWS_NEXT) { - return false; + return code; } SReaderStatus* pStatus = &pReader->status; - int32_t code = tsdbAcquireReader(pReader); + code = tsdbAcquireReader(pReader); qTrace("tsdb/read: %p, take read mutex, code: %d", pReader, code); if (pReader->suspended) { @@ -4438,16 +4721,21 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { } if (pReader->innerReader[0] != NULL && pReader->step == 0) { - bool ret = doTsdbNextDataBlock(pReader->innerReader[0]); + code = doTsdbNextDataBlock(pReader->innerReader[0], hasNext); + if (code) { + tsdbReleaseReader(pReader); + return code; + } + pReader->step = EXTERNAL_ROWS_PREV; - if (ret) { + if (*hasNext) { pStatus = &pReader->innerReader[0]->status; if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } } @@ -4464,14 +4752,19 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { pReader->step = EXTERNAL_ROWS_MAIN; } - bool ret = doTsdbNextDataBlock(pReader); - if (ret) { + code = doTsdbNextDataBlock(pReader, hasNext); + if (code != TSDB_CODE_SUCCESS) { + tsdbReleaseReader(pReader); + return code; + } + + if (*hasNext) { if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } if (pReader->step == EXTERNAL_ROWS_MAIN && pReader->innerReader[1] != NULL) { @@ -4483,23 +4776,28 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return code; } - ret = doTsdbNextDataBlock(pReader->innerReader[1]); + code = doTsdbNextDataBlock(pReader->innerReader[1], hasNext); + if (code != TSDB_CODE_SUCCESS) { + tsdbReleaseReader(pReader); + return code; + } + pReader->step = EXTERNAL_ROWS_NEXT; - if (ret) { + if (*hasNext) { pStatus = &pReader->innerReader[1]->status; if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } } qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); - return false; + return code; } static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, SColumnDataAgg* pTsAgg) { @@ -4644,20 +4942,27 @@ STableBlockScanInfo* getTableBlockScanInfo(SHashObj* pTableMap, uint64_t uid, co static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; + int32_t code = TSDB_CODE_SUCCESS; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter); STableBlockScanInfo* pBlockScanInfo = getTableBlockScanInfo(pStatus->pTableMap, pBlockInfo->uid, pReader->idStr); if (pBlockScanInfo == NULL) { return NULL; } - int32_t code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); + code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); + if (code != TSDB_CODE_SUCCESS) { + tBlockDataDestroy(&pStatus->fileBlockData); + terrno = code; + return NULL; + } + + code = copyBlockDataToSDataBlock(pReader); if (code != TSDB_CODE_SUCCESS) { tBlockDataDestroy(&pStatus->fileBlockData); terrno = code; return NULL; } - copyBlockDataToSDataBlock(pReader); return pReader->pResBlock; } @@ -4698,7 +5003,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { return TSDB_CODE_SUCCESS; } - SReaderStatus* pStatus = &pReader->status; + SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; pReader->order = pCond->order; @@ -4719,9 +5024,9 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { resetDataBlockIterator(pBlockIter, pReader->order); resetTableListIndex(&pReader->status); - bool asc = ASCENDING_TRAVERSE(pReader->order); - int32_t step = asc? 1:-1; - int64_t ts = asc? pReader->window.skey - 1 : pReader->window.ekey + 1; + bool asc = ASCENDING_TRAVERSE(pReader->order); + int32_t step = asc ? 1 : -1; + int64_t ts = asc ? pReader->window.skey - 1 : pReader->window.ekey + 1; resetAllDataBlockScanInfo(pStatus->pTableMap, ts, step); int32_t code = 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index c323ae1532a..dd11134bd0e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -638,13 +638,17 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) { // SRowMerger ====================================================== -int32_t tsdbRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema) { +int32_t tsdbRowMergerInit(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema) { int32_t code = 0; TSDBKEY key = TSDBROW_KEY(pRow); SColVal *pColVal = &(SColVal){0}; STColumn *pTColumn; int32_t iCol, jCol = 0; + if (NULL == pResTSchema) { + pResTSchema = pTSchema; + } + pMerger->pTSchema = pResTSchema; pMerger->version = key.version; @@ -712,6 +716,9 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) STColumn *pTColumn; int32_t iCol, jCol = 1; + if (NULL == pTSchema) { + pTSchema = pMerger->pTSchema; + } ASSERT(((SColVal *)pMerger->pArray->pData)->value.val == key.ts); for (iCol = 1; iCol < pMerger->pTSchema->numOfCols && jCol < pTSchema->numOfCols; ++iCol) { @@ -727,23 +734,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) tsdbRowGetColVal(pRow, pTSchema, jCol++, pColVal); if (key.version > pMerger->version) { -#if 0 - if (!COL_VAL_IS_NONE(pColVal)) { - if ((!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) { - SColVal *tColVal = taosArrayGet(pMerger->pArray, iCol); - code = tRealloc(&tColVal->value.pData, pColVal->value.nData); - if (code) return code; - - tColVal->value.nData = pColVal->value.nData; - if (pColVal->value.nData) { - memcpy(tColVal->value.pData, pColVal->value.pData, pColVal->value.nData); - } - tColVal->flag = 0; - } else { - taosArraySet(pMerger->pArray, iCol, pColVal); - } - } -#endif if (!COL_VAL_IS_NONE(pColVal)) { if (IS_VAR_DATA_TYPE(pColVal->type)) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); @@ -758,7 +748,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) pTColVal->flag = 0; } else { tFree(pTColVal->value.pData); - pTColVal->value.pData = NULL; taosArraySet(pMerger->pArray, iCol, pColVal); } } else { @@ -789,7 +778,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) pMerger->version = key.version; return code; } - +/* int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { int32_t code = 0; TSDBKEY key = TSDBROW_KEY(pRow); @@ -840,7 +829,7 @@ int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema _exit: return code; } - +*/ void tsdbRowMergerClear(SRowMerger *pMerger) { for (int32_t iCol = 1; iCol < pMerger->pTSchema->numOfCols; iCol++) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); @@ -851,7 +840,7 @@ void tsdbRowMergerClear(SRowMerger *pMerger) { taosArrayDestroy(pMerger->pArray); } - +/* int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) { int32_t code = 0; TSDBKEY key = TSDBROW_KEY(pRow); @@ -916,7 +905,7 @@ int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) { _exit: return code; } - +*/ int32_t tsdbRowMergerGetRow(SRowMerger *pMerger, SRow **ppRow) { return tRowBuild(pMerger->pArray, pMerger->pTSchema, ppRow); } diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 718b5979a15..3d2b032156d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -541,6 +541,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { return vnodeGetBatchMeta(pVnode, pMsg); case TDMT_VND_TMQ_CONSUME: return tqProcessPollReq(pVnode->pTq, pMsg); + case TDMT_STREAM_TASK_RUN: return tqProcessTaskRunReq(pVnode->pTq, pMsg); #if 1 diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index b49ca70bfae..d681f5b65e2 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -378,7 +378,7 @@ static int32_t vnodeSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { return -1; } - int32_t code = tmsgPutToQueue(msgcb, SYNC_CTRL_QUEUE, pMsg); + int32_t code = tmsgPutToQueue(msgcb, SYNC_RD_QUEUE, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index f99c7de93d9..9b8f034e448 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -107,6 +107,7 @@ int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t uint64_t tableListGetSize(const STableListInfo* pTableList); uint64_t tableListGetSuid(const STableListInfo* pTableList); STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index); +int32_t tableListFind(const STableListInfo* pTableList, uint64_t uid, int32_t startIndex); size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); void initResultRowInfo(SResultRowInfo* pResultRowInfo); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 3f519568c4b..16433dc34e1 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -128,10 +128,10 @@ enum { typedef struct { // TODO remove prepareStatus - STqOffsetVal prepareStatus; // for tmq - STqOffsetVal lastStatus; // for tmq +// STqOffsetVal prepareStatus; // for tmq + STqOffsetVal currentOffset; // for tmq SMqMetaRsp metaRsp; // for tmq fetching meta - int8_t returned; +// int8_t returned; int64_t snapshotVer; // const SSubmitReq* pReq; @@ -143,10 +143,7 @@ typedef struct { SQueryTableDataCond tableCond; int64_t fillHistoryVer1; int64_t fillHistoryVer2; - - // int8_t triggerSaved; - // int64_t deleteMarkSaved; - SStreamState* pState; + SStreamState* pState; } SStreamTaskInfo; typedef struct { @@ -168,18 +165,16 @@ typedef struct STaskStopInfo { } STaskStopInfo; struct SExecTaskInfo { - STaskIdInfo id; - uint32_t status; - STimeWindow window; - STaskCostInfo cost; - int64_t owner; // if it is in execution - int32_t code; - int32_t qbufQuota; // total available buffer (in KB) during execution query - - int64_t version; // used for stream to record wal version, why not move to sschemainfo + STaskIdInfo id; + uint32_t status; + STimeWindow window; + STaskCostInfo cost; + int64_t owner; // if it is in execution + int32_t code; + int32_t qbufQuota; // total available buffer (in KB) during execution query + int64_t version; // used for stream to record wal version, why not move to sschemainfo SStreamTaskInfo streamInfo; SSchemaInfo schemaInfo; - STableListInfo* pTableInfoList; // this is a table list const char* sql; // query sql string jmp_buf env; // jump to this position when error happens. EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] @@ -188,6 +183,7 @@ struct SExecTaskInfo { SLocalFetch localFetch; SArray* pResultBlockList; // result block list STaskStopInfo stopInfo; + SRWLatch lock; // secure the access of STableListInfo }; enum { @@ -195,7 +191,7 @@ enum { OP_OPENED = 0x1, OP_RES_TO_RETURN = 0x5, OP_EXEC_DONE = 0x9, - OP_EXEC_RECV = 0x11, +// OP_EXEC_RECV = 0x11, }; typedef struct SOperatorFpSet { @@ -326,6 +322,8 @@ typedef struct STableScanBase { int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan int32_t dataBlockLoadFlag; SLimitInfo limitInfo; + // there are more than one table list exists in one task, if only one vnode exists. + STableListInfo* pTableListInfo; } STableScanBase; typedef struct STableScanInfo { @@ -339,6 +337,7 @@ typedef struct STableScanInfo { int8_t scanMode; int8_t assignBlockUid; bool hasGroupByTag; + bool countOnly; } STableScanInfo; typedef struct STableMergeScanInfo { @@ -365,11 +364,12 @@ typedef struct STableMergeScanInfo { } STableMergeScanInfo; typedef struct STagScanInfo { - SColumnInfo* pCols; - SSDataBlock* pRes; - SColMatchInfo matchInfo; - int32_t curPos; - SReadHandle readHandle; + SColumnInfo* pCols; + SSDataBlock* pRes; + SColMatchInfo matchInfo; + int32_t curPos; + SReadHandle readHandle; + STableListInfo* pTableListInfo; } STagScanInfo; typedef enum EStreamScanMode { @@ -485,16 +485,11 @@ typedef struct SStreamScanInfo { } SStreamScanInfo; typedef struct { - // int8_t subType; - // bool withMeta; - // int64_t suid; - // int64_t snapVersion; - // void *metaInfo; - // void *dataInfo; - SVnode* vnode; - SSDataBlock pRes; // result SSDataBlock - STsdbReader* dataReader; - SSnapContext* sContext; + SVnode* vnode; + SSDataBlock pRes; // result SSDataBlock + STsdbReader* dataReader; + SSnapContext* sContext; + STableListInfo* pTableListInfo; } SStreamRawScanInfo; typedef struct STableCountScanSupp { @@ -507,16 +502,6 @@ typedef struct STableCountScanSupp { char stbNameFilter[TSDB_TABLE_NAME_LEN]; } STableCountScanSupp; -typedef struct STableCountScanOperatorInfo { - SReadHandle readHandle; - SSDataBlock* pRes; - - STableCountScanSupp supp; - - int32_t currGrpIdx; - SArray* stbUidList; // when group by db_name and/or stable_name -} STableCountScanOperatorInfo; - typedef struct SOptrBasicInfo { SResultRowInfo resultRowInfo; SSDataBlock* pRes; @@ -693,6 +678,8 @@ typedef struct SStreamFillOperatorInfo { #define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED) #define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED) +SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, char* dbFName); + SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, __optr_explain_fn_t explain); int32_t optrDummyOpenFn(SOperatorInfo* pOperator); @@ -737,6 +724,7 @@ void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int3 STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); +SOperatorInfo* extractOperatorInTree(SOperatorInfo* pOperator, int32_t type, const char* id); int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag, bool inheritUsOrder); int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); @@ -759,11 +747,11 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // clang-format off SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableList, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); @@ -779,7 +767,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); @@ -793,9 +781,9 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); @@ -840,9 +828,11 @@ void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); char* buildTaskId(uint64_t taskId, uint64_t queryId); +SArray* getTableListInfo(const SExecTaskInfo* pTaskInfo); + int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, int32_t vgId, char* sql, EOPTR_EXEC_MODEL model); -int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* pTask, SReadHandle* readHandle); int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList); STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, @@ -856,7 +846,6 @@ bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap); bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); -bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup); void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName); diff --git a/source/libs/executor/src/aggregateoperator.c b/source/libs/executor/src/aggregateoperator.c new file mode 100644 index 00000000000..ec8060348d4 --- /dev/null +++ b/source/libs/executor/src/aggregateoperator.c @@ -0,0 +1,573 @@ +/* + * 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 "filter.h" +#include "function.h" +#include "functionMgt.h" +#include "os.h" +#include "querynodes.h" +#include "tfill.h" +#include "tname.h" + +#include "tdatablock.h" +#include "tglobal.h" +#include "tmsg.h" +#include "ttime.h" + +#include "executorimpl.h" +#include "index.h" +#include "query.h" +#include "tcompare.h" +#include "thash.h" +#include "ttypes.h" +#include "vnode.h" + +typedef struct { + bool hasAgg; + int32_t numOfRows; + int32_t startOffset; +} SFunctionCtxStatus; + +typedef struct SAggOperatorInfo { + SOptrBasicInfo binfo; + SAggSupporter aggSup; + STableQueryInfo* current; + uint64_t groupId; + SGroupResInfo groupResInfo; + SExprSupp scalarExprSup; + bool groupKeyOptimized; +} SAggOperatorInfo; + +static void destroyAggOperatorInfo(void* param); +static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); + +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock); +static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock); + +static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator); +static int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx); +static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator); + +static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, + const char* pKey); + +static int32_t addNewResultRowBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size); + +static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); + +static void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus); +static void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus); + +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, + SExecTaskInfo* pTaskInfo) { + SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + SSDataBlock* pResBlock = createDataBlockFromDescNode(pAggNode->node.pOutputDataBlockDesc); + initBasicInfo(&pInfo->binfo, pResBlock); + + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + initResultSizeInfo(&pOperator->resultInfo, 4096); + + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = NULL; + if (pAggNode->pExprs != NULL) { + pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); + } + + code = initExprSupp(&pInfo->scalarExprSup, pScalarExprInfo, numOfScalarExpr); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + code = filterInitFromNode((SNode*)pAggNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; + pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; + pInfo->groupId = UINT64_MAX; + + setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, + pTaskInfo); + pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, + optrDefaultBufFn, NULL); + + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + STableScanInfo* pTableScanInfo = downstream->info; + pTableScanInfo->base.pdInfo.pExprSup = &pOperator->exprSupp; + pTableScanInfo->base.pdInfo.pAggSup = &pInfo->aggSup; + } + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + return pOperator; + + _error: + if (pInfo != NULL) { + destroyAggOperatorInfo(pInfo); + } + + if (pOperator != NULL) { + cleanupExprSupp(&pOperator->exprSupp); + } + + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} + +void destroyAggOperatorInfo(void* param) { + SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param; + cleanupBasicInfo(&pInfo->binfo); + + cleanupAggSup(&pInfo->aggSup); + cleanupExprSupp(&pInfo->scalarExprSup); + cleanupGroupResInfo(&pInfo->groupResInfo); + taosMemoryFreeClear(param); +} + +// this is a blocking operator +int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { + if (OPTR_IS_OPENED(pOperator)) { + return TSDB_CODE_SUCCESS; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SAggOperatorInfo* pAggInfo = pOperator->info; + + SExprSupp* pSup = &pOperator->exprSupp; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + + int64_t st = taosGetTimestampUs(); + + int32_t order = TSDB_ORDER_ASC; + int32_t scanFlag = MAIN_SCAN; + + bool hasValidBlock = false; + + while (1) { + bool blockAllocated = false; + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + if (!hasValidBlock) { + createDataBlockForEmptyInput(pOperator, &pBlock); + if (pBlock == NULL) { + break; + } + blockAllocated = true; + } else { + break; + } + } + hasValidBlock = true; + + int32_t code = getTableScanInfo(pOperator, &order, &scanFlag, false); + if (code != TSDB_CODE_SUCCESS) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + + // there is an scalar expression that needs to be calculated before apply the group aggregation. + if (pAggInfo->scalarExprSup.pExprInfo != NULL && !blockAllocated) { + SExprSupp* pSup1 = &pAggInfo->scalarExprSup; + code = projectApplyFunctions(pSup1->pExprInfo, pBlock, pBlock, pSup1->pCtx, pSup1->numOfExprs, NULL); + if (code != TSDB_CODE_SUCCESS) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + } + + // the pDataBlock are always the same one, no need to call this again + setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.id.groupId); + setInputDataBlock(pSup, pBlock, order, scanFlag, true); + code = doAggregateImpl(pOperator, pSup->pCtx); + if (code != 0) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + } + + // the downstream operator may return with error code, so let's check the code before generating results. + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + + initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0); + OPTR_SET_OPENED(pOperator); + + pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; + return pTaskInfo->code; +} + +SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) { + SAggOperatorInfo* pAggInfo = pOperator->info; + SOptrBasicInfo* pInfo = &pAggInfo->binfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + pTaskInfo->code = pOperator->fpSet._openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + setOperatorCompleted(pOperator); + return NULL; + } + + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + while (1) { + doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); + doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL); + + if (!hasRemainResults(&pAggInfo->groupResInfo)) { + setOperatorCompleted(pOperator); + break; + } + + if (pInfo->pRes->info.rows > 0) { + break; + } + } + + size_t rows = blockDataGetNumOfRows(pInfo->pRes); + pOperator->resultInfo.totalRows += rows; + + return (rows == 0) ? NULL : pInfo->pRes; +} + +int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx) { + for (int32_t k = 0; k < pOperator->exprSupp.numOfExprs; ++k) { + if (functionNeedToExecute(&pCtx[k])) { + // todo add a dummy funtion to avoid process check + if (pCtx[k].fpSet.process == NULL) { + continue; + } + + 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)); + return code; + } + } + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { + if (!tsCountAlwaysReturnValue) { + return TSDB_CODE_SUCCESS; + } + + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupKeyOptimized) { + return TSDB_CODE_SUCCESS; + } + + SOperatorInfo* downstream = pOperator->pDownstream[0]; + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || + (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && + ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { + return TSDB_CODE_SUCCESS; + } + + SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; + bool hasCountFunc = false; + + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { + const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; + if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || + (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { + hasCountFunc = true; + break; + } + } + + if (!hasCountFunc) { + return TSDB_CODE_SUCCESS; + } + + SSDataBlock* pBlock = createDataBlock(); + pBlock->info.rows = 1; + pBlock->info.capacity = 0; + + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { + SColumnInfoData colInfo = {0}; + colInfo.hasNull = true; + colInfo.info.type = TSDB_DATA_TYPE_NULL; + colInfo.info.bytes = 1; + + SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i]; + for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { + SFunctParam* pFuncParam = &pOneExpr->base.pParam[j]; + if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { + int32_t slotId = pFuncParam->pCol->slotId; + int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + if (slotId >= numOfCols) { + taosArrayEnsureCap(pBlock->pDataBlock, slotId + 1); + for (int32_t k = numOfCols; k < slotId + 1; ++k) { + taosArrayPush(pBlock->pDataBlock, &colInfo); + } + } + } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { + // do nothing + } + } + } + + blockDataEnsureCapacity(pBlock, pBlock->info.rows); + *ppBlock = pBlock; + + return TSDB_CODE_SUCCESS; +} + +void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { + if (!blockAllocated) { + return; + } + + blockDataDestroy(*ppBlock); + *ppBlock = NULL; +} + +void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupId != UINT64_MAX && pAggInfo->groupId == groupId) { + return; + } + + doSetTableGroupOutputBuf(pOperator, numOfOutput, groupId); + + // record the current active group id + pAggInfo->groupId = groupId; +} + +void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + // for simple group by query without interval, all the tables belong to one group result. + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SAggOperatorInfo* pAggInfo = pOperator->info; + + SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; + SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; + int32_t* rowEntryInfoOffset = pOperator->exprSupp.rowEntryInfoOffset; + + SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, (char*)&groupId, + sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup, true); + /* + * not assign result buffer yet, add new result buffer + * all group belong to one result set, and each group result has different group id so set the id to be one + */ + if (pResultRow->pageId == -1) { + int32_t ret = addNewResultRowBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); + if (ret != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + } + + setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset); +} + +// a new buffer page for each table. Needs to opt this design +int32_t addNewResultRowBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) { + if (pWindowRes->pageId != -1) { + return 0; + } + + SFilePage* pData = NULL; + + // in the first scan, new space needed for results + int32_t pageId = -1; + SArray* list = getDataBufPagesIdList(pResultBuf); + + if (taosArrayGetSize(list) == 0) { + pData = getNewBufPage(pResultBuf, &pageId); + pData->num = sizeof(SFilePage); + } else { + SPageInfo* pi = getLastPageInfo(list); + pData = getBufPage(pResultBuf, getPageId(pi)); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return terrno; + } + + pageId = getPageId(pi); + + if (pData->num + size > getBufPageSize(pResultBuf)) { + // release current page first, and prepare the next one + releaseBufPageInfo(pResultBuf, pi); + + pData = getNewBufPage(pResultBuf, &pageId); + if (pData != NULL) { + pData->num = sizeof(SFilePage); + } + } + } + + if (pData == NULL) { + return -1; + } + + // set the number of rows in current disk page + if (pWindowRes->pageId == -1) { // not allocated yet, allocate new buffer + pWindowRes->pageId = pageId; + pWindowRes->offset = (int32_t)pData->num; + + pData->num += size; + } + + return 0; +} + +int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, + const char* pKey) { + int32_t code = 0; + // _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + + pAggSup->currentPageId = -1; + pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); + pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); + pAggSup->pResultRowHashTable = tSimpleHashInit(100, taosFastHash); + + if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + uint32_t defaultPgsz = 0; + uint32_t defaultBufsz = 0; + getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); + + if (!osTempSpaceAvailable()) { + code = TSDB_CODE_NO_AVAIL_DISK; + qError("Init stream agg supporter failed since %s, %s", terrstr(code), pKey); + return code; + } + + code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, tsTempDir); + if (code != TSDB_CODE_SUCCESS) { + qError("Create agg result buf failed since %s, %s", tstrerror(code), pKey); + return code; + } + + return code; +} + +void cleanupAggSup(SAggSupporter* pAggSup) { + taosMemoryFreeClear(pAggSup->keyBuf); + tSimpleHashCleanup(pAggSup->pResultRowHashTable); + destroyDiskbasedBuf(pAggSup->pResultBuf); +} + +int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, + const char* pkey, void* pState) { + int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = doInitAggInfoSup(pAggSup, pSup->pCtx, numOfCols, keyBufSize, pkey); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + for (int32_t i = 0; i < numOfCols; ++i) { + if (pState) { + pSup->pCtx[i].saveHandle.pBuf = NULL; + pSup->pCtx[i].saveHandle.pState = pState; + pSup->pCtx[i].exprIdx = i; + } else { + pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + } + } + + return TSDB_CODE_SUCCESS; +} + +void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, + int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput) { + for (int32_t k = 0; k < numOfOutput; ++k) { + // keep it temporarily + SFunctionCtxStatus status = {0}; + functionCtxSave(&pCtx[k], &status); + + pCtx[k].input.startRowIndex = offset; + pCtx[k].input.numOfRows = forwardStep; + + // not a whole block involved in query processing, statistics data can not be used + // NOTE: the original value of isSet have been changed here + if (pCtx[k].input.colDataSMAIsSet && forwardStep < numOfTotal) { + pCtx[k].input.colDataSMAIsSet = false; + } + + if (pCtx[k].isPseudoFunc) { + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]); + + char* p = GET_ROWCELL_INTERBUF(pEntryInfo); + + SColumnInfoData idata = {0}; + idata.info.type = TSDB_DATA_TYPE_BIGINT; + idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + idata.pData = p; + + SScalarParam out = {.columnData = &idata}; + SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData}; + pCtx[k].sfp.process(&tw, 1, &out); + pEntryInfo->numOfRes = 1; + } else { + int32_t code = TSDB_CODE_SUCCESS; + if (functionNeedToExecute(&pCtx[k]) && pCtx[k].fpSet.process != NULL) { + code = pCtx[k].fpSet.process(&pCtx[k]); + + if (code != TSDB_CODE_SUCCESS) { + qError("%s apply functions error, code: %s", GET_TASKID(taskInfo), tstrerror(code)); + taskInfo->code = code; + T_LONG_JMP(taskInfo->env, code); + } + } + + // restore it + functionCtxRestore(&pCtx[k], &status); + } + } +} + +void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { + pStatus->hasAgg = pCtx->input.colDataSMAIsSet; + pStatus->numOfRows = pCtx->input.numOfRows; + pStatus->startOffset = pCtx->input.startRowIndex; +} + +void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { + pCtx->input.colDataSMAIsSet = pStatus->hasAgg; + pCtx->input.numOfRows = pStatus->numOfRows; + pCtx->input.startRowIndex = pStatus->startOffset; +} diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index d42b348fd8c..f6fc332b379 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -37,6 +37,7 @@ typedef struct SCacheRowsScanInfo { SSDataBlock* pBufferredRes; SArray* pUidList; int32_t indexOfBufferedRes; + STableListInfo* pTableList; } SCacheRowsScanInfo; static SSDataBlock* doScanCache(SOperatorInfo* pOperator); @@ -47,15 +48,17 @@ static int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColM #define SCAN_ROW_TYPE(_t) ((_t)? CACHESCAN_RETRIEVE_LAST : CACHESCAN_RETRIEVE_LAST_ROW) SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { int32_t code = TSDB_CODE_SUCCESS; SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } + pInfo->pTableList = pTableListInfo; pInfo->readHandle = *readHandle; SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc; @@ -75,20 +78,18 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe goto _error; } - STableListInfo* pTableList = pTaskInfo->pTableInfoList; - - int32_t totalTables = tableListGetSize(pTableList); + int32_t totalTables = tableListGetSize(pTableListInfo); int32_t capacity = 0; pInfo->pUidList = taosArrayInit(4, sizeof(int64_t)); // partition by tbname - if (oneTableForEachGroup(pTableList) || (totalTables == 1)) { + if (oneTableForEachGroup(pTableListInfo) || (totalTables == 1)) { pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL | SCAN_ROW_TYPE(pScanNode->ignoreNull); - STableKeyInfo* pList = tableListGetInfo(pTableList, 0); + STableKeyInfo* pList = tableListGetInfo(pTableListInfo, 0); - uint64_t suid = tableListGetSuid(pTableList); + uint64_t suid = tableListGetSuid(pTableListInfo); code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables, taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { @@ -136,7 +137,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { SCacheRowsScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - STableListInfo* pTableList = pTaskInfo->pTableInfoList; + STableListInfo* pTableList = pInfo->pTableList; uint64_t suid = tableListGetSuid(pTableList); int32_t size = tableListGetSize(pTableList); @@ -281,6 +282,7 @@ void destroyCacheScanOperator(void* param) { taosMemoryFree(pInfo->pSlotIds); taosArrayDestroy(pInfo->pUidList); taosArrayDestroy(pInfo->matchInfo.pList); + tableListDestroy(pInfo->pTableList); if (pInfo->pLastrowReader != NULL) { pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader); diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index 3bdecbe748f..c855a104b2c 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -70,7 +70,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } for (int32_t i = 0; i < totalSources; ++i) { @@ -212,6 +212,11 @@ static SSDataBlock* loadRemoteData(SOperatorInfo* pOperator) { return NULL; } + doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL); + if (blockDataGetNumOfRows(pBlock) == 0) { + continue; + } + SLimitInfo* pLimitInfo = &pExchangeInfo->limitInfo; if (hasLimitOffsetInfo(pLimitInfo)) { int32_t status = handleLimitOffset(pOperator, pLimitInfo, pBlock, false); @@ -303,6 +308,11 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode pTaskInfo); pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock); + code = filterInitFromNode((SNode*)pExNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, loadRemoteData, NULL, destroyExchangeOperatorInfo, optrDefaultBufFn, NULL); return pOperator; @@ -566,7 +576,7 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; pOperator->cost.openCost = taosGetTimestampUs() - startTs; if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } return TSDB_CODE_SUCCESS; @@ -619,7 +629,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) { doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current); tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 953d6149514..7d318786ba1 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -34,7 +34,7 @@ struct STableListInfo { int32_t numOfOuputGroups; // the data block will be generated one by one int32_t* groupOffset; // keep the offset value for each group in the tableList SArray* pTableList; - SHashObj* map; // speedup acquire the tableQueryInfo by table uid + SHashObj* map; // speedup acquire the tableQueryInfo by table uid uint64_t suid; }; @@ -571,6 +571,10 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis memcpy(pStart, data, len); pStart += len; } else if (IS_VAR_DATA_TYPE(pValue->info.type)) { + if (varDataTLen(data) > pValue->info.bytes) { + code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + goto end; + } memcpy(pStart, data, varDataTLen(data)); pStart += varDataTLen(data); } else { @@ -1800,6 +1804,21 @@ STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index) return taosArrayGet(pTableList->pTableList, index); } +int32_t tableListFind(const STableListInfo* pTableList, uint64_t uid, int32_t startIndex) { + int32_t numOfTables = taosArrayGetSize(pTableList->pTableList); + if (startIndex >= numOfTables) { + return -1; + } + + for (int32_t i = startIndex; i < numOfTables; ++i) { + STableKeyInfo* p = taosArrayGet(pTableList->pTableList, i); + if (p->uid == uid) { + return i; + } + } + return -1; +} + uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) { int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid)); ASSERT(pTableList->map != NULL && slot != NULL); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 85f17c0d538..1670eb3c59f 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -127,12 +127,10 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu pOperator->status = OP_NOT_OPENED; SStreamScanInfo* pInfo = pOperator->info; - qDebug("stream set total blocks:%d, task id:%s" PRIx64, (int32_t)numOfBlocks, id); - ASSERT(pInfo->validBlockIndex == 0); - ASSERT(taosArrayGetSize(pInfo->pBlockLists) == 0); + qDebug("task stream set total blocks:%d %s", (int32_t)numOfBlocks, id); + ASSERT(pInfo->validBlockIndex == 0 && taosArrayGetSize(pInfo->pBlockLists) == 0); if (type == STREAM_INPUT__MERGED_SUBMIT) { - // ASSERT(numOfBlocks > 1); for (int32_t i = 0; i < numOfBlocks; i++) { SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData)); taosArrayPush(pInfo->pBlockLists, pReq); @@ -242,30 +240,28 @@ int32_t qSetSMAInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, return code; } -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, SSchemaWrapper** pSchema) { - if (msg == NULL) { - // create raw scan - SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, uint64_t id) { + if (msg == NULL) { // create raw scan + SExecTaskInfo* pTaskInfo = doCreateExecTaskInfo(0, id, vgId, OPTR_EXEC_MODEL_QUEUE, ""); if (NULL == pTaskInfo) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); - - pTaskInfo->cost.created = taosGetTimestampUs(); - pTaskInfo->execModel = OPTR_EXEC_MODEL_QUEUE; pTaskInfo->pRoot = createRawScanOperatorInfo(pReaderHandle, pTaskInfo); if (NULL == pTaskInfo->pRoot) { terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pTaskInfo); return NULL; } + + qDebug("create raw scan task info completed, vgId:%d, %s", vgId, GET_TASKID(pTaskInfo)); return pTaskInfo; } struct SSubplan* pPlan = NULL; - int32_t code = qStringToSubplan(msg, &pPlan); + + int32_t code = qStringToSubplan(msg, &pPlan); if (code != TSDB_CODE_SUCCESS) { terrno = code; return NULL; @@ -292,9 +288,6 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3 } } - if (pSchema) { - *pSchema = tCloneSSchemaWrapper(((SExecTaskInfo*)pTaskInfo)->schemaInfo.qsw); - } return pTaskInfo; } @@ -409,7 +402,8 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } } - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; + STableListInfo* pTableListInfo = ((STableScanInfo*)pScanInfo->pTableScanOp->info)->base.pTableListInfo; + taosWLockLatch(&pTaskInfo->lock); for (int32_t i = 0; i < numOfQualifiedTables; ++i) { uint64_t* uid = taosArrayGet(qa, i); @@ -424,6 +418,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(keyBuf); taosArrayDestroy(qa); + taosWUnLockLatch(&pTaskInfo->lock); return code; } } @@ -445,6 +440,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo tableListAddTableInfo(pTableListInfo, keyInfo.uid, keyInfo.groupId); } + taosWUnLockLatch(&pTaskInfo->lock); if (keyBuf != NULL) { taosMemoryFree(keyBuf); } @@ -452,7 +448,9 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo taosArrayDestroy(qa); } else { // remove the table id in current list qDebug(" %d remove child tables from the stream scanner", (int32_t)taosArrayGetSize(tableIdList)); + taosWLockLatch(&pTaskInfo->lock); code = tqReaderRemoveTbUidList(pScanInfo->tqReader, tableIdList); + taosWUnLockLatch(&pTaskInfo->lock); } return code; @@ -485,9 +483,7 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, char* sql, EOPTR_EXEC_MODEL model) { - assert(pSubplan != NULL); SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo; - taosThreadOnce(&initPoolOnce, initRefPool); qDebug("start to create task, TID:0x%" PRIx64 " QID:0x%" PRIx64 ", vgId:%d", taskId, pSubplan->id.queryId, vgId); @@ -507,7 +503,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, if (handle) { void* pSinkParam = NULL; - code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo, readHandle); + code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, (*pTask), readHandle); if (code != TSDB_CODE_SUCCESS) { qError("failed to createDataSinkParam, vgId:%d, code:%s, %s", vgId, tstrerror(code), (*pTask)->id.str); goto _error; @@ -755,8 +751,8 @@ int32_t qKillTask(qTaskInfo_t tinfo, int32_t rspCode) { return TSDB_CODE_QRY_INVALID_QHANDLE; } - qDebug("%s execTask async killed", GET_TASKID(pTaskInfo)); - setTaskKilled(pTaskInfo, rspCode); + qDebug("%s sync killed execTask", GET_TASKID(pTaskInfo)); + setTaskKilled(pTaskInfo, TSDB_CODE_TSC_QUERY_KILLED); while(qTaskIsExecuting(pTaskInfo)) { taosMsleep(10); @@ -1000,6 +996,7 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) { } return 0; } + bool qStreamRecoverScanFinished(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; return pTaskInfo->streamInfo.recoverScanFinished; @@ -1025,15 +1022,9 @@ SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { return &pTaskInfo->streamInfo.metaRsp; } -int64_t qStreamExtractPrepareUid(qTaskInfo_t tinfo) { +void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - return pTaskInfo->streamInfo.prepareStatus.uid; -} - -int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - memcpy(pOffset, &pTaskInfo->streamInfo.lastStatus, sizeof(STqOffsetVal)); - return 0; + memcpy(pOffset, &pTaskInfo->streamInfo.currentOffset, sizeof(STqOffsetVal)); } int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) { @@ -1079,36 +1070,39 @@ int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit) { return 0; } -int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType) { +void qStreamSetOpen(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - SOperatorInfo* pOperator = pTaskInfo->pRoot; - pTaskInfo->streamInfo.prepareStatus = *pOffset; - pTaskInfo->streamInfo.returned = 0; + SOperatorInfo* pOperator = pTaskInfo->pRoot; + pOperator->status = OP_NOT_OPENED; +} + +int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + SOperatorInfo* pOperator = pTaskInfo->pRoot; + const char* id = GET_TASKID(pTaskInfo); - if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.lastStatus)) { + // if pOffset equal to current offset, means continue consume + if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.currentOffset)) { return 0; } if (subType == TOPIC_SUB_TYPE__COLUMN) { - pOperator->status = OP_OPENED; - - // TODO add more check - if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - if(pOperator->numOfDownstream != 1){ - qError("pOperator->numOfDownstream != 1:%d", pOperator->numOfDownstream); - return -1; - } - pOperator = pOperator->pDownstream[0]; + pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id); + if (pOperator == NULL) { + return -1; } - SStreamScanInfo* pInfo = pOperator->info; + STableScanInfo* pScanInfo = pInfo->pTableScanOp->info; + STableScanBase* pScanBaseInfo = &pScanInfo->base; + STableListInfo* pTableListInfo = pScanBaseInfo->pTableListInfo; + if (pOffset->type == TMQ_OFFSET__LOG) { - STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; - tsdbReaderClose(pTSInfo->base.dataReader); - pTSInfo->base.dataReader = NULL; + tsdbReaderClose(pScanBaseInfo->dataReader); + pScanBaseInfo->dataReader = NULL; + // let's seek to the next version in wal file - if (tqSeekVer(pInfo->tqReader, pOffset->version + 1, pTaskInfo->id.str) < 0) { - qError("tqSeekVer failed ver:%" PRId64, pOffset->version + 1); + if (tqSeekVer(pInfo->tqReader, pOffset->version + 1, id) < 0) { + qError("tqSeekVer failed ver:%"PRId64", %s", pOffset->version + 1, id); return -1; } } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { @@ -1116,121 +1110,134 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT // those data are from the snapshot in tsdb, besides the data in the wal file. int64_t uid = pOffset->uid; int64_t ts = pOffset->ts; + int32_t index = 0; + + // this value may be changed if new tables are created + taosRLockLatch(&pTaskInfo->lock); + int32_t numOfTables = tableListGetSize(pTableListInfo); if (uid == 0) { - if (tableListGetSize(pTaskInfo->pTableInfoList) != 0) { - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, 0); + if (numOfTables != 0) { + STableKeyInfo* pTableInfo = tableListGetInfo(pTableListInfo, 0); uid = pTableInfo->uid; ts = INT64_MIN; + pScanInfo->currentTable = 0; } else { - qError("uid == 0 and tablelist size is 0"); + taosRUnLockLatch(&pTaskInfo->lock); + qError("no table in table list, %s", id); return -1; } } - /*if (pTaskInfo->streamInfo.lastStatus.type != TMQ_OFFSET__SNAPSHOT_DATA ||*/ - /*pTaskInfo->streamInfo.lastStatus.uid != uid || pTaskInfo->streamInfo.lastStatus.ts != ts) {*/ - STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; - int32_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); - qDebug("switch to table uid:%" PRId64 " ts:%" PRId64 "% "PRId64 " rows returned", uid, ts, pInfo->pTableScanOp->resultInfo.totalRows); pInfo->pTableScanOp->resultInfo.totalRows = 0; - bool found = false; - for (int32_t i = 0; i < numOfTables; i++) { - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, i); - if (pTableInfo->uid == uid) { - found = true; - pTableScanInfo->currentTable = i; - break; - } - } - - // TODO after dropping table, table may not found - if(!found){ - qError("uid not found in tablelist %" PRId64, uid); + // start from current accessed position + // we cannot start from the pScanInfo->currentTable, since the commit offset may cause the rollback of the start + // position, let's find it from the beginning. + index = tableListFind(pTableListInfo, uid, 0); + taosRUnLockLatch(&pTaskInfo->lock); + + if (index >= 0) { + pScanInfo->currentTable = index; + } else { + qError("vgId:%d uid:%" PRIu64 " not found in table list, total:%d, index:%d %s", pTaskInfo->id.vgId, uid, + numOfTables, pScanInfo->currentTable, id); return -1; } - if (pTableScanInfo->base.dataReader == NULL) { - STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0); - int32_t num = tableListGetSize(pTaskInfo->pTableInfoList); + STableKeyInfo keyInfo = {.uid = uid}; + int64_t oldSkey = pScanBaseInfo->cond.twindows.skey; - if (tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &pTableScanInfo->base.cond, pList, num, - pTableScanInfo->pResBlock, &pTableScanInfo->base.dataReader, NULL) < 0 || - pTableScanInfo->base.dataReader == NULL) { - qError("tsdbReaderOpen failed. uid:%" PRIi64, pOffset->uid); + // let's start from the next ts that returned to consumer. + pScanBaseInfo->cond.twindows.skey = ts + 1; + pScanInfo->scanTimes = 0; + + if (pScanBaseInfo->dataReader == NULL) { + int32_t code = tsdbReaderOpen(pScanBaseInfo->readHandle.vnode, &pScanBaseInfo->cond, &keyInfo, 1, + pScanInfo->pResBlock, &pScanBaseInfo->dataReader, id, false); + if (code != TSDB_CODE_SUCCESS) { + qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id); + terrno = code; return -1; } - } - STableKeyInfo tki = {.uid = uid}; - tsdbSetTableList(pTableScanInfo->base.dataReader, &tki, 1); - int64_t oldSkey = pTableScanInfo->base.cond.twindows.skey; - pTableScanInfo->base.cond.twindows.skey = ts + 1; - tsdbReaderReset(pTableScanInfo->base.dataReader, &pTableScanInfo->base.cond); - pTableScanInfo->base.cond.twindows.skey = oldSkey; - pTableScanInfo->scanTimes = 0; + qDebug("tsdb reader created with offset(snapshot) uid:%" PRId64 " ts:%" PRId64 " table index:%d, total:%d, %s", + uid, pScanBaseInfo->cond.twindows.skey, pScanInfo->currentTable, numOfTables, id); + } else { + tsdbSetTableList(pScanBaseInfo->dataReader, &keyInfo, 1); + tsdbReaderReset(pScanBaseInfo->dataReader, &pScanBaseInfo->cond); + qDebug("tsdb reader offset seek snapshot to uid:%" PRId64 " ts %" PRId64 " table index:%d numOfTable:%d, %s", + uid, pScanBaseInfo->cond.twindows.skey, pScanInfo->currentTable, numOfTables, id); + } - qDebug("tsdb reader offset seek snapshot to uid:%" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, - ts, pTableScanInfo->currentTable, numOfTables); + // restore the key value + pScanBaseInfo->cond.twindows.skey = oldSkey; } else { - qError("invalid pOffset->type:%d", pOffset->type); - return -1; - } - } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if (setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setDataForSnapShot error. uid:%" PRIi64, pOffset->uid); + qError("invalid pOffset->type:%d, %s", pOffset->type, id); return -1; } - SMetaTableInfo mtInfo = getUidfromSnapShot(sContext); - tsdbReaderClose(pInfo->dataReader); - pInfo->dataReader = NULL; + } else { // subType == TOPIC_SUB_TYPE__TABLE/TOPIC_SUB_TYPE__DB - cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); - tableListClear(pTaskInfo->pTableInfoList); + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + SStreamRawScanInfo* pInfo = pOperator->info; + SSnapContext* sContext = pInfo->sContext; - if (mtInfo.uid == 0) { - return 0; // no data - } + SOperatorInfo* p = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, id); + STableListInfo* pTableListInfo = ((SStreamRawScanInfo*)(p->info))->pTableListInfo; - initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo); - pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setDataForSnapShot error. uid:%" PRId64" , %s", pOffset->uid, id); + return -1; + } - if (pTaskInfo->pTableInfoList == NULL) { - pTaskInfo->pTableInfoList = tableListCreate(); - } + SMetaTableInfo mtInfo = getUidfromSnapShot(sContext); + tsdbReaderClose(pInfo->dataReader); + pInfo->dataReader = NULL; - tableListAddTableInfo(pTaskInfo->pTableInfoList, mtInfo.uid, 0); + cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); + tableListClear(pTableListInfo); - STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0); - int32_t size = tableListGetSize(pTaskInfo->pTableInfoList); + if (mtInfo.uid == 0) { + goto end; // no data + } - tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL); + initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo); + pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts; - cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); - strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); - tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); - pTaskInfo->streamInfo.schema = mtInfo.schema; + tableListAddTableInfo(pTableListInfo, mtInfo.uid, 0); - qDebug("tmqsnap qStreamPrepareScan snapshot data uid:%" PRId64 " ts %" PRId64, mtInfo.uid, pOffset->ts); - } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { - SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if (setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version); - return -1; + STableKeyInfo* pList = tableListGetInfo(pTableListInfo, 0); + int32_t size = tableListGetSize(pTableListInfo); + + tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL, false); + + cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); + strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); + tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); + pTaskInfo->streamInfo.schema = mtInfo.schema; + + qDebug("tmqsnap qStreamPrepareScan snapshot data uid:%" PRId64 " ts %" PRId64" %s", mtInfo.uid, pOffset->ts, id); + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { + SStreamRawScanInfo* pInfo = pOperator->info; + SSnapContext* sContext = pInfo->sContext; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version); + return -1; + } + qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64 " %s", pOffset->uid, pOffset->ts, id); + } else if (pOffset->type == TMQ_OFFSET__LOG) { + SStreamRawScanInfo* pInfo = pOperator->info; + tsdbReaderClose(pInfo->dataReader); + pInfo->dataReader = NULL; + qDebug("tmqsnap qStreamPrepareScan snapshot log, %s", id); } - qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64, pOffset->uid, pOffset->ts); - } else if (pOffset->type == TMQ_OFFSET__LOG) { - SStreamRawScanInfo* pInfo = pOperator->info; - tsdbReaderClose(pInfo->dataReader); - pInfo->dataReader = NULL; - qDebug("tmqsnap qStreamPrepareScan snapshot log"); } + +end: + pTaskInfo->streamInfo.currentOffset = *pOffset; + return 0; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 24a26d575a0..11753c181c3 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -34,9 +34,7 @@ #include "ttypes.h" #include "vnode.h" -#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN) #define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN) - #define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP) #if 0 @@ -74,34 +72,21 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { #endif #define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st))) -#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0) - -typedef struct SAggOperatorInfo { - SOptrBasicInfo binfo; - SAggSupporter aggSup; - STableQueryInfo* current; - uint64_t groupId; - SGroupResInfo groupResInfo; - SExprSupp scalarExprSup; - bool groupKeyOptimized; -} SAggOperatorInfo; static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static void releaseQueryBuf(size_t numOfTables); -static void destroyAggOperatorInfo(void* param); static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); -static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, - const char* pKey); + static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status); static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol); static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo); +static SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); void setOperatorCompleted(SOperatorInfo* pOperator) { pOperator->status = OP_EXEC_DONE; @@ -266,57 +251,6 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR return pResult; } -// a new buffer page for each table. Needs to opt this design -static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) { - if (pWindowRes->pageId != -1) { - return 0; - } - - SFilePage* pData = NULL; - - // in the first scan, new space needed for results - int32_t pageId = -1; - SArray* list = getDataBufPagesIdList(pResultBuf); - - if (taosArrayGetSize(list) == 0) { - pData = getNewBufPage(pResultBuf, &pageId); - pData->num = sizeof(SFilePage); - } else { - SPageInfo* pi = getLastPageInfo(list); - pData = getBufPage(pResultBuf, getPageId(pi)); - if (pData == NULL) { - qError("failed to get buffer, code:%s", tstrerror(terrno)); - return terrno; - } - - pageId = getPageId(pi); - - if (pData->num + size > getBufPageSize(pResultBuf)) { - // release current page first, and prepare the next one - releaseBufPageInfo(pResultBuf, pi); - - pData = getNewBufPage(pResultBuf, &pageId); - if (pData != NULL) { - pData->num = sizeof(SFilePage); - } - } - } - - if (pData == NULL) { - return -1; - } - - // set the number of rows in current disk page - if (pWindowRes->pageId == -1) { // not allocated yet, allocate new buffer - pWindowRes->pageId = pageId; - pWindowRes->offset = (int32_t)pData->num; - - pData->num += size; - } - - return 0; -} - // query_range_start, query_range_end, window_duration, window_start, window_end void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow) { pColData->info.type = TSDB_DATA_TYPE_TIMESTAMP; @@ -332,72 +266,6 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow colDataSetInt64(pColData, 4, &pQueryWindow->ekey); } -typedef struct { - bool hasAgg; - int32_t numOfRows; - int32_t startOffset; -} SFunctionCtxStatus; - -static void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { - pStatus->hasAgg = pCtx->input.colDataSMAIsSet; - pStatus->numOfRows = pCtx->input.numOfRows; - pStatus->startOffset = pCtx->input.startRowIndex; -} - -static void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { - pCtx->input.colDataSMAIsSet = pStatus->hasAgg; - pCtx->input.numOfRows = pStatus->numOfRows; - pCtx->input.startRowIndex = pStatus->startOffset; -} - -void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, - int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput) { - for (int32_t k = 0; k < numOfOutput; ++k) { - // keep it temporarily - SFunctionCtxStatus status = {0}; - functionCtxSave(&pCtx[k], &status); - - pCtx[k].input.startRowIndex = offset; - pCtx[k].input.numOfRows = forwardStep; - - // not a whole block involved in query processing, statistics data can not be used - // NOTE: the original value of isSet have been changed here - if (pCtx[k].input.colDataSMAIsSet && forwardStep < numOfTotal) { - pCtx[k].input.colDataSMAIsSet = false; - } - - if (pCtx[k].isPseudoFunc) { - SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]); - - char* p = GET_ROWCELL_INTERBUF(pEntryInfo); - - SColumnInfoData idata = {0}; - idata.info.type = TSDB_DATA_TYPE_BIGINT; - idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; - idata.pData = p; - - SScalarParam out = {.columnData = &idata}; - SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData}; - pCtx[k].sfp.process(&tw, 1, &out); - pEntryInfo->numOfRes = 1; - } else { - int32_t code = TSDB_CODE_SUCCESS; - if (functionNeedToExecute(&pCtx[k]) && pCtx[k].fpSet.process != NULL) { - code = pCtx[k].fpSet.process(&pCtx[k]); - - if (code != TSDB_CODE_SUCCESS) { - qError("%s apply functions error, code: %s", GET_TASKID(taskInfo), tstrerror(code)); - taskInfo->code = code; - T_LONG_JMP(taskInfo->env, code); - } - } - - // restore it - functionCtxRestore(&pCtx[k], &status); - } - } -} - static void doSetInputDataBlockInfo(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) { SqlFunctionCtx* pCtx = pExprSup->pCtx; for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) { @@ -512,25 +380,6 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int return code; } -static int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx) { - for (int32_t k = 0; k < pOperator->exprSupp.numOfExprs; ++k) { - if (functionNeedToExecute(&pCtx[k])) { - // todo add a dummy funtion to avoid process check - if (pCtx[k].fpSet.process == NULL) { - continue; - } - - 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)); - return code; - } - } - } - - return TSDB_CODE_SUCCESS; -} - bool functionNeedToExecute(SqlFunctionCtx* pCtx) { struct SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); @@ -654,149 +503,6 @@ STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int return win; } -int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, - uint32_t* status) { - *status = BLK_DATA_NOT_LOAD; - - pBlock->pDataBlock = NULL; - pBlock->pBlockAgg = NULL; - - // int64_t groupId = pRuntimeEnv->current->groupIndex; - // bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); - - STaskCostInfo* pCost = &pTaskInfo->cost; - -// pCost->totalBlocks += 1; -// pCost->totalRows += pBlock->info.rows; -#if 0 - // Calculate all time windows that are overlapping or contain current data block. - // If current data block is contained by all possible time window, do not load current data block. - if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 || - (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) { - (*status) = BLK_DATA_DATA_LOAD; - } - - // check if this data block is required to load - if ((*status) != BLK_DATA_DATA_LOAD) { - bool needFilter = true; - - // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, - // the filter result may be incorrect. So in case of interval query, we need to set the correct time output buffer - if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { - SResultRow* pResult = NULL; - - bool masterScan = IS_MAIN_SCAN(pRuntimeEnv); - TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; - - STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (pQueryAttr->pointInterpQuery) { - needFilter = chkWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset); - } else { - if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); - } - } - } else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery)) { // stable aggregate, not interval aggregate or normal column aggregate - doSetTableGroupOutputBuf(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pTableScanInfo->pCtx, - pTableScanInfo->rowEntryInfoOffset, pTableScanInfo->numOfOutput, - pRuntimeEnv->current->groupIndex); - } - - if (needFilter) { - (*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock); - } else { - (*status) = BLK_DATA_DATA_LOAD; - } - } - - SDataBlockInfo* pBlockInfo = &pBlock->info; -// *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status); - - if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) { - //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, -// pBlockInfo->window.ekey, pBlockInfo->rows); - pCost->skipBlocks += 1; - } else if ((*status) == BLK_DATA_SMA_LOAD) { - // this function never returns error? - pCost->loadBlockStatis += 1; -// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); - - if (pBlock->pBlockAgg == NULL) { // data block statistics does not exist, load data block -// pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); - pCost->totalCheckedRows += pBlock->info.rows; - } - } else { - assert((*status) == BLK_DATA_DATA_LOAD); - - // load the data block statistics to perform further filter - pCost->loadBlockStatis += 1; -// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); - - if (pQueryAttr->topBotQuery && pBlock->pBlockAgg != NULL) { - { // set previous window - if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { - SResultRow* pResult = NULL; - - bool masterScan = IS_MAIN_SCAN(pRuntimeEnv); - TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; - - STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); - } - } - } - bool load = false; - for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { - int32_t functionId = pTableScanInfo->pCtx[i].functionId; - if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM) { -// load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockAgg[i].min), -// (char*)&(pBlock->pBlockAgg[i].max)); - if (!load) { // current block has been discard due to filter applied - pCost->skipBlocks += 1; - //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, -// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - (*status) = BLK_DATA_FILTEROUT; - return TSDB_CODE_SUCCESS; - } - } - } - } - - // current block has been discard due to filter applied -// if (!doFilterByBlockSMA(pRuntimeEnv, pBlock->pBlockAgg, pTableScanInfo->pCtx, pBlockInfo->rows)) { -// pCost->skipBlocks += 1; -// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, -// pBlockInfo->window.ekey, pBlockInfo->rows); -// (*status) = BLK_DATA_FILTEROUT; -// return TSDB_CODE_SUCCESS; -// } - - pCost->totalCheckedRows += pBlockInfo->rows; - pCost->loadBlocks += 1; -// pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); -// if (pBlock->pDataBlock == NULL) { -// return terrno; -// } - -// if (pQueryAttr->pFilters != NULL) { -// filterSetColFieldData(pQueryAttr->pFilters, taosArrayGetSize(pBlock->pDataBlock), pBlock->pDataBlock); -// } - -// if (pQueryAttr->pFilters != NULL || pRuntimeEnv->pTsBuf != NULL) { -// filterColRowsInDataBlock(pRuntimeEnv, pBlock, ascQuery); -// } - } -#endif - return TSDB_CODE_SUCCESS; -} - void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status) { if (status == TASK_NOT_COMPLETED) { pTaskInfo->status = status; @@ -1027,43 +733,6 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD } } -void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { - // for simple group by query without interval, all the tables belong to one group result. - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SAggOperatorInfo* pAggInfo = pOperator->info; - - SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; - SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - int32_t* rowEntryInfoOffset = pOperator->exprSupp.rowEntryInfoOffset; - - SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, (char*)&groupId, - sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup, true); - /* - * not assign result buffer yet, add new result buffer - * all group belong to one result set, and each group result has different group id so set the id to be one - */ - if (pResultRow->pageId == -1) { - int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); - if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, terrno); - } - } - - setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset); -} - -static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { - SAggOperatorInfo* pAggInfo = pOperator->info; - if (pAggInfo->groupId != UINT64_MAX && pAggInfo->groupId == groupId) { - return; - } - - doSetTableGroupOutputBuf(pOperator, numOfOutput, groupId); - - // record the current active group id - pAggInfo->groupId = groupId; -} - void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) { bool returnNotNull = false; for (int32_t j = 0; j < numOfExprs; ++j) { @@ -1201,7 +870,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { blockDataEnsureCapacity(pBlock, pBlock->info.rows + pRow->numOfRows); - qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", + qDebug("datablock capacity not sufficient, expand to required:%" PRId64 ", current capacity:%d, %s", (pRow->numOfRows+pBlock->info.rows), pBlock->info.capacity, GET_TASKID(pTaskInfo)); // todo set the pOperator->resultInfo size @@ -1214,7 +883,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS pBlock->info.rows += pRow->numOfRows; } - qDebug("%s result generated, rows:%d, groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, + qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, pBlock->info.id.groupId); pBlock->info.dataLoad = 1; blockDataUpdateTsWindow(pBlock, 0); @@ -1281,161 +950,6 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG } } -// static TSKEY doSkipIntervalProcess(STaskRuntimeEnv* pRuntimeEnv, STimeWindow* win, SDataBlockInfo* pBlockInfo, -// STableQueryInfo* pTableQueryInfo) { -// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; -// SResultRowInfo *pWindowResInfo = &pRuntimeEnv->resultRowInfo; -// -// STimeWindow tw = *win; -// getNextTimeWindow(pQueryAttr, &tw); -// -// if ((tw.skey <= pBlockInfo->window.ekey && QUERY_IS_ASC_QUERY(pQueryAttr)) || -// (tw.ekey >= pBlockInfo->window.skey && !QUERY_IS_ASC_QUERY(pQueryAttr))) { -// -// // load the data block and check data remaining in current data block -// // TODO optimize performance -// SArray * pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pTsdbReadHandle, NULL); -// SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); -// -// tw = *win; -// int32_t startPos = -// getNextQualifiedWindow(pQueryAttr, &tw, pBlockInfo, pColInfoData->pData, binarySearchForKey, -1); -// -// // set the abort info -// pQueryAttr->pos = startPos; -// -// // reset the query start timestamp -// pTableQueryInfo->win.skey = ((TSKEY *)pColInfoData->pData)[startPos]; -// pQueryAttr->window.skey = pTableQueryInfo->win.skey; -// TSKEY key = pTableQueryInfo->win.skey; -// -// pWindowResInfo->prevSKey = tw.skey; -// int32_t index = pRuntimeEnv->resultRowInfo.curIndex; -// -// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock); -// pRuntimeEnv->resultRowInfo.curIndex = index; // restore the window index -// -// //qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, -// lastKey:%" PRId64, -// GET_TASKID(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, -// pQueryAttr->current->lastKey); -// -// return key; -// } else { // do nothing -// pQueryAttr->window.skey = tw.skey; -// pWindowResInfo->prevSKey = tw.skey; -// pTableQueryInfo->lastKey = tw.skey; -// -// return tw.skey; -// } -// -// return true; -// } - -// static bool skipTimeInterval(STaskRuntimeEnv *pRuntimeEnv, TSKEY* start) { -// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; -// -// // if queried with value filter, do NOT forward query start position -// if (pQueryAttr->limit.offset <= 0 || pQueryAttr->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL || -// pRuntimeEnv->pFillInfo != NULL) { -// return true; -// } -// -// /* -// * 1. for interval without interpolation query we forward pQueryAttr->interval.interval at a time for -// * pQueryAttr->limit.offset times. Since hole exists, pQueryAttr->interval.interval*pQueryAttr->limit.offset -// value is -// * not valid. otherwise, we only forward pQueryAttr->limit.offset number of points -// */ -// STimeWindow w = TSWINDOW_INITIALIZER; -// bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); -// -// SResultRowInfo *pWindowResInfo = &pRuntimeEnv->resultRowInfo; -// STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current; -// -// SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; -// while (tsdbNextDataBlock(pRuntimeEnv->pTsdbReadHandle)) { -// tsdbRetrieveDataBlockInfo(pRuntimeEnv->pTsdbReadHandle, &blockInfo); -// -// if (QUERY_IS_ASC_QUERY(pQueryAttr)) { -// if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) { -// getAlignQueryTimeWindow(pQueryAttr, blockInfo.window.skey, blockInfo.window.skey, pQueryAttr->window.ekey, -// &w); pWindowResInfo->prevSKey = w.skey; -// } -// } else { -// getAlignQueryTimeWindow(pQueryAttr, blockInfo.window.ekey, pQueryAttr->window.ekey, blockInfo.window.ekey, &w); -// pWindowResInfo->prevSKey = w.skey; -// } -// -// // the first time window -// STimeWindow win = getActiveTimeWindow(pWindowResInfo, pWindowResInfo->prevSKey, pQueryAttr); -// -// while (pQueryAttr->limit.offset > 0) { -// STimeWindow tw = win; -// -// if ((win.ekey <= blockInfo.window.ekey && ascQuery) || (win.ekey >= blockInfo.window.skey && !ascQuery)) { -// pQueryAttr->limit.offset -= 1; -// pWindowResInfo->prevSKey = win.skey; -// -// // current time window is aligned with blockInfo.window.ekey -// // restart it from next data block by set prevSKey to be TSKEY_INITIAL_VAL; -// if ((win.ekey == blockInfo.window.ekey && ascQuery) || (win.ekey == blockInfo.window.skey && !ascQuery)) { -// pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL; -// } -// } -// -// if (pQueryAttr->limit.offset == 0) { -// *start = doSkipIntervalProcess(pRuntimeEnv, &win, &blockInfo, pTableQueryInfo); -// return true; -// } -// -// // current window does not ended in current data block, try next data block -// getNextTimeWindow(pQueryAttr, &tw); -// -// /* -// * If the next time window still starts from current data block, -// * load the primary timestamp column first, and then find the start position for the next queried time window. -// * Note that only the primary timestamp column is required. -// * TODO: Optimize for this cases. All data blocks are not needed to be loaded, only if the first actually -// required -// * time window resides in current data block. -// */ -// if ((tw.skey <= blockInfo.window.ekey && ascQuery) || (tw.ekey >= blockInfo.window.skey && !ascQuery)) { -// -// SArray *pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pTsdbReadHandle, NULL); -// SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); -// -// if ((win.ekey > blockInfo.window.ekey && ascQuery) || (win.ekey < blockInfo.window.skey && !ascQuery)) { -// pQueryAttr->limit.offset -= 1; -// } -// -// if (pQueryAttr->limit.offset == 0) { -// *start = doSkipIntervalProcess(pRuntimeEnv, &win, &blockInfo, pTableQueryInfo); -// return true; -// } else { -// tw = win; -// int32_t startPos = -// getNextQualifiedWindow(pQueryAttr, &tw, &blockInfo, pColInfoData->pData, binarySearchForKey, -1); -// // set the abort info -// pQueryAttr->pos = startPos; -// pTableQueryInfo->lastKey = ((TSKEY *)pColInfoData->pData)[startPos]; -// pWindowResInfo->prevSKey = tw.skey; -// win = tw; -// } -// } else { -// break; // offset is not 0, and next time window begins or ends in the next block. -// } -// } -// } -// -// // check for error -// if (terrno != TSDB_CODE_SUCCESS) { -// T_LONG_JMP(pRuntimeEnv->env, terrno); -// } -// -// return true; -// } - int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num) { p->pDownstream = taosMemoryCalloc(1, num * POINTER_BYTES); if (p->pDownstream == NULL) { @@ -1481,191 +995,23 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } -static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { - if (!tsCountAlwaysReturnValue) { - return TSDB_CODE_SUCCESS; - } - - SAggOperatorInfo* pAggInfo = pOperator->info; - if (pAggInfo->groupKeyOptimized) { - return TSDB_CODE_SUCCESS; - } - - SOperatorInfo* downstream = pOperator->pDownstream[0]; - if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || - (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && - ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { - return TSDB_CODE_SUCCESS; - } - - SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - bool hasCountFunc = false; - - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; - if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || - (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { - hasCountFunc = true; - break; - } - } - - if (!hasCountFunc) { - return TSDB_CODE_SUCCESS; - } - - SSDataBlock* pBlock = createDataBlock(); - pBlock->info.rows = 1; - pBlock->info.capacity = 0; - - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - SColumnInfoData colInfo = {0}; - colInfo.hasNull = true; - colInfo.info.type = TSDB_DATA_TYPE_NULL; - colInfo.info.bytes = 1; - - SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i]; - for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { - SFunctParam* pFuncParam = &pOneExpr->base.pParam[j]; - if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { - int32_t slotId = pFuncParam->pCol->slotId; - int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - if (slotId >= numOfCols) { - taosArrayEnsureCap(pBlock->pDataBlock, slotId + 1); - for (int32_t k = numOfCols; k < slotId + 1; ++k) { - taosArrayPush(pBlock->pDataBlock, &colInfo); - } - } - } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { - // do nothing - } - } - } - - blockDataEnsureCapacity(pBlock, pBlock->info.rows); - *ppBlock = pBlock; - - return TSDB_CODE_SUCCESS; -} - -static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { - if (!blockAllocated) { - return; - } - - blockDataDestroy(*ppBlock); - *ppBlock = NULL; -} - -// this is a blocking operator -static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { - if (OPTR_IS_OPENED(pOperator)) { - return TSDB_CODE_SUCCESS; - } - - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SAggOperatorInfo* pAggInfo = pOperator->info; - - SExprSupp* pSup = &pOperator->exprSupp; - SOperatorInfo* downstream = pOperator->pDownstream[0]; - - int64_t st = taosGetTimestampUs(); - - int32_t order = TSDB_ORDER_ASC; - int32_t scanFlag = MAIN_SCAN; - - bool hasValidBlock = false; - bool blockAllocated = false; - - while (1) { - SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); - if (pBlock == NULL) { - if (!hasValidBlock) { - createDataBlockForEmptyInput(pOperator, &pBlock); - if (pBlock == NULL) { - break; - } - blockAllocated = true; - } else { - break; - } - } - hasValidBlock = true; - - int32_t code = getTableScanInfo(pOperator, &order, &scanFlag, false); - if (code != TSDB_CODE_SUCCESS) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - - // there is an scalar expression that needs to be calculated before apply the group aggregation. - if (pAggInfo->scalarExprSup.pExprInfo != NULL && !blockAllocated) { - SExprSupp* pSup1 = &pAggInfo->scalarExprSup; - code = projectApplyFunctions(pSup1->pExprInfo, pBlock, pBlock, pSup1->pCtx, pSup1->numOfExprs, NULL); - if (code != TSDB_CODE_SUCCESS) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - } - - // the pDataBlock are always the same one, no need to call this again - setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.id.groupId); - setInputDataBlock(pSup, pBlock, order, scanFlag, true); - code = doAggregateImpl(pOperator, pSup->pCtx); - if (code != 0) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - } - - // the downstream operator may return with error code, so let's check the code before generating results. - if (pTaskInfo->code != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); - } - - initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0); - OPTR_SET_OPENED(pOperator); - - pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; - return pTaskInfo->code; -} - -static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) { - SAggOperatorInfo* pAggInfo = pOperator->info; - SOptrBasicInfo* pInfo = &pAggInfo->binfo; - - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - pTaskInfo->code = pOperator->fpSet._openFn(pOperator); - if (pTaskInfo->code != TSDB_CODE_SUCCESS) { - setOperatorCompleted(pOperator); +//QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN +SOperatorInfo* extractOperatorInTree(SOperatorInfo* pOperator, int32_t type, const char* id) { + if (pOperator == NULL) { + qError("invalid operator, failed to find tableScanOperator %s", id); return NULL; } - blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); - while (1) { - doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); - doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL); - - if (!hasRemainResults(&pAggInfo->groupResInfo)) { - setOperatorCompleted(pOperator); - break; + if (pOperator->operatorType == type) { + return pOperator; + } else { + if (pOperator->pDownstream == NULL || pOperator->pDownstream[0] == NULL) { + qError("invalid operator, failed to find tableScanOperator %s", id); + return NULL; } - if (pInfo->pRes->info.rows > 0) { - break; - } + return extractOperatorInTree(pOperator->pDownstream[0], type, id); } - - size_t rows = blockDataGetNumOfRows(pInfo->pRes); - pOperator->resultInfo.totalRows += rows; - - return (rows == 0) ? NULL : pInfo->pRes; } void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) { @@ -1732,70 +1078,6 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul return 0; } -int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, - const char* pKey) { - int32_t code = 0; - // _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - - pAggSup->currentPageId = -1; - pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); - pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); - pAggSup->pResultRowHashTable = tSimpleHashInit(100, taosFastHash); - - if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - uint32_t defaultPgsz = 0; - uint32_t defaultBufsz = 0; - getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); - - if (!osTempSpaceAvailable()) { - code = TSDB_CODE_NO_AVAIL_DISK; - qError("Init stream agg supporter failed since %s, %s", terrstr(code), pKey); - return code; - } - - code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, tsTempDir); - if (code != TSDB_CODE_SUCCESS) { - qError("Create agg result buf failed since %s, %s", tstrerror(code), pKey); - return code; - } - - return code; -} - -void cleanupAggSup(SAggSupporter* pAggSup) { - taosMemoryFreeClear(pAggSup->keyBuf); - tSimpleHashCleanup(pAggSup->pResultRowHashTable); - destroyDiskbasedBuf(pAggSup->pResultBuf); -} - -int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey, void* pState) { - int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doInitAggInfoSup(pAggSup, pSup->pCtx, numOfCols, keyBufSize, pkey); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - for (int32_t i = 0; i < numOfCols; ++i) { - if (pState) { - pSup->pCtx[i].saveHandle.pBuf = NULL; - pSup->pCtx[i].saveHandle.pState = pState; - pSup->pCtx[i].exprIdx = i; - } else { - pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; - } - } - - return TSDB_CODE_SUCCESS; -} - void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows) { if (numOfRows == 0) { numOfRows = 4096; @@ -1814,7 +1096,7 @@ void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock) { initResultRowInfo(&pInfo->resultRowInfo); } -void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { +static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { if (pCtx == NULL) { return NULL; } @@ -1866,99 +1148,8 @@ void cleanupExprSupp(SExprSupp* pSupp) { taosMemoryFree(pSupp->rowEntryInfoOffset); } -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, - SExecTaskInfo* pTaskInfo) { - SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL) { - goto _error; - } - - SSDataBlock* pResBlock = createDataBlockFromDescNode(pAggNode->node.pOutputDataBlockDesc); - initBasicInfo(&pInfo->binfo, pResBlock); - - size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - initResultSizeInfo(&pOperator->resultInfo, 4096); - - int32_t num = 0; - SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, - pTaskInfo->streamInfo.pState); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - int32_t numOfScalarExpr = 0; - SExprInfo* pScalarExprInfo = NULL; - if (pAggNode->pExprs != NULL) { - pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); - } - - code = initExprSupp(&pInfo->scalarExprSup, pScalarExprInfo, numOfScalarExpr); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - code = filterInitFromNode((SNode*)pAggNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; - pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; - pInfo->groupId = UINT64_MAX; - - setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, - pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, - optrDefaultBufFn, NULL); - - if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { - STableScanInfo* pTableScanInfo = downstream->info; - pTableScanInfo->base.pdInfo.pExprSup = &pOperator->exprSupp; - pTableScanInfo->base.pdInfo.pAggSup = &pInfo->aggSup; - } - - code = appendDownstream(pOperator, &downstream, 1); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - return pOperator; - -_error: - if (pInfo != NULL) { - destroyAggOperatorInfo(pInfo); - } - - if (pOperator != NULL) { - cleanupExprSupp(&pOperator->exprSupp); - } - - taosMemoryFreeClear(pOperator); - pTaskInfo->code = code; - return NULL; -} - void cleanupBasicInfo(SOptrBasicInfo* pInfo) { pInfo->pRes = blockDataDestroy(pInfo->pRes); } -static void freeItem(void* pItem) { - void** p = pItem; - if (*p != NULL) { - taosMemoryFreeClear(*p); - } -} - -void destroyAggOperatorInfo(void* param) { - SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param; - cleanupBasicInfo(&pInfo->binfo); - - cleanupAggSup(&pInfo->aggSup); - cleanupExprSupp(&pInfo->scalarExprSup); - cleanupGroupResInfo(&pInfo->groupResInfo); - taosMemoryFreeClear(param); -} - char* buildTaskId(uint64_t taskId, uint64_t queryId) { char* p = taosMemoryMalloc(64); @@ -1974,7 +1165,7 @@ char* buildTaskId(uint64_t taskId, uint64_t queryId) { return p; } -static SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, char* dbFName) { +SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, char* dbFName) { SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); if (pTaskInfo == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -1982,21 +1173,20 @@ static SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, in } setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); + pTaskInfo->cost.created = taosGetTimestampUs(); pTaskInfo->schemaInfo.dbname = taosStrdup(dbFName); pTaskInfo->execModel = model; - pTaskInfo->pTableInfoList = tableListCreate(); pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo)); pTaskInfo->pResultBlockList = taosArrayInit(128, POINTER_BYTES); + taosInitRWLatch(&pTaskInfo->lock); pTaskInfo->id.vgId = vgId; pTaskInfo->id.queryId = queryId; pTaskInfo->id.str = buildTaskId(taskId, queryId); return pTaskInfo; } -SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); - int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) { SMetaReader mr = {0}; metaReaderInit(&mr, pHandle->meta, 0); @@ -2099,7 +1289,6 @@ bool groupbyTbname(SNodeList* pGroupList) { SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, SNode* pTagCond, SNode* pTagIndexCond, const char* pUser) { int32_t type = nodeType(pPhyNode); - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; const char* idstr = GET_TASKID(pTaskInfo); if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { @@ -2113,11 +1302,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTableScanNode->groupSort = true; } + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code:%s, %s", tstrerror(code), idstr); return NULL; } @@ -2125,10 +1316,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } - pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); if (NULL == pOperator) { pTaskInfo->code = terrno; return NULL; @@ -2138,11 +1330,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTaskInfo->cost.pRecoder = &pScanInfo->base.readRecorder; } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, true, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code: %s", tstrerror(code)); return NULL; } @@ -2150,12 +1344,14 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } - pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); if (NULL == pOperator) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } @@ -2166,29 +1362,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); + if (pHandle->vnode) { int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code: %s", tstrerror(code)); return NULL; } - -#ifndef NDEBUG - int32_t sz = tableListGetSize(pTableListInfo); - qDebug("vgId:%d create stream task, total qualified tables:%d, %s", pTaskInfo->id.vgId, sz, idstr); - - for (int32_t i = 0; i < sz; i++) { - STableKeyInfo* pKeyInfo = tableListGetInfo(pTableListInfo, i); - qDebug("add table uid:%" PRIu64 ", gid:%" PRIu64, pKeyInfo->uid, pKeyInfo->groupId); - } -#endif } pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); - pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); + pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; pOperator = createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pUser, pTaskInfo); @@ -2197,7 +1386,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOperator = createTableCountScanOperatorInfo(pHandle, pTblCountScanNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) { STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode; - + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(pScanPhyNode, NULL, false, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code != TSDB_CODE_SUCCESS) { @@ -2206,9 +1395,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - pOperator = createTagScanOperatorInfo(pHandle, pScanPhyNode, pTaskInfo); + pOperator = createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) { SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); if (pBlockNode->tableType == TSDB_SUPER_TABLE) { SArray* pList = taosArrayInit(4, sizeof(STableKeyInfo)); @@ -2229,9 +1419,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo tableListAddTableInfo(pTableListInfo, pBlockNode->uid, 0); } - pOperator = createDataBlockInfoScanOperator(pHandle, pBlockNode, pTaskInfo); + pOperator = createDataBlockInfoScanOperator(pHandle, pBlockNode, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN == type) { SLastRowScanPhysiNode* pScanNode = (SLastRowScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(&pScanNode->scan, pScanNode->pGroupTags, true, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); @@ -2246,7 +1437,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - pOperator = createCacherowsScanOperator(pScanNode, pHandle, pTaskInfo); + pOperator = createCacherowsScanOperator(pScanNode, pHandle, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) { pOperator = createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pPhyNode, pTaskInfo); } else { @@ -2254,7 +1445,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - if (pOperator != NULL) { + if (pOperator != NULL) { // todo moved away pOperator->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId; } @@ -2395,9 +1586,7 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { return -1; } -int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) { - SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo; - +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* pTask, SReadHandle* readHandle) { switch (pNode->type) { case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: { SInserterParam* pInserterParam = taosMemoryCalloc(1, sizeof(SInserterParam)); @@ -2414,18 +1603,23 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pT if (NULL == pDeleterParam) { return TSDB_CODE_OUT_OF_MEMORY; } - int32_t tbNum = tableListGetSize(pTask->pTableInfoList); - pDeleterParam->suid = tableListGetSuid(pTask->pTableInfoList); + + SArray* pInfoList = getTableListInfo(pTask); + STableListInfo* pTableListInfo = taosArrayGetP(pInfoList, 0); + taosArrayDestroy(pInfoList); + + pDeleterParam->suid = tableListGetSuid(pTableListInfo); // TODO extract uid list - pDeleterParam->pUidList = taosArrayInit(tbNum, sizeof(uint64_t)); + int32_t numOfTables = tableListGetSize(pTableListInfo); + pDeleterParam->pUidList = taosArrayInit(numOfTables, sizeof(uint64_t)); if (NULL == pDeleterParam->pUidList) { taosMemoryFree(pDeleterParam); return TSDB_CODE_OUT_OF_MEMORY; } - for (int32_t i = 0; i < tbNum; ++i) { - STableKeyInfo* pTable = tableListGetInfo(pTask->pTableInfoList, i); + for (int32_t i = 0; i < numOfTables; ++i) { + STableKeyInfo* pTable = tableListGetInfo(pTableListInfo, i); taosArrayPush(pDeleterParam->pUidList, &pTable->uid); } @@ -2464,7 +1658,6 @@ int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHand goto _complete; } - (*pTaskInfo)->cost.created = taosGetTimestampUs(); return TSDB_CODE_SUCCESS; _complete: @@ -2480,8 +1673,6 @@ static void freeBlock(void* pParam) { void doDestroyTask(SExecTaskInfo* pTaskInfo) { qDebug("%s execTask is freed", GET_TASKID(pTaskInfo)); - - pTaskInfo->pTableInfoList = tableListDestroy(pTaskInfo->pTableInfoList); destroyOperatorInfo(pTaskInfo->pRoot); cleanupTableSchemaInfo(&pTaskInfo->schemaInfo); cleanupStreamInfo(&pTaskInfo->streamInfo); @@ -2779,11 +1970,11 @@ void qStreamCloseTsdbReader(void* task) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)task; SOperatorInfo* pOp = pTaskInfo->pRoot; - qDebug("stream close tsdb reader, reset status uid:%" PRId64 " ts:%" PRId64, pTaskInfo->streamInfo.lastStatus.uid, - pTaskInfo->streamInfo.lastStatus.ts); + qDebug("stream close tsdb reader, reset status uid:%" PRId64 " ts:%" PRId64, pTaskInfo->streamInfo.currentOffset.uid, + pTaskInfo->streamInfo.currentOffset.ts); // todo refactor, other thread may already use this read to extract data. - pTaskInfo->streamInfo.lastStatus = (STqOffsetVal){0}; + pTaskInfo->streamInfo.currentOffset = (STqOffsetVal){0}; while (pOp->numOfDownstream == 1 && pOp->pDownstream[0]) { SOperatorInfo* pDownstreamOp = pOp->pDownstream[0]; if (pDownstreamOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { @@ -2808,3 +1999,21 @@ void qStreamCloseTsdbReader(void* task) { } } } + +static void extractTableList(SArray* pList, const SOperatorInfo* pOperator) { + if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + STableScanInfo* pScanInfo = pOperator->info; + taosArrayPush(pList, &pScanInfo->base.pTableListInfo); + } else { + if (pOperator->pDownstream != NULL && pOperator->pDownstream[0] != NULL) { + extractTableList(pList, pOperator->pDownstream[0]); + } + } +} + +SArray* getTableListInfo(const SExecTaskInfo* pTaskInfo) { + SArray* pArray = taosArrayInit(0, POINTER_BYTES); + SOperatorInfo* pOperator = pTaskInfo->pRoot; + extractTableList(pArray, pOperator); + return pArray; +} \ No newline at end of file diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 4e2e105d145..86c49e0fc82 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -227,17 +227,8 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { blockDataCleanup(pFinalRes); SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - if (pTaskInfo->streamInfo.submit.msgStr) { - pOperator->status = OP_OPENED; - } if (pOperator->status == OP_EXEC_DONE) { - if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { - pOperator->status = OP_OPENED; - qDebug("projection in queue model, set status open and return null"); - return NULL; - } - return NULL; } @@ -263,23 +254,14 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // The downstream exec may change the value of the newgroup, so use a local variable instead. SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { - if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE && pFinalRes->info.rows == 0) { - pOperator->status = OP_OPENED; - if (pOperator->status == OP_EXEC_RECV) { - continue; - } else { - return NULL; - } - } - qDebug("set op close, exec %d, status %d rows %d", pTaskInfo->execModel, pOperator->status, - pFinalRes->info.rows); + qDebug("set op close, exec %d, status %d rows %" PRId64 , pTaskInfo->execModel, pOperator->status, pFinalRes->info.rows); setOperatorCompleted(pOperator); break; } - if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { - qDebug("set status recv"); - pOperator->status = OP_EXEC_RECV; - } +// if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { +// qDebug("set status recv"); +// pOperator->status = OP_EXEC_RECV; +// } // for stream interval if (pBlock->info.type == STREAM_RETRIEVE || pBlock->info.type == STREAM_DELETE_RESULT || @@ -337,7 +319,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // when apply the limit/offset for each group, pRes->info.rows may be 0, due to limit constraint. if (pFinalRes->info.rows > 0 || (pOperator->status == OP_EXEC_DONE)) { - qDebug("project return %d rows, status %d", pFinalRes->info.rows, pOperator->status); + qDebug("project return %" PRId64 " rows, status %d", pFinalRes->info.rows, pOperator->status); break; } } else { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 5dff1abb979..29990f2d069 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -31,6 +31,8 @@ #include "thash.h" #include "ttypes.h" +int32_t scanDebug = 0; + #define MULTI_READER_MAX_TABLE_NUM 5000 #define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN) #define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC)) @@ -49,6 +51,16 @@ typedef struct STableMergeScanSortSourceParam { STsdbReader* dataReader; } STableMergeScanSortSourceParam; +typedef struct STableCountScanOperatorInfo { + SReadHandle readHandle; + SSDataBlock* pRes; + + STableCountScanSupp supp; + + int32_t currGrpIdx; + SArray* stbUidList; // when group by db_name and/or stable_name +} STableCountScanOperatorInfo; + static bool processBlockWithProbability(const SSampleExecInfo* pInfo); bool processBlockWithProbability(const SSampleExecInfo* pInfo) { @@ -308,14 +320,14 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca taosMemoryFreeClear(pBlock->pBlockAgg); if (*status == FUNC_DATA_REQUIRED_FILTEROUT) { - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 , GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->filterOutBlocks += 1; pCost->totalRows += pBlock->info.rows; tsdbReleaseDataBlock(pTableScanInfo->dataReader); return TSDB_CODE_SUCCESS; } else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { - qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d, uid:%" PRIu64, GET_TASKID(pTaskInfo), + qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 ", uid:%" PRIu64, GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, pBlockInfo->id.uid); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1); pCost->skipBlocks += 1; @@ -326,7 +338,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca loadSMA = true; // mark the operation of load sma; bool success = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo); if (success) { // failed to load the block sma data, data block statistics does not exist, load data block instead - qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 , GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1); tsdbReleaseDataBlock(pTableScanInfo->dataReader); @@ -346,7 +358,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca size_t size = taosArrayGetSize(pBlock->pDataBlock); bool keep = doFilterByBlockSMA(pOperator->exprSupp.pFilterInfo, pBlock->pBlockAgg, size, pBlockInfo->rows); if (!keep) { - qDebug("%s data block filter out by block SMA, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block filter out by block SMA, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 , GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->filterOutBlocks += 1; (*status) = FUNC_DATA_REQUIRED_FILTEROUT; @@ -363,7 +375,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca // try to filter data block according to current results doDynamicPruneDataBlock(pOperator, pBlockInfo, status); if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { - qDebug("%s data block skipped due to dynamic prune, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block skipped due to dynamic prune, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 , GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->skipBlocks += 1; tsdbReleaseDataBlock(pTableScanInfo->dataReader); @@ -394,7 +406,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca if (pBlock->info.rows == 0) { pCost->filterOutBlocks += 1; - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%.2f ms", + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 ", elapsed time:%.2f ms", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, el); } else { qDebug("%s data block filter applied, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), el); @@ -584,10 +596,16 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int if (isNullVal) { colDataSetNNULL(pColInfoData, 0, pBlock->info.rows); } else if (pColInfoData->info.type != TSDB_DATA_TYPE_JSON) { - colDataSetNItems(pColInfoData, 0, data, pBlock->info.rows); + code = colDataSetNItems(pColInfoData, 0, data, pBlock->info.rows, false); if (IS_VAR_DATA_TYPE(((const STagVal*)p)->type)) { taosMemoryFree(data); } + if (code) { + if (freeReader) { + metaReaderClear(&mr); + } + return code; + } } else { // todo opt for json tag for (int32_t i = 0; i < pBlock->info.rows; ++i) { colDataSetVal(pColInfoData, i, data, false); @@ -634,10 +652,22 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { STableScanInfo* pTableScanInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSDataBlock* pBlock = pTableScanInfo->pResBlock; + bool hasNext = false; + int32_t code = TSDB_CODE_SUCCESS; int64_t st = taosGetTimestampUs(); - while (tsdbNextDataBlock(pTableScanInfo->base.dataReader)) { + while (true) { + code = tsdbNextDataBlock(pTableScanInfo->base.dataReader, &hasNext); + if (code) { + tsdbReleaseDataBlock(pTableScanInfo->base.dataReader); + T_LONG_JMP(pTaskInfo->env, code); + } + + if (!hasNext) { + break; + } + if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(pTableScanInfo->base.dataReader); T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); @@ -654,9 +684,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { continue; } - ASSERT(pBlock->info.id.uid != 0); - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); - + if (pBlock->info.id.uid) { + pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); + } + uint32_t status = 0; int32_t code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { @@ -676,11 +707,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { // todo refactor /*pTableScanInfo->lastStatus.uid = pBlock->info.id.uid;*/ /*pTableScanInfo->lastStatus.ts = pBlock->info.window.ekey;*/ - pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA; - pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.id.uid; - pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey; +// pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA; +// pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.id.uid; +// pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey; - ASSERT(pBlock->info.id.uid != 0); return pBlock; } return NULL; @@ -750,42 +780,51 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { // scan table one by one sequentially if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) { - int32_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); + int32_t numOfTables = 0;//tableListGetSize(pTaskInfo->pTableListInfo); + STableKeyInfo tInfo = {0}; while (1) { SSDataBlock* result = doGroupedTableScan(pOperator); - if (result || (pOperator->status == OP_EXEC_DONE)) { + if (result || (pOperator->status == OP_EXEC_DONE) || isTaskKilled(pTaskInfo)) { return result; } // if no data, switch to next table and continue scan pInfo->currentTable++; + + taosRLockLatch(&pTaskInfo->lock); + numOfTables = tableListGetSize(pInfo->base.pTableListInfo); + if (pInfo->currentTable >= numOfTables) { + qDebug("all table checked in table list, total:%d, return NULL, %s", numOfTables, GET_TASKID(pTaskInfo)); + taosRUnLockLatch(&pTaskInfo->lock); return NULL; } - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->currentTable); - tsdbSetTableList(pInfo->base.dataReader, pTableInfo, 1); - qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables, - pInfo->currentTable, pTaskInfo->id.str); + tInfo = *(STableKeyInfo*) tableListGetInfo(pInfo->base.pTableListInfo, pInfo->currentTable); + taosRUnLockLatch(&pTaskInfo->lock); + + tsdbSetTableList(pInfo->base.dataReader, &tInfo, 1); + qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d/%d %s", tInfo.uid, numOfTables, + pInfo->currentTable, numOfTables, GET_TASKID(pTaskInfo)); tsdbReaderReset(pInfo->base.dataReader, &pInfo->base.cond); pInfo->scanTimes = 0; } } else { // scan table group by group sequentially if (pInfo->currentGroupId == -1) { - if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) { + if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) { setOperatorCompleted(pOperator); return NULL; } int32_t num = 0; STableKeyInfo* pList = NULL; - tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num); + tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, &pList, &num); ASSERT(pInfo->base.dataReader == NULL); int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock, - (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo)); + (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), pInfo->countOnly); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -797,11 +836,10 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { SSDataBlock* result = doGroupedTableScan(pOperator); if (result != NULL) { - ASSERT(result->info.id.uid != 0); return result; } - if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) { + if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) { setOperatorCompleted(pOperator); return NULL; } @@ -812,7 +850,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { int32_t num = 0; STableKeyInfo* pList = NULL; - tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num); + tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, &pList, &num); tsdbSetTableList(pInfo->base.dataReader, pList, num); tsdbReaderReset(pInfo->base.dataReader, &pInfo->base.cond); @@ -837,28 +875,35 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr return 0; } -static void destroyTableScanOperatorInfo(void* param) { - STableScanInfo* pTableScanInfo = (STableScanInfo*)param; - blockDataDestroy(pTableScanInfo->pResBlock); - cleanupQueryTableDataCond(&pTableScanInfo->base.cond); +static void destroyTableScanBase(STableScanBase* pBase) { + cleanupQueryTableDataCond(&pBase->cond); - tsdbReaderClose(pTableScanInfo->base.dataReader); - pTableScanInfo->base.dataReader = NULL; + tsdbReaderClose(pBase->dataReader); + pBase->dataReader = NULL; - if (pTableScanInfo->base.matchInfo.pList != NULL) { - taosArrayDestroy(pTableScanInfo->base.matchInfo.pList); + if (pBase->matchInfo.pList != NULL) { + taosArrayDestroy(pBase->matchInfo.pList); } - taosLRUCacheCleanup(pTableScanInfo->base.metaCache.pTableMetaEntryCache); - cleanupExprSupp(&pTableScanInfo->base.pseudoSup); + tableListDestroy(pBase->pTableListInfo); + taosLRUCacheCleanup(pBase->metaCache.pTableMetaEntryCache); + cleanupExprSupp(&pBase->pseudoSup); +} + +static void destroyTableScanOperatorInfo(void* param) { + STableScanInfo* pTableScanInfo = (STableScanInfo*)param; + blockDataDestroy(pTableScanInfo->pResBlock); + destroyTableScanBase(&pTableScanInfo->base); taosMemoryFreeClear(param); } SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { + int32_t code = 0; STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; goto _error; } @@ -866,8 +911,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc; int32_t numOfCols = 0; - int32_t code = - extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->base.matchInfo); + code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->base.matchInfo); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -911,12 +955,17 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pTaskInfo); pOperator->exprSupp.numOfExprs = numOfCols; + pInfo->base.pTableListInfo = pTableListInfo; pInfo->base.metaCache.pTableMetaEntryCache = taosLRUCacheInit(1024 * 128, -1, .5); if (pInfo->base.metaCache.pTableMetaEntryCache == NULL) { code = terrno; goto _error; } + if (scanDebug) { + pInfo->countOnly = true; + } + taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false); pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo, optrDefaultBufFn, getTableScannerExecInfo); @@ -1008,21 +1057,29 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU SSDataBlock* pBlock = pTableScanInfo->pResBlock; STsdbReader* pReader = NULL; int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, - (STsdbReader**)&pReader, GET_TASKID(pTaskInfo)); + (STsdbReader**)&pReader, GET_TASKID(pTaskInfo), false); if (code != TSDB_CODE_SUCCESS) { terrno = code; T_LONG_JMP(pTaskInfo->env, code); return NULL; } - if (tsdbNextDataBlock(pReader)) { + bool hasNext = false; + code = tsdbNextDataBlock(pReader, &hasNext); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + T_LONG_JMP(pTaskInfo->env, code); + return NULL; + } + + if (hasNext) { /*SSDataBlock* p = */ tsdbRetrieveDataBlock(pReader, NULL); doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows); - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); } tsdbReaderClose(pReader); - qDebug("retrieve prev rows:%d, skey:%" PRId64 ", ekey:%" PRId64 " uid:%" PRIu64 ", max ver:%" PRId64 + qDebug("retrieve prev rows:%" PRId64 ", skey:%" PRId64 ", ekey:%" PRId64 " uid:%" PRIu64 ", max ver:%" PRId64 ", suid:%" PRIu64, pBlock->info.rows, startTs, endTs, tbUid, maxVersion, cond.suid); @@ -1039,7 +1096,8 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, } static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) { - return getTableGroupId(pInfo->pTableScanOp->pTaskInfo->pTableInfoList, uid); + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + return getTableGroupId(pTableScanInfo->base.pTableListInfo, uid); } static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { @@ -1513,7 +1571,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock pInfo->pRes->info.type = STREAM_NORMAL; pInfo->pRes->info.version = pBlock->info.version; - pInfo->pRes->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + pInfo->pRes->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); // todo extract method for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { @@ -1569,22 +1628,16 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamScanInfo* pInfo = pOperator->info; + const char* id = GET_TASKID(pTaskInfo); - qDebug("start to exec queue scan"); + qDebug("start to exec queue scan, %s", id); if (pTaskInfo->streamInfo.submit.msgStr != NULL) { if (pInfo->tqReader->msg2.msgStr == NULL) { - /*pInfo->tqReader->pMsg = pTaskInfo->streamInfo.pReq;*/ - - /*const SSubmitReq* pSubmit = pInfo->tqReader->pMsg;*/ - /*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/ - /*void* msgStr = pTaskInfo->streamInfo.*/ SPackedData submit = pTaskInfo->streamInfo.submit; if (tqReaderSetSubmitReq2(pInfo->tqReader, submit.msgStr, submit.msgLen, submit.ver) < 0) { qError("submit msg messed up when initing stream submit block %p", submit.msgStr); - pInfo->tqReader->msg2 = (SPackedData){0}; - pInfo->tqReader->setMsg = 0; - ASSERT(0); + return NULL; } } @@ -1607,72 +1660,49 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { } pInfo->tqReader->msg2 = (SPackedData){0}; - pInfo->tqReader->setMsg = 0; pTaskInfo->streamInfo.submit = (SPackedData){0}; return NULL; } - if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { + if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); if (pResult && pResult->info.rows > 0) { - qDebug("queue scan tsdb return %d rows min:%" PRId64 " max:%" PRId64 " wal curVersion:%" PRId64, pResult->info.rows, + qDebug("queue scan tsdb return %"PRId64" rows min:%" PRId64 " max:%" PRId64 " wal curVersion:%" PRId64, pResult->info.rows, pResult->info.window.skey, pResult->info.window.ekey, pInfo->tqReader->pWalReader->curVersion); - pTaskInfo->streamInfo.returned = 1; + tqOffsetResetToData(&pTaskInfo->streamInfo.currentOffset, pResult->info.id.uid, pResult->info.window.ekey); return pResult; - } else { - if (!pTaskInfo->streamInfo.returned) { - STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; - tsdbReaderClose(pTSInfo->base.dataReader); - qDebug("3"); - pTSInfo->base.dataReader = NULL; - tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer); - qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1); - if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1, pTaskInfo->id.str) < 0) { - tqOffsetResetToLog(&pTaskInfo->streamInfo.lastStatus, pTaskInfo->streamInfo.snapshotVer); - return NULL; - } - } else { - return NULL; - } } + STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; + tsdbReaderClose(pTSInfo->base.dataReader); + pTSInfo->base.dataReader = NULL; + qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1); + if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1, pTaskInfo->id.str) < 0) { + return NULL; + } + tqOffsetResetToLog(&pTaskInfo->streamInfo.currentOffset, pTaskInfo->streamInfo.snapshotVer); } - if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { + if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__LOG) { while (1) { SFetchRet ret = {0}; - if (tqNextBlock(pInfo->tqReader, &ret) < 0) { - // if the end is reached, terrno is 0 - if (terrno != 0) { - qError("failed to get next log block since %s", terrstr()); - } - } + tqNextBlock(pInfo->tqReader, &ret); + tqOffsetResetToLog(&pTaskInfo->streamInfo.currentOffset, pInfo->tqReader->pWalReader->curVersion - 1); //curVersion move to next, so currentOffset = curVersion - 1 if (ret.fetchType == FETCH_TYPE__DATA) { + qDebug("doQueueScan get data from log %"PRId64" rows, version:%" PRId64, ret.data.info.rows, pTaskInfo->streamInfo.currentOffset.version); blockDataCleanup(pInfo->pRes); setBlockIntoRes(pInfo, &ret.data, true); if (pInfo->pRes->info.rows > 0) { - pOperator->status = OP_EXEC_RECV; - qDebug("queue scan log return %d rows", pInfo->pRes->info.rows); + qDebug("doQueueScan get data from log %"PRId64" rows, return, version:%" PRId64, pInfo->pRes->info.rows, pTaskInfo->streamInfo.currentOffset.version); return pInfo->pRes; } - } else if (ret.fetchType == FETCH_TYPE__META) { - qError("unexpected ret.fetchType:%d", ret.fetchType); - continue; - // pTaskInfo->streamInfo.lastStatus = ret.offset; - // pTaskInfo->streamInfo.metaBlk = ret.meta; - // return NULL; - } else if (ret.fetchType == FETCH_TYPE__NONE || - (ret.fetchType == FETCH_TYPE__SEP && pOperator->status == OP_EXEC_RECV)) { - pTaskInfo->streamInfo.lastStatus = ret.offset; - char formatBuf[80]; - tFormatOffset(formatBuf, 80, &ret.offset); - qDebug("queue scan log return null, offset %s", formatBuf); - pOperator->status = OP_OPENED; + }else if(ret.fetchType == FETCH_TYPE__NONE){ + qDebug("doQueueScan get none from log, return, version:%" PRId64, pTaskInfo->streamInfo.currentOffset.version); return NULL; } } } else { - qError("unexpected streamInfo prepare type: %d", pTaskInfo->streamInfo.prepareStatus.type); + qError("unexpected streamInfo prepare type: %d", pTaskInfo->streamInfo.currentOffset.type); return NULL; } } @@ -1806,6 +1836,15 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { printDataBlock(pInfo->pUpdateRes, "recover update"); return pInfo->pUpdateRes; } break; + case STREAM_SCAN_FROM_DELETE_DATA: { + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); + prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); + pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; + copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); + pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; + printDataBlock(pInfo->pDeleteDataRes, "recover delete"); + return pInfo->pDeleteDataRes; + } break; case STREAM_SCAN_FROM_DATAREADER_RANGE: { SSDataBlock* pSDB = doRangeScan(pInfo, pInfo->pUpdateRes, pInfo->primaryTsIndex, &pInfo->updateResIndex); if (pSDB) { @@ -1842,7 +1881,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { printDataBlock(pInfo->pCreateTbRes, "recover createTbl"); return pInfo->pCreateTbRes; } - qDebug("stream recover scan get block, rows %d", pInfo->pRecoverRes->info.rows); + qDebug("stream recover scan get block, rows %" PRId64 , pInfo->pRecoverRes->info.rows); printDataBlock(pInfo->pRecoverRes, "scan recover"); return pInfo->pRecoverRes; } @@ -1998,6 +2037,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { copyDataBlock(pInfo->pUpdateRes, pSup->pScanBlock); blockDataCleanup(pSup->pScanBlock); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); + pInfo->pUpdateRes->info.type = STREAM_DELETE_DATA; return pInfo->pUpdateRes; } @@ -2017,7 +2057,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { int32_t current = pInfo->validBlockIndex++; SPackedData* pSubmit = taosArrayGet(pInfo->pBlockLists, current); - /*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/ if (tqReaderSetSubmitReq2(pInfo->tqReader, pSubmit->msgStr, pSubmit->msgLen, pSubmit->ver) < 0) { qError("submit msg messed up when initing stream submit block %p, current %d, total %d", pSubmit, current, totBlockNum); @@ -2071,7 +2110,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { pOperator->resultInfo.totalRows += pBlockInfo->rows; // printDataBlock(pInfo->pRes, "stream scan"); - qDebug("scan rows: %d", pBlockInfo->rows); + qDebug("scan rows: %" PRId64 , pBlockInfo->rows); if (pBlockInfo->rows > 0) { return pInfo->pRes; } @@ -2104,45 +2143,50 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamRawScanInfo* pInfo = pOperator->info; + int32_t code = TSDB_CODE_SUCCESS; pTaskInfo->streamInfo.metaRsp.metaRspLen = 0; // use metaRspLen !=0 to judge if data is meta pTaskInfo->streamInfo.metaRsp.metaRsp = NULL; qDebug("tmqsnap doRawScan called"); - if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { - if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) { + if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { + bool hasNext = false; + if (pInfo->dataReader) { + code = tsdbNextDataBlock(pInfo->dataReader, &hasNext); + if (code) { + tsdbReleaseDataBlock(pInfo->dataReader); + T_LONG_JMP(pTaskInfo->env, code); + } + } + + if (pInfo->dataReader && hasNext) { if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(pInfo->dataReader); - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } SSDataBlock* pBlock = tsdbRetrieveDataBlock(pInfo->dataReader, NULL); if (pBlock == NULL) { - longjmp(pTaskInfo->env, terrno); + T_LONG_JMP(pTaskInfo->env, terrno); } qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.id.uid); - pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA; - pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.id.uid; - pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey; + tqOffsetResetToData(&pTaskInfo->streamInfo.currentOffset, pBlock->info.id.uid, pBlock->info.window.ekey); return pBlock; } SMetaTableInfo mtInfo = getUidfromSnapShot(pInfo->sContext); + STqOffsetVal offset = {0}; if (mtInfo.uid == 0) { // read snapshot done, change to get data from wal qDebug("tmqsnap read snapshot done, change to get data from wal"); - pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid; - pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; - pTaskInfo->streamInfo.lastStatus.version = pInfo->sContext->snapVersion; + tqOffsetResetToLog(&offset, pInfo->sContext->snapVersion); } else { - pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid; - pTaskInfo->streamInfo.prepareStatus.ts = INT64_MIN; + tqOffsetResetToData(&offset, mtInfo.uid, INT64_MIN); qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid); - qStreamPrepareScan(pTaskInfo, &pTaskInfo->streamInfo.prepareStatus, pInfo->sContext->subType); } + qStreamPrepareScan(pTaskInfo, &offset, pInfo->sContext->subType); tDeleteSSchemaWrapper(mtInfo.schema); - qDebug("tmqsnap stream scan tsdb return null"); return NULL; - } else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_META) { + } else if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_META) { SSnapContext* sContext = pInfo->sContext; void* data = NULL; int32_t dataLen = 0; @@ -2154,16 +2198,12 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { return NULL; } - if (!sContext->queryMetaOrData) { // change to get data next poll request - pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_META; - pTaskInfo->streamInfo.lastStatus.uid = uid; - pTaskInfo->streamInfo.metaRsp.rspOffset.type = TMQ_OFFSET__SNAPSHOT_DATA; - pTaskInfo->streamInfo.metaRsp.rspOffset.uid = 0; - pTaskInfo->streamInfo.metaRsp.rspOffset.ts = INT64_MIN; + if (!sContext->queryMeta) { // change to get data next poll request + STqOffsetVal offset = {0}; + tqOffsetResetToData(&offset, 0, INT64_MIN); + qStreamPrepareScan(pTaskInfo, &offset, pInfo->sContext->subType); } else { - pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_META; - pTaskInfo->streamInfo.lastStatus.uid = uid; - pTaskInfo->streamInfo.metaRsp.rspOffset = pTaskInfo->streamInfo.lastStatus; + tqOffsetResetToMeta(&pTaskInfo->streamInfo.currentOffset, uid); pTaskInfo->streamInfo.metaRsp.resMsgType = type; pTaskInfo->streamInfo.metaRsp.metaRspLen = dataLen; pTaskInfo->streamInfo.metaRsp.metaRsp = data; @@ -2216,6 +2256,7 @@ static void destroyRawScanOperatorInfo(void* param) { SStreamRawScanInfo* pRawScan = (SStreamRawScanInfo*)param; tsdbReaderClose(pRawScan->dataReader); destroySnapContext(pRawScan->sContext); + tableListDestroy(pRawScan->pTableListInfo); taosMemoryFree(pRawScan); } @@ -2237,6 +2278,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT goto _end; } + pInfo->pTableListInfo = tableListCreate(); pInfo->vnode = pHandle->vnode; pInfo->sContext = pHandle->sContext; @@ -2255,9 +2297,11 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT static void destroyStreamScanOperatorInfo(void* param) { SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param; + if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) { destroyOperatorInfo(pStreamScan->pTableScanOp); } + if (pStreamScan->tqReader) { tqCloseReader(pStreamScan->tqReader); } @@ -2284,13 +2328,14 @@ static void destroyStreamScanOperatorInfo(void* param) { } SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { SArray* pColIds = NULL; SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } @@ -2304,6 +2349,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys int32_t code = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); if (code != TSDB_CODE_SUCCESS) { + tableListDestroy(pTableListInfo); goto _error; } @@ -2323,11 +2369,14 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SExprInfo* pSubTableExpr = taosMemoryCalloc(1, sizeof(SExprInfo)); if (pSubTableExpr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } + pInfo->tbnameCalSup.pExprInfo = pSubTableExpr; createExprFromOneNode(pSubTableExpr, pTableScanNode->pSubtable, 0); if (initExprSupp(&pInfo->tbnameCalSup, pSubTableExpr, 1) != 0) { + tableListDestroy(pTableListInfo); goto _error; } } @@ -2337,10 +2386,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SExprInfo* pTagExpr = createExpr(pTableScanNode->pTags, &numOfTags); if (pTagExpr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } } @@ -2348,11 +2399,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pBlockLists = taosArrayInit(4, sizeof(SPackedData)); if (pInfo->pBlockLists == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } if (pHandle->vnode) { - SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info; if (pHandle->version > 0) { pTSInfo->base.cond.endVersion = pHandle->version; @@ -2360,12 +2412,11 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys STableKeyInfo* pList = NULL; int32_t num = 0; - tableListGetGroupList(pTaskInfo->pTableInfoList, 0, &pList, &num); + tableListGetGroupList(pTableListInfo, 0, &pList, &num); if (pHandle->initTableReader) { pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER; pTSInfo->base.dataReader = NULL; - pTaskInfo->streamInfo.lastStatus.uid = -1; } if (pHandle->initTqReader) { @@ -2391,16 +2442,18 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys // set the extract column id to streamHandle tqReaderSetColIdList(pInfo->tqReader, pColIds); - SArray* tableIdList = extractTableIdList(pTaskInfo->pTableInfoList); + SArray* tableIdList = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo); code = tqReaderSetTbUidList(pInfo->tqReader, tableIdList); if (code != 0) { taosArrayDestroy(tableIdList); goto _error; } + taosArrayDestroy(tableIdList); memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond)); } else { taosArrayDestroy(pColIds); + tableListDestroy(pTableListInfo); pColIds = NULL; } @@ -2435,7 +2488,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pTaskInfo); pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); - __optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan; + __optr_fn_t nextFn = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) ? doStreamScan : doQueueScan; pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL); @@ -2466,7 +2519,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = pInfo->pRes; blockDataCleanup(pRes); - int32_t size = tableListGetSize(pTaskInfo->pTableInfoList); + int32_t size = tableListGetSize(pInfo->pTableListInfo); if (size == 0) { setTaskStatus(pTaskInfo, TASK_COMPLETED); return NULL; @@ -2478,7 +2531,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { metaReaderInit(&mr, pInfo->readHandle.meta, 0); while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) { - STableKeyInfo* item = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->curPos); + STableKeyInfo* item = tableListGetInfo(pInfo->pTableListInfo, pInfo->curPos); int32_t code = metaGetTableEntryByUid(&mr, item->uid); tDecoderClear(&mr.coder); if (code != TSDB_CODE_SUCCESS) { @@ -2539,10 +2592,11 @@ static void destroyTagScanOperatorInfo(void* param) { STagScanInfo* pInfo = (STagScanInfo*)param; pInfo->pRes = blockDataDestroy(pInfo->pRes); taosArrayDestroy(pInfo->matchInfo.pList); + pInfo->pTableListInfo = tableListDestroy(pInfo->pTableListInfo); taosMemoryFreeClear(param); } -SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, +SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -2565,6 +2619,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi goto _error; } + pInfo->pTableListInfo = pTableListInfo; pInfo->pRes = createDataBlockFromDescNode(pDescNode); pInfo->readHandle = *pReadHandle; pInfo->curPos = 0; @@ -2598,11 +2653,11 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx); int64_t st = taosGetTimestampUs(); - void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex); + void* p = tableListGetInfo(pInfo->base.pTableListInfo, readIdx + pInfo->tableStartIndex); SReadHandle* pHandle = &pInfo->base.readHandle; if (NULL == source->dataReader || !source->multiReader) { - code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &source->dataReader, GET_TASKID(pTaskInfo)); + code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &source->dataReader, GET_TASKID(pTaskInfo), false); if (code != 0) { T_LONG_JMP(pTaskInfo->env, code); } @@ -2610,8 +2665,21 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { pInfo->base.dataReader = source->dataReader; STsdbReader* reader = pInfo->base.dataReader; + bool hasNext = false; qTrace("tsdb/read-table-data: %p, enter next reader", reader); - while (tsdbNextDataBlock(reader)) { + + while (true) { + code = tsdbNextDataBlock(reader, &hasNext); + if (code != 0) { + tsdbReleaseDataBlock(reader); + pInfo->base.dataReader = NULL; + T_LONG_JMP(pTaskInfo->env, code); + } + + if (!hasNext) { + break; + } + if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(reader); pInfo->base.dataReader = NULL; @@ -2642,7 +2710,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { continue; } - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + pBlock->info.id.groupId = getTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); pOperator->resultInfo.totalRows += pBlock->info.rows; pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; @@ -2698,10 +2766,10 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; { - size_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); + size_t numOfTables = tableListGetSize(pInfo->base.pTableListInfo); int32_t i = pInfo->tableStartIndex + 1; for (; i < numOfTables; ++i) { - STableKeyInfo* tableKeyInfo = tableListGetInfo(pTaskInfo->pTableInfoList, i); + STableKeyInfo* tableKeyInfo = tableListGetInfo(pInfo->base.pTableListInfo, i); if (tableKeyInfo->groupId != pInfo->groupId) { break; } @@ -2816,7 +2884,7 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* } bool limitReached = applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo); - qDebug("%s get sorted row block, rows:%d, limit:%" PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows, + qDebug("%s get sorted row block, rows:%" PRId64 ", limit:%" PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows, pInfo->limitInfo.numOfOutputRows); return (pResBlock->info.rows > 0) ? pResBlock : NULL; @@ -2835,7 +2903,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, code); } - size_t tableListSize = tableListGetSize(pTaskInfo->pTableInfoList); + size_t tableListSize = tableListGetSize(pInfo->base.pTableListInfo); if (!pInfo->hasGroupId) { pInfo->hasGroupId = true; @@ -2844,7 +2912,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { return NULL; } pInfo->tableStartIndex = 0; - pInfo->groupId = ((STableKeyInfo*)tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->tableStartIndex))->groupId; + pInfo->groupId = ((STableKeyInfo*)tableListGetInfo(pInfo->base.pTableListInfo, pInfo->tableStartIndex))->groupId; startGroupTableMergeScan(pOperator); } @@ -2869,7 +2937,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { } pInfo->tableStartIndex = pInfo->tableEndIndex + 1; - pInfo->groupId = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->tableStartIndex)->groupId; + pInfo->groupId = tableListGetInfo(pInfo->base.pTableListInfo, pInfo->tableStartIndex)->groupId; startGroupTableMergeScan(pOperator); resetLimitInfoForNextGroup(&pInfo->limitInfo); } @@ -2891,9 +2959,6 @@ void destroyTableMergeScanOperatorInfo(void* param) { p->dataReader = NULL; } - tsdbReaderClose(pTableScanInfo->base.dataReader); - pTableScanInfo->base.dataReader = NULL; - taosArrayDestroy(pTableScanInfo->sortSourceParams); tsortDestroySortHandle(pTableScanInfo->pSortHandle); pTableScanInfo->pSortHandle = NULL; @@ -2902,20 +2967,14 @@ void destroyTableMergeScanOperatorInfo(void* param) { SQueryTableDataCond* pCond = taosArrayGet(pTableScanInfo->queryConds, i); taosMemoryFree(pCond->colList); } - taosArrayDestroy(pTableScanInfo->queryConds); - if (pTableScanInfo->base.matchInfo.pList != NULL) { - taosArrayDestroy(pTableScanInfo->base.matchInfo.pList); - } + taosArrayDestroy(pTableScanInfo->queryConds); + destroyTableScanBase(&pTableScanInfo->base); pTableScanInfo->pResBlock = blockDataDestroy(pTableScanInfo->pResBlock); pTableScanInfo->pSortInputBlock = blockDataDestroy(pTableScanInfo->pSortInputBlock); taosArrayDestroy(pTableScanInfo->pSortInfo); - cleanupExprSupp(&pTableScanInfo->base.pseudoSup); - - taosLRUCacheCleanup(pTableScanInfo->base.metaCache.pTableMetaEntryCache); - taosMemoryFreeClear(param); } @@ -2934,7 +2993,7 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla } SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2976,6 +3035,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo->base.limitInfo.limit.limit = -1; pInfo->base.limitInfo.slimit.limit = -1; + pInfo->base.pTableListInfo = pTableListInfo; pInfo->sample.sampleRatio = pTableScanNode->ratio; pInfo->sample.seed = taosGetTimestampSec(); diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 90c7fa10ca7..cb0f1aa0684 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -698,7 +698,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData pDataBlock->info.dataLoad = 1; } - qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId, + qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%" PRId64 , GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId, pDataBlock->info.rows); return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index f24d3523c88..1abe678ac64 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -83,10 +83,11 @@ typedef struct MergeIndex { } MergeIndex; typedef struct SBlockDistInfo { - SSDataBlock* pResBlock; - STsdbReader* pHandle; - SReadHandle readHandle; - uint64_t uid; // table uid + SSDataBlock* pResBlock; + STsdbReader* pHandle; + SReadHandle readHandle; + STableListInfo* pTableListInfo; + uint64_t uid; // table uid } SBlockDistInfo; static int32_t sysChkFilter__Comm(SNode* pNode); @@ -1627,7 +1628,7 @@ static void sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScan char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(varTbName, name); - colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows); + colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows, true); } doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL); @@ -2214,6 +2215,7 @@ static void destroyBlockDistScanOperatorInfo(void* param) { SBlockDistInfo* pDistInfo = (SBlockDistInfo*)param; blockDataDestroy(pDistInfo->pResBlock); tsdbReaderClose(pDistInfo->pHandle); + tableListDestroy(pDistInfo->pTableListInfo); taosMemoryFreeClear(param); } @@ -2245,7 +2247,7 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC } SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2263,11 +2265,11 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi goto _error; } - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; - size_t num = tableListGetSize(pTableListInfo); - void* pList = tableListGetInfo(pTableListInfo, 0); + pInfo->pTableListInfo = pTableListInfo; + size_t num = tableListGetSize(pTableListInfo); + void* pList = tableListGetInfo(pTableListInfo, 0); - code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str); + code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str, false); cleanupQueryTableDataCond(&cond); if (code != 0) { goto _error; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index b01143841c4..1a1fb6208d7 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -128,8 +128,9 @@ FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn if (end >= 0) { forwardRows = end; - if (pData[end + pos] == ekey) { + while (pData[end + pos] == ekey) { forwardRows += 1; + ++pos; } } } else { @@ -137,8 +138,9 @@ FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn if (end >= 0) { forwardRows = end; - if (pData[end + pos] == ekey) { + while (pData[end + pos] == ekey) { forwardRows += 1; + ++pos; } } // int32_t end = searchFn((char*)pData, pos + 1, ekey, order); @@ -936,6 +938,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } + TSKEY ekey = ascScan ? win.ekey : win.skey; int32_t forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); @@ -2173,13 +2176,6 @@ static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, S } } -bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { - SET_RES_WINDOW_KEY(pSup->keyBuf, &pWin->skey, sizeof(int64_t), groupId); - SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, - GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); - return p1 == NULL; -} - bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup) { if (pWin->ekey < pTwSup->maxTs - pTwSup->deleteMark) { SWinKey key = {.ts = pWin->skey, .groupId = groupId}; @@ -4762,6 +4758,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (!pInfo->pUpdated) { pInfo->pUpdated = taosArrayInit(4, sizeof(SWinKey)); } + if (!pInfo->pUpdatedMap) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pInfo->pUpdatedMap = tSimpleHashInit(1024, hashFn); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 4fcc9ac1ada..a88b1388bab 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -480,14 +480,16 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le return code; } - pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + pFunc->node.resType = + (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; } static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters - pFunc->node.resType = (SDataType){.bytes =tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + pFunc->node.resType = + (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; } @@ -509,13 +511,11 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (!IS_NUMERIC_TYPE(para1Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - for (int32_t i = 1; i < numOfParams; ++i) { SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i); pValue->notReserved = true; @@ -2375,7 +2375,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "spread", .type = FUNCTION_TYPE_SPREAD, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateSpread, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getSpreadFuncEnv, @@ -2417,7 +2417,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "elapsed", .type = FUNCTION_TYPE_ELAPSED, - .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_SPECIAL_DATA_REQUIRED, .dataRequiredFunc = statisDataRequired, .translateFunc = translateElapsed, .getEnvFunc = getElapsedFuncEnv, @@ -2457,7 +2457,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "interp", .type = FUNCTION_TYPE_INTERP, .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | - FUNC_MGT_FORBID_STREAM_FUNC, + FUNC_MGT_FORBID_STREAM_FUNC|FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateInterp, .getEnvFunc = getSelectivityFuncEnv, .initFunc = functionSetup, @@ -2491,7 +2491,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateFirstLast, .dynDataRequiredFunc = lastDynDataReq, .getEnvFunc = getFirstLastFuncEnv, @@ -2500,7 +2500,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = firstLastScalarFunction, .pPartialFunc = "_last_row_partial", .pMergeFunc = "_last_row_merge", - .finalizeFunc = firstLastFinalize + .finalizeFunc = firstLastFinalize, + .combineFunc = lastCombine }, { .name = "_cache_last_row", @@ -2809,7 +2810,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "mode", .type = FUNCTION_TYPE_MODE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateMode, .getEnvFunc = getModeFuncEnv, .initFunc = modeFunctionSetup, @@ -3212,7 +3213,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_block_dist", .type = FUNCTION_TYPE_BLOCK_DIST, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateBlockDistFunc, .getEnvFunc = getBlockDistFuncEnv, .initFunc = blockDistSetup, @@ -3277,7 +3278,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_irowts", .type = FUNCTION_TYPE_IROWTS, - .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_INTERP_PC_FUNC, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_INTERP_PC_FUNC|FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 3c9f2fe8caa..6d093c130f3 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -494,8 +494,8 @@ bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } -static int32_t getNumOfElems(SqlFunctionCtx* pCtx) { - int32_t numOfElem = 0; +static int64_t getNumOfElems(SqlFunctionCtx* pCtx) { + int64_t numOfElem = 0; /* * 1. column data missing (schema modified) causes pInputCol->hasNull == true. pInput->colDataSMAIsSet == true; @@ -528,7 +528,7 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) { * count function does not use the pCtx->interResBuf to keep the intermediate buffer */ int32_t countFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElem = 0; + int64_t numOfElem = 0; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; @@ -555,7 +555,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) { } int32_t countInvertFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElem = getNumOfElems(pCtx); + int64_t numOfElem = getNumOfElems(pCtx); SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); char* buf = GET_ROWCELL_INTERBUF(pResInfo); @@ -871,6 +871,12 @@ int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STu SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + // group_key function has its own process function + // do not process there + if (fmIsGroupKeyFunc(pc->functionId)) { + continue; + } + SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); if (nullList[j]) { colDataSetNULL(pDstCol, rowIndex); @@ -1929,7 +1935,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - qDebug("%s total %d rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto); + qDebug("%s total %" PRId64 " rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto); int32_t start = pInput->startRowIndex; for (int32_t i = start; i < start + pInput->numOfRows; ++i) { @@ -3091,6 +3097,12 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid for (int32_t i = 0; i < pSubsidiaryies->num; ++i) { SqlFunctionCtx* pc = pSubsidiaryies->pCtx[i]; + // group_key function has its own process function + // do not process there + if (fmIsGroupKeyFunc(pc->functionId)) { + continue; + } + SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; int32_t srcSlotId = pFuncParam->pCol->slotId; diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 40c50ed9cb9..9e7ed521042 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -127,8 +127,6 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of blk->blockId = blkId; blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); ASSERTS(blk->nread <= kBlockSize, "index read incomplete data"); - if (blk->nread > kBlockSize) break; - if (blk->nread < kBlockSize && blk->nread < len) { taosMemoryFree(blk); break; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 0d1ca9aa9f0..dbf61c55b75 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -334,7 +334,7 @@ column_def_list(A) ::= column_def(B). column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); } column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); } -column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); } +//column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); } %type type_name { SDataType } %destructor type_name { } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index a7f6d7cb3c8..c25d0e7036a 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -337,8 +337,14 @@ static SNodeList* getChildProjection(SNode* pStmt) { static void eraseSetOpChildProjection(SSetOperator* pSetOp, int32_t index) { SNodeList* pLeftProjs = getChildProjection(pSetOp->pLeft); nodesListErase(pLeftProjs, nodesListGetCell(pLeftProjs, index)); + if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pLeft)) { + eraseSetOpChildProjection((SSetOperator*)pSetOp->pLeft, index); + } SNodeList* pRightProjs = getChildProjection(pSetOp->pRight); nodesListErase(pRightProjs, nodesListGetCell(pRightProjs, index)); + if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pRight)) { + eraseSetOpChildProjection((SSetOperator*)pSetOp->pRight, index); + } } typedef struct SNotRefByOrderByCxt { diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index 106ee641af9..1c921b2d7c2 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -25,6 +25,8 @@ static void clearColValArray(SArray* pCols) { if (TSDB_DATA_TYPE_NCHAR == pCol->type) { taosMemoryFreeClear(pCol->value.pData); } + pCol->flag = CV_FLAG_NONE; + pCol->value.val = 0; } } @@ -123,6 +125,12 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem SSchema* pTagSchema = &pSchema[tags->pColIndex[i]]; SSmlKv* kv = taosArrayGet(cols, i); + if(kv->keyLen != strlen(pTagSchema->name) || memcmp(kv->key, pTagSchema->name, kv->keyLen) != 0 || kv->type != pTagSchema->type){ + code = TSDB_CODE_SML_INVALID_DATA; + uError("SML smlBuildCol error col not same %s", pTagSchema->name); + goto end; + } + taosArrayPush(*tagName, pTagSchema->name); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; // strcpy(val.colName, pTagSchema->name); diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 0ed32afbbc0..ac504b9809a 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -470,11 +470,11 @@ int32_t insMergeTableDataCxt(SHashObj* pTableHash, SArray** pVgDataBlocks) { if (TSDB_CODE_SUCCESS == code) { SVgroupDataCxt* pVgCxt = NULL; int32_t vgId = pTableCxt->pMeta->vgId; - void** p = taosHashGet(pVgroupHash, &vgId, sizeof(vgId)); - if (NULL == p) { + void** pp = taosHashGet(pVgroupHash, &vgId, sizeof(vgId)); + if (NULL == pp) { code = createVgroupDataCxt(pTableCxt, pVgroupHash, pVgroupList, &pVgCxt); } else { - pVgCxt = *(SVgroupDataCxt**)p; + pVgCxt = *(SVgroupDataCxt**)pp; } if (TSDB_CODE_SUCCESS == code) { code = fillVgroupDataCxt(pTableCxt, pVgCxt); @@ -631,10 +631,10 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate ret = TSDB_CODE_INVALID_PARA; goto end; } - for (int c = 0; c < boundInfo->numOfBound; ++c) { - SSchema* pColSchema = &pSchema[c]; - SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); - if(tFields == NULL || findFileds(pColSchema, tFields, numFields)){ + if(tFields == NULL){ + for (int j = 0; j < boundInfo->numOfBound; j++){ + SSchema* pColSchema = &pSchema[j]; + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { uError("type or bytes not equal"); ret = TSDB_CODE_INVALID_PARA; @@ -652,12 +652,52 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); fields += sizeof(int8_t) + sizeof(int32_t); if (needChangeLength) { - pStart += htonl(colLength[c]); + pStart += htonl(colLength[j]); } else { - pStart += colLength[c]; + pStart += colLength[j]; + } + } + }else{ + for (int i = 0; i < numFields; i++) { + for (int j = 0; j < boundInfo->numOfBound; j++){ + SSchema* pColSchema = &pSchema[j]; + if(strcmp(pColSchema->name, tFields[i].name) == 0){ + if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { + uError("type or bytes not equal"); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } + + int8_t* offset = pStart; + if (IS_VAR_DATA_TYPE(pColSchema->type)) { + pStart += numOfRows * sizeof(int32_t); + } else { + pStart += BitmapLen(numOfRows); + } + char* pData = pStart; + + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); + tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); + fields += sizeof(int8_t) + sizeof(int32_t); + if (needChangeLength) { + pStart += htonl(colLength[i]); + } else { + pStart += colLength[i]; + } + boundInfo->pColIndex[j] = -1; + break; + } + } + + } + + for (int c = 0; c < boundInfo->numOfBound; ++c) { + if( boundInfo->pColIndex[c] != -1){ + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); + tColDataAddValueByDataBlock(pCol, 0, 0, numOfRows, NULL, NULL); + }else{ + boundInfo->pColIndex[c] = c; // restore for next block } - }else{ - tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, NULL, NULL); } } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index b8b445a3354..1d6d123cb45 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -755,9 +755,11 @@ static bool isPrimaryKeyImpl(SNode* pExpr) { } else if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { SFunctionNode* pFunc = (SFunctionNode*)pExpr; if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType || FUNCTION_TYPE_GROUP_KEY == pFunc->funcType || - FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType) { + FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType || + FUNCTION_TYPE_LAST_ROW == pFunc->funcType) { return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0)); - } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType) { + } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType || + FUNCTION_TYPE_IROWTS == pFunc->funcType) { return true; } } @@ -1635,13 +1637,15 @@ static bool isTableStar(SNode* pNode) { (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } +static bool isStarParam(SNode* pNode) { return isStar(pNode) || isTableStar(pNode); } + static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (!fmIsMultiResFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } if (SQL_CLAUSE_SELECT != pCxt->currClause) { SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); - if (isStar(pPara) || isTableStar(pPara)) { + if (isStarParam(pPara)) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s(*) is only supported in SELECTed list", pFunc->functionName); } @@ -1655,7 +1659,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu static int32_t getMultiResFuncNum(SNodeList* pParameterList) { if (1 == LIST_LENGTH(pParameterList)) { - return isStar(nodesListGetNode(pParameterList, 0)) ? 2 : 1; + return isStarParam(nodesListGetNode(pParameterList, 0)) ? 2 : 1; } return LIST_LENGTH(pParameterList); } @@ -1688,6 +1692,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { pSelect->hasUniqueFunc = pSelect->hasUniqueFunc ? true : (FUNCTION_TYPE_UNIQUE == pFunc->funcType); pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); + pSelect->hasInterpPseudoColFunc = pSelect->hasInterpPseudoColFunc ? true : fmIsInterpPseudoColumnFunc(pFunc->funcId); pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType); pSelect->hasLastFunc = pSelect->hasLastFunc ? true : (FUNCTION_TYPE_LAST == pFunc->funcType); pSelect->hasTimeLineFunc = pSelect->hasTimeLineFunc ? true : fmIsTimelineFunc(pFunc->funcId); @@ -3118,6 +3123,19 @@ static const char* getPrecisionStr(uint8_t precision) { return "unknown"; } +static void convertVarDuration(SValueNode* pOffset, uint8_t precision) { + const int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; + const int8_t units[3] = {TIME_UNIT_MILLISECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_NANOSECOND}; + + if (pOffset->unit == 'n') { + pOffset->datum.i = pOffset->datum.i * 31 * (NANOSECOND_PER_DAY / factors[precision]); + } else { + pOffset->datum.i = pOffset->datum.i * 365 * (NANOSECOND_PER_DAY / factors[precision]); + } + + pOffset->unit = units[precision]; +} + static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision; @@ -3142,6 +3160,10 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit))) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG); } + + if (pOffset->unit == 'n' || pOffset->unit == 'y') { + convertVarDuration(pOffset, precision); + } } if (NULL != pInterval->pSliding) { @@ -3349,6 +3371,9 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) { if (NULL != pSelect->pRange || NULL != pSelect->pEvery || NULL != pSelect->pFill) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE); } + if (pSelect->hasInterpPseudoColFunc) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "Has Interp pseudo column(s) but missing interp function"); + } return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 87ab47f4ac2..77008e627fa 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -140,17 +140,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 755 -#define YYNRULE 575 +#define YYNSTATE 753 +#define YYNRULE 574 #define YYNTOKEN 328 -#define YY_MAX_SHIFT 754 -#define YY_MIN_SHIFTREDUCE 1123 -#define YY_MAX_SHIFTREDUCE 1697 -#define YY_ERROR_ACTION 1698 -#define YY_ACCEPT_ACTION 1699 -#define YY_NO_ACTION 1700 -#define YY_MIN_REDUCE 1701 -#define YY_MAX_REDUCE 2275 +#define YY_MAX_SHIFT 752 +#define YY_MIN_SHIFTREDUCE 1121 +#define YY_MAX_SHIFTREDUCE 1694 +#define YY_ERROR_ACTION 1695 +#define YY_ACCEPT_ACTION 1696 +#define YY_NO_ACTION 1697 +#define YY_MIN_REDUCE 1698 +#define YY_MAX_REDUCE 2271 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -217,762 +217,756 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2778) +#define YY_ACTTAB_COUNT (2744) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2087, 494, 1920, 1986, 495, 1737, 1856, 644, 1867, 366, - /* 10 */ 661, 1965, 46, 44, 1625, 379, 2073, 1918, 1983, 631, - /* 20 */ 388, 601, 1474, 39, 38, 133, 2069, 45, 43, 42, - /* 30 */ 41, 40, 532, 1555, 123, 1472, 2105, 122, 121, 120, - /* 40 */ 119, 118, 117, 116, 115, 114, 499, 2105, 2055, 1178, - /* 50 */ 660, 1177, 496, 427, 1986, 192, 2087, 426, 1858, 1550, - /* 60 */ 2065, 2071, 369, 66, 226, 19, 661, 511, 2069, 1984, - /* 70 */ 631, 654, 1480, 180, 502, 619, 140, 495, 1737, 2086, - /* 80 */ 348, 1179, 1247, 2122, 643, 1907, 169, 2088, 664, 2090, - /* 90 */ 2091, 659, 2105, 654, 177, 1499, 434, 751, 582, 600, - /* 100 */ 15, 2246, 2065, 2071, 2055, 1499, 660, 619, 140, 435, - /* 110 */ 46, 44, 1474, 654, 355, 1969, 2252, 184, 388, 1249, - /* 120 */ 1474, 2247, 608, 167, 1584, 1472, 583, 2212, 209, 1699, - /* 130 */ 1812, 1555, 497, 1472, 1744, 2086, 1557, 1558, 2073, 2122, - /* 140 */ 1950, 1965, 110, 2088, 664, 2090, 2091, 659, 2069, 654, - /* 150 */ 1156, 168, 143, 1713, 150, 2146, 2175, 1550, 62, 62, - /* 160 */ 382, 2171, 1480, 19, 49, 211, 1530, 1540, 643, 497, - /* 170 */ 1480, 1744, 1556, 1559, 273, 2183, 618, 643, 134, 617, - /* 180 */ 1585, 2246, 2065, 2071, 370, 194, 1475, 751, 1473, 1158, - /* 190 */ 629, 1161, 1162, 654, 2073, 751, 606, 184, 15, 401, - /* 200 */ 1499, 2247, 608, 400, 2069, 621, 182, 2183, 2184, 1843, - /* 210 */ 138, 2188, 1478, 1479, 1773, 1529, 1532, 1533, 1534, 1535, - /* 220 */ 1536, 1537, 1538, 1539, 656, 652, 1548, 1549, 1551, 1552, - /* 230 */ 1553, 1554, 2, 393, 1557, 1558, 1913, 1915, 2065, 2071, - /* 240 */ 383, 1393, 1394, 425, 582, 424, 698, 2246, 49, 654, - /* 250 */ 87, 35, 386, 1579, 1580, 1581, 1582, 1583, 1587, 1588, - /* 260 */ 1589, 1590, 2252, 184, 1530, 1540, 357, 2247, 608, 423, - /* 270 */ 1556, 1559, 1920, 698, 607, 1862, 1475, 2246, 1473, 376, - /* 280 */ 62, 548, 547, 546, 1475, 1629, 1473, 1918, 538, 137, - /* 290 */ 542, 1499, 606, 184, 541, 451, 1653, 2247, 608, 540, - /* 300 */ 545, 602, 1478, 1479, 450, 539, 2023, 187, 187, 1500, - /* 310 */ 1478, 1479, 1844, 1529, 1532, 1533, 1534, 1535, 1536, 1537, - /* 320 */ 1538, 1539, 656, 652, 1548, 1549, 1551, 1552, 1553, 1554, - /* 330 */ 2, 12, 46, 44, 644, 1867, 644, 1867, 696, 1724, - /* 340 */ 388, 1702, 1474, 594, 593, 1651, 1652, 1654, 1655, 1656, - /* 350 */ 625, 244, 189, 1555, 55, 1472, 155, 154, 693, 692, - /* 360 */ 691, 152, 123, 433, 1498, 122, 121, 120, 119, 118, - /* 370 */ 117, 116, 115, 114, 45, 43, 42, 41, 40, 1550, - /* 380 */ 276, 548, 547, 546, 243, 19, 1920, 2055, 538, 137, - /* 390 */ 542, 571, 1480, 381, 541, 582, 1164, 187, 2246, 540, - /* 400 */ 545, 1918, 1498, 39, 38, 539, 336, 45, 43, 42, - /* 410 */ 41, 40, 2087, 2252, 184, 2190, 2251, 751, 2247, 608, - /* 420 */ 15, 62, 661, 93, 696, 1338, 1339, 619, 140, 187, - /* 430 */ 46, 44, 1560, 1501, 644, 1867, 597, 1531, 388, 1701, - /* 440 */ 1474, 2187, 155, 154, 693, 692, 691, 152, 2105, 1448, - /* 450 */ 1449, 1555, 133, 1472, 644, 1867, 1557, 1558, 62, 537, - /* 460 */ 2055, 630, 660, 132, 131, 130, 129, 128, 127, 126, - /* 470 */ 125, 124, 431, 630, 2087, 39, 38, 1550, 12, 45, - /* 480 */ 43, 42, 41, 40, 622, 1965, 1530, 1540, 380, 165, - /* 490 */ 1480, 2086, 1556, 1559, 1258, 2122, 165, 1870, 111, 2088, - /* 500 */ 664, 2090, 2091, 659, 1869, 654, 1475, 1257, 1473, 1501, - /* 510 */ 2105, 509, 2175, 1979, 1687, 751, 2174, 2171, 47, 603, - /* 520 */ 598, 591, 2055, 628, 660, 1979, 183, 2183, 2184, 198, - /* 530 */ 138, 2188, 1478, 1479, 87, 1529, 1532, 1533, 1534, 1535, - /* 540 */ 1536, 1537, 1538, 1539, 656, 652, 1548, 1549, 1551, 1552, - /* 550 */ 1553, 1554, 2, 2086, 1557, 1558, 2250, 2122, 196, 1863, - /* 560 */ 110, 2088, 664, 2090, 2091, 659, 2190, 654, 1664, 480, - /* 570 */ 187, 1723, 181, 1694, 2175, 1480, 619, 140, 382, 2171, - /* 580 */ 391, 275, 644, 1867, 1530, 1540, 611, 1920, 162, 391, - /* 590 */ 1556, 1559, 2186, 1304, 353, 367, 1869, 165, 84, 2202, - /* 600 */ 432, 83, 1918, 1918, 1475, 1869, 1473, 187, 630, 1295, - /* 610 */ 686, 685, 684, 1299, 683, 1301, 1302, 682, 679, 2055, - /* 620 */ 1310, 676, 1312, 1313, 673, 670, 1565, 42, 41, 40, - /* 630 */ 1478, 1479, 1499, 1529, 1532, 1533, 1534, 1535, 1536, 1537, - /* 640 */ 1538, 1539, 656, 652, 1548, 1549, 1551, 1552, 1553, 1554, - /* 650 */ 2, 46, 44, 710, 2087, 644, 1867, 275, 639, 388, - /* 660 */ 1979, 1474, 394, 607, 661, 12, 2246, 10, 553, 1693, - /* 670 */ 165, 1262, 1555, 441, 1472, 185, 2183, 2184, 1869, 138, - /* 680 */ 2188, 606, 184, 563, 1261, 360, 2247, 608, 39, 38, - /* 690 */ 2105, 107, 45, 43, 42, 41, 40, 240, 1550, 644, - /* 700 */ 1867, 1920, 2055, 2190, 660, 242, 9, 141, 392, 241, - /* 710 */ 1722, 1480, 153, 556, 177, 1859, 1918, 456, 550, 142, - /* 720 */ 39, 38, 2146, 239, 45, 43, 42, 41, 40, 2185, - /* 730 */ 644, 1867, 1502, 2086, 471, 1970, 751, 2122, 1502, 47, - /* 740 */ 170, 2088, 664, 2090, 2091, 659, 482, 654, 457, 46, - /* 750 */ 44, 361, 2087, 359, 358, 689, 534, 388, 2055, 1474, - /* 760 */ 536, 1852, 658, 70, 644, 1867, 69, 90, 343, 54, - /* 770 */ 1555, 365, 1472, 564, 2251, 1557, 1558, 2246, 1531, 39, - /* 780 */ 38, 535, 510, 45, 43, 42, 41, 40, 2105, 644, - /* 790 */ 1867, 609, 2267, 2250, 200, 199, 1550, 2247, 2249, 50, - /* 800 */ 2055, 562, 660, 644, 1867, 1530, 1540, 1864, 646, 1480, - /* 810 */ 2147, 1556, 1559, 612, 560, 28, 558, 470, 644, 1867, - /* 820 */ 1586, 245, 610, 285, 286, 1475, 420, 1473, 284, 101, - /* 830 */ 1500, 2086, 644, 1867, 751, 2122, 578, 15, 330, 2088, - /* 840 */ 664, 2090, 2091, 659, 657, 654, 645, 2140, 422, 418, - /* 850 */ 623, 1478, 1479, 1860, 1529, 1532, 1533, 1534, 1535, 1536, - /* 860 */ 1537, 1538, 1539, 656, 652, 1548, 1549, 1551, 1552, 1553, - /* 870 */ 1554, 2, 1842, 1557, 1558, 36, 294, 39, 38, 1854, - /* 880 */ 253, 45, 43, 42, 41, 40, 193, 14, 13, 644, - /* 890 */ 1867, 33, 648, 339, 2147, 1497, 644, 1867, 1178, 1850, - /* 900 */ 1177, 1591, 464, 1530, 1540, 478, 32, 627, 477, 1556, - /* 910 */ 1559, 688, 39, 38, 289, 1618, 45, 43, 42, 41, - /* 920 */ 40, 34, 1622, 1475, 447, 1473, 479, 39, 38, 449, - /* 930 */ 1179, 45, 43, 42, 41, 40, 39, 38, 1914, 1915, - /* 940 */ 45, 43, 42, 41, 40, 2048, 1410, 1411, 187, 1478, - /* 950 */ 1479, 1499, 1529, 1532, 1533, 1534, 1535, 1536, 1537, 1538, - /* 960 */ 1539, 656, 652, 1548, 1549, 1551, 1552, 1553, 1554, 2, - /* 970 */ 1641, 644, 1867, 536, 356, 1770, 2251, 544, 543, 2246, - /* 980 */ 644, 1867, 1409, 1412, 696, 690, 437, 1598, 1911, 641, - /* 990 */ 582, 1721, 1720, 2246, 535, 2250, 722, 720, 642, 2247, - /* 1000 */ 2248, 1920, 155, 154, 693, 692, 691, 152, 2252, 184, - /* 1010 */ 1161, 1162, 614, 2247, 608, 475, 1919, 577, 469, 468, + /* 0 */ 2083, 380, 393, 1982, 2247, 1909, 1911, 644, 1864, 165, + /* 10 */ 661, 1961, 46, 44, 1622, 379, 2069, 1866, 1979, 631, + /* 20 */ 388, 1498, 1471, 39, 38, 133, 2065, 45, 43, 42, + /* 30 */ 41, 40, 532, 1552, 123, 1469, 2101, 122, 121, 120, + /* 40 */ 119, 118, 117, 116, 115, 114, 36, 294, 2051, 1176, + /* 50 */ 660, 1175, 643, 427, 643, 192, 2083, 426, 1982, 1547, + /* 60 */ 2061, 2067, 369, 209, 226, 19, 661, 497, 2069, 1741, + /* 70 */ 167, 654, 1477, 1980, 631, 619, 140, 1809, 2065, 2082, + /* 80 */ 348, 1177, 168, 2118, 1710, 1855, 169, 2084, 664, 2086, + /* 90 */ 2087, 659, 2101, 654, 511, 2065, 1256, 749, 582, 211, + /* 100 */ 15, 2242, 1684, 497, 2051, 1741, 660, 619, 140, 1255, + /* 110 */ 46, 44, 2061, 2067, 370, 433, 2248, 184, 388, 499, + /* 120 */ 1471, 2243, 608, 654, 1581, 496, 583, 2208, 62, 2061, + /* 130 */ 2067, 1552, 49, 1469, 49, 2082, 1554, 1555, 2069, 2118, + /* 140 */ 654, 66, 110, 2084, 664, 2086, 2087, 659, 2065, 654, + /* 150 */ 1497, 1721, 143, 180, 150, 2142, 2171, 1547, 336, 1619, + /* 160 */ 382, 2167, 1176, 19, 1175, 1903, 1527, 1537, 1496, 275, + /* 170 */ 1477, 480, 1553, 1556, 273, 2179, 618, 1496, 134, 617, + /* 180 */ 1582, 2242, 2061, 2067, 383, 1720, 1472, 494, 1470, 1498, + /* 190 */ 495, 1734, 1961, 654, 1177, 749, 606, 184, 15, 2051, + /* 200 */ 502, 2243, 608, 495, 1734, 621, 182, 2179, 2180, 643, + /* 210 */ 138, 2184, 1475, 1476, 1698, 1526, 1529, 1530, 1531, 1532, + /* 220 */ 1533, 1534, 1535, 1536, 656, 652, 1545, 1546, 1548, 1549, + /* 230 */ 1550, 1551, 2, 2051, 1554, 1555, 194, 62, 132, 131, + /* 240 */ 130, 129, 128, 127, 126, 125, 124, 2019, 62, 1910, + /* 250 */ 1911, 35, 386, 1576, 1577, 1578, 1579, 1580, 1584, 1585, + /* 260 */ 1586, 1587, 32, 629, 1527, 1537, 1335, 1336, 39, 38, + /* 270 */ 1553, 1556, 45, 43, 42, 41, 40, 187, 1301, 602, + /* 280 */ 1696, 242, 177, 187, 1472, 241, 1470, 45, 43, 42, + /* 290 */ 41, 40, 244, 1292, 686, 685, 684, 1296, 683, 1298, + /* 300 */ 1299, 682, 679, 1966, 1307, 676, 1309, 1310, 673, 670, + /* 310 */ 1475, 1476, 1841, 1526, 1529, 1530, 1531, 1532, 1533, 1534, + /* 320 */ 1535, 1536, 656, 652, 1545, 1546, 1548, 1549, 1550, 1551, + /* 330 */ 2, 12, 46, 44, 1839, 227, 2070, 275, 644, 1864, + /* 340 */ 388, 1699, 1471, 90, 343, 2246, 2065, 365, 1154, 564, + /* 350 */ 401, 172, 1719, 1552, 400, 1469, 133, 528, 524, 520, + /* 360 */ 516, 224, 123, 537, 696, 122, 121, 120, 119, 118, + /* 370 */ 117, 116, 115, 114, 62, 548, 547, 546, 1245, 1547, + /* 380 */ 2061, 2067, 538, 137, 542, 19, 187, 1156, 541, 1159, + /* 390 */ 1160, 654, 1477, 540, 545, 582, 34, 187, 2242, 539, + /* 400 */ 2051, 88, 39, 38, 222, 1618, 45, 43, 42, 41, + /* 410 */ 40, 276, 2083, 2248, 184, 1247, 177, 749, 2243, 608, + /* 420 */ 15, 74, 661, 694, 155, 154, 691, 690, 689, 152, + /* 430 */ 46, 44, 1557, 1162, 107, 1496, 355, 1965, 388, 1495, + /* 440 */ 1471, 694, 155, 154, 691, 690, 689, 152, 2101, 50, + /* 450 */ 141, 1552, 62, 1469, 93, 1840, 1554, 1555, 1856, 425, + /* 460 */ 2051, 424, 660, 694, 155, 154, 691, 690, 689, 152, + /* 470 */ 82, 221, 215, 391, 2083, 630, 220, 1547, 507, 644, + /* 480 */ 1864, 162, 1718, 1717, 622, 423, 1527, 1537, 367, 1866, + /* 490 */ 1477, 2082, 1553, 1556, 213, 2118, 1914, 189, 111, 2084, + /* 500 */ 664, 2086, 2087, 659, 1495, 654, 1472, 646, 1470, 2143, + /* 510 */ 2101, 1716, 2171, 1916, 1916, 749, 2170, 2167, 47, 696, + /* 520 */ 353, 366, 2051, 187, 660, 509, 471, 1975, 1914, 1914, + /* 530 */ 2051, 2051, 1475, 1476, 1583, 1526, 1529, 1530, 1531, 1532, + /* 540 */ 1533, 1534, 1535, 1536, 656, 652, 1545, 1546, 1548, 1549, + /* 550 */ 1550, 1551, 2, 2082, 1554, 1555, 648, 2118, 2143, 2051, + /* 560 */ 110, 2084, 664, 2086, 2087, 659, 12, 654, 544, 543, + /* 570 */ 644, 1864, 181, 597, 2171, 1650, 619, 140, 382, 2167, + /* 580 */ 752, 1390, 1391, 106, 1527, 1537, 200, 199, 55, 607, + /* 590 */ 1553, 1556, 2242, 103, 301, 601, 644, 1864, 187, 2198, + /* 600 */ 571, 187, 243, 2186, 1472, 33, 1470, 606, 184, 470, + /* 610 */ 176, 610, 2243, 608, 431, 1588, 742, 738, 734, 730, + /* 620 */ 299, 2101, 594, 593, 1648, 1649, 1651, 1652, 1653, 2183, + /* 630 */ 1475, 1476, 1770, 1526, 1529, 1530, 1531, 1532, 1533, 1534, + /* 640 */ 1535, 1536, 656, 652, 1545, 1546, 1548, 1549, 1550, 1551, + /* 650 */ 2, 46, 44, 87, 2083, 1916, 603, 598, 591, 388, + /* 660 */ 108, 1471, 376, 292, 661, 619, 140, 1445, 1446, 357, + /* 670 */ 1914, 420, 1552, 600, 1469, 183, 2179, 2180, 1859, 138, + /* 680 */ 2184, 39, 38, 1496, 2186, 45, 43, 42, 41, 40, + /* 690 */ 2101, 644, 1864, 422, 418, 640, 644, 1864, 1547, 548, + /* 700 */ 547, 546, 2051, 2186, 660, 1477, 538, 137, 542, 432, + /* 710 */ 2182, 1477, 541, 12, 441, 10, 1961, 540, 545, 142, + /* 720 */ 39, 38, 2142, 539, 45, 43, 42, 41, 40, 2181, + /* 730 */ 279, 1916, 1499, 2082, 101, 278, 749, 2118, 381, 47, + /* 740 */ 170, 2084, 664, 2086, 2087, 659, 1914, 654, 1471, 46, + /* 750 */ 44, 1434, 2083, 247, 196, 391, 1715, 388, 1857, 1471, + /* 760 */ 198, 1469, 658, 165, 185, 2179, 2180, 1626, 138, 2184, + /* 770 */ 1552, 1866, 1469, 1496, 1661, 1554, 1555, 644, 1864, 39, + /* 780 */ 38, 644, 1864, 45, 43, 42, 41, 40, 2101, 687, + /* 790 */ 1497, 609, 2263, 165, 84, 456, 1547, 83, 1477, 457, + /* 800 */ 2051, 1867, 660, 1499, 2051, 1527, 1537, 688, 394, 1477, + /* 810 */ 1907, 1553, 1556, 562, 39, 38, 165, 1260, 45, 43, + /* 820 */ 42, 41, 40, 749, 1866, 1472, 560, 1470, 558, 1528, + /* 830 */ 1259, 2082, 644, 1864, 749, 2118, 630, 15, 330, 2084, + /* 840 */ 664, 2086, 2087, 659, 657, 654, 645, 2136, 611, 360, + /* 850 */ 510, 1475, 1476, 1714, 1526, 1529, 1530, 1531, 1532, 1533, + /* 860 */ 1534, 1535, 1536, 656, 652, 1545, 1546, 1548, 1549, 1550, + /* 870 */ 1551, 2, 1638, 1554, 1555, 87, 1853, 39, 38, 1916, + /* 880 */ 253, 45, 43, 42, 41, 40, 628, 709, 1975, 1826, + /* 890 */ 14, 13, 482, 339, 1915, 1494, 630, 9, 644, 1864, + /* 900 */ 1860, 2051, 464, 1527, 1537, 478, 1407, 1408, 477, 1553, + /* 910 */ 1556, 708, 1472, 28, 1470, 361, 1861, 359, 358, 1528, + /* 920 */ 534, 1744, 1713, 1472, 447, 1470, 479, 39, 38, 449, + /* 930 */ 1849, 45, 43, 42, 41, 40, 1499, 625, 1475, 1476, + /* 940 */ 251, 536, 1406, 1409, 2044, 535, 639, 1842, 1975, 1475, + /* 950 */ 1476, 193, 1526, 1529, 1530, 1531, 1532, 1533, 1534, 1535, + /* 960 */ 1536, 656, 652, 1545, 1546, 1548, 1549, 1550, 1551, 2, + /* 970 */ 2051, 744, 39, 38, 356, 1767, 45, 43, 42, 41, + /* 980 */ 40, 1562, 582, 91, 1691, 2242, 437, 1496, 1916, 582, + /* 990 */ 1595, 148, 2242, 644, 1864, 392, 644, 1864, 644, 1864, + /* 1000 */ 2248, 184, 52, 1914, 3, 2243, 608, 2248, 184, 2191, + /* 1010 */ 1615, 245, 2243, 608, 627, 475, 578, 1851, 469, 468, /* 1020 */ 467, 466, 463, 462, 461, 460, 459, 455, 454, 453, - /* 1030 */ 452, 338, 444, 443, 442, 2049, 439, 438, 354, 2055, - /* 1040 */ 2055, 248, 728, 727, 726, 725, 398, 1719, 724, 723, - /* 1050 */ 144, 718, 717, 716, 715, 714, 713, 712, 157, 708, - /* 1060 */ 707, 706, 397, 396, 703, 702, 701, 700, 699, 166, - /* 1070 */ 694, 2087, 1718, 1911, 314, 644, 1867, 1717, 1716, 1502, - /* 1080 */ 582, 622, 1715, 2246, 644, 1867, 2195, 1618, 312, 73, - /* 1090 */ 2074, 2087, 72, 295, 1712, 2055, 164, 1531, 2252, 184, - /* 1100 */ 2069, 661, 395, 2247, 608, 1711, 695, 2105, 1710, 1911, - /* 1110 */ 1760, 207, 490, 488, 485, 1709, 1483, 1708, 1707, 2055, - /* 1120 */ 2055, 660, 1753, 581, 1706, 2055, 2055, 2105, 308, 1845, - /* 1130 */ 2055, 1897, 549, 232, 2065, 2071, 230, 1705, 1704, 2055, - /* 1140 */ 234, 660, 2055, 233, 551, 654, 569, 711, 1714, 1829, - /* 1150 */ 2086, 62, 2041, 2055, 2122, 74, 2055, 110, 2088, 664, - /* 1160 */ 2090, 2091, 659, 2055, 654, 2055, 2055, 153, 1621, 181, - /* 1170 */ 2086, 2175, 2055, 148, 2122, 382, 2171, 169, 2088, 664, - /* 1180 */ 2090, 2091, 659, 153, 654, 2055, 2055, 2087, 186, 109, - /* 1190 */ 52, 582, 3, 146, 2246, 135, 2201, 661, 1751, 1746, - /* 1200 */ 236, 408, 238, 235, 82, 237, 566, 64, 565, 2252, - /* 1210 */ 184, 64, 251, 655, 2247, 608, 1696, 1697, 2213, 1482, - /* 1220 */ 554, 651, 257, 2105, 1443, 153, 48, 252, 270, 81, - /* 1230 */ 80, 430, 282, 71, 191, 2055, 2087, 660, 151, 153, - /* 1240 */ 1446, 615, 2215, 53, 64, 48, 661, 1747, 2209, 1813, - /* 1250 */ 14, 13, 2076, 337, 48, 91, 416, 668, 414, 410, - /* 1260 */ 406, 403, 423, 151, 1650, 225, 2086, 595, 1649, 1486, - /* 1270 */ 2122, 153, 2105, 110, 2088, 664, 2090, 2091, 659, 259, - /* 1280 */ 654, 136, 626, 1407, 2055, 2266, 660, 2175, 151, 287, - /* 1290 */ 636, 382, 2171, 106, 2087, 291, 1288, 746, 1208, 704, - /* 1300 */ 187, 1592, 1541, 103, 661, 2078, 2222, 264, 2106, 705, - /* 1310 */ 399, 307, 1974, 1738, 1316, 2086, 1908, 1743, 2205, 2122, - /* 1320 */ 1320, 1227, 110, 2088, 664, 2090, 2091, 659, 1327, 654, - /* 1330 */ 2105, 1225, 620, 272, 2266, 1209, 2175, 269, 1325, 1, - /* 1340 */ 382, 2171, 2055, 5, 660, 156, 402, 407, 352, 1430, - /* 1350 */ 302, 197, 2087, 436, 1502, 445, 440, 473, 1975, 1497, - /* 1360 */ 458, 472, 661, 1967, 589, 465, 474, 483, 1576, 484, - /* 1370 */ 481, 202, 1485, 2086, 486, 201, 487, 2122, 204, 489, - /* 1380 */ 110, 2088, 664, 2090, 2091, 659, 491, 654, 2105, 1503, - /* 1390 */ 492, 4, 2266, 493, 2175, 500, 2087, 501, 382, 2171, - /* 1400 */ 2055, 1505, 660, 503, 1500, 1504, 661, 1506, 2240, 212, - /* 1410 */ 505, 504, 214, 506, 217, 508, 512, 219, 85, 86, - /* 1420 */ 223, 1181, 529, 530, 2087, 533, 2032, 531, 2029, 112, - /* 1430 */ 1857, 2086, 2105, 2028, 661, 2122, 2194, 342, 110, 2088, - /* 1440 */ 664, 2090, 2091, 659, 2055, 654, 660, 568, 385, 384, - /* 1450 */ 2266, 229, 2175, 1853, 231, 158, 382, 2171, 1488, 570, - /* 1460 */ 2105, 89, 159, 246, 1855, 249, 1851, 160, 161, 1555, - /* 1470 */ 579, 1481, 2055, 572, 660, 2086, 596, 2221, 634, 2122, - /* 1480 */ 2206, 149, 110, 2088, 664, 2090, 2091, 659, 303, 654, - /* 1490 */ 576, 2216, 586, 592, 2266, 1550, 2175, 255, 8, 371, - /* 1500 */ 382, 2171, 258, 2086, 2220, 599, 2087, 2122, 1480, 573, - /* 1510 */ 110, 2088, 664, 2090, 2091, 659, 661, 654, 605, 173, - /* 1520 */ 587, 2087, 2266, 585, 2175, 584, 372, 268, 382, 2171, - /* 1530 */ 616, 661, 613, 650, 2197, 266, 263, 1618, 139, 1501, - /* 1540 */ 2191, 265, 2105, 624, 375, 277, 1507, 1980, 304, 632, - /* 1550 */ 96, 633, 1994, 1993, 2055, 267, 660, 2105, 1992, 378, - /* 1560 */ 305, 637, 638, 98, 1868, 61, 100, 2087, 2156, 2055, - /* 1570 */ 306, 660, 102, 1830, 309, 1912, 2245, 661, 2269, 666, - /* 1580 */ 271, 298, 747, 333, 748, 2086, 750, 51, 313, 2122, - /* 1590 */ 318, 2087, 324, 2088, 664, 2090, 2091, 659, 2047, 654, - /* 1600 */ 2086, 661, 332, 2105, 2122, 2046, 344, 110, 2088, 664, - /* 1610 */ 2090, 2091, 659, 311, 654, 2055, 322, 660, 2045, 2150, - /* 1620 */ 345, 2175, 1489, 2087, 1484, 382, 2171, 2105, 78, 2042, - /* 1630 */ 404, 1465, 405, 661, 1466, 604, 409, 190, 2040, 2055, - /* 1640 */ 413, 660, 411, 412, 2039, 415, 2086, 2038, 1492, 1494, - /* 1650 */ 2122, 417, 2037, 170, 2088, 664, 2090, 2091, 659, 2105, - /* 1660 */ 654, 652, 1548, 1549, 1551, 1552, 1553, 1554, 419, 2036, - /* 1670 */ 2086, 2055, 421, 660, 2122, 79, 1433, 110, 2088, 664, - /* 1680 */ 2090, 2091, 659, 1432, 654, 2006, 2005, 2004, 428, 2148, - /* 1690 */ 429, 2175, 2003, 2002, 2087, 382, 2171, 1958, 1384, 1957, - /* 1700 */ 1955, 145, 2086, 1954, 661, 2268, 2122, 1953, 1956, 110, - /* 1710 */ 2088, 664, 2090, 2091, 659, 1952, 654, 1951, 1949, 1948, - /* 1720 */ 1947, 647, 195, 2175, 2087, 446, 1946, 382, 2171, 448, - /* 1730 */ 2105, 1960, 1945, 1944, 661, 1943, 1942, 1941, 1940, 1939, - /* 1740 */ 1938, 1937, 2055, 1936, 660, 1935, 1934, 1933, 1932, 1931, - /* 1750 */ 1930, 147, 1929, 1928, 1959, 1927, 2087, 1926, 1925, 1924, - /* 1760 */ 2105, 1923, 476, 1922, 1386, 1921, 661, 1776, 1775, 340, - /* 1770 */ 203, 341, 2055, 2086, 660, 205, 1774, 2122, 1259, 1255, - /* 1780 */ 111, 2088, 664, 2090, 2091, 659, 1263, 654, 206, 1772, - /* 1790 */ 2087, 1733, 2105, 208, 2175, 1163, 1732, 2019, 649, 2171, - /* 1800 */ 661, 76, 2013, 662, 2055, 77, 660, 2122, 2001, 210, - /* 1810 */ 111, 2088, 664, 2090, 2091, 659, 178, 654, 2075, 216, - /* 1820 */ 179, 498, 218, 2000, 2175, 1978, 2105, 513, 347, 2171, - /* 1830 */ 1846, 377, 1771, 1769, 514, 2086, 1201, 515, 2055, 2122, - /* 1840 */ 660, 1767, 111, 2088, 664, 2090, 2091, 659, 2087, 654, - /* 1850 */ 517, 519, 518, 1765, 521, 522, 2175, 523, 658, 1763, - /* 1860 */ 526, 2172, 1750, 525, 1749, 2087, 1729, 1848, 527, 2086, - /* 1870 */ 1332, 1331, 1847, 2122, 1246, 661, 331, 2088, 664, 2090, - /* 1880 */ 2091, 659, 228, 654, 2105, 1245, 63, 1244, 719, 1243, - /* 1890 */ 1242, 721, 1239, 1238, 1761, 1237, 2055, 362, 660, 363, - /* 1900 */ 1236, 2105, 1754, 1752, 364, 555, 387, 552, 1728, 2087, - /* 1910 */ 1727, 557, 1726, 2055, 559, 660, 113, 561, 1453, 661, - /* 1920 */ 1455, 1452, 1457, 2018, 27, 1439, 67, 2086, 56, 2012, - /* 1930 */ 1999, 2122, 2087, 754, 330, 2088, 664, 2090, 2091, 659, - /* 1940 */ 574, 654, 661, 2141, 2086, 2105, 1997, 301, 2122, 250, - /* 1950 */ 389, 331, 2088, 664, 2090, 2091, 659, 2055, 654, 660, - /* 1960 */ 2251, 575, 368, 176, 20, 580, 17, 6, 2105, 744, - /* 1970 */ 740, 736, 732, 299, 29, 163, 7, 590, 588, 1666, - /* 1980 */ 2055, 2087, 660, 59, 254, 60, 261, 171, 2086, 256, - /* 1990 */ 1648, 661, 2122, 260, 262, 331, 2088, 664, 2090, 2091, - /* 2000 */ 659, 30, 654, 2076, 31, 1640, 92, 65, 1686, 22, - /* 2010 */ 1687, 567, 1681, 108, 1680, 2122, 292, 2105, 326, 2088, - /* 2020 */ 664, 2090, 2091, 659, 373, 654, 1685, 1684, 374, 2055, - /* 2030 */ 274, 660, 1615, 1614, 57, 21, 18, 2087, 58, 1998, - /* 2040 */ 1996, 1995, 174, 1977, 94, 95, 280, 661, 640, 23, - /* 2050 */ 1976, 281, 1646, 2087, 283, 288, 293, 97, 103, 68, - /* 2060 */ 2086, 290, 635, 661, 2122, 24, 99, 315, 2088, 664, - /* 2070 */ 2090, 2091, 659, 2105, 654, 1490, 1567, 11, 1566, 13, - /* 2080 */ 1577, 2125, 653, 279, 37, 2055, 1545, 660, 278, 2105, - /* 2090 */ 1522, 1543, 175, 188, 667, 390, 671, 1542, 16, 665, - /* 2100 */ 25, 2055, 1514, 660, 1437, 26, 247, 674, 1317, 2087, - /* 2110 */ 669, 663, 1314, 672, 677, 1311, 2086, 1305, 680, 661, - /* 2120 */ 2122, 1303, 675, 316, 2088, 664, 2090, 2091, 659, 678, - /* 2130 */ 654, 681, 2086, 1294, 104, 1309, 2122, 296, 1308, 317, - /* 2140 */ 2088, 664, 2090, 2091, 659, 2105, 654, 1307, 1306, 687, - /* 2150 */ 1326, 105, 75, 1322, 1233, 1199, 697, 2055, 2087, 660, - /* 2160 */ 1232, 1231, 1230, 1229, 1228, 1226, 1253, 1224, 661, 1223, - /* 2170 */ 1222, 2087, 709, 1220, 1219, 1218, 1217, 297, 1216, 1215, - /* 2180 */ 1214, 661, 1250, 1248, 1211, 1210, 1207, 1206, 2086, 1205, - /* 2190 */ 1204, 1768, 2122, 1766, 2105, 323, 2088, 664, 2090, 2091, - /* 2200 */ 659, 729, 654, 731, 733, 730, 2055, 2105, 660, 734, - /* 2210 */ 735, 1764, 737, 739, 738, 1762, 741, 742, 743, 2055, - /* 2220 */ 1748, 660, 745, 1153, 1725, 300, 749, 1700, 1476, 752, - /* 2230 */ 2087, 310, 753, 1700, 1700, 1700, 1700, 2086, 1700, 1700, - /* 2240 */ 661, 2122, 1700, 1700, 327, 2088, 664, 2090, 2091, 659, - /* 2250 */ 2086, 654, 1700, 1700, 2122, 1700, 1700, 319, 2088, 664, - /* 2260 */ 2090, 2091, 659, 1700, 654, 1700, 2105, 1700, 1700, 1700, - /* 2270 */ 1700, 1700, 1700, 1700, 2087, 1700, 1700, 1700, 2055, 1700, - /* 2280 */ 660, 1700, 1700, 1700, 661, 1700, 1700, 1700, 1700, 2087, - /* 2290 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 661, - /* 2300 */ 1700, 1700, 2087, 1700, 1700, 1700, 1700, 1700, 1700, 2086, - /* 2310 */ 2105, 1700, 661, 2122, 1700, 1700, 328, 2088, 664, 2090, - /* 2320 */ 2091, 659, 2055, 654, 660, 2105, 1700, 1700, 1700, 1700, - /* 2330 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 2055, 2105, 660, - /* 2340 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 2087, 1700, - /* 2350 */ 2055, 1700, 660, 2086, 1700, 1700, 1700, 2122, 661, 1700, - /* 2360 */ 320, 2088, 664, 2090, 2091, 659, 1700, 654, 2086, 1700, - /* 2370 */ 1700, 1700, 2122, 1700, 1700, 329, 2088, 664, 2090, 2091, - /* 2380 */ 659, 2086, 654, 1700, 2105, 2122, 1700, 227, 321, 2088, - /* 2390 */ 664, 2090, 2091, 659, 1700, 654, 2055, 1700, 660, 1700, - /* 2400 */ 1700, 1700, 1700, 172, 2087, 1700, 1700, 1700, 1700, 528, - /* 2410 */ 524, 520, 516, 224, 661, 1700, 1700, 1700, 1700, 2087, - /* 2420 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 2086, 1700, 661, - /* 2430 */ 1700, 2122, 1700, 1700, 334, 2088, 664, 2090, 2091, 659, - /* 2440 */ 2105, 654, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, - /* 2450 */ 1700, 1700, 2055, 88, 660, 2105, 222, 1700, 1700, 1700, - /* 2460 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 2055, 2087, 660, - /* 2470 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 661, 1700, - /* 2480 */ 1700, 1700, 1700, 2086, 1700, 1700, 1700, 2122, 1700, 2087, - /* 2490 */ 335, 2088, 664, 2090, 2091, 659, 1700, 654, 2086, 661, - /* 2500 */ 1700, 1700, 2122, 1700, 2105, 2099, 2088, 664, 2090, 2091, - /* 2510 */ 659, 1700, 654, 1700, 1700, 1700, 2055, 1700, 660, 1700, - /* 2520 */ 1700, 1700, 1700, 221, 215, 2105, 1700, 1700, 220, 1700, - /* 2530 */ 507, 1700, 1700, 1700, 1700, 1700, 1700, 2055, 2087, 660, - /* 2540 */ 1700, 1700, 1700, 1700, 1700, 1700, 213, 2086, 661, 1700, - /* 2550 */ 1700, 2122, 1700, 2087, 2098, 2088, 664, 2090, 2091, 659, - /* 2560 */ 1700, 654, 1700, 661, 1700, 1700, 1700, 1700, 2086, 1700, - /* 2570 */ 1700, 1700, 2122, 1700, 2105, 2097, 2088, 664, 2090, 2091, - /* 2580 */ 659, 1700, 654, 1700, 1700, 1700, 2055, 1700, 660, 2105, - /* 2590 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, - /* 2600 */ 1700, 2055, 1700, 660, 1700, 1700, 1700, 1700, 1700, 1700, - /* 2610 */ 1700, 1700, 2087, 1700, 1700, 1700, 1700, 2086, 1700, 1700, - /* 2620 */ 1700, 2122, 661, 1700, 349, 2088, 664, 2090, 2091, 659, - /* 2630 */ 1700, 654, 2086, 1700, 1700, 1700, 2122, 1700, 1700, 350, - /* 2640 */ 2088, 664, 2090, 2091, 659, 1700, 654, 1700, 2105, 1700, - /* 2650 */ 1700, 1700, 1700, 1700, 1700, 1700, 2087, 1700, 1700, 1700, - /* 2660 */ 2055, 1700, 660, 1700, 1700, 1700, 661, 1700, 1700, 1700, - /* 2670 */ 1700, 2087, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, - /* 2680 */ 1700, 661, 1700, 1700, 2087, 1700, 1700, 1700, 1700, 1700, - /* 2690 */ 1700, 2086, 2105, 1700, 661, 2122, 1700, 1700, 346, 2088, - /* 2700 */ 664, 2090, 2091, 659, 2055, 654, 660, 2105, 1700, 1700, - /* 2710 */ 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 2055, - /* 2720 */ 2105, 660, 1700, 1700, 1700, 1700, 1700, 1700, 1700, 1700, - /* 2730 */ 1700, 1700, 2055, 1700, 660, 2086, 1700, 1700, 1700, 2122, - /* 2740 */ 1700, 1700, 351, 2088, 664, 2090, 2091, 659, 1700, 654, - /* 2750 */ 662, 1700, 1700, 1700, 2122, 1700, 1700, 326, 2088, 664, - /* 2760 */ 2090, 2091, 659, 2086, 654, 1700, 1700, 2122, 1700, 1700, - /* 2770 */ 325, 2088, 664, 2090, 2091, 659, 1700, 654, + /* 1030 */ 452, 338, 444, 443, 442, 1847, 439, 438, 354, 42, + /* 1040 */ 41, 40, 726, 725, 724, 723, 398, 1946, 722, 721, + /* 1050 */ 144, 716, 715, 714, 713, 712, 711, 710, 157, 706, + /* 1060 */ 705, 704, 397, 396, 701, 700, 699, 698, 697, 166, + /* 1070 */ 553, 2083, 644, 1864, 314, 612, 644, 1864, 1712, 607, + /* 1080 */ 1690, 622, 2242, 1709, 252, 563, 644, 1864, 312, 73, + /* 1090 */ 295, 2083, 72, 1868, 623, 285, 286, 606, 184, 240, + /* 1100 */ 284, 661, 2243, 608, 289, 2247, 1615, 2101, 2242, 720, + /* 1110 */ 718, 207, 490, 488, 485, 556, 644, 1864, 1708, 2051, + /* 1120 */ 550, 660, 644, 1864, 2246, 239, 2051, 2101, 2243, 2245, + /* 1130 */ 434, 2051, 164, 1528, 641, 1159, 1160, 644, 1864, 2051, + /* 1140 */ 642, 660, 614, 435, 1707, 1706, 2045, 1705, 1480, 536, + /* 1150 */ 2082, 62, 1704, 535, 2118, 395, 569, 110, 2084, 664, + /* 1160 */ 2086, 2087, 659, 2037, 654, 70, 2051, 1479, 69, 181, + /* 1170 */ 2082, 2171, 577, 1703, 2118, 382, 2167, 169, 2084, 664, + /* 1180 */ 2086, 2087, 659, 692, 654, 1702, 1907, 2083, 186, 109, + /* 1190 */ 1701, 582, 2051, 2051, 2242, 2051, 2197, 661, 153, 1743, + /* 1200 */ 2051, 582, 451, 693, 2242, 308, 1907, 1810, 1893, 2248, + /* 1210 */ 184, 450, 408, 232, 2243, 608, 230, 581, 2209, 2248, + /* 1220 */ 184, 2051, 651, 2101, 2243, 608, 146, 1711, 135, 81, + /* 1230 */ 80, 430, 1757, 2051, 191, 2051, 2083, 660, 2051, 234, + /* 1240 */ 236, 153, 233, 235, 2247, 153, 661, 2242, 2205, 238, + /* 1250 */ 64, 64, 237, 337, 549, 54, 416, 1750, 414, 410, + /* 1260 */ 406, 403, 423, 2246, 257, 2072, 2082, 2243, 2244, 248, + /* 1270 */ 2118, 1748, 2101, 110, 2084, 664, 2086, 2087, 659, 551, + /* 1280 */ 654, 566, 153, 565, 2051, 2262, 660, 2171, 1693, 1694, + /* 1290 */ 48, 382, 2167, 554, 2083, 655, 282, 71, 1440, 151, + /* 1300 */ 187, 1483, 1443, 153, 661, 270, 2218, 1647, 1646, 14, + /* 1310 */ 13, 64, 1206, 48, 2211, 2082, 595, 48, 2074, 2118, + /* 1320 */ 1482, 259, 110, 2084, 664, 2086, 2087, 659, 225, 654, + /* 1330 */ 2101, 264, 668, 151, 2262, 702, 2171, 53, 153, 626, + /* 1340 */ 382, 2167, 2051, 703, 660, 2102, 136, 1404, 151, 1207, + /* 1350 */ 399, 1970, 2083, 287, 636, 1735, 291, 1225, 1740, 1904, + /* 1360 */ 1286, 2201, 661, 620, 589, 1223, 272, 269, 1589, 1573, + /* 1370 */ 1538, 615, 5, 2082, 307, 1, 407, 2118, 402, 352, + /* 1380 */ 110, 2084, 664, 2086, 2087, 659, 1427, 654, 2101, 1313, + /* 1390 */ 1317, 302, 2262, 197, 2171, 1324, 2083, 436, 382, 2167, + /* 1400 */ 2051, 1499, 660, 1322, 1971, 156, 661, 473, 2236, 440, + /* 1410 */ 445, 1494, 458, 1963, 465, 472, 474, 483, 202, 484, + /* 1420 */ 481, 201, 204, 486, 2083, 487, 489, 491, 1500, 492, + /* 1430 */ 4, 2082, 2101, 1502, 661, 2118, 2190, 493, 110, 2084, + /* 1440 */ 664, 2086, 2087, 659, 2051, 654, 660, 500, 385, 384, + /* 1450 */ 2262, 503, 2171, 501, 212, 1497, 382, 2167, 1485, 214, + /* 1460 */ 2101, 504, 1501, 1503, 505, 217, 508, 506, 219, 1552, + /* 1470 */ 512, 1478, 2051, 85, 660, 2082, 86, 223, 529, 2118, + /* 1480 */ 1179, 531, 110, 2084, 664, 2086, 2087, 659, 530, 654, + /* 1490 */ 533, 2028, 568, 1854, 2262, 1547, 2171, 342, 229, 89, + /* 1500 */ 382, 2167, 112, 2082, 1850, 231, 2083, 2118, 1477, 158, + /* 1510 */ 110, 2084, 664, 2086, 2087, 659, 661, 654, 159, 2025, + /* 1520 */ 1852, 2083, 2262, 1848, 2171, 160, 161, 570, 382, 2167, + /* 1530 */ 572, 661, 303, 650, 2024, 246, 579, 249, 2202, 2212, + /* 1540 */ 586, 149, 2101, 573, 596, 8, 576, 2217, 605, 592, + /* 1550 */ 634, 2216, 371, 599, 2051, 263, 660, 2101, 2193, 173, + /* 1560 */ 255, 258, 584, 587, 585, 372, 265, 2083, 267, 2051, + /* 1570 */ 616, 660, 268, 2265, 1615, 2241, 613, 661, 139, 1498, + /* 1580 */ 624, 375, 1504, 632, 1976, 2082, 637, 2187, 304, 2118, + /* 1590 */ 277, 2083, 324, 2084, 664, 2086, 2087, 659, 633, 654, + /* 1600 */ 2082, 661, 96, 2101, 2118, 271, 1990, 110, 2084, 664, + /* 1610 */ 2086, 2087, 659, 1989, 654, 2051, 305, 660, 266, 2146, + /* 1620 */ 1988, 2171, 1486, 2083, 1481, 382, 2167, 2101, 378, 98, + /* 1630 */ 100, 306, 61, 661, 638, 604, 102, 1865, 1827, 2051, + /* 1640 */ 1908, 660, 2152, 666, 745, 309, 2082, 298, 1489, 1491, + /* 1650 */ 2118, 746, 51, 170, 2084, 664, 2086, 2087, 659, 2101, + /* 1660 */ 654, 652, 1545, 1546, 1548, 1549, 1550, 1551, 748, 333, + /* 1670 */ 2082, 2051, 318, 660, 2118, 344, 332, 110, 2084, 664, + /* 1680 */ 2086, 2087, 659, 311, 654, 313, 322, 2043, 2042, 2144, + /* 1690 */ 2041, 2171, 2038, 78, 2083, 382, 2167, 404, 345, 405, + /* 1700 */ 1462, 1463, 2082, 190, 661, 2264, 2118, 409, 2036, 110, + /* 1710 */ 2084, 664, 2086, 2087, 659, 411, 654, 412, 413, 2035, + /* 1720 */ 415, 647, 2034, 2171, 2083, 419, 417, 382, 2167, 2033, + /* 1730 */ 2101, 2032, 421, 79, 661, 1430, 1429, 2002, 2001, 2000, + /* 1740 */ 428, 429, 2051, 1999, 660, 1998, 1381, 1954, 1953, 1951, + /* 1750 */ 1950, 145, 1949, 1952, 1948, 1947, 2083, 1945, 1944, 1943, + /* 1760 */ 2101, 195, 446, 1942, 448, 1956, 661, 1941, 1940, 1939, + /* 1770 */ 1938, 1937, 2051, 2082, 660, 1936, 1935, 2118, 1934, 1933, + /* 1780 */ 111, 2084, 664, 2086, 2087, 659, 1932, 654, 1931, 1930, + /* 1790 */ 2083, 1929, 2101, 1928, 2171, 1927, 1926, 1925, 649, 2167, + /* 1800 */ 661, 1924, 147, 662, 2051, 1955, 660, 2118, 1923, 1922, + /* 1810 */ 111, 2084, 664, 2086, 2087, 659, 1383, 654, 1921, 1920, + /* 1820 */ 1919, 1918, 476, 1917, 2171, 1257, 2101, 1773, 347, 2167, + /* 1830 */ 340, 377, 1261, 341, 1253, 2082, 203, 1772, 2051, 2118, + /* 1840 */ 660, 1771, 111, 2084, 664, 2086, 2087, 659, 2083, 654, + /* 1850 */ 1769, 205, 1730, 208, 76, 1729, 2171, 206, 658, 2071, + /* 1860 */ 178, 2168, 1161, 2015, 179, 2083, 210, 77, 2009, 2082, + /* 1870 */ 1997, 498, 216, 2118, 1996, 661, 331, 2084, 664, 2086, + /* 1880 */ 2087, 659, 218, 654, 2101, 1974, 1843, 1768, 1199, 1766, + /* 1890 */ 515, 513, 514, 1764, 517, 518, 2051, 519, 660, 1762, + /* 1900 */ 521, 2101, 522, 523, 1760, 527, 387, 525, 1747, 2083, + /* 1910 */ 526, 1746, 1726, 2051, 1845, 660, 63, 1329, 1328, 661, + /* 1920 */ 228, 1844, 717, 1244, 719, 1243, 1242, 2082, 1235, 1241, + /* 1930 */ 1240, 2118, 2083, 1237, 330, 2084, 664, 2086, 2087, 659, + /* 1940 */ 1236, 654, 661, 2137, 2082, 2101, 1758, 1751, 2118, 362, + /* 1950 */ 389, 331, 2084, 664, 2086, 2087, 659, 2051, 654, 660, + /* 1960 */ 1234, 363, 1749, 364, 552, 555, 1725, 557, 2101, 1724, + /* 1970 */ 559, 1723, 561, 1450, 113, 1452, 1454, 1449, 2014, 1436, + /* 1980 */ 2051, 2083, 660, 27, 67, 2008, 574, 1995, 2082, 163, + /* 1990 */ 1993, 661, 2118, 56, 2083, 331, 2084, 664, 2086, 2087, + /* 2000 */ 659, 250, 654, 575, 661, 2247, 368, 580, 1663, 20, + /* 2010 */ 29, 567, 59, 588, 17, 2118, 254, 2101, 326, 2084, + /* 2020 */ 664, 2086, 2087, 659, 6, 654, 60, 7, 171, 2051, + /* 2030 */ 2101, 660, 590, 261, 256, 1645, 21, 31, 262, 2072, + /* 2040 */ 65, 1678, 2051, 2083, 660, 260, 1677, 22, 30, 373, + /* 2050 */ 1637, 92, 1682, 661, 1681, 18, 2083, 1683, 1684, 374, + /* 2060 */ 2082, 1612, 1611, 274, 2118, 58, 661, 315, 2084, 664, + /* 2070 */ 2086, 2087, 659, 2082, 654, 174, 57, 2118, 1994, 2101, + /* 2080 */ 316, 2084, 664, 2086, 2087, 659, 1992, 654, 1991, 1973, + /* 2090 */ 95, 2051, 2101, 660, 94, 280, 23, 635, 1972, 281, + /* 2100 */ 1643, 283, 97, 293, 2051, 2083, 660, 288, 68, 99, + /* 2110 */ 103, 24, 290, 1564, 13, 661, 1563, 1487, 175, 188, + /* 2120 */ 2121, 1574, 2082, 1542, 1540, 653, 2118, 37, 1519, 317, + /* 2130 */ 2084, 664, 2086, 2087, 659, 2082, 654, 11, 16, 2118, + /* 2140 */ 1539, 2101, 323, 2084, 664, 2086, 2087, 659, 1511, 654, + /* 2150 */ 25, 665, 26, 2051, 1314, 660, 667, 390, 669, 671, + /* 2160 */ 1311, 2083, 672, 674, 677, 1308, 663, 1302, 675, 678, + /* 2170 */ 680, 661, 1323, 1319, 1300, 681, 2083, 1306, 296, 1305, + /* 2180 */ 104, 1197, 1304, 1303, 2082, 105, 661, 75, 2118, 1231, + /* 2190 */ 695, 327, 2084, 664, 2086, 2087, 659, 2101, 654, 1230, + /* 2200 */ 1229, 1228, 1227, 1226, 1224, 1222, 1221, 1220, 1251, 2051, + /* 2210 */ 2083, 660, 2101, 707, 1218, 1217, 1216, 297, 1215, 1214, + /* 2220 */ 661, 1213, 1212, 1246, 2051, 1248, 660, 1209, 1208, 1205, + /* 2230 */ 1204, 1203, 1202, 1765, 727, 1763, 731, 729, 1761, 728, + /* 2240 */ 2082, 733, 735, 1759, 2118, 737, 2101, 319, 2084, 664, + /* 2250 */ 2086, 2087, 659, 732, 654, 2082, 739, 736, 2051, 2118, + /* 2260 */ 660, 740, 328, 2084, 664, 2086, 2087, 659, 2083, 654, + /* 2270 */ 741, 1745, 743, 1722, 1151, 300, 747, 750, 661, 1473, + /* 2280 */ 310, 751, 1697, 1697, 2083, 1697, 1697, 1697, 1697, 2082, + /* 2290 */ 1697, 1697, 1697, 2118, 661, 1697, 320, 2084, 664, 2086, + /* 2300 */ 2087, 659, 1697, 654, 2101, 1697, 1697, 1697, 1697, 1697, + /* 2310 */ 1697, 1697, 2083, 1697, 1697, 1697, 2051, 1697, 660, 1697, + /* 2320 */ 2101, 1697, 661, 1697, 1697, 1697, 1697, 1697, 2083, 1697, + /* 2330 */ 1697, 1697, 2051, 1697, 660, 1697, 1697, 1697, 661, 1697, + /* 2340 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2082, 2101, 1697, + /* 2350 */ 1697, 2118, 1697, 1697, 329, 2084, 664, 2086, 2087, 659, + /* 2360 */ 2051, 654, 660, 2082, 2101, 1697, 1697, 2118, 1697, 1697, + /* 2370 */ 321, 2084, 664, 2086, 2087, 659, 2051, 654, 660, 1697, + /* 2380 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2390 */ 1697, 2082, 1697, 1697, 1697, 2118, 2083, 1697, 334, 2084, + /* 2400 */ 664, 2086, 2087, 659, 1697, 654, 661, 2082, 1697, 1697, + /* 2410 */ 1697, 2118, 2083, 1697, 335, 2084, 664, 2086, 2087, 659, + /* 2420 */ 1697, 654, 661, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2430 */ 1697, 1697, 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2440 */ 1697, 1697, 1697, 1697, 2051, 1697, 660, 1697, 2101, 1697, + /* 2450 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2083, 1697, + /* 2460 */ 2051, 1697, 660, 1697, 1697, 1697, 1697, 1697, 661, 1697, + /* 2470 */ 1697, 2083, 1697, 1697, 1697, 2082, 1697, 1697, 1697, 2118, + /* 2480 */ 1697, 661, 2095, 2084, 664, 2086, 2087, 659, 1697, 654, + /* 2490 */ 1697, 2082, 1697, 1697, 2101, 2118, 1697, 1697, 2094, 2084, + /* 2500 */ 664, 2086, 2087, 659, 1697, 654, 2051, 2101, 660, 1697, + /* 2510 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2051, + /* 2520 */ 2083, 660, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2530 */ 661, 1697, 1697, 1697, 1697, 1697, 1697, 2082, 1697, 1697, + /* 2540 */ 1697, 2118, 2083, 1697, 2093, 2084, 664, 2086, 2087, 659, + /* 2550 */ 2082, 654, 661, 1697, 2118, 1697, 2101, 349, 2084, 664, + /* 2560 */ 2086, 2087, 659, 1697, 654, 1697, 1697, 1697, 2051, 1697, + /* 2570 */ 660, 1697, 1697, 1697, 1697, 1697, 2083, 1697, 2101, 1697, + /* 2580 */ 1697, 1697, 1697, 1697, 1697, 1697, 661, 1697, 1697, 1697, + /* 2590 */ 2051, 2083, 660, 1697, 1697, 1697, 1697, 1697, 1697, 2082, + /* 2600 */ 1697, 661, 1697, 2118, 1697, 1697, 350, 2084, 664, 2086, + /* 2610 */ 2087, 659, 2101, 654, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2620 */ 1697, 2082, 1697, 1697, 2051, 2118, 660, 2101, 346, 2084, + /* 2630 */ 664, 2086, 2087, 659, 1697, 654, 1697, 1697, 1697, 2051, + /* 2640 */ 1697, 660, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2650 */ 2083, 1697, 1697, 1697, 1697, 2082, 1697, 1697, 1697, 2118, + /* 2660 */ 661, 1697, 351, 2084, 664, 2086, 2087, 659, 1697, 654, + /* 2670 */ 662, 1697, 1697, 1697, 2118, 1697, 1697, 326, 2084, 664, + /* 2680 */ 2086, 2087, 659, 1697, 654, 1697, 2101, 1697, 1697, 1697, + /* 2690 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2051, 1697, + /* 2700 */ 660, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2710 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, + /* 2720 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2082, + /* 2730 */ 1697, 1697, 1697, 2118, 1697, 1697, 325, 2084, 664, 2086, + /* 2740 */ 2087, 659, 1697, 654, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 331, 335, 367, 381, 338, 339, 368, 340, 341, 374, - /* 10 */ 341, 341, 12, 13, 14, 393, 369, 382, 396, 397, - /* 20 */ 20, 341, 22, 8, 9, 358, 379, 12, 13, 14, + /* 0 */ 331, 359, 377, 381, 3, 380, 381, 340, 341, 367, + /* 10 */ 341, 341, 12, 13, 14, 393, 369, 375, 396, 397, + /* 20 */ 20, 20, 22, 8, 9, 358, 379, 12, 13, 14, /* 30 */ 15, 16, 365, 33, 21, 35, 367, 24, 25, 26, - /* 40 */ 27, 28, 29, 30, 31, 32, 14, 367, 379, 20, - /* 50 */ 381, 22, 20, 398, 381, 385, 331, 402, 369, 59, - /* 60 */ 413, 414, 415, 4, 35, 65, 341, 64, 379, 396, - /* 70 */ 397, 424, 72, 366, 335, 340, 341, 338, 339, 410, - /* 80 */ 65, 52, 35, 414, 20, 378, 417, 418, 419, 420, - /* 90 */ 421, 422, 367, 424, 367, 20, 22, 97, 443, 419, - /* 100 */ 100, 446, 413, 414, 379, 20, 381, 340, 341, 35, - /* 110 */ 12, 13, 22, 424, 387, 388, 461, 462, 20, 72, - /* 120 */ 22, 466, 467, 349, 109, 35, 457, 458, 336, 328, - /* 130 */ 356, 33, 340, 35, 342, 410, 136, 137, 369, 414, - /* 140 */ 0, 341, 417, 418, 419, 420, 421, 422, 379, 424, - /* 150 */ 4, 330, 427, 332, 429, 430, 431, 59, 100, 100, - /* 160 */ 435, 436, 72, 65, 100, 336, 166, 167, 20, 340, - /* 170 */ 72, 342, 172, 173, 439, 440, 441, 20, 443, 444, - /* 180 */ 165, 446, 413, 414, 415, 385, 186, 97, 188, 43, - /* 190 */ 20, 45, 46, 424, 369, 97, 461, 462, 100, 398, - /* 200 */ 20, 466, 467, 402, 379, 438, 439, 440, 441, 0, + /* 40 */ 27, 28, 29, 30, 31, 32, 432, 433, 379, 20, + /* 50 */ 381, 22, 20, 398, 20, 385, 331, 402, 381, 59, + /* 60 */ 413, 414, 415, 336, 35, 65, 341, 340, 369, 342, + /* 70 */ 349, 424, 72, 396, 397, 340, 341, 356, 379, 410, + /* 80 */ 65, 52, 330, 414, 332, 369, 417, 418, 419, 420, + /* 90 */ 421, 422, 367, 424, 64, 379, 22, 97, 443, 336, + /* 100 */ 100, 446, 101, 340, 379, 342, 381, 340, 341, 35, + /* 110 */ 12, 13, 413, 414, 415, 340, 461, 462, 20, 14, + /* 120 */ 22, 466, 467, 424, 109, 20, 457, 458, 100, 413, + /* 130 */ 414, 33, 100, 35, 100, 410, 136, 137, 369, 414, + /* 140 */ 424, 4, 417, 418, 419, 420, 421, 422, 379, 424, + /* 150 */ 20, 331, 427, 366, 429, 430, 431, 59, 383, 4, + /* 160 */ 435, 436, 20, 65, 22, 378, 166, 167, 20, 168, + /* 170 */ 72, 97, 172, 173, 439, 440, 441, 20, 443, 444, + /* 180 */ 165, 446, 413, 414, 415, 331, 186, 335, 188, 20, + /* 190 */ 338, 339, 341, 424, 52, 97, 461, 462, 100, 379, + /* 200 */ 335, 466, 467, 338, 339, 438, 439, 440, 441, 20, /* 210 */ 443, 444, 212, 213, 0, 215, 216, 217, 218, 219, /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - /* 230 */ 230, 231, 232, 377, 136, 137, 380, 381, 413, 414, - /* 240 */ 415, 166, 167, 185, 443, 187, 64, 446, 100, 424, - /* 250 */ 348, 236, 237, 238, 239, 240, 241, 242, 243, 244, - /* 260 */ 245, 246, 461, 462, 166, 167, 364, 466, 467, 211, - /* 270 */ 172, 173, 367, 64, 443, 373, 186, 446, 188, 374, - /* 280 */ 100, 67, 68, 69, 186, 14, 188, 382, 74, 75, - /* 290 */ 76, 20, 461, 462, 80, 155, 212, 466, 467, 85, - /* 300 */ 86, 20, 212, 213, 164, 91, 363, 249, 249, 20, + /* 230 */ 230, 231, 232, 379, 136, 137, 385, 100, 24, 25, + /* 240 */ 26, 27, 28, 29, 30, 31, 32, 363, 100, 380, + /* 250 */ 381, 236, 237, 238, 239, 240, 241, 242, 243, 244, + /* 260 */ 245, 246, 2, 20, 166, 167, 136, 137, 8, 9, + /* 270 */ 172, 173, 12, 13, 14, 15, 16, 249, 97, 20, + /* 280 */ 328, 131, 367, 249, 186, 135, 188, 12, 13, 14, + /* 290 */ 15, 16, 408, 112, 113, 114, 115, 116, 117, 118, + /* 300 */ 119, 120, 121, 388, 123, 124, 125, 126, 127, 128, /* 310 */ 212, 213, 0, 215, 216, 217, 218, 219, 220, 221, /* 320 */ 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, - /* 330 */ 232, 233, 12, 13, 340, 341, 340, 341, 112, 331, - /* 340 */ 20, 0, 22, 259, 260, 261, 262, 263, 264, 265, - /* 350 */ 398, 408, 358, 33, 358, 35, 130, 131, 132, 133, - /* 360 */ 134, 135, 21, 340, 20, 24, 25, 26, 27, 28, - /* 370 */ 29, 30, 31, 32, 12, 13, 14, 15, 16, 59, - /* 380 */ 59, 67, 68, 69, 130, 65, 367, 379, 74, 75, - /* 390 */ 76, 111, 72, 374, 80, 443, 14, 249, 446, 85, - /* 400 */ 86, 382, 20, 8, 9, 91, 383, 12, 13, 14, - /* 410 */ 15, 16, 331, 461, 462, 416, 3, 97, 466, 467, - /* 420 */ 100, 100, 341, 102, 112, 136, 137, 340, 341, 249, - /* 430 */ 12, 13, 14, 20, 340, 341, 171, 166, 20, 0, - /* 440 */ 22, 442, 130, 131, 132, 133, 134, 135, 367, 195, - /* 450 */ 196, 33, 358, 35, 340, 341, 136, 137, 100, 365, - /* 460 */ 379, 340, 381, 24, 25, 26, 27, 28, 29, 30, - /* 470 */ 31, 32, 358, 340, 331, 8, 9, 59, 233, 12, - /* 480 */ 13, 14, 15, 16, 341, 341, 166, 167, 359, 367, - /* 490 */ 72, 410, 172, 173, 22, 414, 367, 375, 417, 418, - /* 500 */ 419, 420, 421, 422, 375, 424, 186, 35, 188, 20, - /* 510 */ 367, 390, 431, 392, 101, 97, 435, 436, 100, 254, - /* 520 */ 255, 256, 379, 390, 381, 392, 439, 440, 441, 385, - /* 530 */ 443, 444, 212, 213, 348, 215, 216, 217, 218, 219, + /* 330 */ 232, 233, 12, 13, 0, 33, 369, 168, 340, 341, + /* 340 */ 20, 0, 22, 193, 194, 3, 379, 197, 4, 199, + /* 350 */ 398, 49, 331, 33, 402, 35, 358, 55, 56, 57, + /* 360 */ 58, 59, 21, 365, 64, 24, 25, 26, 27, 28, + /* 370 */ 29, 30, 31, 32, 100, 67, 68, 69, 35, 59, + /* 380 */ 413, 414, 74, 75, 76, 65, 249, 43, 80, 45, + /* 390 */ 46, 424, 72, 85, 86, 443, 2, 249, 446, 91, + /* 400 */ 379, 99, 8, 9, 102, 250, 12, 13, 14, 15, + /* 410 */ 16, 59, 331, 461, 462, 72, 367, 97, 466, 467, + /* 420 */ 100, 111, 341, 129, 130, 131, 132, 133, 134, 135, + /* 430 */ 12, 13, 14, 14, 346, 20, 387, 388, 20, 20, + /* 440 */ 22, 129, 130, 131, 132, 133, 134, 135, 367, 100, + /* 450 */ 362, 33, 100, 35, 102, 0, 136, 137, 370, 185, + /* 460 */ 379, 187, 381, 129, 130, 131, 132, 133, 134, 135, + /* 470 */ 160, 169, 170, 359, 331, 340, 174, 59, 176, 340, + /* 480 */ 341, 367, 331, 331, 341, 211, 166, 167, 374, 375, + /* 490 */ 72, 410, 172, 173, 192, 414, 382, 358, 417, 418, + /* 500 */ 419, 420, 421, 422, 20, 424, 186, 428, 188, 430, + /* 510 */ 367, 331, 431, 367, 367, 97, 435, 436, 100, 64, + /* 520 */ 374, 374, 379, 249, 381, 390, 81, 392, 382, 382, + /* 530 */ 379, 379, 212, 213, 165, 215, 216, 217, 218, 219, /* 540 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - /* 550 */ 230, 231, 232, 410, 136, 137, 3, 414, 59, 373, - /* 560 */ 417, 418, 419, 420, 421, 422, 416, 424, 101, 97, - /* 570 */ 249, 331, 429, 178, 431, 72, 340, 341, 435, 436, - /* 580 */ 359, 168, 340, 341, 166, 167, 44, 367, 367, 359, - /* 590 */ 172, 173, 442, 97, 374, 374, 375, 367, 99, 456, - /* 600 */ 358, 102, 382, 382, 186, 375, 188, 249, 340, 113, - /* 610 */ 114, 115, 116, 117, 118, 119, 120, 121, 122, 379, - /* 620 */ 124, 125, 126, 127, 128, 129, 14, 14, 15, 16, - /* 630 */ 212, 213, 20, 215, 216, 217, 218, 219, 220, 221, + /* 550 */ 230, 231, 232, 410, 136, 137, 428, 414, 430, 379, + /* 560 */ 417, 418, 419, 420, 421, 422, 233, 424, 353, 354, + /* 570 */ 340, 341, 429, 171, 431, 212, 340, 341, 435, 436, + /* 580 */ 19, 166, 167, 100, 166, 167, 141, 142, 358, 443, + /* 590 */ 172, 173, 446, 110, 33, 341, 340, 341, 249, 456, + /* 600 */ 111, 249, 130, 416, 186, 236, 188, 461, 462, 164, + /* 610 */ 49, 269, 466, 467, 358, 246, 55, 56, 57, 58, + /* 620 */ 59, 367, 259, 260, 261, 262, 263, 264, 265, 442, + /* 630 */ 212, 213, 0, 215, 216, 217, 218, 219, 220, 221, /* 640 */ 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, - /* 650 */ 232, 12, 13, 72, 331, 340, 341, 168, 390, 20, - /* 660 */ 392, 22, 359, 443, 341, 233, 446, 235, 4, 274, - /* 670 */ 367, 22, 33, 358, 35, 439, 440, 441, 375, 443, - /* 680 */ 444, 461, 462, 19, 35, 37, 466, 467, 8, 9, - /* 690 */ 367, 346, 12, 13, 14, 15, 16, 33, 59, 340, - /* 700 */ 341, 367, 379, 416, 381, 131, 39, 362, 374, 135, - /* 710 */ 331, 72, 44, 49, 367, 370, 382, 358, 54, 427, - /* 720 */ 8, 9, 430, 59, 12, 13, 14, 15, 16, 442, - /* 730 */ 340, 341, 20, 410, 81, 388, 97, 414, 20, 100, - /* 740 */ 417, 418, 419, 420, 421, 422, 97, 424, 358, 12, - /* 750 */ 13, 103, 331, 105, 106, 111, 108, 20, 379, 22, - /* 760 */ 112, 368, 341, 99, 340, 341, 102, 193, 194, 101, - /* 770 */ 33, 197, 35, 199, 443, 136, 137, 446, 166, 8, - /* 780 */ 9, 133, 358, 12, 13, 14, 15, 16, 367, 340, - /* 790 */ 341, 468, 469, 462, 141, 142, 59, 466, 467, 100, - /* 800 */ 379, 21, 381, 340, 341, 166, 167, 358, 428, 72, - /* 810 */ 430, 172, 173, 271, 34, 44, 36, 164, 340, 341, - /* 820 */ 165, 358, 269, 130, 131, 186, 181, 188, 135, 346, - /* 830 */ 20, 410, 340, 341, 97, 414, 358, 100, 417, 418, - /* 840 */ 419, 420, 421, 422, 423, 424, 425, 426, 203, 204, - /* 850 */ 358, 212, 213, 370, 215, 216, 217, 218, 219, 220, + /* 650 */ 232, 12, 13, 348, 331, 367, 254, 255, 256, 20, + /* 660 */ 99, 22, 374, 102, 341, 340, 341, 195, 196, 364, + /* 670 */ 382, 181, 33, 419, 35, 439, 440, 441, 373, 443, + /* 680 */ 444, 8, 9, 20, 416, 12, 13, 14, 15, 16, + /* 690 */ 367, 340, 341, 203, 204, 134, 340, 341, 59, 67, + /* 700 */ 68, 69, 379, 416, 381, 72, 74, 75, 76, 358, + /* 710 */ 442, 72, 80, 233, 358, 235, 341, 85, 86, 427, + /* 720 */ 8, 9, 430, 91, 12, 13, 14, 15, 16, 442, + /* 730 */ 169, 367, 20, 410, 346, 174, 97, 414, 374, 100, + /* 740 */ 417, 418, 419, 420, 421, 422, 382, 424, 22, 12, + /* 750 */ 13, 190, 331, 192, 59, 359, 331, 20, 370, 22, + /* 760 */ 385, 35, 341, 367, 439, 440, 441, 14, 443, 444, + /* 770 */ 33, 375, 35, 20, 101, 136, 137, 340, 341, 8, + /* 780 */ 9, 340, 341, 12, 13, 14, 15, 16, 367, 111, + /* 790 */ 20, 468, 469, 367, 99, 358, 59, 102, 72, 358, + /* 800 */ 379, 375, 381, 20, 379, 166, 167, 376, 359, 72, + /* 810 */ 379, 172, 173, 21, 8, 9, 367, 22, 12, 13, + /* 820 */ 14, 15, 16, 97, 375, 186, 34, 188, 36, 166, + /* 830 */ 35, 410, 340, 341, 97, 414, 340, 100, 417, 418, + /* 840 */ 419, 420, 421, 422, 423, 424, 425, 426, 44, 37, + /* 850 */ 358, 212, 213, 331, 215, 216, 217, 218, 219, 220, /* 860 */ 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - /* 870 */ 231, 232, 0, 136, 137, 432, 433, 8, 9, 368, - /* 880 */ 168, 12, 13, 14, 15, 16, 168, 1, 2, 340, - /* 890 */ 341, 236, 428, 18, 430, 20, 340, 341, 20, 368, - /* 900 */ 22, 246, 27, 166, 167, 30, 2, 358, 33, 172, - /* 910 */ 173, 368, 8, 9, 358, 248, 12, 13, 14, 15, - /* 920 */ 16, 2, 4, 186, 49, 188, 51, 8, 9, 54, - /* 930 */ 52, 12, 13, 14, 15, 16, 8, 9, 380, 381, - /* 940 */ 12, 13, 14, 15, 16, 398, 136, 137, 249, 212, - /* 950 */ 213, 20, 215, 216, 217, 218, 219, 220, 221, 222, + /* 870 */ 231, 232, 101, 136, 137, 348, 368, 8, 9, 367, + /* 880 */ 168, 12, 13, 14, 15, 16, 390, 355, 392, 357, + /* 890 */ 1, 2, 97, 18, 382, 20, 340, 39, 340, 341, + /* 900 */ 373, 379, 27, 166, 167, 30, 136, 137, 33, 172, + /* 910 */ 173, 72, 186, 44, 188, 103, 358, 105, 106, 166, + /* 920 */ 108, 0, 331, 186, 49, 188, 51, 8, 9, 54, + /* 930 */ 368, 12, 13, 14, 15, 16, 20, 398, 212, 213, + /* 940 */ 59, 129, 172, 173, 398, 133, 390, 0, 392, 212, + /* 950 */ 213, 168, 215, 216, 217, 218, 219, 220, 221, 222, /* 960 */ 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - /* 970 */ 101, 340, 341, 112, 99, 0, 443, 353, 354, 446, - /* 980 */ 340, 341, 172, 173, 112, 376, 111, 101, 379, 358, - /* 990 */ 443, 331, 331, 446, 133, 462, 353, 354, 358, 466, - /* 1000 */ 467, 367, 130, 131, 132, 133, 134, 135, 461, 462, - /* 1010 */ 45, 46, 44, 466, 467, 140, 382, 403, 143, 144, + /* 970 */ 379, 50, 8, 9, 99, 0, 12, 13, 14, 15, + /* 980 */ 16, 14, 443, 102, 178, 446, 111, 20, 367, 443, + /* 990 */ 101, 44, 446, 340, 341, 374, 340, 341, 340, 341, + /* 1000 */ 461, 462, 42, 382, 44, 466, 467, 461, 462, 247, + /* 1010 */ 248, 358, 466, 467, 358, 140, 358, 368, 143, 144, /* 1020 */ 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - /* 1030 */ 155, 156, 157, 158, 159, 398, 161, 162, 163, 379, - /* 1040 */ 379, 368, 67, 68, 69, 70, 71, 331, 73, 74, + /* 1030 */ 155, 156, 157, 158, 159, 368, 161, 162, 163, 14, + /* 1040 */ 15, 16, 67, 68, 69, 70, 71, 0, 73, 74, /* 1050 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, /* 1060 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 18, - /* 1070 */ 376, 331, 331, 379, 23, 340, 341, 331, 331, 20, - /* 1080 */ 443, 341, 331, 446, 340, 341, 247, 248, 37, 38, - /* 1090 */ 369, 331, 41, 358, 331, 379, 168, 166, 461, 462, - /* 1100 */ 379, 341, 358, 466, 467, 331, 376, 367, 331, 379, - /* 1110 */ 0, 60, 61, 62, 63, 331, 35, 331, 331, 379, - /* 1120 */ 379, 381, 0, 48, 331, 379, 379, 367, 360, 0, - /* 1130 */ 379, 363, 22, 104, 413, 414, 107, 331, 331, 379, - /* 1140 */ 104, 381, 379, 107, 22, 424, 398, 355, 332, 357, - /* 1150 */ 410, 100, 0, 379, 414, 111, 379, 417, 418, 419, - /* 1160 */ 420, 421, 422, 379, 424, 379, 379, 44, 250, 429, - /* 1170 */ 410, 431, 379, 44, 414, 435, 436, 417, 418, 419, - /* 1180 */ 420, 421, 422, 44, 424, 379, 379, 331, 448, 138, - /* 1190 */ 42, 443, 44, 42, 446, 44, 456, 341, 0, 343, - /* 1200 */ 104, 49, 104, 107, 160, 107, 198, 44, 200, 461, - /* 1210 */ 462, 44, 59, 368, 466, 467, 136, 137, 458, 35, - /* 1220 */ 22, 65, 44, 367, 101, 44, 44, 168, 470, 178, - /* 1230 */ 179, 180, 44, 44, 183, 379, 331, 381, 44, 44, - /* 1240 */ 101, 273, 389, 168, 44, 44, 341, 0, 343, 356, - /* 1250 */ 1, 2, 47, 202, 44, 102, 205, 44, 207, 208, - /* 1260 */ 209, 210, 211, 44, 101, 344, 410, 459, 101, 188, - /* 1270 */ 414, 44, 367, 417, 418, 419, 420, 421, 422, 101, - /* 1280 */ 424, 44, 101, 101, 379, 429, 381, 431, 44, 101, - /* 1290 */ 101, 435, 436, 100, 331, 101, 101, 50, 35, 13, - /* 1300 */ 249, 101, 101, 110, 341, 100, 343, 453, 367, 13, - /* 1310 */ 344, 101, 389, 339, 101, 410, 378, 341, 389, 414, - /* 1320 */ 101, 35, 417, 418, 419, 420, 421, 422, 101, 424, - /* 1330 */ 367, 35, 445, 463, 429, 72, 431, 437, 101, 447, - /* 1340 */ 435, 436, 379, 251, 381, 101, 412, 49, 411, 184, - /* 1350 */ 400, 42, 331, 386, 20, 384, 386, 165, 389, 20, - /* 1360 */ 340, 384, 341, 340, 343, 386, 384, 98, 212, 352, - /* 1370 */ 96, 340, 188, 410, 95, 351, 350, 414, 340, 340, - /* 1380 */ 417, 418, 419, 420, 421, 422, 340, 424, 367, 20, - /* 1390 */ 333, 48, 429, 337, 431, 333, 331, 337, 435, 436, - /* 1400 */ 379, 20, 381, 405, 20, 20, 341, 20, 343, 348, - /* 1410 */ 342, 381, 348, 399, 348, 342, 340, 348, 348, 348, - /* 1420 */ 348, 53, 345, 345, 331, 367, 379, 333, 379, 340, - /* 1430 */ 367, 410, 367, 379, 341, 414, 343, 333, 417, 418, - /* 1440 */ 419, 420, 421, 422, 379, 424, 381, 201, 12, 13, - /* 1450 */ 429, 367, 431, 367, 367, 367, 435, 436, 22, 409, - /* 1460 */ 367, 100, 367, 346, 367, 346, 367, 367, 367, 33, - /* 1470 */ 340, 35, 379, 191, 381, 410, 258, 452, 257, 414, - /* 1480 */ 389, 407, 417, 418, 419, 420, 421, 422, 405, 424, - /* 1490 */ 381, 389, 379, 379, 429, 59, 431, 394, 266, 379, - /* 1500 */ 435, 436, 394, 410, 452, 379, 331, 414, 72, 404, - /* 1510 */ 417, 418, 419, 420, 421, 422, 341, 424, 177, 452, - /* 1520 */ 268, 331, 429, 267, 431, 252, 275, 412, 435, 436, - /* 1530 */ 272, 341, 270, 97, 455, 450, 454, 248, 341, 20, - /* 1540 */ 416, 451, 367, 340, 342, 346, 20, 392, 394, 379, - /* 1550 */ 346, 379, 379, 379, 379, 449, 381, 367, 379, 379, - /* 1560 */ 394, 170, 391, 346, 341, 100, 346, 331, 434, 379, - /* 1570 */ 363, 381, 100, 357, 340, 379, 465, 341, 471, 371, - /* 1580 */ 464, 346, 36, 406, 334, 410, 333, 401, 329, 414, - /* 1590 */ 361, 331, 417, 418, 419, 420, 421, 422, 0, 424, - /* 1600 */ 410, 341, 361, 367, 414, 0, 395, 417, 418, 419, - /* 1610 */ 420, 421, 422, 347, 424, 379, 361, 381, 0, 429, - /* 1620 */ 395, 431, 186, 331, 188, 435, 436, 367, 42, 0, - /* 1630 */ 35, 35, 206, 341, 35, 460, 206, 35, 0, 379, - /* 1640 */ 206, 381, 35, 35, 0, 206, 410, 0, 212, 213, - /* 1650 */ 414, 35, 0, 417, 418, 419, 420, 421, 422, 367, - /* 1660 */ 424, 225, 226, 227, 228, 229, 230, 231, 22, 0, - /* 1670 */ 410, 379, 35, 381, 414, 193, 188, 417, 418, 419, - /* 1680 */ 420, 421, 422, 186, 424, 0, 0, 0, 182, 429, - /* 1690 */ 181, 431, 0, 0, 331, 435, 436, 0, 47, 0, - /* 1700 */ 0, 42, 410, 0, 341, 469, 414, 0, 0, 417, - /* 1710 */ 418, 419, 420, 421, 422, 0, 424, 0, 0, 0, - /* 1720 */ 0, 429, 155, 431, 331, 35, 0, 435, 436, 155, - /* 1730 */ 367, 0, 0, 0, 341, 0, 0, 0, 0, 0, - /* 1740 */ 0, 0, 379, 0, 381, 0, 0, 0, 0, 0, + /* 1070 */ 4, 331, 340, 341, 23, 271, 340, 341, 331, 443, + /* 1080 */ 274, 341, 446, 331, 168, 19, 340, 341, 37, 38, + /* 1090 */ 358, 331, 41, 368, 358, 130, 131, 461, 462, 33, + /* 1100 */ 135, 341, 466, 467, 358, 443, 248, 367, 446, 353, + /* 1110 */ 354, 60, 61, 62, 63, 49, 340, 341, 331, 379, + /* 1120 */ 54, 381, 340, 341, 462, 59, 379, 367, 466, 467, + /* 1130 */ 22, 379, 168, 166, 358, 45, 46, 340, 341, 379, + /* 1140 */ 358, 381, 44, 35, 331, 331, 398, 331, 35, 129, + /* 1150 */ 410, 100, 331, 133, 414, 358, 398, 417, 418, 419, + /* 1160 */ 420, 421, 422, 0, 424, 99, 379, 35, 102, 429, + /* 1170 */ 410, 431, 403, 331, 414, 435, 436, 417, 418, 419, + /* 1180 */ 420, 421, 422, 376, 424, 331, 379, 331, 448, 138, + /* 1190 */ 331, 443, 379, 379, 446, 379, 456, 341, 44, 343, + /* 1200 */ 379, 443, 155, 376, 446, 360, 379, 356, 363, 461, + /* 1210 */ 462, 164, 49, 104, 466, 467, 107, 48, 458, 461, + /* 1220 */ 462, 379, 65, 367, 466, 467, 42, 332, 44, 178, + /* 1230 */ 179, 180, 0, 379, 183, 379, 331, 381, 379, 104, + /* 1240 */ 104, 44, 107, 107, 443, 44, 341, 446, 343, 104, + /* 1250 */ 44, 44, 107, 202, 22, 101, 205, 0, 207, 208, + /* 1260 */ 209, 210, 211, 462, 44, 47, 410, 466, 467, 368, + /* 1270 */ 414, 0, 367, 417, 418, 419, 420, 421, 422, 22, + /* 1280 */ 424, 198, 44, 200, 379, 429, 381, 431, 136, 137, + /* 1290 */ 44, 435, 436, 22, 331, 368, 44, 44, 101, 44, + /* 1300 */ 249, 188, 101, 44, 341, 470, 343, 101, 101, 1, + /* 1310 */ 2, 44, 35, 44, 389, 410, 459, 44, 100, 414, + /* 1320 */ 188, 101, 417, 418, 419, 420, 421, 422, 344, 424, + /* 1330 */ 367, 453, 44, 44, 429, 13, 431, 168, 44, 101, + /* 1340 */ 435, 436, 379, 13, 381, 367, 44, 101, 44, 72, + /* 1350 */ 344, 389, 331, 101, 101, 339, 101, 35, 341, 378, + /* 1360 */ 101, 389, 341, 445, 343, 35, 463, 437, 101, 212, + /* 1370 */ 101, 273, 251, 410, 101, 447, 49, 414, 412, 411, + /* 1380 */ 417, 418, 419, 420, 421, 422, 184, 424, 367, 101, + /* 1390 */ 101, 400, 429, 42, 431, 101, 331, 386, 435, 436, + /* 1400 */ 379, 20, 381, 101, 389, 101, 341, 165, 343, 386, + /* 1410 */ 384, 20, 340, 340, 386, 384, 384, 98, 340, 352, + /* 1420 */ 96, 351, 340, 95, 331, 350, 340, 340, 20, 333, + /* 1430 */ 48, 410, 367, 20, 341, 414, 343, 337, 417, 418, + /* 1440 */ 419, 420, 421, 422, 379, 424, 381, 333, 12, 13, + /* 1450 */ 429, 405, 431, 337, 348, 20, 435, 436, 22, 348, + /* 1460 */ 367, 381, 20, 20, 342, 348, 342, 399, 348, 33, + /* 1470 */ 340, 35, 379, 348, 381, 410, 348, 348, 345, 414, + /* 1480 */ 53, 333, 417, 418, 419, 420, 421, 422, 345, 424, + /* 1490 */ 367, 379, 201, 367, 429, 59, 431, 333, 367, 100, + /* 1500 */ 435, 436, 340, 410, 367, 367, 331, 414, 72, 367, + /* 1510 */ 417, 418, 419, 420, 421, 422, 341, 424, 367, 379, + /* 1520 */ 367, 331, 429, 367, 431, 367, 367, 409, 435, 436, + /* 1530 */ 191, 341, 405, 97, 379, 346, 340, 346, 389, 389, + /* 1540 */ 379, 407, 367, 404, 258, 266, 381, 452, 177, 379, + /* 1550 */ 257, 452, 379, 379, 379, 454, 381, 367, 455, 452, + /* 1560 */ 394, 394, 252, 268, 267, 275, 451, 331, 449, 379, + /* 1570 */ 272, 381, 412, 471, 248, 465, 270, 341, 341, 20, + /* 1580 */ 340, 342, 20, 379, 392, 410, 170, 416, 394, 414, + /* 1590 */ 346, 331, 417, 418, 419, 420, 421, 422, 379, 424, + /* 1600 */ 410, 341, 346, 367, 414, 464, 379, 417, 418, 419, + /* 1610 */ 420, 421, 422, 379, 424, 379, 394, 381, 450, 429, + /* 1620 */ 379, 431, 186, 331, 188, 435, 436, 367, 379, 346, + /* 1630 */ 346, 363, 100, 341, 391, 460, 100, 341, 357, 379, + /* 1640 */ 379, 381, 434, 371, 36, 340, 410, 346, 212, 213, + /* 1650 */ 414, 334, 401, 417, 418, 419, 420, 421, 422, 367, + /* 1660 */ 424, 225, 226, 227, 228, 229, 230, 231, 333, 406, + /* 1670 */ 410, 379, 361, 381, 414, 395, 361, 417, 418, 419, + /* 1680 */ 420, 421, 422, 347, 424, 329, 361, 0, 0, 429, + /* 1690 */ 0, 431, 0, 42, 331, 435, 436, 35, 395, 206, + /* 1700 */ 35, 35, 410, 35, 341, 469, 414, 206, 0, 417, + /* 1710 */ 418, 419, 420, 421, 422, 35, 424, 35, 206, 0, + /* 1720 */ 206, 429, 0, 431, 331, 22, 35, 435, 436, 0, + /* 1730 */ 367, 0, 35, 193, 341, 188, 186, 0, 0, 0, + /* 1740 */ 182, 181, 379, 0, 381, 0, 47, 0, 0, 0, /* 1750 */ 0, 42, 0, 0, 0, 0, 331, 0, 0, 0, - /* 1760 */ 367, 0, 139, 0, 22, 0, 341, 0, 0, 48, - /* 1770 */ 59, 48, 379, 410, 381, 59, 0, 414, 22, 35, - /* 1780 */ 417, 418, 419, 420, 421, 422, 22, 424, 59, 0, - /* 1790 */ 331, 0, 367, 42, 431, 14, 0, 0, 435, 436, - /* 1800 */ 341, 39, 0, 410, 379, 39, 381, 414, 0, 40, - /* 1810 */ 417, 418, 419, 420, 421, 422, 44, 424, 47, 39, - /* 1820 */ 47, 47, 177, 0, 431, 0, 367, 35, 435, 436, - /* 1830 */ 0, 372, 0, 0, 49, 410, 66, 39, 379, 414, + /* 1760 */ 367, 155, 35, 0, 155, 0, 341, 0, 0, 0, + /* 1770 */ 0, 0, 379, 410, 381, 0, 0, 414, 0, 0, + /* 1780 */ 417, 418, 419, 420, 421, 422, 0, 424, 0, 0, + /* 1790 */ 331, 0, 367, 0, 431, 0, 0, 0, 435, 436, + /* 1800 */ 341, 0, 42, 410, 379, 0, 381, 414, 0, 0, + /* 1810 */ 417, 418, 419, 420, 421, 422, 22, 424, 0, 0, + /* 1820 */ 0, 0, 139, 0, 431, 22, 367, 0, 435, 436, + /* 1830 */ 48, 372, 22, 48, 35, 410, 59, 0, 379, 414, /* 1840 */ 381, 0, 417, 418, 419, 420, 421, 422, 331, 424, - /* 1850 */ 35, 39, 49, 0, 35, 49, 431, 39, 341, 0, - /* 1860 */ 49, 436, 0, 35, 0, 331, 0, 0, 39, 410, - /* 1870 */ 35, 22, 0, 414, 35, 341, 417, 418, 419, 420, - /* 1880 */ 421, 422, 107, 424, 367, 35, 109, 35, 44, 35, - /* 1890 */ 35, 44, 35, 35, 0, 22, 379, 22, 381, 22, - /* 1900 */ 35, 367, 0, 0, 22, 35, 372, 51, 0, 331, - /* 1910 */ 0, 35, 0, 379, 35, 381, 20, 22, 35, 341, - /* 1920 */ 35, 35, 101, 0, 100, 35, 100, 410, 168, 0, - /* 1930 */ 0, 414, 331, 19, 417, 418, 419, 420, 421, 422, - /* 1940 */ 22, 424, 341, 426, 410, 367, 0, 33, 414, 170, + /* 1850 */ 0, 59, 0, 42, 39, 0, 431, 59, 341, 47, + /* 1860 */ 44, 436, 14, 0, 47, 331, 40, 39, 0, 410, + /* 1870 */ 0, 47, 39, 414, 0, 341, 417, 418, 419, 420, + /* 1880 */ 421, 422, 177, 424, 367, 0, 0, 0, 66, 0, + /* 1890 */ 39, 35, 49, 0, 35, 49, 379, 39, 381, 0, + /* 1900 */ 35, 367, 49, 39, 0, 39, 372, 35, 0, 331, + /* 1910 */ 49, 0, 0, 379, 0, 381, 109, 35, 22, 341, + /* 1920 */ 107, 0, 44, 35, 44, 35, 35, 410, 22, 35, + /* 1930 */ 35, 414, 331, 35, 417, 418, 419, 420, 421, 422, + /* 1940 */ 35, 424, 341, 426, 410, 367, 0, 0, 414, 22, /* 1950 */ 372, 417, 418, 419, 420, 421, 422, 379, 424, 381, - /* 1960 */ 3, 168, 168, 49, 44, 175, 253, 48, 367, 55, - /* 1970 */ 56, 57, 58, 59, 100, 189, 48, 96, 98, 101, - /* 1980 */ 379, 331, 381, 44, 100, 44, 44, 100, 410, 101, - /* 1990 */ 101, 341, 414, 100, 47, 417, 418, 419, 420, 421, - /* 2000 */ 422, 100, 424, 47, 44, 101, 100, 3, 101, 44, - /* 2010 */ 101, 410, 35, 99, 35, 414, 102, 367, 417, 418, - /* 2020 */ 419, 420, 421, 422, 35, 424, 35, 35, 35, 379, - /* 2030 */ 47, 381, 101, 101, 247, 253, 253, 331, 44, 0, - /* 2040 */ 0, 0, 47, 0, 100, 39, 47, 341, 134, 100, - /* 2050 */ 0, 101, 101, 331, 100, 100, 47, 39, 110, 100, - /* 2060 */ 410, 169, 171, 341, 414, 44, 100, 417, 418, 419, - /* 2070 */ 420, 421, 422, 367, 424, 22, 98, 234, 98, 2, - /* 2080 */ 212, 100, 100, 169, 100, 379, 101, 381, 174, 367, - /* 2090 */ 22, 101, 47, 47, 35, 35, 35, 101, 100, 111, - /* 2100 */ 100, 379, 101, 381, 190, 100, 192, 35, 101, 331, - /* 2110 */ 100, 214, 101, 100, 35, 101, 410, 101, 35, 341, - /* 2120 */ 414, 101, 100, 417, 418, 419, 420, 421, 422, 100, - /* 2130 */ 424, 100, 410, 22, 100, 123, 414, 44, 123, 417, - /* 2140 */ 418, 419, 420, 421, 422, 367, 424, 123, 123, 112, - /* 2150 */ 35, 100, 100, 22, 35, 66, 65, 379, 331, 381, - /* 2160 */ 35, 35, 35, 35, 35, 35, 72, 35, 341, 35, - /* 2170 */ 35, 331, 94, 35, 35, 35, 22, 44, 35, 35, - /* 2180 */ 35, 341, 72, 35, 35, 35, 35, 35, 410, 22, - /* 2190 */ 35, 0, 414, 0, 367, 417, 418, 419, 420, 421, - /* 2200 */ 422, 35, 424, 39, 35, 49, 379, 367, 381, 49, - /* 2210 */ 39, 0, 35, 39, 49, 0, 35, 49, 39, 379, - /* 2220 */ 0, 381, 35, 35, 0, 22, 21, 472, 22, 21, - /* 2230 */ 331, 22, 20, 472, 472, 472, 472, 410, 472, 472, - /* 2240 */ 341, 414, 472, 472, 417, 418, 419, 420, 421, 422, - /* 2250 */ 410, 424, 472, 472, 414, 472, 472, 417, 418, 419, - /* 2260 */ 420, 421, 422, 472, 424, 472, 367, 472, 472, 472, - /* 2270 */ 472, 472, 472, 472, 331, 472, 472, 472, 379, 472, - /* 2280 */ 381, 472, 472, 472, 341, 472, 472, 472, 472, 331, - /* 2290 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 341, - /* 2300 */ 472, 472, 331, 472, 472, 472, 472, 472, 472, 410, - /* 2310 */ 367, 472, 341, 414, 472, 472, 417, 418, 419, 420, - /* 2320 */ 421, 422, 379, 424, 381, 367, 472, 472, 472, 472, - /* 2330 */ 472, 472, 472, 472, 472, 472, 472, 379, 367, 381, - /* 2340 */ 472, 472, 472, 472, 472, 472, 472, 472, 331, 472, - /* 2350 */ 379, 472, 381, 410, 472, 472, 472, 414, 341, 472, - /* 2360 */ 417, 418, 419, 420, 421, 422, 472, 424, 410, 472, - /* 2370 */ 472, 472, 414, 472, 472, 417, 418, 419, 420, 421, - /* 2380 */ 422, 410, 424, 472, 367, 414, 472, 33, 417, 418, - /* 2390 */ 419, 420, 421, 422, 472, 424, 379, 472, 381, 472, - /* 2400 */ 472, 472, 472, 49, 331, 472, 472, 472, 472, 55, - /* 2410 */ 56, 57, 58, 59, 341, 472, 472, 472, 472, 331, - /* 2420 */ 472, 472, 472, 472, 472, 472, 472, 410, 472, 341, - /* 2430 */ 472, 414, 472, 472, 417, 418, 419, 420, 421, 422, - /* 2440 */ 367, 424, 472, 472, 472, 472, 472, 472, 472, 472, - /* 2450 */ 472, 472, 379, 99, 381, 367, 102, 472, 472, 472, - /* 2460 */ 472, 472, 472, 472, 472, 472, 472, 379, 331, 381, - /* 2470 */ 472, 472, 472, 472, 472, 472, 472, 472, 341, 472, - /* 2480 */ 472, 472, 472, 410, 472, 472, 472, 414, 472, 331, - /* 2490 */ 417, 418, 419, 420, 421, 422, 472, 424, 410, 341, - /* 2500 */ 472, 472, 414, 472, 367, 417, 418, 419, 420, 421, - /* 2510 */ 422, 472, 424, 472, 472, 472, 379, 472, 381, 472, - /* 2520 */ 472, 472, 472, 169, 170, 367, 472, 472, 174, 472, - /* 2530 */ 176, 472, 472, 472, 472, 472, 472, 379, 331, 381, - /* 2540 */ 472, 472, 472, 472, 472, 472, 192, 410, 341, 472, - /* 2550 */ 472, 414, 472, 331, 417, 418, 419, 420, 421, 422, - /* 2560 */ 472, 424, 472, 341, 472, 472, 472, 472, 410, 472, - /* 2570 */ 472, 472, 414, 472, 367, 417, 418, 419, 420, 421, - /* 2580 */ 422, 472, 424, 472, 472, 472, 379, 472, 381, 367, - /* 2590 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, - /* 2600 */ 472, 379, 472, 381, 472, 472, 472, 472, 472, 472, - /* 2610 */ 472, 472, 331, 472, 472, 472, 472, 410, 472, 472, - /* 2620 */ 472, 414, 341, 472, 417, 418, 419, 420, 421, 422, - /* 2630 */ 472, 424, 410, 472, 472, 472, 414, 472, 472, 417, - /* 2640 */ 418, 419, 420, 421, 422, 472, 424, 472, 367, 472, - /* 2650 */ 472, 472, 472, 472, 472, 472, 331, 472, 472, 472, - /* 2660 */ 379, 472, 381, 472, 472, 472, 341, 472, 472, 472, - /* 2670 */ 472, 331, 472, 472, 472, 472, 472, 472, 472, 472, - /* 2680 */ 472, 341, 472, 472, 331, 472, 472, 472, 472, 472, - /* 2690 */ 472, 410, 367, 472, 341, 414, 472, 472, 417, 418, - /* 2700 */ 419, 420, 421, 422, 379, 424, 381, 367, 472, 472, - /* 2710 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 379, - /* 2720 */ 367, 381, 472, 472, 472, 472, 472, 472, 472, 472, - /* 2730 */ 472, 472, 379, 472, 381, 410, 472, 472, 472, 414, - /* 2740 */ 472, 472, 417, 418, 419, 420, 421, 422, 472, 424, - /* 2750 */ 410, 472, 472, 472, 414, 472, 472, 417, 418, 419, - /* 2760 */ 420, 421, 422, 410, 424, 472, 472, 414, 472, 472, - /* 2770 */ 417, 418, 419, 420, 421, 422, 472, 424, + /* 1960 */ 35, 22, 0, 22, 51, 35, 0, 35, 367, 0, + /* 1970 */ 35, 0, 22, 35, 20, 35, 101, 35, 0, 35, + /* 1980 */ 379, 331, 381, 100, 100, 0, 22, 0, 410, 189, + /* 1990 */ 0, 341, 414, 168, 331, 417, 418, 419, 420, 421, + /* 2000 */ 422, 170, 424, 168, 341, 3, 168, 175, 101, 44, + /* 2010 */ 100, 410, 44, 98, 253, 414, 100, 367, 417, 418, + /* 2020 */ 419, 420, 421, 422, 48, 424, 44, 48, 100, 379, + /* 2030 */ 367, 381, 96, 44, 101, 101, 253, 44, 47, 47, + /* 2040 */ 3, 35, 379, 331, 381, 100, 35, 44, 100, 35, + /* 2050 */ 101, 100, 35, 341, 35, 253, 331, 101, 101, 35, + /* 2060 */ 410, 101, 101, 47, 414, 44, 341, 417, 418, 419, + /* 2070 */ 420, 421, 422, 410, 424, 47, 247, 414, 0, 367, + /* 2080 */ 417, 418, 419, 420, 421, 422, 0, 424, 0, 0, + /* 2090 */ 39, 379, 367, 381, 100, 47, 100, 171, 0, 101, + /* 2100 */ 101, 100, 39, 47, 379, 331, 381, 100, 100, 100, + /* 2110 */ 110, 44, 169, 98, 2, 341, 98, 22, 47, 47, + /* 2120 */ 100, 212, 410, 101, 101, 100, 414, 100, 22, 417, + /* 2130 */ 418, 419, 420, 421, 422, 410, 424, 234, 100, 414, + /* 2140 */ 101, 367, 417, 418, 419, 420, 421, 422, 101, 424, + /* 2150 */ 100, 111, 100, 379, 101, 381, 35, 35, 100, 35, + /* 2160 */ 101, 331, 100, 35, 35, 101, 214, 101, 100, 100, + /* 2170 */ 35, 341, 35, 22, 101, 100, 331, 122, 44, 122, + /* 2180 */ 100, 66, 122, 122, 410, 100, 341, 100, 414, 35, + /* 2190 */ 65, 417, 418, 419, 420, 421, 422, 367, 424, 35, + /* 2200 */ 35, 35, 35, 35, 35, 35, 35, 35, 72, 379, + /* 2210 */ 331, 381, 367, 94, 35, 35, 35, 44, 22, 35, + /* 2220 */ 341, 35, 35, 35, 379, 72, 381, 35, 35, 35, + /* 2230 */ 35, 22, 35, 0, 35, 0, 35, 39, 0, 49, + /* 2240 */ 410, 39, 35, 0, 414, 39, 367, 417, 418, 419, + /* 2250 */ 420, 421, 422, 49, 424, 410, 35, 49, 379, 414, + /* 2260 */ 381, 49, 417, 418, 419, 420, 421, 422, 331, 424, + /* 2270 */ 39, 0, 35, 0, 35, 22, 21, 21, 341, 22, + /* 2280 */ 22, 20, 472, 472, 331, 472, 472, 472, 472, 410, + /* 2290 */ 472, 472, 472, 414, 341, 472, 417, 418, 419, 420, + /* 2300 */ 421, 422, 472, 424, 367, 472, 472, 472, 472, 472, + /* 2310 */ 472, 472, 331, 472, 472, 472, 379, 472, 381, 472, + /* 2320 */ 367, 472, 341, 472, 472, 472, 472, 472, 331, 472, + /* 2330 */ 472, 472, 379, 472, 381, 472, 472, 472, 341, 472, + /* 2340 */ 472, 472, 472, 472, 472, 472, 472, 410, 367, 472, + /* 2350 */ 472, 414, 472, 472, 417, 418, 419, 420, 421, 422, + /* 2360 */ 379, 424, 381, 410, 367, 472, 472, 414, 472, 472, + /* 2370 */ 417, 418, 419, 420, 421, 422, 379, 424, 381, 472, + /* 2380 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, + /* 2390 */ 472, 410, 472, 472, 472, 414, 331, 472, 417, 418, + /* 2400 */ 419, 420, 421, 422, 472, 424, 341, 410, 472, 472, + /* 2410 */ 472, 414, 331, 472, 417, 418, 419, 420, 421, 422, + /* 2420 */ 472, 424, 341, 472, 472, 472, 472, 472, 472, 472, + /* 2430 */ 472, 472, 367, 472, 472, 472, 472, 472, 472, 472, + /* 2440 */ 472, 472, 472, 472, 379, 472, 381, 472, 367, 472, + /* 2450 */ 472, 472, 472, 472, 472, 472, 472, 472, 331, 472, + /* 2460 */ 379, 472, 381, 472, 472, 472, 472, 472, 341, 472, + /* 2470 */ 472, 331, 472, 472, 472, 410, 472, 472, 472, 414, + /* 2480 */ 472, 341, 417, 418, 419, 420, 421, 422, 472, 424, + /* 2490 */ 472, 410, 472, 472, 367, 414, 472, 472, 417, 418, + /* 2500 */ 419, 420, 421, 422, 472, 424, 379, 367, 381, 472, + /* 2510 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 379, + /* 2520 */ 331, 381, 472, 472, 472, 472, 472, 472, 472, 472, + /* 2530 */ 341, 472, 472, 472, 472, 472, 472, 410, 472, 472, + /* 2540 */ 472, 414, 331, 472, 417, 418, 419, 420, 421, 422, + /* 2550 */ 410, 424, 341, 472, 414, 472, 367, 417, 418, 419, + /* 2560 */ 420, 421, 422, 472, 424, 472, 472, 472, 379, 472, + /* 2570 */ 381, 472, 472, 472, 472, 472, 331, 472, 367, 472, + /* 2580 */ 472, 472, 472, 472, 472, 472, 341, 472, 472, 472, + /* 2590 */ 379, 331, 381, 472, 472, 472, 472, 472, 472, 410, + /* 2600 */ 472, 341, 472, 414, 472, 472, 417, 418, 419, 420, + /* 2610 */ 421, 422, 367, 424, 472, 472, 472, 472, 472, 472, + /* 2620 */ 472, 410, 472, 472, 379, 414, 381, 367, 417, 418, + /* 2630 */ 419, 420, 421, 422, 472, 424, 472, 472, 472, 379, + /* 2640 */ 472, 381, 472, 472, 472, 472, 472, 472, 472, 472, + /* 2650 */ 331, 472, 472, 472, 472, 410, 472, 472, 472, 414, + /* 2660 */ 341, 472, 417, 418, 419, 420, 421, 422, 472, 424, + /* 2670 */ 410, 472, 472, 472, 414, 472, 472, 417, 418, 419, + /* 2680 */ 420, 421, 422, 472, 424, 472, 367, 472, 472, 472, + /* 2690 */ 472, 472, 472, 472, 472, 472, 472, 472, 379, 472, + /* 2700 */ 381, 472, 472, 472, 472, 472, 472, 472, 472, 472, + /* 2710 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, + /* 2720 */ 472, 472, 472, 472, 472, 472, 472, 472, 472, 410, + /* 2730 */ 472, 472, 472, 414, 472, 472, 417, 418, 419, 420, + /* 2740 */ 421, 422, 472, 424, }; -#define YY_SHIFT_COUNT (754) +#define YY_SHIFT_COUNT (752) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2354) +#define YY_SHIFT_MAX (2273) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1051, 0, 98, 0, 320, 320, 320, 320, 320, 320, /* 10 */ 320, 320, 320, 320, 320, 320, 418, 639, 639, 737, /* 20 */ 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, /* 30 */ 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, - /* 40 */ 639, 639, 639, 639, 639, 639, 639, 639, 639, 148, - /* 50 */ 180, 58, 64, 321, 358, 699, 358, 64, 64, 1436, - /* 60 */ 1436, 1436, 358, 1436, 1436, 59, 358, 85, 810, 157, - /* 70 */ 157, 810, 146, 146, 75, 289, 32, 32, 157, 157, - /* 80 */ 157, 157, 157, 157, 157, 170, 157, 157, 3, 85, - /* 90 */ 157, 157, 281, 157, 85, 157, 170, 157, 170, 85, - /* 100 */ 157, 157, 85, 157, 85, 85, 85, 157, 182, 875, - /* 110 */ 15, 15, 314, 13, 90, 90, 90, 90, 90, 90, - /* 120 */ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - /* 130 */ 90, 90, 90, 648, 413, 75, 289, 47, 489, 489, - /* 140 */ 489, 209, 432, 432, 47, 344, 344, 344, 3, 280, - /* 150 */ 245, 85, 503, 85, 503, 503, 644, 581, 496, 496, - /* 160 */ 496, 496, 496, 496, 496, 496, 1914, 214, 341, 712, - /* 170 */ 395, 84, 29, 265, 271, 612, 878, 718, 965, 382, - /* 180 */ 861, 1059, 839, 667, 553, 839, 1148, 918, 931, 1092, - /* 190 */ 1298, 1165, 1309, 1334, 1309, 1192, 1339, 1339, 1309, 1192, - /* 200 */ 1192, 1269, 1274, 1339, 1279, 1339, 1339, 1339, 1369, 1343, - /* 210 */ 1369, 1343, 1381, 3, 1384, 3, 1385, 1387, 3, 1385, - /* 220 */ 3, 3, 3, 1339, 3, 1368, 1368, 1369, 85, 85, - /* 230 */ 85, 85, 85, 85, 85, 85, 85, 85, 85, 1339, - /* 240 */ 1369, 503, 503, 503, 1246, 1361, 1381, 182, 1282, 1384, - /* 250 */ 182, 1339, 1334, 1334, 503, 1218, 1221, 503, 1218, 1221, - /* 260 */ 503, 503, 85, 1232, 1341, 1218, 1252, 1256, 1273, 1092, - /* 270 */ 1251, 1258, 1262, 1289, 344, 1519, 1339, 1385, 182, 182, - /* 280 */ 1526, 1221, 503, 503, 503, 503, 503, 1221, 503, 1391, - /* 290 */ 182, 644, 182, 344, 1465, 1472, 503, 581, 1339, 182, - /* 300 */ 1546, 1369, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, - /* 310 */ 2778, 975, 2354, 439, 664, 467, 771, 869, 312, 904, - /* 320 */ 919, 928, 872, 680, 680, 680, 680, 680, 680, 680, - /* 330 */ 680, 680, 226, 574, 362, 362, 653, 645, 140, 499, - /* 340 */ 472, 649, 780, 254, 693, 693, 613, 886, 655, 613, - /* 350 */ 613, 613, 1152, 668, 74, 1151, 1044, 1129, 1029, 1036, - /* 360 */ 1096, 1098, 1110, 1122, 1198, 1008, 1123, 1139, 1153, 1163, - /* 370 */ 1167, 1178, 1080, 542, 968, 1075, 1181, 1182, 1188, 1189, - /* 380 */ 1194, 1195, 1249, 1200, 1081, 1184, 1156, 1201, 1205, 1210, - /* 390 */ 1213, 1219, 1227, 1237, 1244, 1193, 1286, 1296, 1263, 1247, - /* 400 */ 1598, 1605, 1618, 1586, 1629, 1595, 1426, 1596, 1599, 1602, - /* 410 */ 1430, 1638, 1607, 1608, 1434, 1644, 1439, 1647, 1616, 1652, - /* 420 */ 1646, 1669, 1637, 1482, 1488, 1497, 1685, 1686, 1687, 1506, - /* 430 */ 1509, 1692, 1693, 1651, 1697, 1699, 1700, 1659, 1703, 1707, - /* 440 */ 1708, 1715, 1717, 1718, 1719, 1720, 1567, 1690, 1726, 1574, - /* 450 */ 1731, 1732, 1733, 1735, 1736, 1737, 1738, 1739, 1740, 1741, - /* 460 */ 1743, 1745, 1746, 1747, 1748, 1749, 1709, 1750, 1752, 1753, - /* 470 */ 1754, 1755, 1757, 1742, 1758, 1759, 1761, 1623, 1763, 1765, - /* 480 */ 1756, 1721, 1764, 1723, 1767, 1711, 1744, 1768, 1716, 1776, - /* 490 */ 1729, 1789, 1791, 1751, 1762, 1772, 1771, 1773, 1781, 1774, - /* 500 */ 1796, 1769, 1766, 1797, 1802, 1808, 1780, 1645, 1823, 1825, - /* 510 */ 1830, 1770, 1832, 1833, 1792, 1785, 1798, 1841, 1815, 1803, - /* 520 */ 1812, 1853, 1819, 1806, 1818, 1859, 1828, 1811, 1829, 1862, - /* 530 */ 1864, 1866, 1867, 1777, 1775, 1835, 1849, 1872, 1839, 1850, - /* 540 */ 1852, 1854, 1855, 1844, 1847, 1857, 1858, 1873, 1865, 1894, - /* 550 */ 1875, 1902, 1877, 1856, 1903, 1882, 1870, 1908, 1876, 1910, - /* 560 */ 1879, 1912, 1895, 1896, 1883, 1885, 1886, 1821, 1824, 1923, - /* 570 */ 1760, 1826, 1890, 1929, 1786, 1918, 1793, 1779, 1930, 1946, - /* 580 */ 1794, 1790, 1957, 1920, 1713, 1874, 1878, 1884, 1919, 1880, - /* 590 */ 1928, 1881, 1888, 1939, 1941, 1889, 1887, 1893, 1901, 1904, - /* 600 */ 1942, 1947, 1956, 1906, 1960, 1782, 1907, 1909, 2004, 1965, - /* 610 */ 1783, 1977, 1979, 1989, 1991, 1992, 1993, 1931, 1932, 1983, - /* 620 */ 1787, 1994, 1995, 2039, 2040, 2041, 2043, 1944, 2006, 1771, - /* 630 */ 1999, 1949, 1950, 1951, 1954, 1955, 1891, 1959, 2050, 2018, - /* 640 */ 1892, 1966, 1948, 1771, 2009, 2021, 1978, 1843, 1980, 2077, - /* 650 */ 2053, 1868, 1981, 1985, 1982, 1990, 1984, 1996, 2045, 1998, - /* 660 */ 2000, 2046, 2001, 2068, 1897, 2005, 1988, 2007, 2059, 2060, - /* 670 */ 2010, 2011, 2061, 2013, 2014, 2072, 2022, 2016, 2079, 2029, - /* 680 */ 2020, 2083, 2031, 2012, 2015, 2024, 2025, 2111, 2037, 2034, - /* 690 */ 2093, 2051, 2115, 2052, 2093, 2093, 2131, 2089, 2091, 2119, - /* 700 */ 2125, 2126, 2127, 2128, 2129, 2130, 2132, 2134, 2135, 2094, - /* 710 */ 2078, 2133, 2138, 2139, 2140, 2154, 2143, 2144, 2145, 2110, - /* 720 */ 1844, 2148, 1847, 2149, 2150, 2151, 2152, 2167, 2155, 2191, - /* 730 */ 2166, 2156, 2164, 2193, 2169, 2160, 2171, 2211, 2177, 2165, - /* 740 */ 2174, 2215, 2181, 2168, 2179, 2220, 2187, 2188, 2224, 2203, - /* 750 */ 2205, 2206, 2209, 2208, 2212, + /* 40 */ 639, 639, 639, 639, 639, 639, 639, 639, 639, 34, + /* 50 */ 148, 274, 32, 352, 28, 349, 28, 32, 32, 1436, + /* 60 */ 1436, 1436, 28, 1436, 1436, 137, 28, 157, 770, 189, + /* 70 */ 189, 770, 344, 344, 415, 130, 105, 105, 189, 189, + /* 80 */ 189, 189, 189, 189, 189, 243, 189, 189, 30, 157, + /* 90 */ 189, 189, 259, 189, 157, 189, 243, 189, 243, 157, + /* 100 */ 189, 189, 157, 189, 157, 157, 157, 189, 300, 875, + /* 110 */ 15, 15, 308, 13, 726, 726, 726, 726, 726, 726, + /* 120 */ 726, 726, 726, 726, 726, 726, 726, 726, 726, 726, + /* 130 */ 726, 726, 726, 812, 1, 415, 130, 343, 169, 169, + /* 140 */ 169, 455, 480, 480, 343, 484, 484, 484, 30, 489, + /* 150 */ 333, 157, 633, 157, 633, 633, 678, 839, 181, 181, + /* 160 */ 181, 181, 181, 181, 181, 181, 561, 632, 341, 712, + /* 170 */ 806, 363, 29, 402, 753, 967, 142, 783, 1090, 419, + /* 180 */ 1020, 916, 762, 858, 342, 762, 960, 155, 663, 1121, + /* 190 */ 1327, 1202, 1351, 1381, 1351, 1242, 1391, 1391, 1351, 1242, + /* 200 */ 1242, 1319, 1324, 1391, 1328, 1391, 1391, 1391, 1408, 1382, + /* 210 */ 1408, 1382, 1413, 30, 1435, 30, 1442, 1443, 30, 1442, + /* 220 */ 30, 30, 30, 1391, 30, 1427, 1427, 1408, 157, 157, + /* 230 */ 157, 157, 157, 157, 157, 157, 157, 157, 157, 1391, + /* 240 */ 1408, 633, 633, 633, 1291, 1399, 1413, 300, 1339, 1435, + /* 250 */ 300, 1391, 1381, 1381, 633, 1286, 1293, 633, 1286, 1293, + /* 260 */ 633, 633, 157, 1279, 1371, 1286, 1295, 1297, 1310, 1121, + /* 270 */ 1290, 1298, 1306, 1326, 484, 1559, 1391, 1442, 300, 300, + /* 280 */ 1562, 1293, 633, 633, 633, 633, 633, 1293, 633, 1416, + /* 290 */ 300, 678, 300, 484, 1532, 1536, 633, 839, 1391, 300, + /* 300 */ 1608, 1408, 2744, 2744, 2744, 2744, 2744, 2744, 2744, 2744, + /* 310 */ 2744, 975, 302, 214, 1066, 673, 869, 771, 312, 260, + /* 320 */ 394, 964, 334, 919, 919, 919, 919, 919, 919, 919, + /* 330 */ 919, 919, 294, 150, 275, 275, 445, 490, 1047, 695, + /* 340 */ 74, 795, 792, 472, 965, 965, 1025, 889, 369, 1025, + /* 350 */ 1025, 1025, 1163, 1154, 1108, 1184, 310, 947, 1109, 1135, + /* 360 */ 1136, 1145, 1232, 1257, 1271, 1083, 1197, 1201, 881, 1206, + /* 370 */ 1207, 1220, 1152, 804, 1098, 1169, 1238, 1246, 1252, 1253, + /* 380 */ 1255, 1259, 1308, 1267, 1113, 1132, 1157, 1269, 1218, 1273, + /* 390 */ 1288, 1289, 1294, 1302, 1304, 483, 1322, 1330, 1277, 921, + /* 400 */ 1687, 1688, 1690, 1651, 1692, 1662, 1493, 1665, 1666, 1668, + /* 410 */ 1501, 1708, 1680, 1682, 1512, 1719, 1514, 1722, 1691, 1729, + /* 420 */ 1703, 1731, 1697, 1540, 1547, 1550, 1737, 1738, 1739, 1558, + /* 430 */ 1560, 1743, 1745, 1699, 1747, 1748, 1749, 1709, 1750, 1752, + /* 440 */ 1753, 1754, 1755, 1757, 1758, 1759, 1606, 1727, 1763, 1609, + /* 450 */ 1765, 1767, 1768, 1769, 1770, 1771, 1775, 1776, 1778, 1779, + /* 460 */ 1786, 1788, 1789, 1791, 1793, 1795, 1760, 1796, 1797, 1801, + /* 470 */ 1805, 1808, 1809, 1794, 1818, 1819, 1820, 1683, 1821, 1823, + /* 480 */ 1803, 1782, 1810, 1785, 1827, 1777, 1799, 1837, 1792, 1841, + /* 490 */ 1798, 1850, 1852, 1811, 1815, 1816, 1812, 1817, 1848, 1824, + /* 500 */ 1855, 1826, 1828, 1863, 1868, 1870, 1833, 1705, 1874, 1885, + /* 510 */ 1886, 1822, 1887, 1889, 1856, 1843, 1851, 1893, 1859, 1846, + /* 520 */ 1858, 1899, 1865, 1853, 1864, 1904, 1872, 1861, 1866, 1908, + /* 530 */ 1911, 1912, 1914, 1807, 1813, 1882, 1896, 1921, 1888, 1890, + /* 540 */ 1891, 1894, 1895, 1878, 1880, 1898, 1905, 1906, 1925, 1946, + /* 550 */ 1927, 1947, 1939, 1913, 1962, 1941, 1930, 1966, 1932, 1969, + /* 560 */ 1935, 1971, 1950, 1954, 1938, 1940, 1942, 1875, 1883, 1978, + /* 570 */ 1825, 1884, 1944, 1985, 1800, 1964, 1835, 1831, 1987, 1990, + /* 580 */ 1838, 1832, 2002, 1965, 1761, 1910, 1907, 1916, 1976, 1915, + /* 590 */ 1979, 1936, 1933, 1968, 1982, 1934, 1928, 1945, 1948, 1949, + /* 600 */ 1989, 1991, 1992, 1951, 1993, 1783, 1956, 1957, 2037, 2003, + /* 610 */ 1802, 2006, 2011, 2014, 2017, 2019, 2024, 1960, 1961, 2016, + /* 620 */ 1829, 2021, 2028, 2078, 2086, 2088, 2089, 1994, 2051, 1812, + /* 630 */ 2048, 1996, 1998, 1999, 2001, 2007, 1926, 2008, 2098, 2063, + /* 640 */ 1943, 2009, 2000, 1812, 2056, 2067, 2015, 1903, 2018, 2112, + /* 650 */ 2095, 1909, 2020, 2022, 2025, 2023, 2027, 2039, 2071, 2038, + /* 660 */ 2050, 2072, 2047, 2106, 1952, 2052, 2040, 2053, 2121, 2122, + /* 670 */ 2058, 2059, 2124, 2062, 2064, 2128, 2068, 2066, 2129, 2069, + /* 680 */ 2073, 2135, 2075, 2055, 2057, 2060, 2061, 2080, 2134, 2085, + /* 690 */ 2137, 2087, 2134, 2134, 2151, 2115, 2125, 2154, 2164, 2165, + /* 700 */ 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2136, 2119, 2173, + /* 710 */ 2179, 2180, 2181, 2196, 2184, 2186, 2187, 2153, 1878, 2188, + /* 720 */ 1880, 2192, 2193, 2194, 2195, 2209, 2197, 2233, 2199, 2190, + /* 730 */ 2198, 2235, 2201, 2204, 2202, 2238, 2207, 2208, 2206, 2243, + /* 740 */ 2221, 2212, 2231, 2271, 2237, 2239, 2273, 2253, 2255, 2257, + /* 750 */ 2258, 2256, 2261, }; #define YY_REDUCE_COUNT (310) -#define YY_REDUCE_MIN (-378) -#define YY_REDUCE_MAX (2353) +#define YY_REDUCE_MIN (-386) +#define YY_REDUCE_MAX (2319) static const short yy_reduce_ofst[] = { - /* 0 */ -199, 740, -275, 143, 856, 905, 963, 1021, 1065, 1093, + /* 0 */ -48, 740, -275, 143, 856, 905, 963, 1021, 1065, 1093, /* 10 */ 1190, 1260, 1292, 81, 1363, 1393, 421, -331, 323, 1425, - /* 20 */ 760, 1175, 1236, 1459, 1517, 1534, 1578, 1601, 1650, 1706, - /* 30 */ 1722, 1778, 1827, 1840, 1899, 1943, 1958, 1971, 2017, 2073, - /* 40 */ 2088, 2137, 2158, 2207, 2222, 2281, 2325, 2340, 2353, -265, - /* 50 */ 220, -345, -233, -48, 547, 637, 748, 87, 236, -353, - /* 60 */ -231, -175, -169, -311, 721, 331, 533, 221, -378, -333, - /* 70 */ 94, -327, -334, -261, -273, -144, -208, -171, -6, -4, - /* 80 */ 114, 242, 315, 359, 390, 121, 424, 449, -98, -365, - /* 90 */ 463, 478, -320, 492, -95, 549, 133, 556, 268, 129, - /* 100 */ 631, 640, 19, 735, 230, 334, 303, 744, 345, 23, - /* 110 */ 443, 443, -226, -179, 8, 240, 379, 660, 661, 716, - /* 120 */ 741, 746, 747, 751, 763, 774, 777, 784, 786, 787, - /* 130 */ 793, 806, 807, -293, -1, 347, 558, 624, -1, 150, - /* 140 */ 287, 483, 380, 464, 643, -330, -200, 144, 186, -57, - /* 150 */ 292, 122, 609, 634, 694, 730, 768, 792, -362, 393, - /* 160 */ 511, 531, 543, 673, 845, 543, 614, 893, 816, 853, - /* 170 */ 758, 808, 921, 854, 941, 941, 966, 923, 974, 976, - /* 180 */ 938, 929, 887, 887, 870, 887, 900, 892, 941, 934, - /* 190 */ 937, 950, 967, 969, 970, 971, 1020, 1023, 979, 977, - /* 200 */ 982, 1017, 1024, 1031, 1026, 1038, 1039, 1046, 1057, 1056, - /* 210 */ 1062, 1060, 998, 1061, 1030, 1064, 1068, 1014, 1066, 1073, - /* 220 */ 1069, 1070, 1071, 1076, 1072, 1077, 1078, 1094, 1058, 1063, - /* 230 */ 1084, 1086, 1087, 1088, 1095, 1097, 1099, 1100, 1101, 1089, - /* 240 */ 1104, 1047, 1049, 1054, 1050, 1074, 1083, 1117, 1105, 1109, - /* 250 */ 1119, 1130, 1091, 1102, 1113, 1025, 1103, 1114, 1052, 1108, - /* 260 */ 1120, 1126, 941, 1079, 1082, 1067, 1090, 1085, 1106, 1115, - /* 270 */ 1107, 1111, 1116, 887, 1197, 1124, 1203, 1202, 1199, 1204, - /* 280 */ 1155, 1154, 1170, 1172, 1173, 1174, 1179, 1166, 1180, 1171, - /* 290 */ 1217, 1207, 1220, 1223, 1134, 1208, 1196, 1216, 1234, 1235, - /* 300 */ 1250, 1253, 1186, 1177, 1211, 1225, 1229, 1241, 1255, 1266, - /* 310 */ 1259, + /* 20 */ 760, 1175, 1236, 1459, 1517, 1534, 1578, 1601, 1650, 1663, + /* 30 */ 1712, 1725, 1774, 1830, 1845, 1879, 1937, 1953, 1981, 1997, + /* 40 */ 2065, 2081, 2127, 2140, 2189, 2211, 2245, 2260, 2319, -265, + /* 50 */ 146, -345, -233, 539, 546, 748, 758, 236, 325, -353, + /* 60 */ -301, -231, 636, -284, -33, 662, 801, 114, -378, -333, + /* 70 */ -2, -323, -148, -135, 49, -375, -273, -237, 139, 230, + /* 80 */ 256, 351, 356, 437, 441, 135, 492, 558, 305, 147, + /* 90 */ 653, 658, 254, 736, 288, 656, 496, 746, 556, -358, + /* 100 */ 776, 782, 364, 732, 396, 621, 449, 797, 88, -225, + /* 110 */ -386, -386, -279, -248, -180, -146, 21, 151, 152, 180, + /* 120 */ 425, 522, 591, 747, 752, 787, 813, 814, 816, 821, + /* 130 */ 842, 854, 859, -213, 187, -85, -131, 215, 187, 268, + /* 140 */ 287, 388, 79, 128, 756, -330, -149, 375, 527, -116, + /* 150 */ 292, 426, 431, 512, 807, 827, 845, 532, 508, 562, + /* 160 */ 649, 667, 725, 901, 927, 725, 769, 851, 895, 925, + /* 170 */ 835, 857, 984, 878, 978, 978, 1006, 962, 1016, 1017, + /* 180 */ 981, 972, 918, 918, 903, 918, 930, 928, 978, 966, + /* 190 */ 968, 991, 1011, 1015, 1023, 1026, 1072, 1073, 1028, 1031, + /* 200 */ 1032, 1067, 1070, 1078, 1075, 1082, 1086, 1087, 1096, 1100, + /* 210 */ 1114, 1116, 1046, 1106, 1080, 1111, 1122, 1068, 1117, 1124, + /* 220 */ 1120, 1125, 1128, 1130, 1129, 1133, 1143, 1148, 1123, 1126, + /* 230 */ 1131, 1137, 1138, 1142, 1151, 1153, 1156, 1158, 1159, 1162, + /* 240 */ 1164, 1112, 1140, 1155, 1118, 1134, 1127, 1189, 1139, 1165, + /* 250 */ 1191, 1196, 1149, 1150, 1161, 1095, 1166, 1170, 1099, 1167, + /* 260 */ 1173, 1174, 978, 1103, 1101, 1107, 1115, 1168, 1119, 1160, + /* 270 */ 1102, 1110, 1141, 918, 1237, 1171, 1240, 1239, 1244, 1256, + /* 280 */ 1192, 1194, 1204, 1219, 1227, 1234, 1241, 1222, 1249, 1243, + /* 290 */ 1283, 1268, 1284, 1296, 1208, 1272, 1261, 1281, 1305, 1301, + /* 300 */ 1317, 1335, 1251, 1263, 1280, 1303, 1311, 1315, 1325, 1336, + /* 310 */ 1356, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 10 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 20 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 30 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 40 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 50 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 60 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 70 */ 1698, 1698, 1698, 1698, 1968, 1698, 1698, 1698, 1698, 1698, - /* 80 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1780, 1698, - /* 90 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 100 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1778, 1961, - /* 110 */ 2177, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 120 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 130 */ 1698, 1698, 1698, 1698, 2189, 1698, 1698, 1698, 2189, 2189, - /* 140 */ 2189, 1778, 2149, 2149, 1698, 1698, 1698, 1698, 1780, 2022, - /* 150 */ 1698, 1698, 1698, 1698, 1698, 1698, 1896, 1698, 1698, 1698, - /* 160 */ 1698, 1698, 1920, 1698, 1698, 1698, 2014, 1698, 1698, 2214, - /* 170 */ 2270, 1698, 1698, 2217, 1698, 1698, 1698, 1973, 1698, 1698, - /* 180 */ 1849, 2204, 2181, 2195, 2254, 2182, 2179, 2198, 1698, 2208, - /* 190 */ 1698, 2007, 1966, 1698, 1966, 1963, 1698, 1698, 1966, 1963, - /* 200 */ 1963, 1838, 1834, 1698, 1832, 1698, 1698, 1698, 1698, 1745, - /* 210 */ 1698, 1745, 1698, 1780, 1698, 1780, 1698, 1698, 1780, 1698, - /* 220 */ 1780, 1780, 1780, 1698, 1780, 1758, 1758, 1698, 1698, 1698, - /* 230 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 240 */ 1698, 1698, 1698, 1698, 2034, 2020, 1698, 1778, 2016, 1698, - /* 250 */ 1778, 1698, 1698, 1698, 1698, 2225, 2223, 1698, 2225, 2223, - /* 260 */ 1698, 1698, 1698, 2239, 2235, 2225, 2243, 2241, 2210, 2208, - /* 270 */ 2273, 2260, 2256, 2195, 1698, 1698, 1698, 1698, 1778, 1778, - /* 280 */ 1698, 2223, 1698, 1698, 1698, 1698, 1698, 2223, 1698, 1698, - /* 290 */ 1778, 1698, 1778, 1698, 1698, 1865, 1698, 1698, 1698, 1778, - /* 300 */ 1730, 1698, 2009, 2025, 1991, 1991, 1899, 1899, 1899, 1781, - /* 310 */ 1703, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 320 */ 1698, 1698, 1698, 2238, 2237, 2104, 1698, 2153, 2152, 2151, - /* 330 */ 2142, 2103, 1861, 1698, 2102, 2101, 1698, 1698, 1698, 1698, - /* 340 */ 1698, 1698, 1698, 1698, 1982, 1981, 2095, 1698, 1698, 2096, - /* 350 */ 2094, 2093, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 360 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 370 */ 1698, 1698, 1698, 2257, 2261, 1698, 1698, 1698, 1698, 1698, - /* 380 */ 1698, 1698, 2178, 1698, 1698, 1698, 1698, 1698, 2077, 1698, - /* 390 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 400 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 410 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 420 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 430 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 440 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 450 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 460 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 470 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 480 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 490 */ 1698, 1698, 1698, 1698, 1698, 1735, 2082, 1698, 1698, 1698, - /* 500 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 510 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 520 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 530 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 540 */ 1698, 1698, 1698, 1819, 1818, 1698, 1698, 1698, 1698, 1698, - /* 550 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 560 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 2086, 1698, 1698, - /* 570 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 580 */ 1698, 1698, 2253, 2211, 1698, 1698, 1698, 1698, 1698, 1698, - /* 590 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 600 */ 1698, 1698, 2077, 1698, 2236, 1698, 1698, 2251, 1698, 2255, - /* 610 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 2188, 2184, 1698, - /* 620 */ 1698, 2180, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 2085, - /* 630 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 640 */ 1698, 1698, 1698, 2076, 1698, 2139, 1698, 1698, 1698, 2173, - /* 650 */ 1698, 1698, 2124, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 660 */ 1698, 1698, 2086, 1698, 2089, 1698, 1698, 1698, 1698, 1698, - /* 670 */ 1893, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 680 */ 1698, 1698, 1698, 1878, 1876, 1875, 1874, 1698, 1871, 1698, - /* 690 */ 1906, 1698, 1698, 1698, 1902, 1901, 1698, 1698, 1698, 1698, - /* 700 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 710 */ 1698, 1799, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 720 */ 1791, 1698, 1790, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 730 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 740 */ 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, - /* 750 */ 1698, 1698, 1698, 1698, 1698, + /* 0 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 10 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 20 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 30 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 40 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 50 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 60 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 70 */ 1695, 1695, 1695, 1695, 1964, 1695, 1695, 1695, 1695, 1695, + /* 80 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1777, 1695, + /* 90 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 100 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1775, 1957, + /* 110 */ 2173, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 120 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 130 */ 1695, 1695, 1695, 1695, 2185, 1695, 1695, 1695, 2185, 2185, + /* 140 */ 2185, 1775, 2145, 2145, 1695, 1695, 1695, 1695, 1777, 2018, + /* 150 */ 1695, 1695, 1695, 1695, 1695, 1695, 1892, 1695, 1695, 1695, + /* 160 */ 1695, 1695, 1916, 1695, 1695, 1695, 2010, 1695, 1695, 2210, + /* 170 */ 2266, 1695, 1695, 2213, 1695, 1695, 1695, 1969, 1695, 1695, + /* 180 */ 1846, 2200, 2177, 2191, 2250, 2178, 2175, 2194, 1695, 2204, + /* 190 */ 1695, 2003, 1962, 1695, 1962, 1959, 1695, 1695, 1962, 1959, + /* 200 */ 1959, 1835, 1831, 1695, 1829, 1695, 1695, 1695, 1695, 1742, + /* 210 */ 1695, 1742, 1695, 1777, 1695, 1777, 1695, 1695, 1777, 1695, + /* 220 */ 1777, 1777, 1777, 1695, 1777, 1755, 1755, 1695, 1695, 1695, + /* 230 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 240 */ 1695, 1695, 1695, 1695, 2030, 2016, 1695, 1775, 2012, 1695, + /* 250 */ 1775, 1695, 1695, 1695, 1695, 2221, 2219, 1695, 2221, 2219, + /* 260 */ 1695, 1695, 1695, 2235, 2231, 2221, 2239, 2237, 2206, 2204, + /* 270 */ 2269, 2256, 2252, 2191, 1695, 1695, 1695, 1695, 1775, 1775, + /* 280 */ 1695, 2219, 1695, 1695, 1695, 1695, 1695, 2219, 1695, 1695, + /* 290 */ 1775, 1695, 1775, 1695, 1695, 1862, 1695, 1695, 1695, 1775, + /* 300 */ 1727, 1695, 2005, 2021, 1987, 1987, 1895, 1895, 1895, 1778, + /* 310 */ 1700, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 320 */ 1695, 1695, 1695, 2234, 2233, 2100, 1695, 2149, 2148, 2147, + /* 330 */ 2138, 2099, 1858, 1695, 2098, 2097, 1695, 1695, 1695, 1695, + /* 340 */ 1695, 1695, 1695, 1695, 1978, 1977, 2091, 1695, 1695, 2092, + /* 350 */ 2090, 2089, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 360 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 370 */ 1695, 1695, 1695, 2253, 2257, 1695, 1695, 1695, 1695, 1695, + /* 380 */ 1695, 1695, 2174, 1695, 1695, 1695, 1695, 1695, 2073, 1695, + /* 390 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 400 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 410 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 420 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 430 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 440 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 450 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 460 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 470 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 480 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 490 */ 1695, 1695, 1695, 1695, 1695, 1732, 2078, 1695, 1695, 1695, + /* 500 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 510 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 520 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 530 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 540 */ 1695, 1695, 1695, 1816, 1815, 1695, 1695, 1695, 1695, 1695, + /* 550 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 560 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 2082, 1695, 1695, + /* 570 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 580 */ 1695, 1695, 2249, 2207, 1695, 1695, 1695, 1695, 1695, 1695, + /* 590 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 600 */ 1695, 1695, 2073, 1695, 2232, 1695, 1695, 2247, 1695, 2251, + /* 610 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 2184, 2180, 1695, + /* 620 */ 1695, 2176, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 2081, + /* 630 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 640 */ 1695, 1695, 1695, 2072, 1695, 2135, 1695, 1695, 1695, 2169, + /* 650 */ 1695, 1695, 2120, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 660 */ 1695, 1695, 2082, 1695, 2085, 1695, 1695, 1695, 1695, 1695, + /* 670 */ 1889, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 680 */ 1695, 1695, 1695, 1874, 1872, 1871, 1870, 1695, 1902, 1695, + /* 690 */ 1695, 1695, 1898, 1897, 1695, 1695, 1695, 1695, 1695, 1695, + /* 700 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1796, + /* 710 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1788, 1695, + /* 720 */ 1787, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 730 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 740 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, + /* 750 */ 1695, 1695, 1695, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1104,7 +1098,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* NK_EQ => nothing */ 0, /* USING => nothing */ 0, /* TAGS => nothing */ - 0, /* COMMENT => nothing */ 0, /* BOOL => nothing */ 0, /* TINYINT => nothing */ 0, /* SMALLINT => nothing */ @@ -1122,6 +1115,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BLOB => nothing */ 0, /* VARBINARY => nothing */ 0, /* DECIMAL => nothing */ + 0, /* COMMENT => nothing */ 0, /* MAX_DELAY => nothing */ 0, /* WATERMARK => nothing */ 0, /* ROLLUP => nothing */ @@ -1519,24 +1513,24 @@ static const char *const yyTokenName[] = { /* 109 */ "NK_EQ", /* 110 */ "USING", /* 111 */ "TAGS", - /* 112 */ "COMMENT", - /* 113 */ "BOOL", - /* 114 */ "TINYINT", - /* 115 */ "SMALLINT", - /* 116 */ "INT", - /* 117 */ "INTEGER", - /* 118 */ "BIGINT", - /* 119 */ "FLOAT", - /* 120 */ "DOUBLE", - /* 121 */ "BINARY", - /* 122 */ "NCHAR", - /* 123 */ "UNSIGNED", - /* 124 */ "JSON", - /* 125 */ "VARCHAR", - /* 126 */ "MEDIUMBLOB", - /* 127 */ "BLOB", - /* 128 */ "VARBINARY", - /* 129 */ "DECIMAL", + /* 112 */ "BOOL", + /* 113 */ "TINYINT", + /* 114 */ "SMALLINT", + /* 115 */ "INT", + /* 116 */ "INTEGER", + /* 117 */ "BIGINT", + /* 118 */ "FLOAT", + /* 119 */ "DOUBLE", + /* 120 */ "BINARY", + /* 121 */ "NCHAR", + /* 122 */ "UNSIGNED", + /* 123 */ "JSON", + /* 124 */ "VARCHAR", + /* 125 */ "MEDIUMBLOB", + /* 126 */ "BLOB", + /* 127 */ "VARBINARY", + /* 128 */ "DECIMAL", + /* 129 */ "COMMENT", /* 130 */ "MAX_DELAY", /* 131 */ "WATERMARK", /* 132 */ "ROLLUP", @@ -2057,410 +2051,409 @@ static const char *const yyRuleName[] = { /* 168 */ "column_def_list ::= column_def", /* 169 */ "column_def_list ::= column_def_list NK_COMMA column_def", /* 170 */ "column_def ::= column_name type_name", - /* 171 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 172 */ "type_name ::= BOOL", - /* 173 */ "type_name ::= TINYINT", - /* 174 */ "type_name ::= SMALLINT", - /* 175 */ "type_name ::= INT", - /* 176 */ "type_name ::= INTEGER", - /* 177 */ "type_name ::= BIGINT", - /* 178 */ "type_name ::= FLOAT", - /* 179 */ "type_name ::= DOUBLE", - /* 180 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 181 */ "type_name ::= TIMESTAMP", - /* 182 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 183 */ "type_name ::= TINYINT UNSIGNED", - /* 184 */ "type_name ::= SMALLINT UNSIGNED", - /* 185 */ "type_name ::= INT UNSIGNED", - /* 186 */ "type_name ::= BIGINT UNSIGNED", - /* 187 */ "type_name ::= JSON", - /* 188 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 189 */ "type_name ::= MEDIUMBLOB", - /* 190 */ "type_name ::= BLOB", - /* 191 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 192 */ "type_name ::= DECIMAL", - /* 193 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 194 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 195 */ "tags_def_opt ::=", - /* 196 */ "tags_def_opt ::= tags_def", - /* 197 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 198 */ "table_options ::=", - /* 199 */ "table_options ::= table_options COMMENT NK_STRING", - /* 200 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 201 */ "table_options ::= table_options WATERMARK duration_list", - /* 202 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 203 */ "table_options ::= table_options TTL NK_INTEGER", - /* 204 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 205 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 206 */ "alter_table_options ::= alter_table_option", - /* 207 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 208 */ "alter_table_option ::= COMMENT NK_STRING", - /* 209 */ "alter_table_option ::= TTL NK_INTEGER", - /* 210 */ "duration_list ::= duration_literal", - /* 211 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 212 */ "rollup_func_list ::= rollup_func_name", - /* 213 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 214 */ "rollup_func_name ::= function_name", - /* 215 */ "rollup_func_name ::= FIRST", - /* 216 */ "rollup_func_name ::= LAST", - /* 217 */ "col_name_list ::= col_name", - /* 218 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 219 */ "col_name ::= column_name", - /* 220 */ "cmd ::= SHOW DNODES", - /* 221 */ "cmd ::= SHOW USERS", - /* 222 */ "cmd ::= SHOW USER PRIVILEGES", - /* 223 */ "cmd ::= SHOW DATABASES", - /* 224 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 225 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 226 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 227 */ "cmd ::= SHOW MNODES", - /* 228 */ "cmd ::= SHOW QNODES", - /* 229 */ "cmd ::= SHOW FUNCTIONS", - /* 230 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 231 */ "cmd ::= SHOW STREAMS", - /* 232 */ "cmd ::= SHOW ACCOUNTS", - /* 233 */ "cmd ::= SHOW APPS", - /* 234 */ "cmd ::= SHOW CONNECTIONS", - /* 235 */ "cmd ::= SHOW LICENCES", - /* 236 */ "cmd ::= SHOW GRANTS", - /* 237 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 238 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 239 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 240 */ "cmd ::= SHOW QUERIES", - /* 241 */ "cmd ::= SHOW SCORES", - /* 242 */ "cmd ::= SHOW TOPICS", - /* 243 */ "cmd ::= SHOW VARIABLES", - /* 244 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 245 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 246 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 247 */ "cmd ::= SHOW BNODES", - /* 248 */ "cmd ::= SHOW SNODES", - /* 249 */ "cmd ::= SHOW CLUSTER", - /* 250 */ "cmd ::= SHOW TRANSACTIONS", - /* 251 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 252 */ "cmd ::= SHOW CONSUMERS", - /* 253 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 254 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 255 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 256 */ "cmd ::= SHOW VNODES NK_INTEGER", - /* 257 */ "cmd ::= SHOW VNODES NK_STRING", - /* 258 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 259 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 260 */ "db_name_cond_opt ::=", - /* 261 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 262 */ "like_pattern_opt ::=", - /* 263 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 264 */ "table_name_cond ::= table_name", - /* 265 */ "from_db_opt ::=", - /* 266 */ "from_db_opt ::= FROM db_name", - /* 267 */ "tag_list_opt ::=", - /* 268 */ "tag_list_opt ::= tag_item", - /* 269 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 270 */ "tag_item ::= TBNAME", - /* 271 */ "tag_item ::= QTAGS", - /* 272 */ "tag_item ::= column_name", - /* 273 */ "tag_item ::= column_name column_alias", - /* 274 */ "tag_item ::= column_name AS column_alias", - /* 275 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", - /* 276 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", - /* 277 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 278 */ "full_index_name ::= index_name", - /* 279 */ "full_index_name ::= db_name NK_DOT index_name", - /* 280 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 281 */ "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", - /* 282 */ "func_list ::= func", - /* 283 */ "func_list ::= func_list NK_COMMA func", - /* 284 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 285 */ "sma_func_name ::= function_name", - /* 286 */ "sma_func_name ::= COUNT", - /* 287 */ "sma_func_name ::= FIRST", - /* 288 */ "sma_func_name ::= LAST", - /* 289 */ "sma_func_name ::= LAST_ROW", - /* 290 */ "sma_stream_opt ::=", - /* 291 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 292 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 293 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 294 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 295 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 296 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 297 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 298 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 299 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 300 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 301 */ "cmd ::= DESC full_table_name", - /* 302 */ "cmd ::= DESCRIBE full_table_name", - /* 303 */ "cmd ::= RESET QUERY CACHE", - /* 304 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 305 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 306 */ "analyze_opt ::=", - /* 307 */ "analyze_opt ::= ANALYZE", - /* 308 */ "explain_options ::=", - /* 309 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 310 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 311 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 312 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 313 */ "agg_func_opt ::=", - /* 314 */ "agg_func_opt ::= AGGREGATE", - /* 315 */ "bufsize_opt ::=", - /* 316 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 317 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 318 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 319 */ "col_list_opt ::=", - /* 320 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 321 */ "tag_def_or_ref_opt ::=", - /* 322 */ "tag_def_or_ref_opt ::= tags_def", - /* 323 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 324 */ "stream_options ::=", - /* 325 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 326 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 327 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 328 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 329 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 330 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 331 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 332 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 333 */ "subtable_opt ::=", - /* 334 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 335 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 336 */ "cmd ::= KILL QUERY NK_STRING", - /* 337 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 338 */ "cmd ::= BALANCE VGROUP", - /* 339 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 340 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 341 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 342 */ "dnode_list ::= DNODE NK_INTEGER", - /* 343 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 344 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 345 */ "cmd ::= query_or_subquery", - /* 346 */ "cmd ::= insert_query", - /* 347 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 348 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 349 */ "literal ::= NK_INTEGER", - /* 350 */ "literal ::= NK_FLOAT", - /* 351 */ "literal ::= NK_STRING", - /* 352 */ "literal ::= NK_BOOL", - /* 353 */ "literal ::= TIMESTAMP NK_STRING", - /* 354 */ "literal ::= duration_literal", - /* 355 */ "literal ::= NULL", - /* 356 */ "literal ::= NK_QUESTION", - /* 357 */ "duration_literal ::= NK_VARIABLE", - /* 358 */ "signed ::= NK_INTEGER", - /* 359 */ "signed ::= NK_PLUS NK_INTEGER", - /* 360 */ "signed ::= NK_MINUS NK_INTEGER", - /* 361 */ "signed ::= NK_FLOAT", - /* 362 */ "signed ::= NK_PLUS NK_FLOAT", - /* 363 */ "signed ::= NK_MINUS NK_FLOAT", - /* 364 */ "signed_literal ::= signed", - /* 365 */ "signed_literal ::= NK_STRING", - /* 366 */ "signed_literal ::= NK_BOOL", - /* 367 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 368 */ "signed_literal ::= duration_literal", - /* 369 */ "signed_literal ::= NULL", - /* 370 */ "signed_literal ::= literal_func", - /* 371 */ "signed_literal ::= NK_QUESTION", - /* 372 */ "literal_list ::= signed_literal", - /* 373 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 374 */ "db_name ::= NK_ID", - /* 375 */ "table_name ::= NK_ID", - /* 376 */ "column_name ::= NK_ID", - /* 377 */ "function_name ::= NK_ID", - /* 378 */ "table_alias ::= NK_ID", - /* 379 */ "column_alias ::= NK_ID", - /* 380 */ "user_name ::= NK_ID", - /* 381 */ "topic_name ::= NK_ID", - /* 382 */ "stream_name ::= NK_ID", - /* 383 */ "cgroup_name ::= NK_ID", - /* 384 */ "index_name ::= NK_ID", - /* 385 */ "expr_or_subquery ::= expression", - /* 386 */ "expression ::= literal", - /* 387 */ "expression ::= pseudo_column", - /* 388 */ "expression ::= column_reference", - /* 389 */ "expression ::= function_expression", - /* 390 */ "expression ::= case_when_expression", - /* 391 */ "expression ::= NK_LP expression NK_RP", - /* 392 */ "expression ::= NK_PLUS expr_or_subquery", - /* 393 */ "expression ::= NK_MINUS expr_or_subquery", - /* 394 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 395 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 396 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 397 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 398 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 399 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 400 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 401 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 402 */ "expression_list ::= expr_or_subquery", - /* 403 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 404 */ "column_reference ::= column_name", - /* 405 */ "column_reference ::= table_name NK_DOT column_name", - /* 406 */ "pseudo_column ::= ROWTS", - /* 407 */ "pseudo_column ::= TBNAME", - /* 408 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 409 */ "pseudo_column ::= QSTART", - /* 410 */ "pseudo_column ::= QEND", - /* 411 */ "pseudo_column ::= QDURATION", - /* 412 */ "pseudo_column ::= WSTART", - /* 413 */ "pseudo_column ::= WEND", - /* 414 */ "pseudo_column ::= WDURATION", - /* 415 */ "pseudo_column ::= IROWTS", - /* 416 */ "pseudo_column ::= ISFILLED", - /* 417 */ "pseudo_column ::= QTAGS", - /* 418 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 419 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 420 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 421 */ "function_expression ::= literal_func", - /* 422 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 423 */ "literal_func ::= NOW", - /* 424 */ "noarg_func ::= NOW", - /* 425 */ "noarg_func ::= TODAY", - /* 426 */ "noarg_func ::= TIMEZONE", - /* 427 */ "noarg_func ::= DATABASE", - /* 428 */ "noarg_func ::= CLIENT_VERSION", - /* 429 */ "noarg_func ::= SERVER_VERSION", - /* 430 */ "noarg_func ::= SERVER_STATUS", - /* 431 */ "noarg_func ::= CURRENT_USER", - /* 432 */ "noarg_func ::= USER", - /* 433 */ "star_func ::= COUNT", - /* 434 */ "star_func ::= FIRST", - /* 435 */ "star_func ::= LAST", - /* 436 */ "star_func ::= LAST_ROW", - /* 437 */ "star_func_para_list ::= NK_STAR", - /* 438 */ "star_func_para_list ::= other_para_list", - /* 439 */ "other_para_list ::= star_func_para", - /* 440 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 441 */ "star_func_para ::= expr_or_subquery", - /* 442 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 443 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 444 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 445 */ "when_then_list ::= when_then_expr", - /* 446 */ "when_then_list ::= when_then_list when_then_expr", - /* 447 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 448 */ "case_when_else_opt ::=", - /* 449 */ "case_when_else_opt ::= ELSE common_expression", - /* 450 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 451 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 452 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 453 */ "predicate ::= expr_or_subquery IS NULL", - /* 454 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 455 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 456 */ "compare_op ::= NK_LT", - /* 457 */ "compare_op ::= NK_GT", - /* 458 */ "compare_op ::= NK_LE", - /* 459 */ "compare_op ::= NK_GE", - /* 460 */ "compare_op ::= NK_NE", - /* 461 */ "compare_op ::= NK_EQ", - /* 462 */ "compare_op ::= LIKE", - /* 463 */ "compare_op ::= NOT LIKE", - /* 464 */ "compare_op ::= MATCH", - /* 465 */ "compare_op ::= NMATCH", - /* 466 */ "compare_op ::= CONTAINS", - /* 467 */ "in_op ::= IN", - /* 468 */ "in_op ::= NOT IN", - /* 469 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 470 */ "boolean_value_expression ::= boolean_primary", - /* 471 */ "boolean_value_expression ::= NOT boolean_primary", - /* 472 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 473 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 474 */ "boolean_primary ::= predicate", - /* 475 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 476 */ "common_expression ::= expr_or_subquery", - /* 477 */ "common_expression ::= boolean_value_expression", - /* 478 */ "from_clause_opt ::=", - /* 479 */ "from_clause_opt ::= FROM table_reference_list", - /* 480 */ "table_reference_list ::= table_reference", - /* 481 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 482 */ "table_reference ::= table_primary", - /* 483 */ "table_reference ::= joined_table", - /* 484 */ "table_primary ::= table_name alias_opt", - /* 485 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 486 */ "table_primary ::= subquery alias_opt", - /* 487 */ "table_primary ::= parenthesized_joined_table", - /* 488 */ "alias_opt ::=", - /* 489 */ "alias_opt ::= table_alias", - /* 490 */ "alias_opt ::= AS table_alias", - /* 491 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 492 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 493 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 494 */ "join_type ::=", - /* 495 */ "join_type ::= INNER", - /* 496 */ "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", - /* 497 */ "set_quantifier_opt ::=", - /* 498 */ "set_quantifier_opt ::= DISTINCT", - /* 499 */ "set_quantifier_opt ::= ALL", - /* 500 */ "select_list ::= select_item", - /* 501 */ "select_list ::= select_list NK_COMMA select_item", - /* 502 */ "select_item ::= NK_STAR", - /* 503 */ "select_item ::= common_expression", - /* 504 */ "select_item ::= common_expression column_alias", - /* 505 */ "select_item ::= common_expression AS column_alias", - /* 506 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 507 */ "where_clause_opt ::=", - /* 508 */ "where_clause_opt ::= WHERE search_condition", - /* 509 */ "partition_by_clause_opt ::=", - /* 510 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 511 */ "partition_list ::= partition_item", - /* 512 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 513 */ "partition_item ::= expr_or_subquery", - /* 514 */ "partition_item ::= expr_or_subquery column_alias", - /* 515 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 516 */ "twindow_clause_opt ::=", - /* 517 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 518 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 519 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 520 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 521 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 522 */ "sliding_opt ::=", - /* 523 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 524 */ "fill_opt ::=", - /* 525 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 526 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 527 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", - /* 528 */ "fill_mode ::= NONE", - /* 529 */ "fill_mode ::= PREV", - /* 530 */ "fill_mode ::= NULL", - /* 531 */ "fill_mode ::= NULL_F", - /* 532 */ "fill_mode ::= LINEAR", - /* 533 */ "fill_mode ::= NEXT", - /* 534 */ "group_by_clause_opt ::=", - /* 535 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 536 */ "group_by_list ::= expr_or_subquery", - /* 537 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 538 */ "having_clause_opt ::=", - /* 539 */ "having_clause_opt ::= HAVING search_condition", - /* 540 */ "range_opt ::=", - /* 541 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 542 */ "every_opt ::=", - /* 543 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 544 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 545 */ "query_simple ::= query_specification", - /* 546 */ "query_simple ::= union_query_expression", - /* 547 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 548 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 549 */ "query_simple_or_subquery ::= query_simple", - /* 550 */ "query_simple_or_subquery ::= subquery", - /* 551 */ "query_or_subquery ::= query_expression", - /* 552 */ "query_or_subquery ::= subquery", - /* 553 */ "order_by_clause_opt ::=", - /* 554 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 555 */ "slimit_clause_opt ::=", - /* 556 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 557 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 558 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 559 */ "limit_clause_opt ::=", - /* 560 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 561 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 562 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 563 */ "subquery ::= NK_LP query_expression NK_RP", - /* 564 */ "subquery ::= NK_LP subquery NK_RP", - /* 565 */ "search_condition ::= common_expression", - /* 566 */ "sort_specification_list ::= sort_specification", - /* 567 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 568 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 569 */ "ordering_specification_opt ::=", - /* 570 */ "ordering_specification_opt ::= ASC", - /* 571 */ "ordering_specification_opt ::= DESC", - /* 572 */ "null_ordering_opt ::=", - /* 573 */ "null_ordering_opt ::= NULLS FIRST", - /* 574 */ "null_ordering_opt ::= NULLS LAST", + /* 171 */ "type_name ::= BOOL", + /* 172 */ "type_name ::= TINYINT", + /* 173 */ "type_name ::= SMALLINT", + /* 174 */ "type_name ::= INT", + /* 175 */ "type_name ::= INTEGER", + /* 176 */ "type_name ::= BIGINT", + /* 177 */ "type_name ::= FLOAT", + /* 178 */ "type_name ::= DOUBLE", + /* 179 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 180 */ "type_name ::= TIMESTAMP", + /* 181 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 182 */ "type_name ::= TINYINT UNSIGNED", + /* 183 */ "type_name ::= SMALLINT UNSIGNED", + /* 184 */ "type_name ::= INT UNSIGNED", + /* 185 */ "type_name ::= BIGINT UNSIGNED", + /* 186 */ "type_name ::= JSON", + /* 187 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 188 */ "type_name ::= MEDIUMBLOB", + /* 189 */ "type_name ::= BLOB", + /* 190 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 191 */ "type_name ::= DECIMAL", + /* 192 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 193 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 194 */ "tags_def_opt ::=", + /* 195 */ "tags_def_opt ::= tags_def", + /* 196 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 197 */ "table_options ::=", + /* 198 */ "table_options ::= table_options COMMENT NK_STRING", + /* 199 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 200 */ "table_options ::= table_options WATERMARK duration_list", + /* 201 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 202 */ "table_options ::= table_options TTL NK_INTEGER", + /* 203 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 204 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 205 */ "alter_table_options ::= alter_table_option", + /* 206 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 207 */ "alter_table_option ::= COMMENT NK_STRING", + /* 208 */ "alter_table_option ::= TTL NK_INTEGER", + /* 209 */ "duration_list ::= duration_literal", + /* 210 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 211 */ "rollup_func_list ::= rollup_func_name", + /* 212 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 213 */ "rollup_func_name ::= function_name", + /* 214 */ "rollup_func_name ::= FIRST", + /* 215 */ "rollup_func_name ::= LAST", + /* 216 */ "col_name_list ::= col_name", + /* 217 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 218 */ "col_name ::= column_name", + /* 219 */ "cmd ::= SHOW DNODES", + /* 220 */ "cmd ::= SHOW USERS", + /* 221 */ "cmd ::= SHOW USER PRIVILEGES", + /* 222 */ "cmd ::= SHOW DATABASES", + /* 223 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 224 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 225 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 226 */ "cmd ::= SHOW MNODES", + /* 227 */ "cmd ::= SHOW QNODES", + /* 228 */ "cmd ::= SHOW FUNCTIONS", + /* 229 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 230 */ "cmd ::= SHOW STREAMS", + /* 231 */ "cmd ::= SHOW ACCOUNTS", + /* 232 */ "cmd ::= SHOW APPS", + /* 233 */ "cmd ::= SHOW CONNECTIONS", + /* 234 */ "cmd ::= SHOW LICENCES", + /* 235 */ "cmd ::= SHOW GRANTS", + /* 236 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 237 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 238 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 239 */ "cmd ::= SHOW QUERIES", + /* 240 */ "cmd ::= SHOW SCORES", + /* 241 */ "cmd ::= SHOW TOPICS", + /* 242 */ "cmd ::= SHOW VARIABLES", + /* 243 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 244 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 245 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 246 */ "cmd ::= SHOW BNODES", + /* 247 */ "cmd ::= SHOW SNODES", + /* 248 */ "cmd ::= SHOW CLUSTER", + /* 249 */ "cmd ::= SHOW TRANSACTIONS", + /* 250 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 251 */ "cmd ::= SHOW CONSUMERS", + /* 252 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 253 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 254 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 255 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 256 */ "cmd ::= SHOW VNODES NK_STRING", + /* 257 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 258 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 259 */ "db_name_cond_opt ::=", + /* 260 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 261 */ "like_pattern_opt ::=", + /* 262 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 263 */ "table_name_cond ::= table_name", + /* 264 */ "from_db_opt ::=", + /* 265 */ "from_db_opt ::= FROM db_name", + /* 266 */ "tag_list_opt ::=", + /* 267 */ "tag_list_opt ::= tag_item", + /* 268 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 269 */ "tag_item ::= TBNAME", + /* 270 */ "tag_item ::= QTAGS", + /* 271 */ "tag_item ::= column_name", + /* 272 */ "tag_item ::= column_name column_alias", + /* 273 */ "tag_item ::= column_name AS column_alias", + /* 274 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", + /* 275 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", + /* 276 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 277 */ "full_index_name ::= index_name", + /* 278 */ "full_index_name ::= db_name NK_DOT index_name", + /* 279 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 280 */ "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", + /* 281 */ "func_list ::= func", + /* 282 */ "func_list ::= func_list NK_COMMA func", + /* 283 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 284 */ "sma_func_name ::= function_name", + /* 285 */ "sma_func_name ::= COUNT", + /* 286 */ "sma_func_name ::= FIRST", + /* 287 */ "sma_func_name ::= LAST", + /* 288 */ "sma_func_name ::= LAST_ROW", + /* 289 */ "sma_stream_opt ::=", + /* 290 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 291 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 292 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 293 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 294 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 295 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 296 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 297 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 298 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 299 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 300 */ "cmd ::= DESC full_table_name", + /* 301 */ "cmd ::= DESCRIBE full_table_name", + /* 302 */ "cmd ::= RESET QUERY CACHE", + /* 303 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 304 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 305 */ "analyze_opt ::=", + /* 306 */ "analyze_opt ::= ANALYZE", + /* 307 */ "explain_options ::=", + /* 308 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 309 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 310 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 311 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 312 */ "agg_func_opt ::=", + /* 313 */ "agg_func_opt ::= AGGREGATE", + /* 314 */ "bufsize_opt ::=", + /* 315 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 316 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 317 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 318 */ "col_list_opt ::=", + /* 319 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 320 */ "tag_def_or_ref_opt ::=", + /* 321 */ "tag_def_or_ref_opt ::= tags_def", + /* 322 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", + /* 323 */ "stream_options ::=", + /* 324 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 325 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 326 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 327 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 328 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 329 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 330 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 331 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 332 */ "subtable_opt ::=", + /* 333 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 334 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 335 */ "cmd ::= KILL QUERY NK_STRING", + /* 336 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 337 */ "cmd ::= BALANCE VGROUP", + /* 338 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 339 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 340 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 341 */ "dnode_list ::= DNODE NK_INTEGER", + /* 342 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 343 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 344 */ "cmd ::= query_or_subquery", + /* 345 */ "cmd ::= insert_query", + /* 346 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 347 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 348 */ "literal ::= NK_INTEGER", + /* 349 */ "literal ::= NK_FLOAT", + /* 350 */ "literal ::= NK_STRING", + /* 351 */ "literal ::= NK_BOOL", + /* 352 */ "literal ::= TIMESTAMP NK_STRING", + /* 353 */ "literal ::= duration_literal", + /* 354 */ "literal ::= NULL", + /* 355 */ "literal ::= NK_QUESTION", + /* 356 */ "duration_literal ::= NK_VARIABLE", + /* 357 */ "signed ::= NK_INTEGER", + /* 358 */ "signed ::= NK_PLUS NK_INTEGER", + /* 359 */ "signed ::= NK_MINUS NK_INTEGER", + /* 360 */ "signed ::= NK_FLOAT", + /* 361 */ "signed ::= NK_PLUS NK_FLOAT", + /* 362 */ "signed ::= NK_MINUS NK_FLOAT", + /* 363 */ "signed_literal ::= signed", + /* 364 */ "signed_literal ::= NK_STRING", + /* 365 */ "signed_literal ::= NK_BOOL", + /* 366 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 367 */ "signed_literal ::= duration_literal", + /* 368 */ "signed_literal ::= NULL", + /* 369 */ "signed_literal ::= literal_func", + /* 370 */ "signed_literal ::= NK_QUESTION", + /* 371 */ "literal_list ::= signed_literal", + /* 372 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 373 */ "db_name ::= NK_ID", + /* 374 */ "table_name ::= NK_ID", + /* 375 */ "column_name ::= NK_ID", + /* 376 */ "function_name ::= NK_ID", + /* 377 */ "table_alias ::= NK_ID", + /* 378 */ "column_alias ::= NK_ID", + /* 379 */ "user_name ::= NK_ID", + /* 380 */ "topic_name ::= NK_ID", + /* 381 */ "stream_name ::= NK_ID", + /* 382 */ "cgroup_name ::= NK_ID", + /* 383 */ "index_name ::= NK_ID", + /* 384 */ "expr_or_subquery ::= expression", + /* 385 */ "expression ::= literal", + /* 386 */ "expression ::= pseudo_column", + /* 387 */ "expression ::= column_reference", + /* 388 */ "expression ::= function_expression", + /* 389 */ "expression ::= case_when_expression", + /* 390 */ "expression ::= NK_LP expression NK_RP", + /* 391 */ "expression ::= NK_PLUS expr_or_subquery", + /* 392 */ "expression ::= NK_MINUS expr_or_subquery", + /* 393 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 394 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 395 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 396 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 397 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 398 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 399 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 400 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 401 */ "expression_list ::= expr_or_subquery", + /* 402 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 403 */ "column_reference ::= column_name", + /* 404 */ "column_reference ::= table_name NK_DOT column_name", + /* 405 */ "pseudo_column ::= ROWTS", + /* 406 */ "pseudo_column ::= TBNAME", + /* 407 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 408 */ "pseudo_column ::= QSTART", + /* 409 */ "pseudo_column ::= QEND", + /* 410 */ "pseudo_column ::= QDURATION", + /* 411 */ "pseudo_column ::= WSTART", + /* 412 */ "pseudo_column ::= WEND", + /* 413 */ "pseudo_column ::= WDURATION", + /* 414 */ "pseudo_column ::= IROWTS", + /* 415 */ "pseudo_column ::= ISFILLED", + /* 416 */ "pseudo_column ::= QTAGS", + /* 417 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 418 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 419 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 420 */ "function_expression ::= literal_func", + /* 421 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 422 */ "literal_func ::= NOW", + /* 423 */ "noarg_func ::= NOW", + /* 424 */ "noarg_func ::= TODAY", + /* 425 */ "noarg_func ::= TIMEZONE", + /* 426 */ "noarg_func ::= DATABASE", + /* 427 */ "noarg_func ::= CLIENT_VERSION", + /* 428 */ "noarg_func ::= SERVER_VERSION", + /* 429 */ "noarg_func ::= SERVER_STATUS", + /* 430 */ "noarg_func ::= CURRENT_USER", + /* 431 */ "noarg_func ::= USER", + /* 432 */ "star_func ::= COUNT", + /* 433 */ "star_func ::= FIRST", + /* 434 */ "star_func ::= LAST", + /* 435 */ "star_func ::= LAST_ROW", + /* 436 */ "star_func_para_list ::= NK_STAR", + /* 437 */ "star_func_para_list ::= other_para_list", + /* 438 */ "other_para_list ::= star_func_para", + /* 439 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 440 */ "star_func_para ::= expr_or_subquery", + /* 441 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 442 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 443 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 444 */ "when_then_list ::= when_then_expr", + /* 445 */ "when_then_list ::= when_then_list when_then_expr", + /* 446 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 447 */ "case_when_else_opt ::=", + /* 448 */ "case_when_else_opt ::= ELSE common_expression", + /* 449 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 450 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 451 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 452 */ "predicate ::= expr_or_subquery IS NULL", + /* 453 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 454 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 455 */ "compare_op ::= NK_LT", + /* 456 */ "compare_op ::= NK_GT", + /* 457 */ "compare_op ::= NK_LE", + /* 458 */ "compare_op ::= NK_GE", + /* 459 */ "compare_op ::= NK_NE", + /* 460 */ "compare_op ::= NK_EQ", + /* 461 */ "compare_op ::= LIKE", + /* 462 */ "compare_op ::= NOT LIKE", + /* 463 */ "compare_op ::= MATCH", + /* 464 */ "compare_op ::= NMATCH", + /* 465 */ "compare_op ::= CONTAINS", + /* 466 */ "in_op ::= IN", + /* 467 */ "in_op ::= NOT IN", + /* 468 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 469 */ "boolean_value_expression ::= boolean_primary", + /* 470 */ "boolean_value_expression ::= NOT boolean_primary", + /* 471 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 472 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 473 */ "boolean_primary ::= predicate", + /* 474 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 475 */ "common_expression ::= expr_or_subquery", + /* 476 */ "common_expression ::= boolean_value_expression", + /* 477 */ "from_clause_opt ::=", + /* 478 */ "from_clause_opt ::= FROM table_reference_list", + /* 479 */ "table_reference_list ::= table_reference", + /* 480 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 481 */ "table_reference ::= table_primary", + /* 482 */ "table_reference ::= joined_table", + /* 483 */ "table_primary ::= table_name alias_opt", + /* 484 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 485 */ "table_primary ::= subquery alias_opt", + /* 486 */ "table_primary ::= parenthesized_joined_table", + /* 487 */ "alias_opt ::=", + /* 488 */ "alias_opt ::= table_alias", + /* 489 */ "alias_opt ::= AS table_alias", + /* 490 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 491 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 492 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 493 */ "join_type ::=", + /* 494 */ "join_type ::= INNER", + /* 495 */ "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", + /* 496 */ "set_quantifier_opt ::=", + /* 497 */ "set_quantifier_opt ::= DISTINCT", + /* 498 */ "set_quantifier_opt ::= ALL", + /* 499 */ "select_list ::= select_item", + /* 500 */ "select_list ::= select_list NK_COMMA select_item", + /* 501 */ "select_item ::= NK_STAR", + /* 502 */ "select_item ::= common_expression", + /* 503 */ "select_item ::= common_expression column_alias", + /* 504 */ "select_item ::= common_expression AS column_alias", + /* 505 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 506 */ "where_clause_opt ::=", + /* 507 */ "where_clause_opt ::= WHERE search_condition", + /* 508 */ "partition_by_clause_opt ::=", + /* 509 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 510 */ "partition_list ::= partition_item", + /* 511 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 512 */ "partition_item ::= expr_or_subquery", + /* 513 */ "partition_item ::= expr_or_subquery column_alias", + /* 514 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 515 */ "twindow_clause_opt ::=", + /* 516 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 517 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 518 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 519 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 520 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 521 */ "sliding_opt ::=", + /* 522 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 523 */ "fill_opt ::=", + /* 524 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 525 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 526 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", + /* 527 */ "fill_mode ::= NONE", + /* 528 */ "fill_mode ::= PREV", + /* 529 */ "fill_mode ::= NULL", + /* 530 */ "fill_mode ::= NULL_F", + /* 531 */ "fill_mode ::= LINEAR", + /* 532 */ "fill_mode ::= NEXT", + /* 533 */ "group_by_clause_opt ::=", + /* 534 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 535 */ "group_by_list ::= expr_or_subquery", + /* 536 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 537 */ "having_clause_opt ::=", + /* 538 */ "having_clause_opt ::= HAVING search_condition", + /* 539 */ "range_opt ::=", + /* 540 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 541 */ "every_opt ::=", + /* 542 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 543 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 544 */ "query_simple ::= query_specification", + /* 545 */ "query_simple ::= union_query_expression", + /* 546 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 547 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 548 */ "query_simple_or_subquery ::= query_simple", + /* 549 */ "query_simple_or_subquery ::= subquery", + /* 550 */ "query_or_subquery ::= query_expression", + /* 551 */ "query_or_subquery ::= subquery", + /* 552 */ "order_by_clause_opt ::=", + /* 553 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 554 */ "slimit_clause_opt ::=", + /* 555 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 556 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 557 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 558 */ "limit_clause_opt ::=", + /* 559 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 560 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 561 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 562 */ "subquery ::= NK_LP query_expression NK_RP", + /* 563 */ "subquery ::= NK_LP subquery NK_RP", + /* 564 */ "search_condition ::= common_expression", + /* 565 */ "sort_specification_list ::= sort_specification", + /* 566 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 567 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 568 */ "ordering_specification_opt ::=", + /* 569 */ "ordering_specification_opt ::= ASC", + /* 570 */ "ordering_specification_opt ::= DESC", + /* 571 */ "null_ordering_opt ::=", + /* 572 */ "null_ordering_opt ::= NULLS FIRST", + /* 573 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3256,410 +3249,409 @@ static const struct { { 359, -1 }, /* (168) column_def_list ::= column_def */ { 359, -3 }, /* (169) column_def_list ::= column_def_list NK_COMMA column_def */ { 375, -2 }, /* (170) column_def ::= column_name type_name */ - { 375, -4 }, /* (171) column_def ::= column_name type_name COMMENT NK_STRING */ - { 368, -1 }, /* (172) type_name ::= BOOL */ - { 368, -1 }, /* (173) type_name ::= TINYINT */ - { 368, -1 }, /* (174) type_name ::= SMALLINT */ - { 368, -1 }, /* (175) type_name ::= INT */ - { 368, -1 }, /* (176) type_name ::= INTEGER */ - { 368, -1 }, /* (177) type_name ::= BIGINT */ - { 368, -1 }, /* (178) type_name ::= FLOAT */ - { 368, -1 }, /* (179) type_name ::= DOUBLE */ - { 368, -4 }, /* (180) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 368, -1 }, /* (181) type_name ::= TIMESTAMP */ - { 368, -4 }, /* (182) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 368, -2 }, /* (183) type_name ::= TINYINT UNSIGNED */ - { 368, -2 }, /* (184) type_name ::= SMALLINT UNSIGNED */ - { 368, -2 }, /* (185) type_name ::= INT UNSIGNED */ - { 368, -2 }, /* (186) type_name ::= BIGINT UNSIGNED */ - { 368, -1 }, /* (187) type_name ::= JSON */ - { 368, -4 }, /* (188) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 368, -1 }, /* (189) type_name ::= MEDIUMBLOB */ - { 368, -1 }, /* (190) type_name ::= BLOB */ - { 368, -4 }, /* (191) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 368, -1 }, /* (192) type_name ::= DECIMAL */ - { 368, -4 }, /* (193) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 368, -6 }, /* (194) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 360, 0 }, /* (195) tags_def_opt ::= */ - { 360, -1 }, /* (196) tags_def_opt ::= tags_def */ - { 363, -4 }, /* (197) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 361, 0 }, /* (198) table_options ::= */ - { 361, -3 }, /* (199) table_options ::= table_options COMMENT NK_STRING */ - { 361, -3 }, /* (200) table_options ::= table_options MAX_DELAY duration_list */ - { 361, -3 }, /* (201) table_options ::= table_options WATERMARK duration_list */ - { 361, -5 }, /* (202) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 361, -3 }, /* (203) table_options ::= table_options TTL NK_INTEGER */ - { 361, -5 }, /* (204) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 361, -3 }, /* (205) table_options ::= table_options DELETE_MARK duration_list */ - { 366, -1 }, /* (206) alter_table_options ::= alter_table_option */ - { 366, -2 }, /* (207) alter_table_options ::= alter_table_options alter_table_option */ - { 378, -2 }, /* (208) alter_table_option ::= COMMENT NK_STRING */ - { 378, -2 }, /* (209) alter_table_option ::= TTL NK_INTEGER */ - { 376, -1 }, /* (210) duration_list ::= duration_literal */ - { 376, -3 }, /* (211) duration_list ::= duration_list NK_COMMA duration_literal */ - { 377, -1 }, /* (212) rollup_func_list ::= rollup_func_name */ - { 377, -3 }, /* (213) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 380, -1 }, /* (214) rollup_func_name ::= function_name */ - { 380, -1 }, /* (215) rollup_func_name ::= FIRST */ - { 380, -1 }, /* (216) rollup_func_name ::= LAST */ - { 374, -1 }, /* (217) col_name_list ::= col_name */ - { 374, -3 }, /* (218) col_name_list ::= col_name_list NK_COMMA col_name */ - { 382, -1 }, /* (219) col_name ::= column_name */ - { 328, -2 }, /* (220) cmd ::= SHOW DNODES */ - { 328, -2 }, /* (221) cmd ::= SHOW USERS */ - { 328, -3 }, /* (222) cmd ::= SHOW USER PRIVILEGES */ - { 328, -2 }, /* (223) cmd ::= SHOW DATABASES */ - { 328, -4 }, /* (224) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 328, -4 }, /* (225) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 328, -3 }, /* (226) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 328, -2 }, /* (227) cmd ::= SHOW MNODES */ - { 328, -2 }, /* (228) cmd ::= SHOW QNODES */ - { 328, -2 }, /* (229) cmd ::= SHOW FUNCTIONS */ - { 328, -5 }, /* (230) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 328, -2 }, /* (231) cmd ::= SHOW STREAMS */ - { 328, -2 }, /* (232) cmd ::= SHOW ACCOUNTS */ - { 328, -2 }, /* (233) cmd ::= SHOW APPS */ - { 328, -2 }, /* (234) cmd ::= SHOW CONNECTIONS */ - { 328, -2 }, /* (235) cmd ::= SHOW LICENCES */ - { 328, -2 }, /* (236) cmd ::= SHOW GRANTS */ - { 328, -4 }, /* (237) cmd ::= SHOW CREATE DATABASE db_name */ - { 328, -4 }, /* (238) cmd ::= SHOW CREATE TABLE full_table_name */ - { 328, -4 }, /* (239) cmd ::= SHOW CREATE STABLE full_table_name */ - { 328, -2 }, /* (240) cmd ::= SHOW QUERIES */ - { 328, -2 }, /* (241) cmd ::= SHOW SCORES */ - { 328, -2 }, /* (242) cmd ::= SHOW TOPICS */ - { 328, -2 }, /* (243) cmd ::= SHOW VARIABLES */ - { 328, -3 }, /* (244) cmd ::= SHOW CLUSTER VARIABLES */ - { 328, -3 }, /* (245) cmd ::= SHOW LOCAL VARIABLES */ - { 328, -5 }, /* (246) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - { 328, -2 }, /* (247) cmd ::= SHOW BNODES */ - { 328, -2 }, /* (248) cmd ::= SHOW SNODES */ - { 328, -2 }, /* (249) cmd ::= SHOW CLUSTER */ - { 328, -2 }, /* (250) cmd ::= SHOW TRANSACTIONS */ - { 328, -4 }, /* (251) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 328, -2 }, /* (252) cmd ::= SHOW CONSUMERS */ - { 328, -2 }, /* (253) cmd ::= SHOW SUBSCRIPTIONS */ - { 328, -5 }, /* (254) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 328, -7 }, /* (255) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - { 328, -3 }, /* (256) cmd ::= SHOW VNODES NK_INTEGER */ - { 328, -3 }, /* (257) cmd ::= SHOW VNODES NK_STRING */ - { 328, -3 }, /* (258) cmd ::= SHOW db_name_cond_opt ALIVE */ - { 328, -3 }, /* (259) cmd ::= SHOW CLUSTER ALIVE */ - { 383, 0 }, /* (260) db_name_cond_opt ::= */ - { 383, -2 }, /* (261) db_name_cond_opt ::= db_name NK_DOT */ - { 384, 0 }, /* (262) like_pattern_opt ::= */ - { 384, -2 }, /* (263) like_pattern_opt ::= LIKE NK_STRING */ - { 385, -1 }, /* (264) table_name_cond ::= table_name */ - { 386, 0 }, /* (265) from_db_opt ::= */ - { 386, -2 }, /* (266) from_db_opt ::= FROM db_name */ - { 387, 0 }, /* (267) tag_list_opt ::= */ - { 387, -1 }, /* (268) tag_list_opt ::= tag_item */ - { 387, -3 }, /* (269) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - { 388, -1 }, /* (270) tag_item ::= TBNAME */ - { 388, -1 }, /* (271) tag_item ::= QTAGS */ - { 388, -1 }, /* (272) tag_item ::= column_name */ - { 388, -2 }, /* (273) tag_item ::= column_name column_alias */ - { 388, -3 }, /* (274) tag_item ::= column_name AS column_alias */ - { 328, -8 }, /* (275) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ - { 328, -9 }, /* (276) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ - { 328, -4 }, /* (277) cmd ::= DROP INDEX exists_opt full_index_name */ - { 390, -1 }, /* (278) full_index_name ::= index_name */ - { 390, -3 }, /* (279) full_index_name ::= db_name NK_DOT index_name */ - { 391, -10 }, /* (280) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 391, -12 }, /* (281) 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 */ - { 393, -1 }, /* (282) func_list ::= func */ - { 393, -3 }, /* (283) func_list ::= func_list NK_COMMA func */ - { 396, -4 }, /* (284) func ::= sma_func_name NK_LP expression_list NK_RP */ - { 397, -1 }, /* (285) sma_func_name ::= function_name */ - { 397, -1 }, /* (286) sma_func_name ::= COUNT */ - { 397, -1 }, /* (287) sma_func_name ::= FIRST */ - { 397, -1 }, /* (288) sma_func_name ::= LAST */ - { 397, -1 }, /* (289) sma_func_name ::= LAST_ROW */ - { 395, 0 }, /* (290) sma_stream_opt ::= */ - { 395, -3 }, /* (291) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - { 395, -3 }, /* (292) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - { 395, -3 }, /* (293) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - { 328, -6 }, /* (294) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 328, -7 }, /* (295) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 328, -9 }, /* (296) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 328, -7 }, /* (297) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 328, -9 }, /* (298) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 328, -4 }, /* (299) cmd ::= DROP TOPIC exists_opt topic_name */ - { 328, -7 }, /* (300) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 328, -2 }, /* (301) cmd ::= DESC full_table_name */ - { 328, -2 }, /* (302) cmd ::= DESCRIBE full_table_name */ - { 328, -3 }, /* (303) cmd ::= RESET QUERY CACHE */ - { 328, -4 }, /* (304) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 328, -4 }, /* (305) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - { 400, 0 }, /* (306) analyze_opt ::= */ - { 400, -1 }, /* (307) analyze_opt ::= ANALYZE */ - { 401, 0 }, /* (308) explain_options ::= */ - { 401, -3 }, /* (309) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 401, -3 }, /* (310) explain_options ::= explain_options RATIO NK_FLOAT */ - { 328, -10 }, /* (311) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 328, -4 }, /* (312) cmd ::= DROP FUNCTION exists_opt function_name */ - { 403, 0 }, /* (313) agg_func_opt ::= */ - { 403, -1 }, /* (314) agg_func_opt ::= AGGREGATE */ - { 404, 0 }, /* (315) bufsize_opt ::= */ - { 404, -2 }, /* (316) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 328, -12 }, /* (317) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - { 328, -4 }, /* (318) cmd ::= DROP STREAM exists_opt stream_name */ - { 407, 0 }, /* (319) col_list_opt ::= */ - { 407, -3 }, /* (320) col_list_opt ::= NK_LP col_name_list NK_RP */ - { 408, 0 }, /* (321) tag_def_or_ref_opt ::= */ - { 408, -1 }, /* (322) tag_def_or_ref_opt ::= tags_def */ - { 408, -4 }, /* (323) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - { 406, 0 }, /* (324) stream_options ::= */ - { 406, -3 }, /* (325) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 406, -3 }, /* (326) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 406, -4 }, /* (327) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 406, -3 }, /* (328) stream_options ::= stream_options WATERMARK duration_literal */ - { 406, -4 }, /* (329) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 406, -3 }, /* (330) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 406, -3 }, /* (331) stream_options ::= stream_options DELETE_MARK duration_literal */ - { 406, -4 }, /* (332) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - { 409, 0 }, /* (333) subtable_opt ::= */ - { 409, -4 }, /* (334) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 328, -3 }, /* (335) cmd ::= KILL CONNECTION NK_INTEGER */ - { 328, -3 }, /* (336) cmd ::= KILL QUERY NK_STRING */ - { 328, -3 }, /* (337) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 328, -2 }, /* (338) cmd ::= BALANCE VGROUP */ - { 328, -4 }, /* (339) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 328, -4 }, /* (340) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 328, -3 }, /* (341) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 411, -2 }, /* (342) dnode_list ::= DNODE NK_INTEGER */ - { 411, -3 }, /* (343) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 328, -4 }, /* (344) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 328, -1 }, /* (345) cmd ::= query_or_subquery */ - { 328, -1 }, /* (346) cmd ::= insert_query */ - { 402, -7 }, /* (347) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 402, -4 }, /* (348) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - { 331, -1 }, /* (349) literal ::= NK_INTEGER */ - { 331, -1 }, /* (350) literal ::= NK_FLOAT */ - { 331, -1 }, /* (351) literal ::= NK_STRING */ - { 331, -1 }, /* (352) literal ::= NK_BOOL */ - { 331, -2 }, /* (353) literal ::= TIMESTAMP NK_STRING */ - { 331, -1 }, /* (354) literal ::= duration_literal */ - { 331, -1 }, /* (355) literal ::= NULL */ - { 331, -1 }, /* (356) literal ::= NK_QUESTION */ - { 379, -1 }, /* (357) duration_literal ::= NK_VARIABLE */ - { 413, -1 }, /* (358) signed ::= NK_INTEGER */ - { 413, -2 }, /* (359) signed ::= NK_PLUS NK_INTEGER */ - { 413, -2 }, /* (360) signed ::= NK_MINUS NK_INTEGER */ - { 413, -1 }, /* (361) signed ::= NK_FLOAT */ - { 413, -2 }, /* (362) signed ::= NK_PLUS NK_FLOAT */ - { 413, -2 }, /* (363) signed ::= NK_MINUS NK_FLOAT */ - { 369, -1 }, /* (364) signed_literal ::= signed */ - { 369, -1 }, /* (365) signed_literal ::= NK_STRING */ - { 369, -1 }, /* (366) signed_literal ::= NK_BOOL */ - { 369, -2 }, /* (367) signed_literal ::= TIMESTAMP NK_STRING */ - { 369, -1 }, /* (368) signed_literal ::= duration_literal */ - { 369, -1 }, /* (369) signed_literal ::= NULL */ - { 369, -1 }, /* (370) signed_literal ::= literal_func */ - { 369, -1 }, /* (371) signed_literal ::= NK_QUESTION */ - { 415, -1 }, /* (372) literal_list ::= signed_literal */ - { 415, -3 }, /* (373) literal_list ::= literal_list NK_COMMA signed_literal */ - { 340, -1 }, /* (374) db_name ::= NK_ID */ - { 341, -1 }, /* (375) table_name ::= NK_ID */ - { 367, -1 }, /* (376) column_name ::= NK_ID */ - { 381, -1 }, /* (377) function_name ::= NK_ID */ - { 416, -1 }, /* (378) table_alias ::= NK_ID */ - { 389, -1 }, /* (379) column_alias ::= NK_ID */ - { 333, -1 }, /* (380) user_name ::= NK_ID */ - { 342, -1 }, /* (381) topic_name ::= NK_ID */ - { 405, -1 }, /* (382) stream_name ::= NK_ID */ - { 399, -1 }, /* (383) cgroup_name ::= NK_ID */ - { 392, -1 }, /* (384) index_name ::= NK_ID */ - { 417, -1 }, /* (385) expr_or_subquery ::= expression */ - { 410, -1 }, /* (386) expression ::= literal */ - { 410, -1 }, /* (387) expression ::= pseudo_column */ - { 410, -1 }, /* (388) expression ::= column_reference */ - { 410, -1 }, /* (389) expression ::= function_expression */ - { 410, -1 }, /* (390) expression ::= case_when_expression */ - { 410, -3 }, /* (391) expression ::= NK_LP expression NK_RP */ - { 410, -2 }, /* (392) expression ::= NK_PLUS expr_or_subquery */ - { 410, -2 }, /* (393) expression ::= NK_MINUS expr_or_subquery */ - { 410, -3 }, /* (394) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 410, -3 }, /* (395) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 410, -3 }, /* (396) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 410, -3 }, /* (397) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 410, -3 }, /* (398) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 410, -3 }, /* (399) expression ::= column_reference NK_ARROW NK_STRING */ - { 410, -3 }, /* (400) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 410, -3 }, /* (401) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 372, -1 }, /* (402) expression_list ::= expr_or_subquery */ - { 372, -3 }, /* (403) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 419, -1 }, /* (404) column_reference ::= column_name */ - { 419, -3 }, /* (405) column_reference ::= table_name NK_DOT column_name */ - { 418, -1 }, /* (406) pseudo_column ::= ROWTS */ - { 418, -1 }, /* (407) pseudo_column ::= TBNAME */ - { 418, -3 }, /* (408) pseudo_column ::= table_name NK_DOT TBNAME */ - { 418, -1 }, /* (409) pseudo_column ::= QSTART */ - { 418, -1 }, /* (410) pseudo_column ::= QEND */ - { 418, -1 }, /* (411) pseudo_column ::= QDURATION */ - { 418, -1 }, /* (412) pseudo_column ::= WSTART */ - { 418, -1 }, /* (413) pseudo_column ::= WEND */ - { 418, -1 }, /* (414) pseudo_column ::= WDURATION */ - { 418, -1 }, /* (415) pseudo_column ::= IROWTS */ - { 418, -1 }, /* (416) pseudo_column ::= ISFILLED */ - { 418, -1 }, /* (417) pseudo_column ::= QTAGS */ - { 420, -4 }, /* (418) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 420, -4 }, /* (419) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 420, -6 }, /* (420) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 420, -1 }, /* (421) function_expression ::= literal_func */ - { 414, -3 }, /* (422) literal_func ::= noarg_func NK_LP NK_RP */ - { 414, -1 }, /* (423) literal_func ::= NOW */ - { 424, -1 }, /* (424) noarg_func ::= NOW */ - { 424, -1 }, /* (425) noarg_func ::= TODAY */ - { 424, -1 }, /* (426) noarg_func ::= TIMEZONE */ - { 424, -1 }, /* (427) noarg_func ::= DATABASE */ - { 424, -1 }, /* (428) noarg_func ::= CLIENT_VERSION */ - { 424, -1 }, /* (429) noarg_func ::= SERVER_VERSION */ - { 424, -1 }, /* (430) noarg_func ::= SERVER_STATUS */ - { 424, -1 }, /* (431) noarg_func ::= CURRENT_USER */ - { 424, -1 }, /* (432) noarg_func ::= USER */ - { 422, -1 }, /* (433) star_func ::= COUNT */ - { 422, -1 }, /* (434) star_func ::= FIRST */ - { 422, -1 }, /* (435) star_func ::= LAST */ - { 422, -1 }, /* (436) star_func ::= LAST_ROW */ - { 423, -1 }, /* (437) star_func_para_list ::= NK_STAR */ - { 423, -1 }, /* (438) star_func_para_list ::= other_para_list */ - { 425, -1 }, /* (439) other_para_list ::= star_func_para */ - { 425, -3 }, /* (440) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 426, -1 }, /* (441) star_func_para ::= expr_or_subquery */ - { 426, -3 }, /* (442) star_func_para ::= table_name NK_DOT NK_STAR */ - { 421, -4 }, /* (443) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 421, -5 }, /* (444) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 427, -1 }, /* (445) when_then_list ::= when_then_expr */ - { 427, -2 }, /* (446) when_then_list ::= when_then_list when_then_expr */ - { 430, -4 }, /* (447) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 428, 0 }, /* (448) case_when_else_opt ::= */ - { 428, -2 }, /* (449) case_when_else_opt ::= ELSE common_expression */ - { 431, -3 }, /* (450) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 431, -5 }, /* (451) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 431, -6 }, /* (452) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 431, -3 }, /* (453) predicate ::= expr_or_subquery IS NULL */ - { 431, -4 }, /* (454) predicate ::= expr_or_subquery IS NOT NULL */ - { 431, -3 }, /* (455) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 432, -1 }, /* (456) compare_op ::= NK_LT */ - { 432, -1 }, /* (457) compare_op ::= NK_GT */ - { 432, -1 }, /* (458) compare_op ::= NK_LE */ - { 432, -1 }, /* (459) compare_op ::= NK_GE */ - { 432, -1 }, /* (460) compare_op ::= NK_NE */ - { 432, -1 }, /* (461) compare_op ::= NK_EQ */ - { 432, -1 }, /* (462) compare_op ::= LIKE */ - { 432, -2 }, /* (463) compare_op ::= NOT LIKE */ - { 432, -1 }, /* (464) compare_op ::= MATCH */ - { 432, -1 }, /* (465) compare_op ::= NMATCH */ - { 432, -1 }, /* (466) compare_op ::= CONTAINS */ - { 433, -1 }, /* (467) in_op ::= IN */ - { 433, -2 }, /* (468) in_op ::= NOT IN */ - { 434, -3 }, /* (469) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 435, -1 }, /* (470) boolean_value_expression ::= boolean_primary */ - { 435, -2 }, /* (471) boolean_value_expression ::= NOT boolean_primary */ - { 435, -3 }, /* (472) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 435, -3 }, /* (473) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 436, -1 }, /* (474) boolean_primary ::= predicate */ - { 436, -3 }, /* (475) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 429, -1 }, /* (476) common_expression ::= expr_or_subquery */ - { 429, -1 }, /* (477) common_expression ::= boolean_value_expression */ - { 437, 0 }, /* (478) from_clause_opt ::= */ - { 437, -2 }, /* (479) from_clause_opt ::= FROM table_reference_list */ - { 438, -1 }, /* (480) table_reference_list ::= table_reference */ - { 438, -3 }, /* (481) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 439, -1 }, /* (482) table_reference ::= table_primary */ - { 439, -1 }, /* (483) table_reference ::= joined_table */ - { 440, -2 }, /* (484) table_primary ::= table_name alias_opt */ - { 440, -4 }, /* (485) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 440, -2 }, /* (486) table_primary ::= subquery alias_opt */ - { 440, -1 }, /* (487) table_primary ::= parenthesized_joined_table */ - { 442, 0 }, /* (488) alias_opt ::= */ - { 442, -1 }, /* (489) alias_opt ::= table_alias */ - { 442, -2 }, /* (490) alias_opt ::= AS table_alias */ - { 444, -3 }, /* (491) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 444, -3 }, /* (492) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 441, -6 }, /* (493) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 445, 0 }, /* (494) join_type ::= */ - { 445, -1 }, /* (495) join_type ::= INNER */ - { 446, -12 }, /* (496) 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 */ - { 447, 0 }, /* (497) set_quantifier_opt ::= */ - { 447, -1 }, /* (498) set_quantifier_opt ::= DISTINCT */ - { 447, -1 }, /* (499) set_quantifier_opt ::= ALL */ - { 448, -1 }, /* (500) select_list ::= select_item */ - { 448, -3 }, /* (501) select_list ::= select_list NK_COMMA select_item */ - { 456, -1 }, /* (502) select_item ::= NK_STAR */ - { 456, -1 }, /* (503) select_item ::= common_expression */ - { 456, -2 }, /* (504) select_item ::= common_expression column_alias */ - { 456, -3 }, /* (505) select_item ::= common_expression AS column_alias */ - { 456, -3 }, /* (506) select_item ::= table_name NK_DOT NK_STAR */ - { 412, 0 }, /* (507) where_clause_opt ::= */ - { 412, -2 }, /* (508) where_clause_opt ::= WHERE search_condition */ - { 449, 0 }, /* (509) partition_by_clause_opt ::= */ - { 449, -3 }, /* (510) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 457, -1 }, /* (511) partition_list ::= partition_item */ - { 457, -3 }, /* (512) partition_list ::= partition_list NK_COMMA partition_item */ - { 458, -1 }, /* (513) partition_item ::= expr_or_subquery */ - { 458, -2 }, /* (514) partition_item ::= expr_or_subquery column_alias */ - { 458, -3 }, /* (515) partition_item ::= expr_or_subquery AS column_alias */ - { 453, 0 }, /* (516) twindow_clause_opt ::= */ - { 453, -6 }, /* (517) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 453, -4 }, /* (518) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 453, -6 }, /* (519) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 453, -8 }, /* (520) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 453, -7 }, /* (521) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - { 394, 0 }, /* (522) sliding_opt ::= */ - { 394, -4 }, /* (523) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 452, 0 }, /* (524) fill_opt ::= */ - { 452, -4 }, /* (525) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 452, -6 }, /* (526) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 452, -6 }, /* (527) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ - { 459, -1 }, /* (528) fill_mode ::= NONE */ - { 459, -1 }, /* (529) fill_mode ::= PREV */ - { 459, -1 }, /* (530) fill_mode ::= NULL */ - { 459, -1 }, /* (531) fill_mode ::= NULL_F */ - { 459, -1 }, /* (532) fill_mode ::= LINEAR */ - { 459, -1 }, /* (533) fill_mode ::= NEXT */ - { 454, 0 }, /* (534) group_by_clause_opt ::= */ - { 454, -3 }, /* (535) group_by_clause_opt ::= GROUP BY group_by_list */ - { 460, -1 }, /* (536) group_by_list ::= expr_or_subquery */ - { 460, -3 }, /* (537) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 455, 0 }, /* (538) having_clause_opt ::= */ - { 455, -2 }, /* (539) having_clause_opt ::= HAVING search_condition */ - { 450, 0 }, /* (540) range_opt ::= */ - { 450, -6 }, /* (541) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 451, 0 }, /* (542) every_opt ::= */ - { 451, -4 }, /* (543) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 461, -4 }, /* (544) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 462, -1 }, /* (545) query_simple ::= query_specification */ - { 462, -1 }, /* (546) query_simple ::= union_query_expression */ - { 466, -4 }, /* (547) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 466, -3 }, /* (548) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 467, -1 }, /* (549) query_simple_or_subquery ::= query_simple */ - { 467, -1 }, /* (550) query_simple_or_subquery ::= subquery */ - { 398, -1 }, /* (551) query_or_subquery ::= query_expression */ - { 398, -1 }, /* (552) query_or_subquery ::= subquery */ - { 463, 0 }, /* (553) order_by_clause_opt ::= */ - { 463, -3 }, /* (554) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 464, 0 }, /* (555) slimit_clause_opt ::= */ - { 464, -2 }, /* (556) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 464, -4 }, /* (557) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 464, -4 }, /* (558) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 465, 0 }, /* (559) limit_clause_opt ::= */ - { 465, -2 }, /* (560) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 465, -4 }, /* (561) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 465, -4 }, /* (562) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 443, -3 }, /* (563) subquery ::= NK_LP query_expression NK_RP */ - { 443, -3 }, /* (564) subquery ::= NK_LP subquery NK_RP */ - { 343, -1 }, /* (565) search_condition ::= common_expression */ - { 468, -1 }, /* (566) sort_specification_list ::= sort_specification */ - { 468, -3 }, /* (567) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 469, -3 }, /* (568) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 470, 0 }, /* (569) ordering_specification_opt ::= */ - { 470, -1 }, /* (570) ordering_specification_opt ::= ASC */ - { 470, -1 }, /* (571) ordering_specification_opt ::= DESC */ - { 471, 0 }, /* (572) null_ordering_opt ::= */ - { 471, -2 }, /* (573) null_ordering_opt ::= NULLS FIRST */ - { 471, -2 }, /* (574) null_ordering_opt ::= NULLS LAST */ + { 368, -1 }, /* (171) type_name ::= BOOL */ + { 368, -1 }, /* (172) type_name ::= TINYINT */ + { 368, -1 }, /* (173) type_name ::= SMALLINT */ + { 368, -1 }, /* (174) type_name ::= INT */ + { 368, -1 }, /* (175) type_name ::= INTEGER */ + { 368, -1 }, /* (176) type_name ::= BIGINT */ + { 368, -1 }, /* (177) type_name ::= FLOAT */ + { 368, -1 }, /* (178) type_name ::= DOUBLE */ + { 368, -4 }, /* (179) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 368, -1 }, /* (180) type_name ::= TIMESTAMP */ + { 368, -4 }, /* (181) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 368, -2 }, /* (182) type_name ::= TINYINT UNSIGNED */ + { 368, -2 }, /* (183) type_name ::= SMALLINT UNSIGNED */ + { 368, -2 }, /* (184) type_name ::= INT UNSIGNED */ + { 368, -2 }, /* (185) type_name ::= BIGINT UNSIGNED */ + { 368, -1 }, /* (186) type_name ::= JSON */ + { 368, -4 }, /* (187) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 368, -1 }, /* (188) type_name ::= MEDIUMBLOB */ + { 368, -1 }, /* (189) type_name ::= BLOB */ + { 368, -4 }, /* (190) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 368, -1 }, /* (191) type_name ::= DECIMAL */ + { 368, -4 }, /* (192) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 368, -6 }, /* (193) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 360, 0 }, /* (194) tags_def_opt ::= */ + { 360, -1 }, /* (195) tags_def_opt ::= tags_def */ + { 363, -4 }, /* (196) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 361, 0 }, /* (197) table_options ::= */ + { 361, -3 }, /* (198) table_options ::= table_options COMMENT NK_STRING */ + { 361, -3 }, /* (199) table_options ::= table_options MAX_DELAY duration_list */ + { 361, -3 }, /* (200) table_options ::= table_options WATERMARK duration_list */ + { 361, -5 }, /* (201) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 361, -3 }, /* (202) table_options ::= table_options TTL NK_INTEGER */ + { 361, -5 }, /* (203) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 361, -3 }, /* (204) table_options ::= table_options DELETE_MARK duration_list */ + { 366, -1 }, /* (205) alter_table_options ::= alter_table_option */ + { 366, -2 }, /* (206) alter_table_options ::= alter_table_options alter_table_option */ + { 378, -2 }, /* (207) alter_table_option ::= COMMENT NK_STRING */ + { 378, -2 }, /* (208) alter_table_option ::= TTL NK_INTEGER */ + { 376, -1 }, /* (209) duration_list ::= duration_literal */ + { 376, -3 }, /* (210) duration_list ::= duration_list NK_COMMA duration_literal */ + { 377, -1 }, /* (211) rollup_func_list ::= rollup_func_name */ + { 377, -3 }, /* (212) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 380, -1 }, /* (213) rollup_func_name ::= function_name */ + { 380, -1 }, /* (214) rollup_func_name ::= FIRST */ + { 380, -1 }, /* (215) rollup_func_name ::= LAST */ + { 374, -1 }, /* (216) col_name_list ::= col_name */ + { 374, -3 }, /* (217) col_name_list ::= col_name_list NK_COMMA col_name */ + { 382, -1 }, /* (218) col_name ::= column_name */ + { 328, -2 }, /* (219) cmd ::= SHOW DNODES */ + { 328, -2 }, /* (220) cmd ::= SHOW USERS */ + { 328, -3 }, /* (221) cmd ::= SHOW USER PRIVILEGES */ + { 328, -2 }, /* (222) cmd ::= SHOW DATABASES */ + { 328, -4 }, /* (223) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 328, -4 }, /* (224) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 328, -3 }, /* (225) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 328, -2 }, /* (226) cmd ::= SHOW MNODES */ + { 328, -2 }, /* (227) cmd ::= SHOW QNODES */ + { 328, -2 }, /* (228) cmd ::= SHOW FUNCTIONS */ + { 328, -5 }, /* (229) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 328, -2 }, /* (230) cmd ::= SHOW STREAMS */ + { 328, -2 }, /* (231) cmd ::= SHOW ACCOUNTS */ + { 328, -2 }, /* (232) cmd ::= SHOW APPS */ + { 328, -2 }, /* (233) cmd ::= SHOW CONNECTIONS */ + { 328, -2 }, /* (234) cmd ::= SHOW LICENCES */ + { 328, -2 }, /* (235) cmd ::= SHOW GRANTS */ + { 328, -4 }, /* (236) cmd ::= SHOW CREATE DATABASE db_name */ + { 328, -4 }, /* (237) cmd ::= SHOW CREATE TABLE full_table_name */ + { 328, -4 }, /* (238) cmd ::= SHOW CREATE STABLE full_table_name */ + { 328, -2 }, /* (239) cmd ::= SHOW QUERIES */ + { 328, -2 }, /* (240) cmd ::= SHOW SCORES */ + { 328, -2 }, /* (241) cmd ::= SHOW TOPICS */ + { 328, -2 }, /* (242) cmd ::= SHOW VARIABLES */ + { 328, -3 }, /* (243) cmd ::= SHOW CLUSTER VARIABLES */ + { 328, -3 }, /* (244) cmd ::= SHOW LOCAL VARIABLES */ + { 328, -5 }, /* (245) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 328, -2 }, /* (246) cmd ::= SHOW BNODES */ + { 328, -2 }, /* (247) cmd ::= SHOW SNODES */ + { 328, -2 }, /* (248) cmd ::= SHOW CLUSTER */ + { 328, -2 }, /* (249) cmd ::= SHOW TRANSACTIONS */ + { 328, -4 }, /* (250) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 328, -2 }, /* (251) cmd ::= SHOW CONSUMERS */ + { 328, -2 }, /* (252) cmd ::= SHOW SUBSCRIPTIONS */ + { 328, -5 }, /* (253) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 328, -7 }, /* (254) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 328, -3 }, /* (255) cmd ::= SHOW VNODES NK_INTEGER */ + { 328, -3 }, /* (256) cmd ::= SHOW VNODES NK_STRING */ + { 328, -3 }, /* (257) cmd ::= SHOW db_name_cond_opt ALIVE */ + { 328, -3 }, /* (258) cmd ::= SHOW CLUSTER ALIVE */ + { 383, 0 }, /* (259) db_name_cond_opt ::= */ + { 383, -2 }, /* (260) db_name_cond_opt ::= db_name NK_DOT */ + { 384, 0 }, /* (261) like_pattern_opt ::= */ + { 384, -2 }, /* (262) like_pattern_opt ::= LIKE NK_STRING */ + { 385, -1 }, /* (263) table_name_cond ::= table_name */ + { 386, 0 }, /* (264) from_db_opt ::= */ + { 386, -2 }, /* (265) from_db_opt ::= FROM db_name */ + { 387, 0 }, /* (266) tag_list_opt ::= */ + { 387, -1 }, /* (267) tag_list_opt ::= tag_item */ + { 387, -3 }, /* (268) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 388, -1 }, /* (269) tag_item ::= TBNAME */ + { 388, -1 }, /* (270) tag_item ::= QTAGS */ + { 388, -1 }, /* (271) tag_item ::= column_name */ + { 388, -2 }, /* (272) tag_item ::= column_name column_alias */ + { 388, -3 }, /* (273) tag_item ::= column_name AS column_alias */ + { 328, -8 }, /* (274) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + { 328, -9 }, /* (275) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ + { 328, -4 }, /* (276) cmd ::= DROP INDEX exists_opt full_index_name */ + { 390, -1 }, /* (277) full_index_name ::= index_name */ + { 390, -3 }, /* (278) full_index_name ::= db_name NK_DOT index_name */ + { 391, -10 }, /* (279) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 391, -12 }, /* (280) 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 */ + { 393, -1 }, /* (281) func_list ::= func */ + { 393, -3 }, /* (282) func_list ::= func_list NK_COMMA func */ + { 396, -4 }, /* (283) func ::= sma_func_name NK_LP expression_list NK_RP */ + { 397, -1 }, /* (284) sma_func_name ::= function_name */ + { 397, -1 }, /* (285) sma_func_name ::= COUNT */ + { 397, -1 }, /* (286) sma_func_name ::= FIRST */ + { 397, -1 }, /* (287) sma_func_name ::= LAST */ + { 397, -1 }, /* (288) sma_func_name ::= LAST_ROW */ + { 395, 0 }, /* (289) sma_stream_opt ::= */ + { 395, -3 }, /* (290) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + { 395, -3 }, /* (291) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + { 395, -3 }, /* (292) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + { 328, -6 }, /* (293) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 328, -7 }, /* (294) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 328, -9 }, /* (295) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 328, -7 }, /* (296) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 328, -9 }, /* (297) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 328, -4 }, /* (298) cmd ::= DROP TOPIC exists_opt topic_name */ + { 328, -7 }, /* (299) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 328, -2 }, /* (300) cmd ::= DESC full_table_name */ + { 328, -2 }, /* (301) cmd ::= DESCRIBE full_table_name */ + { 328, -3 }, /* (302) cmd ::= RESET QUERY CACHE */ + { 328, -4 }, /* (303) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 328, -4 }, /* (304) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + { 400, 0 }, /* (305) analyze_opt ::= */ + { 400, -1 }, /* (306) analyze_opt ::= ANALYZE */ + { 401, 0 }, /* (307) explain_options ::= */ + { 401, -3 }, /* (308) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 401, -3 }, /* (309) explain_options ::= explain_options RATIO NK_FLOAT */ + { 328, -10 }, /* (310) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 328, -4 }, /* (311) cmd ::= DROP FUNCTION exists_opt function_name */ + { 403, 0 }, /* (312) agg_func_opt ::= */ + { 403, -1 }, /* (313) agg_func_opt ::= AGGREGATE */ + { 404, 0 }, /* (314) bufsize_opt ::= */ + { 404, -2 }, /* (315) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 328, -12 }, /* (316) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + { 328, -4 }, /* (317) cmd ::= DROP STREAM exists_opt stream_name */ + { 407, 0 }, /* (318) col_list_opt ::= */ + { 407, -3 }, /* (319) col_list_opt ::= NK_LP col_name_list NK_RP */ + { 408, 0 }, /* (320) tag_def_or_ref_opt ::= */ + { 408, -1 }, /* (321) tag_def_or_ref_opt ::= tags_def */ + { 408, -4 }, /* (322) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + { 406, 0 }, /* (323) stream_options ::= */ + { 406, -3 }, /* (324) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 406, -3 }, /* (325) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 406, -4 }, /* (326) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 406, -3 }, /* (327) stream_options ::= stream_options WATERMARK duration_literal */ + { 406, -4 }, /* (328) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 406, -3 }, /* (329) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 406, -3 }, /* (330) stream_options ::= stream_options DELETE_MARK duration_literal */ + { 406, -4 }, /* (331) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + { 409, 0 }, /* (332) subtable_opt ::= */ + { 409, -4 }, /* (333) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 328, -3 }, /* (334) cmd ::= KILL CONNECTION NK_INTEGER */ + { 328, -3 }, /* (335) cmd ::= KILL QUERY NK_STRING */ + { 328, -3 }, /* (336) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 328, -2 }, /* (337) cmd ::= BALANCE VGROUP */ + { 328, -4 }, /* (338) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 328, -4 }, /* (339) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 328, -3 }, /* (340) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 411, -2 }, /* (341) dnode_list ::= DNODE NK_INTEGER */ + { 411, -3 }, /* (342) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 328, -4 }, /* (343) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 328, -1 }, /* (344) cmd ::= query_or_subquery */ + { 328, -1 }, /* (345) cmd ::= insert_query */ + { 402, -7 }, /* (346) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 402, -4 }, /* (347) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + { 331, -1 }, /* (348) literal ::= NK_INTEGER */ + { 331, -1 }, /* (349) literal ::= NK_FLOAT */ + { 331, -1 }, /* (350) literal ::= NK_STRING */ + { 331, -1 }, /* (351) literal ::= NK_BOOL */ + { 331, -2 }, /* (352) literal ::= TIMESTAMP NK_STRING */ + { 331, -1 }, /* (353) literal ::= duration_literal */ + { 331, -1 }, /* (354) literal ::= NULL */ + { 331, -1 }, /* (355) literal ::= NK_QUESTION */ + { 379, -1 }, /* (356) duration_literal ::= NK_VARIABLE */ + { 413, -1 }, /* (357) signed ::= NK_INTEGER */ + { 413, -2 }, /* (358) signed ::= NK_PLUS NK_INTEGER */ + { 413, -2 }, /* (359) signed ::= NK_MINUS NK_INTEGER */ + { 413, -1 }, /* (360) signed ::= NK_FLOAT */ + { 413, -2 }, /* (361) signed ::= NK_PLUS NK_FLOAT */ + { 413, -2 }, /* (362) signed ::= NK_MINUS NK_FLOAT */ + { 369, -1 }, /* (363) signed_literal ::= signed */ + { 369, -1 }, /* (364) signed_literal ::= NK_STRING */ + { 369, -1 }, /* (365) signed_literal ::= NK_BOOL */ + { 369, -2 }, /* (366) signed_literal ::= TIMESTAMP NK_STRING */ + { 369, -1 }, /* (367) signed_literal ::= duration_literal */ + { 369, -1 }, /* (368) signed_literal ::= NULL */ + { 369, -1 }, /* (369) signed_literal ::= literal_func */ + { 369, -1 }, /* (370) signed_literal ::= NK_QUESTION */ + { 415, -1 }, /* (371) literal_list ::= signed_literal */ + { 415, -3 }, /* (372) literal_list ::= literal_list NK_COMMA signed_literal */ + { 340, -1 }, /* (373) db_name ::= NK_ID */ + { 341, -1 }, /* (374) table_name ::= NK_ID */ + { 367, -1 }, /* (375) column_name ::= NK_ID */ + { 381, -1 }, /* (376) function_name ::= NK_ID */ + { 416, -1 }, /* (377) table_alias ::= NK_ID */ + { 389, -1 }, /* (378) column_alias ::= NK_ID */ + { 333, -1 }, /* (379) user_name ::= NK_ID */ + { 342, -1 }, /* (380) topic_name ::= NK_ID */ + { 405, -1 }, /* (381) stream_name ::= NK_ID */ + { 399, -1 }, /* (382) cgroup_name ::= NK_ID */ + { 392, -1 }, /* (383) index_name ::= NK_ID */ + { 417, -1 }, /* (384) expr_or_subquery ::= expression */ + { 410, -1 }, /* (385) expression ::= literal */ + { 410, -1 }, /* (386) expression ::= pseudo_column */ + { 410, -1 }, /* (387) expression ::= column_reference */ + { 410, -1 }, /* (388) expression ::= function_expression */ + { 410, -1 }, /* (389) expression ::= case_when_expression */ + { 410, -3 }, /* (390) expression ::= NK_LP expression NK_RP */ + { 410, -2 }, /* (391) expression ::= NK_PLUS expr_or_subquery */ + { 410, -2 }, /* (392) expression ::= NK_MINUS expr_or_subquery */ + { 410, -3 }, /* (393) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 410, -3 }, /* (394) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 410, -3 }, /* (395) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 410, -3 }, /* (396) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 410, -3 }, /* (397) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 410, -3 }, /* (398) expression ::= column_reference NK_ARROW NK_STRING */ + { 410, -3 }, /* (399) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 410, -3 }, /* (400) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 372, -1 }, /* (401) expression_list ::= expr_or_subquery */ + { 372, -3 }, /* (402) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 419, -1 }, /* (403) column_reference ::= column_name */ + { 419, -3 }, /* (404) column_reference ::= table_name NK_DOT column_name */ + { 418, -1 }, /* (405) pseudo_column ::= ROWTS */ + { 418, -1 }, /* (406) pseudo_column ::= TBNAME */ + { 418, -3 }, /* (407) pseudo_column ::= table_name NK_DOT TBNAME */ + { 418, -1 }, /* (408) pseudo_column ::= QSTART */ + { 418, -1 }, /* (409) pseudo_column ::= QEND */ + { 418, -1 }, /* (410) pseudo_column ::= QDURATION */ + { 418, -1 }, /* (411) pseudo_column ::= WSTART */ + { 418, -1 }, /* (412) pseudo_column ::= WEND */ + { 418, -1 }, /* (413) pseudo_column ::= WDURATION */ + { 418, -1 }, /* (414) pseudo_column ::= IROWTS */ + { 418, -1 }, /* (415) pseudo_column ::= ISFILLED */ + { 418, -1 }, /* (416) pseudo_column ::= QTAGS */ + { 420, -4 }, /* (417) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 420, -4 }, /* (418) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 420, -6 }, /* (419) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 420, -1 }, /* (420) function_expression ::= literal_func */ + { 414, -3 }, /* (421) literal_func ::= noarg_func NK_LP NK_RP */ + { 414, -1 }, /* (422) literal_func ::= NOW */ + { 424, -1 }, /* (423) noarg_func ::= NOW */ + { 424, -1 }, /* (424) noarg_func ::= TODAY */ + { 424, -1 }, /* (425) noarg_func ::= TIMEZONE */ + { 424, -1 }, /* (426) noarg_func ::= DATABASE */ + { 424, -1 }, /* (427) noarg_func ::= CLIENT_VERSION */ + { 424, -1 }, /* (428) noarg_func ::= SERVER_VERSION */ + { 424, -1 }, /* (429) noarg_func ::= SERVER_STATUS */ + { 424, -1 }, /* (430) noarg_func ::= CURRENT_USER */ + { 424, -1 }, /* (431) noarg_func ::= USER */ + { 422, -1 }, /* (432) star_func ::= COUNT */ + { 422, -1 }, /* (433) star_func ::= FIRST */ + { 422, -1 }, /* (434) star_func ::= LAST */ + { 422, -1 }, /* (435) star_func ::= LAST_ROW */ + { 423, -1 }, /* (436) star_func_para_list ::= NK_STAR */ + { 423, -1 }, /* (437) star_func_para_list ::= other_para_list */ + { 425, -1 }, /* (438) other_para_list ::= star_func_para */ + { 425, -3 }, /* (439) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 426, -1 }, /* (440) star_func_para ::= expr_or_subquery */ + { 426, -3 }, /* (441) star_func_para ::= table_name NK_DOT NK_STAR */ + { 421, -4 }, /* (442) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 421, -5 }, /* (443) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 427, -1 }, /* (444) when_then_list ::= when_then_expr */ + { 427, -2 }, /* (445) when_then_list ::= when_then_list when_then_expr */ + { 430, -4 }, /* (446) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 428, 0 }, /* (447) case_when_else_opt ::= */ + { 428, -2 }, /* (448) case_when_else_opt ::= ELSE common_expression */ + { 431, -3 }, /* (449) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 431, -5 }, /* (450) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 431, -6 }, /* (451) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 431, -3 }, /* (452) predicate ::= expr_or_subquery IS NULL */ + { 431, -4 }, /* (453) predicate ::= expr_or_subquery IS NOT NULL */ + { 431, -3 }, /* (454) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 432, -1 }, /* (455) compare_op ::= NK_LT */ + { 432, -1 }, /* (456) compare_op ::= NK_GT */ + { 432, -1 }, /* (457) compare_op ::= NK_LE */ + { 432, -1 }, /* (458) compare_op ::= NK_GE */ + { 432, -1 }, /* (459) compare_op ::= NK_NE */ + { 432, -1 }, /* (460) compare_op ::= NK_EQ */ + { 432, -1 }, /* (461) compare_op ::= LIKE */ + { 432, -2 }, /* (462) compare_op ::= NOT LIKE */ + { 432, -1 }, /* (463) compare_op ::= MATCH */ + { 432, -1 }, /* (464) compare_op ::= NMATCH */ + { 432, -1 }, /* (465) compare_op ::= CONTAINS */ + { 433, -1 }, /* (466) in_op ::= IN */ + { 433, -2 }, /* (467) in_op ::= NOT IN */ + { 434, -3 }, /* (468) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 435, -1 }, /* (469) boolean_value_expression ::= boolean_primary */ + { 435, -2 }, /* (470) boolean_value_expression ::= NOT boolean_primary */ + { 435, -3 }, /* (471) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 435, -3 }, /* (472) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 436, -1 }, /* (473) boolean_primary ::= predicate */ + { 436, -3 }, /* (474) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 429, -1 }, /* (475) common_expression ::= expr_or_subquery */ + { 429, -1 }, /* (476) common_expression ::= boolean_value_expression */ + { 437, 0 }, /* (477) from_clause_opt ::= */ + { 437, -2 }, /* (478) from_clause_opt ::= FROM table_reference_list */ + { 438, -1 }, /* (479) table_reference_list ::= table_reference */ + { 438, -3 }, /* (480) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 439, -1 }, /* (481) table_reference ::= table_primary */ + { 439, -1 }, /* (482) table_reference ::= joined_table */ + { 440, -2 }, /* (483) table_primary ::= table_name alias_opt */ + { 440, -4 }, /* (484) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 440, -2 }, /* (485) table_primary ::= subquery alias_opt */ + { 440, -1 }, /* (486) table_primary ::= parenthesized_joined_table */ + { 442, 0 }, /* (487) alias_opt ::= */ + { 442, -1 }, /* (488) alias_opt ::= table_alias */ + { 442, -2 }, /* (489) alias_opt ::= AS table_alias */ + { 444, -3 }, /* (490) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 444, -3 }, /* (491) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 441, -6 }, /* (492) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 445, 0 }, /* (493) join_type ::= */ + { 445, -1 }, /* (494) join_type ::= INNER */ + { 446, -12 }, /* (495) 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 */ + { 447, 0 }, /* (496) set_quantifier_opt ::= */ + { 447, -1 }, /* (497) set_quantifier_opt ::= DISTINCT */ + { 447, -1 }, /* (498) set_quantifier_opt ::= ALL */ + { 448, -1 }, /* (499) select_list ::= select_item */ + { 448, -3 }, /* (500) select_list ::= select_list NK_COMMA select_item */ + { 456, -1 }, /* (501) select_item ::= NK_STAR */ + { 456, -1 }, /* (502) select_item ::= common_expression */ + { 456, -2 }, /* (503) select_item ::= common_expression column_alias */ + { 456, -3 }, /* (504) select_item ::= common_expression AS column_alias */ + { 456, -3 }, /* (505) select_item ::= table_name NK_DOT NK_STAR */ + { 412, 0 }, /* (506) where_clause_opt ::= */ + { 412, -2 }, /* (507) where_clause_opt ::= WHERE search_condition */ + { 449, 0 }, /* (508) partition_by_clause_opt ::= */ + { 449, -3 }, /* (509) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 457, -1 }, /* (510) partition_list ::= partition_item */ + { 457, -3 }, /* (511) partition_list ::= partition_list NK_COMMA partition_item */ + { 458, -1 }, /* (512) partition_item ::= expr_or_subquery */ + { 458, -2 }, /* (513) partition_item ::= expr_or_subquery column_alias */ + { 458, -3 }, /* (514) partition_item ::= expr_or_subquery AS column_alias */ + { 453, 0 }, /* (515) twindow_clause_opt ::= */ + { 453, -6 }, /* (516) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 453, -4 }, /* (517) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 453, -6 }, /* (518) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 453, -8 }, /* (519) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 453, -7 }, /* (520) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + { 394, 0 }, /* (521) sliding_opt ::= */ + { 394, -4 }, /* (522) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 452, 0 }, /* (523) fill_opt ::= */ + { 452, -4 }, /* (524) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 452, -6 }, /* (525) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 452, -6 }, /* (526) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + { 459, -1 }, /* (527) fill_mode ::= NONE */ + { 459, -1 }, /* (528) fill_mode ::= PREV */ + { 459, -1 }, /* (529) fill_mode ::= NULL */ + { 459, -1 }, /* (530) fill_mode ::= NULL_F */ + { 459, -1 }, /* (531) fill_mode ::= LINEAR */ + { 459, -1 }, /* (532) fill_mode ::= NEXT */ + { 454, 0 }, /* (533) group_by_clause_opt ::= */ + { 454, -3 }, /* (534) group_by_clause_opt ::= GROUP BY group_by_list */ + { 460, -1 }, /* (535) group_by_list ::= expr_or_subquery */ + { 460, -3 }, /* (536) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 455, 0 }, /* (537) having_clause_opt ::= */ + { 455, -2 }, /* (538) having_clause_opt ::= HAVING search_condition */ + { 450, 0 }, /* (539) range_opt ::= */ + { 450, -6 }, /* (540) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 451, 0 }, /* (541) every_opt ::= */ + { 451, -4 }, /* (542) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 461, -4 }, /* (543) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 462, -1 }, /* (544) query_simple ::= query_specification */ + { 462, -1 }, /* (545) query_simple ::= union_query_expression */ + { 466, -4 }, /* (546) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 466, -3 }, /* (547) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 467, -1 }, /* (548) query_simple_or_subquery ::= query_simple */ + { 467, -1 }, /* (549) query_simple_or_subquery ::= subquery */ + { 398, -1 }, /* (550) query_or_subquery ::= query_expression */ + { 398, -1 }, /* (551) query_or_subquery ::= subquery */ + { 463, 0 }, /* (552) order_by_clause_opt ::= */ + { 463, -3 }, /* (553) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 464, 0 }, /* (554) slimit_clause_opt ::= */ + { 464, -2 }, /* (555) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 464, -4 }, /* (556) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 464, -4 }, /* (557) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 465, 0 }, /* (558) limit_clause_opt ::= */ + { 465, -2 }, /* (559) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 465, -4 }, /* (560) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 465, -4 }, /* (561) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 443, -3 }, /* (562) subquery ::= NK_LP query_expression NK_RP */ + { 443, -3 }, /* (563) subquery ::= NK_LP subquery NK_RP */ + { 343, -1 }, /* (564) search_condition ::= common_expression */ + { 468, -1 }, /* (565) sort_specification_list ::= sort_specification */ + { 468, -3 }, /* (566) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 469, -3 }, /* (567) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 470, 0 }, /* (568) ordering_specification_opt ::= */ + { 470, -1 }, /* (569) ordering_specification_opt ::= ASC */ + { 470, -1 }, /* (570) ordering_specification_opt ::= DESC */ + { 471, 0 }, /* (571) null_ordering_opt ::= */ + { 471, -2 }, /* (572) null_ordering_opt ::= NULLS FIRST */ + { 471, -2 }, /* (573) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3862,25 +3854,25 @@ static YYACTIONTYPE yy_reduce( case 44: /* with_opt ::= */ case 133: /* start_opt ::= */ yytestcase(yyruleno==133); case 137: /* end_opt ::= */ yytestcase(yyruleno==137); - case 262: /* like_pattern_opt ::= */ yytestcase(yyruleno==262); - case 333: /* subtable_opt ::= */ yytestcase(yyruleno==333); - case 448: /* case_when_else_opt ::= */ yytestcase(yyruleno==448); - case 478: /* from_clause_opt ::= */ yytestcase(yyruleno==478); - case 507: /* where_clause_opt ::= */ yytestcase(yyruleno==507); - case 516: /* twindow_clause_opt ::= */ yytestcase(yyruleno==516); - case 522: /* sliding_opt ::= */ yytestcase(yyruleno==522); - case 524: /* fill_opt ::= */ yytestcase(yyruleno==524); - case 538: /* having_clause_opt ::= */ yytestcase(yyruleno==538); - case 540: /* range_opt ::= */ yytestcase(yyruleno==540); - case 542: /* every_opt ::= */ yytestcase(yyruleno==542); - case 555: /* slimit_clause_opt ::= */ yytestcase(yyruleno==555); - case 559: /* limit_clause_opt ::= */ yytestcase(yyruleno==559); + case 261: /* like_pattern_opt ::= */ yytestcase(yyruleno==261); + case 332: /* subtable_opt ::= */ yytestcase(yyruleno==332); + case 447: /* case_when_else_opt ::= */ yytestcase(yyruleno==447); + case 477: /* from_clause_opt ::= */ yytestcase(yyruleno==477); + case 506: /* where_clause_opt ::= */ yytestcase(yyruleno==506); + case 515: /* twindow_clause_opt ::= */ yytestcase(yyruleno==515); + case 521: /* sliding_opt ::= */ yytestcase(yyruleno==521); + case 523: /* fill_opt ::= */ yytestcase(yyruleno==523); + case 537: /* having_clause_opt ::= */ yytestcase(yyruleno==537); + case 539: /* range_opt ::= */ yytestcase(yyruleno==539); + case 541: /* every_opt ::= */ yytestcase(yyruleno==541); + case 554: /* slimit_clause_opt ::= */ yytestcase(yyruleno==554); + case 558: /* limit_clause_opt ::= */ yytestcase(yyruleno==558); { yymsp[1].minor.yy792 = NULL; } break; case 45: /* with_opt ::= WITH search_condition */ - case 479: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==479); - case 508: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==508); - case 539: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==539); + case 478: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==478); + case 507: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==507); + case 538: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==538); { yymsp[-1].minor.yy792 = yymsp[0].minor.yy792; } break; case 46: /* cmd ::= CREATE DNODE dnode_endpoint */ @@ -3910,49 +3902,49 @@ static YYACTIONTYPE yy_reduce( case 54: /* dnode_endpoint ::= NK_STRING */ case 55: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==55); case 56: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==56); - case 286: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==286); - case 287: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==287); - case 288: /* sma_func_name ::= LAST */ yytestcase(yyruleno==288); - case 289: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==289); - case 374: /* db_name ::= NK_ID */ yytestcase(yyruleno==374); - case 375: /* table_name ::= NK_ID */ yytestcase(yyruleno==375); - case 376: /* column_name ::= NK_ID */ yytestcase(yyruleno==376); - case 377: /* function_name ::= NK_ID */ yytestcase(yyruleno==377); - case 378: /* table_alias ::= NK_ID */ yytestcase(yyruleno==378); - case 379: /* column_alias ::= NK_ID */ yytestcase(yyruleno==379); - case 380: /* user_name ::= NK_ID */ yytestcase(yyruleno==380); - case 381: /* topic_name ::= NK_ID */ yytestcase(yyruleno==381); - case 382: /* stream_name ::= NK_ID */ yytestcase(yyruleno==382); - case 383: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==383); - case 384: /* index_name ::= NK_ID */ yytestcase(yyruleno==384); - case 424: /* noarg_func ::= NOW */ yytestcase(yyruleno==424); - case 425: /* noarg_func ::= TODAY */ yytestcase(yyruleno==425); - case 426: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==426); - case 427: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==427); - case 428: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==428); - case 429: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==429); - case 430: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==430); - case 431: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==431); - case 432: /* noarg_func ::= USER */ yytestcase(yyruleno==432); - case 433: /* star_func ::= COUNT */ yytestcase(yyruleno==433); - case 434: /* star_func ::= FIRST */ yytestcase(yyruleno==434); - case 435: /* star_func ::= LAST */ yytestcase(yyruleno==435); - case 436: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==436); + case 285: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==285); + case 286: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==286); + case 287: /* sma_func_name ::= LAST */ yytestcase(yyruleno==287); + case 288: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==288); + case 373: /* db_name ::= NK_ID */ yytestcase(yyruleno==373); + case 374: /* table_name ::= NK_ID */ yytestcase(yyruleno==374); + case 375: /* column_name ::= NK_ID */ yytestcase(yyruleno==375); + case 376: /* function_name ::= NK_ID */ yytestcase(yyruleno==376); + case 377: /* table_alias ::= NK_ID */ yytestcase(yyruleno==377); + case 378: /* column_alias ::= NK_ID */ yytestcase(yyruleno==378); + case 379: /* user_name ::= NK_ID */ yytestcase(yyruleno==379); + case 380: /* topic_name ::= NK_ID */ yytestcase(yyruleno==380); + case 381: /* stream_name ::= NK_ID */ yytestcase(yyruleno==381); + case 382: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==382); + case 383: /* index_name ::= NK_ID */ yytestcase(yyruleno==383); + case 423: /* noarg_func ::= NOW */ yytestcase(yyruleno==423); + case 424: /* noarg_func ::= TODAY */ yytestcase(yyruleno==424); + case 425: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==425); + case 426: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==426); + case 427: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==427); + case 428: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==428); + case 429: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==429); + case 430: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==430); + case 431: /* noarg_func ::= USER */ yytestcase(yyruleno==431); + case 432: /* star_func ::= COUNT */ yytestcase(yyruleno==432); + case 433: /* star_func ::= FIRST */ yytestcase(yyruleno==433); + case 434: /* star_func ::= LAST */ yytestcase(yyruleno==434); + case 435: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==435); { yylhsminor.yy97 = yymsp[0].minor.yy0; } yymsp[0].minor.yy97 = yylhsminor.yy97; break; case 57: /* force_opt ::= */ case 77: /* not_exists_opt ::= */ yytestcase(yyruleno==77); case 79: /* exists_opt ::= */ yytestcase(yyruleno==79); - case 306: /* analyze_opt ::= */ yytestcase(yyruleno==306); - case 313: /* agg_func_opt ::= */ yytestcase(yyruleno==313); - case 497: /* set_quantifier_opt ::= */ yytestcase(yyruleno==497); + case 305: /* analyze_opt ::= */ yytestcase(yyruleno==305); + case 312: /* agg_func_opt ::= */ yytestcase(yyruleno==312); + case 496: /* set_quantifier_opt ::= */ yytestcase(yyruleno==496); { yymsp[1].minor.yy89 = false; } break; case 58: /* force_opt ::= FORCE */ - case 307: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==307); - case 314: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==314); - case 498: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==498); + case 306: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==306); + case 313: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==313); + case 497: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==497); { yymsp[0].minor.yy89 = true; } break; case 59: /* cmd ::= ALTER LOCAL NK_STRING */ @@ -4181,7 +4173,7 @@ static YYACTIONTYPE yy_reduce( yymsp[0].minor.yy520 = yylhsminor.yy520; break; case 125: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 343: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==343); + case 342: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==342); { yylhsminor.yy520 = addNodeToList(pCxt, yymsp[-2].minor.yy520, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy520 = yylhsminor.yy520; break; @@ -4197,31 +4189,31 @@ static YYACTIONTYPE yy_reduce( case 158: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==158); case 161: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==161); case 168: /* column_def_list ::= column_def */ yytestcase(yyruleno==168); - case 212: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==212); - case 217: /* col_name_list ::= col_name */ yytestcase(yyruleno==217); - case 268: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==268); - case 282: /* func_list ::= func */ yytestcase(yyruleno==282); - case 372: /* literal_list ::= signed_literal */ yytestcase(yyruleno==372); - case 439: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==439); - case 445: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==445); - case 500: /* select_list ::= select_item */ yytestcase(yyruleno==500); - case 511: /* partition_list ::= partition_item */ yytestcase(yyruleno==511); - case 566: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==566); + case 211: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==211); + case 216: /* col_name_list ::= col_name */ yytestcase(yyruleno==216); + case 267: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==267); + case 281: /* func_list ::= func */ yytestcase(yyruleno==281); + case 371: /* literal_list ::= signed_literal */ yytestcase(yyruleno==371); + case 438: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==438); + case 444: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==444); + case 499: /* select_list ::= select_item */ yytestcase(yyruleno==499); + case 510: /* partition_list ::= partition_item */ yytestcase(yyruleno==510); + case 565: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==565); { yylhsminor.yy520 = createNodeList(pCxt, yymsp[0].minor.yy792); } yymsp[0].minor.yy520 = yylhsminor.yy520; break; case 129: /* retention_list ::= retention_list NK_COMMA retention */ case 162: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==162); case 169: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==169); - case 213: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==213); - case 218: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==218); - case 269: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==269); - case 283: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==283); - case 373: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==373); - case 440: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==440); - case 501: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==501); - case 512: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==512); - case 567: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==567); + case 212: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==212); + case 217: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==217); + case 268: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==268); + case 282: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==282); + case 372: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==372); + case 439: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==439); + case 500: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==500); + case 511: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==511); + case 566: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==566); { yylhsminor.yy520 = addNodeToList(pCxt, yymsp[-2].minor.yy520, yymsp[0].minor.yy792); } yymsp[-2].minor.yy520 = yylhsminor.yy520; break; @@ -4230,11 +4222,11 @@ static YYACTIONTYPE yy_reduce( yymsp[-2].minor.yy792 = yylhsminor.yy792; break; case 131: /* speed_opt ::= */ - case 315: /* bufsize_opt ::= */ yytestcase(yyruleno==315); + case 314: /* bufsize_opt ::= */ yytestcase(yyruleno==314); { yymsp[1].minor.yy20 = 0; } break; case 132: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 316: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==316); + case 315: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==315); { yymsp[-1].minor.yy20 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 134: /* start_opt ::= START WITH NK_INTEGER */ @@ -4263,8 +4255,8 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy89, yymsp[0].minor.yy792); } break; case 146: /* cmd ::= ALTER TABLE alter_table_clause */ - case 345: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==345); - case 346: /* cmd ::= insert_query */ yytestcase(yyruleno==346); + case 344: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==344); + case 345: /* cmd ::= insert_query */ yytestcase(yyruleno==345); { pCxt->pRootNode = yymsp[0].minor.yy792; } break; case 147: /* cmd ::= ALTER STABLE alter_table_clause */ @@ -4311,7 +4303,7 @@ static YYACTIONTYPE yy_reduce( yymsp[-5].minor.yy792 = yylhsminor.yy792; break; case 159: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 446: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==446); + case 445: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==445); { yylhsminor.yy520 = addNodeToList(pCxt, yymsp[-1].minor.yy520, yymsp[0].minor.yy792); } yymsp[-1].minor.yy520 = yylhsminor.yy520; break; @@ -4324,17 +4316,17 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy792 = yylhsminor.yy792; break; case 164: /* specific_cols_opt ::= */ - case 195: /* tags_def_opt ::= */ yytestcase(yyruleno==195); - case 267: /* tag_list_opt ::= */ yytestcase(yyruleno==267); - case 319: /* col_list_opt ::= */ yytestcase(yyruleno==319); - case 321: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==321); - case 509: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==509); - case 534: /* group_by_clause_opt ::= */ yytestcase(yyruleno==534); - case 553: /* order_by_clause_opt ::= */ yytestcase(yyruleno==553); + case 194: /* tags_def_opt ::= */ yytestcase(yyruleno==194); + case 266: /* tag_list_opt ::= */ yytestcase(yyruleno==266); + case 318: /* col_list_opt ::= */ yytestcase(yyruleno==318); + case 320: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==320); + case 508: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==508); + case 533: /* group_by_clause_opt ::= */ yytestcase(yyruleno==533); + case 552: /* order_by_clause_opt ::= */ yytestcase(yyruleno==552); { yymsp[1].minor.yy520 = NULL; } break; case 165: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 320: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==320); + case 319: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==319); { yymsp[-2].minor.yy520 = yymsp[-1].minor.yy520; } break; case 166: /* full_table_name ::= table_name */ @@ -4349,537 +4341,533 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy792 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy97, yymsp[0].minor.yy848, NULL); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 171: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy792 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy97, yymsp[-2].minor.yy848, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy792 = yylhsminor.yy792; - break; - case 172: /* type_name ::= BOOL */ + case 171: /* type_name ::= BOOL */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 173: /* type_name ::= TINYINT */ + case 172: /* type_name ::= TINYINT */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 174: /* type_name ::= SMALLINT */ + case 173: /* type_name ::= SMALLINT */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 175: /* type_name ::= INT */ - case 176: /* type_name ::= INTEGER */ yytestcase(yyruleno==176); + case 174: /* type_name ::= INT */ + case 175: /* type_name ::= INTEGER */ yytestcase(yyruleno==175); { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 177: /* type_name ::= BIGINT */ + case 176: /* type_name ::= BIGINT */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 178: /* type_name ::= FLOAT */ + case 177: /* type_name ::= FLOAT */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 179: /* type_name ::= DOUBLE */ + case 178: /* type_name ::= DOUBLE */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 180: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + case 179: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy848 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 181: /* type_name ::= TIMESTAMP */ + case 180: /* type_name ::= TIMESTAMP */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 182: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + case 181: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy848 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 183: /* type_name ::= TINYINT UNSIGNED */ + case 182: /* type_name ::= TINYINT UNSIGNED */ { yymsp[-1].minor.yy848 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 184: /* type_name ::= SMALLINT UNSIGNED */ + case 183: /* type_name ::= SMALLINT UNSIGNED */ { yymsp[-1].minor.yy848 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 185: /* type_name ::= INT UNSIGNED */ + case 184: /* type_name ::= INT UNSIGNED */ { yymsp[-1].minor.yy848 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 186: /* type_name ::= BIGINT UNSIGNED */ + case 185: /* type_name ::= BIGINT UNSIGNED */ { yymsp[-1].minor.yy848 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 187: /* type_name ::= JSON */ + case 186: /* type_name ::= JSON */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 188: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + case 187: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy848 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 189: /* type_name ::= MEDIUMBLOB */ + case 188: /* type_name ::= MEDIUMBLOB */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 190: /* type_name ::= BLOB */ + case 189: /* type_name ::= BLOB */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 191: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + case 190: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy848 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 192: /* type_name ::= DECIMAL */ + case 191: /* type_name ::= DECIMAL */ { yymsp[0].minor.yy848 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 193: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + case 192: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy848 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 194: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + case 193: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ { yymsp[-5].minor.yy848 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 196: /* tags_def_opt ::= tags_def */ - case 322: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==322); - case 438: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==438); + case 195: /* tags_def_opt ::= tags_def */ + case 321: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==321); + case 437: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==437); { yylhsminor.yy520 = yymsp[0].minor.yy520; } yymsp[0].minor.yy520 = yylhsminor.yy520; break; - case 197: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 323: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==323); + case 196: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ + case 322: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==322); { yymsp[-3].minor.yy520 = yymsp[-1].minor.yy520; } break; - case 198: /* table_options ::= */ + case 197: /* table_options ::= */ { yymsp[1].minor.yy792 = createDefaultTableOptions(pCxt); } break; - case 199: /* table_options ::= table_options COMMENT NK_STRING */ + case 198: /* table_options ::= table_options COMMENT NK_STRING */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-2].minor.yy792, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 200: /* table_options ::= table_options MAX_DELAY duration_list */ + case 199: /* table_options ::= table_options MAX_DELAY duration_list */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-2].minor.yy792, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy520); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 201: /* table_options ::= table_options WATERMARK duration_list */ + case 200: /* table_options ::= table_options WATERMARK duration_list */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-2].minor.yy792, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy520); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 202: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + case 201: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-4].minor.yy792, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy520); } yymsp[-4].minor.yy792 = yylhsminor.yy792; break; - case 203: /* table_options ::= table_options TTL NK_INTEGER */ + case 202: /* table_options ::= table_options TTL NK_INTEGER */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-2].minor.yy792, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 204: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + case 203: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-4].minor.yy792, TABLE_OPTION_SMA, yymsp[-1].minor.yy520); } yymsp[-4].minor.yy792 = yylhsminor.yy792; break; - case 205: /* table_options ::= table_options DELETE_MARK duration_list */ + case 204: /* table_options ::= table_options DELETE_MARK duration_list */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-2].minor.yy792, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy520); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 206: /* alter_table_options ::= alter_table_option */ + case 205: /* alter_table_options ::= alter_table_option */ { yylhsminor.yy792 = createAlterTableOptions(pCxt); yylhsminor.yy792 = setTableOption(pCxt, yylhsminor.yy792, yymsp[0].minor.yy285.type, &yymsp[0].minor.yy285.val); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 207: /* alter_table_options ::= alter_table_options alter_table_option */ + case 206: /* alter_table_options ::= alter_table_options alter_table_option */ { yylhsminor.yy792 = setTableOption(pCxt, yymsp[-1].minor.yy792, yymsp[0].minor.yy285.type, &yymsp[0].minor.yy285.val); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 208: /* alter_table_option ::= COMMENT NK_STRING */ + case 207: /* alter_table_option ::= COMMENT NK_STRING */ { yymsp[-1].minor.yy285.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy285.val = yymsp[0].minor.yy0; } break; - case 209: /* alter_table_option ::= TTL NK_INTEGER */ + case 208: /* alter_table_option ::= TTL NK_INTEGER */ { yymsp[-1].minor.yy285.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy285.val = yymsp[0].minor.yy0; } break; - case 210: /* duration_list ::= duration_literal */ - case 402: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==402); + case 209: /* duration_list ::= duration_literal */ + case 401: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==401); { yylhsminor.yy520 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[0].minor.yy520 = yylhsminor.yy520; break; - case 211: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 403: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==403); + case 210: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 402: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==402); { yylhsminor.yy520 = addNodeToList(pCxt, yymsp[-2].minor.yy520, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[-2].minor.yy520 = yylhsminor.yy520; break; - case 214: /* rollup_func_name ::= function_name */ + case 213: /* rollup_func_name ::= function_name */ { yylhsminor.yy792 = createFunctionNode(pCxt, &yymsp[0].minor.yy97, NULL); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 215: /* rollup_func_name ::= FIRST */ - case 216: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==216); - case 271: /* tag_item ::= QTAGS */ yytestcase(yyruleno==271); + case 214: /* rollup_func_name ::= FIRST */ + case 215: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==215); + case 270: /* tag_item ::= QTAGS */ yytestcase(yyruleno==270); { yylhsminor.yy792 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 219: /* col_name ::= column_name */ - case 272: /* tag_item ::= column_name */ yytestcase(yyruleno==272); + case 218: /* col_name ::= column_name */ + case 271: /* tag_item ::= column_name */ yytestcase(yyruleno==271); { yylhsminor.yy792 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy97); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 220: /* cmd ::= SHOW DNODES */ + case 219: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 221: /* cmd ::= SHOW USERS */ + case 220: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 222: /* cmd ::= SHOW USER PRIVILEGES */ + case 221: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } break; - case 223: /* cmd ::= SHOW DATABASES */ + case 222: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 224: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + case 223: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy792, yymsp[0].minor.yy792, OP_TYPE_LIKE); } break; - case 225: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + case 224: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy792, yymsp[0].minor.yy792, OP_TYPE_LIKE); } break; - case 226: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ + case 225: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy792, NULL, OP_TYPE_LIKE); } break; - case 227: /* cmd ::= SHOW MNODES */ + case 226: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 228: /* cmd ::= SHOW QNODES */ + case 227: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 229: /* cmd ::= SHOW FUNCTIONS */ + case 228: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 230: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + case 229: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy792, yymsp[-1].minor.yy792, OP_TYPE_EQUAL); } break; - case 231: /* cmd ::= SHOW STREAMS */ + case 230: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 232: /* cmd ::= SHOW ACCOUNTS */ + case 231: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 233: /* cmd ::= SHOW APPS */ + case 232: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 234: /* cmd ::= SHOW CONNECTIONS */ + case 233: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 235: /* cmd ::= SHOW LICENCES */ - case 236: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==236); + case 234: /* cmd ::= SHOW LICENCES */ + case 235: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==235); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 237: /* cmd ::= SHOW CREATE DATABASE db_name */ + case 236: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy97); } break; - case 238: /* cmd ::= SHOW CREATE TABLE full_table_name */ + case 237: /* cmd ::= SHOW CREATE TABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy792); } break; - case 239: /* cmd ::= SHOW CREATE STABLE full_table_name */ + case 238: /* cmd ::= SHOW CREATE STABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy792); } break; - case 240: /* cmd ::= SHOW QUERIES */ + case 239: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 241: /* cmd ::= SHOW SCORES */ + case 240: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 242: /* cmd ::= SHOW TOPICS */ + case 241: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 243: /* cmd ::= SHOW VARIABLES */ - case 244: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==244); + case 242: /* cmd ::= SHOW VARIABLES */ + case 243: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==243); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 245: /* cmd ::= SHOW LOCAL VARIABLES */ + case 244: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 246: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + case 245: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy792); } break; - case 247: /* cmd ::= SHOW BNODES */ + case 246: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 248: /* cmd ::= SHOW SNODES */ + case 247: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 249: /* cmd ::= SHOW CLUSTER */ + case 248: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 250: /* cmd ::= SHOW TRANSACTIONS */ + case 249: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 251: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + case 250: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy792); } break; - case 252: /* cmd ::= SHOW CONSUMERS */ + case 251: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 253: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 252: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 254: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + case 253: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy792, yymsp[-1].minor.yy792, OP_TYPE_EQUAL); } break; - case 255: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + case 254: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy792, yymsp[0].minor.yy792, yymsp[-3].minor.yy520); } break; - case 256: /* cmd ::= SHOW VNODES NK_INTEGER */ + case 255: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 257: /* cmd ::= SHOW VNODES NK_STRING */ + case 256: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 258: /* cmd ::= SHOW db_name_cond_opt ALIVE */ + case 257: /* cmd ::= SHOW db_name_cond_opt ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy792, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; - case 259: /* cmd ::= SHOW CLUSTER ALIVE */ + case 258: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; - case 260: /* db_name_cond_opt ::= */ - case 265: /* from_db_opt ::= */ yytestcase(yyruleno==265); + case 259: /* db_name_cond_opt ::= */ + case 264: /* from_db_opt ::= */ yytestcase(yyruleno==264); { yymsp[1].minor.yy792 = createDefaultDatabaseCondValue(pCxt); } break; - case 261: /* db_name_cond_opt ::= db_name NK_DOT */ + case 260: /* db_name_cond_opt ::= db_name NK_DOT */ { yylhsminor.yy792 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy97); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 263: /* like_pattern_opt ::= LIKE NK_STRING */ + case 262: /* like_pattern_opt ::= LIKE NK_STRING */ { yymsp[-1].minor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 264: /* table_name_cond ::= table_name */ + case 263: /* table_name_cond ::= table_name */ { yylhsminor.yy792 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy97); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 266: /* from_db_opt ::= FROM db_name */ + case 265: /* from_db_opt ::= FROM db_name */ { yymsp[-1].minor.yy792 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy97); } break; - case 270: /* tag_item ::= TBNAME */ + case 269: /* tag_item ::= TBNAME */ { yylhsminor.yy792 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 273: /* tag_item ::= column_name column_alias */ + case 272: /* tag_item ::= column_name column_alias */ { yylhsminor.yy792 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy97), &yymsp[0].minor.yy97); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 274: /* tag_item ::= column_name AS column_alias */ + case 273: /* tag_item ::= column_name AS column_alias */ { yylhsminor.yy792 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy97), &yymsp[0].minor.yy97); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 275: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + case 274: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy89, yymsp[-3].minor.yy792, yymsp[-1].minor.yy792, NULL, yymsp[0].minor.yy792); } break; - case 276: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ + case 275: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy89, yymsp[-5].minor.yy792, yymsp[-3].minor.yy792, yymsp[-1].minor.yy520, NULL); } break; - case 277: /* cmd ::= DROP INDEX exists_opt full_index_name */ + case 276: /* cmd ::= DROP INDEX exists_opt full_index_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy89, yymsp[0].minor.yy792); } break; - case 278: /* full_index_name ::= index_name */ + case 277: /* full_index_name ::= index_name */ { yylhsminor.yy792 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy97); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 279: /* full_index_name ::= db_name NK_DOT index_name */ + case 278: /* full_index_name ::= db_name NK_DOT index_name */ { yylhsminor.yy792 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy97); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 280: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + case 279: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { yymsp[-9].minor.yy792 = createIndexOption(pCxt, yymsp[-7].minor.yy520, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), NULL, yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 281: /* 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 */ + case 280: /* 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.yy792 = createIndexOption(pCxt, yymsp[-9].minor.yy520, releaseRawExprNode(pCxt, yymsp[-5].minor.yy792), releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 284: /* func ::= sma_func_name NK_LP expression_list NK_RP */ + case 283: /* func ::= sma_func_name NK_LP expression_list NK_RP */ { yylhsminor.yy792 = createFunctionNode(pCxt, &yymsp[-3].minor.yy97, yymsp[-1].minor.yy520); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 285: /* sma_func_name ::= function_name */ - case 489: /* alias_opt ::= table_alias */ yytestcase(yyruleno==489); + case 284: /* sma_func_name ::= function_name */ + case 488: /* alias_opt ::= table_alias */ yytestcase(yyruleno==488); { yylhsminor.yy97 = yymsp[0].minor.yy97; } yymsp[0].minor.yy97 = yylhsminor.yy97; break; - case 290: /* sma_stream_opt ::= */ - case 324: /* stream_options ::= */ yytestcase(yyruleno==324); + case 289: /* sma_stream_opt ::= */ + case 323: /* stream_options ::= */ yytestcase(yyruleno==323); { yymsp[1].minor.yy792 = createStreamOptions(pCxt); } break; - case 291: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + case 290: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy792)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = yymsp[-2].minor.yy792; } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 292: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + case 291: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy792)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = yymsp[-2].minor.yy792; } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 293: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + case 292: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy792)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = yymsp[-2].minor.yy792; } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 294: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + case 293: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy89, &yymsp[-2].minor.yy97, yymsp[0].minor.yy792); } break; - case 295: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + case 294: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy89, &yymsp[-3].minor.yy97, &yymsp[0].minor.yy97, false); } break; - case 296: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + case 295: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy89, &yymsp[-5].minor.yy97, &yymsp[0].minor.yy97, true); } break; - case 297: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + case 296: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy89, &yymsp[-3].minor.yy97, yymsp[0].minor.yy792, false); } break; - case 298: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + case 297: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy89, &yymsp[-5].minor.yy97, yymsp[0].minor.yy792, true); } break; - case 299: /* cmd ::= DROP TOPIC exists_opt topic_name */ + case 298: /* cmd ::= DROP TOPIC exists_opt topic_name */ { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy97); } break; - case 300: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + case 299: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy89, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy97); } break; - case 301: /* cmd ::= DESC full_table_name */ - case 302: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==302); + case 300: /* cmd ::= DESC full_table_name */ + case 301: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==301); { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy792); } break; - case 303: /* cmd ::= RESET QUERY CACHE */ + case 302: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 304: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 305: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==305); + case 303: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 304: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==304); { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy89, yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 308: /* explain_options ::= */ + case 307: /* explain_options ::= */ { yymsp[1].minor.yy792 = createDefaultExplainOptions(pCxt); } break; - case 309: /* explain_options ::= explain_options VERBOSE NK_BOOL */ + case 308: /* explain_options ::= explain_options VERBOSE NK_BOOL */ { yylhsminor.yy792 = setExplainVerbose(pCxt, yymsp[-2].minor.yy792, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 310: /* explain_options ::= explain_options RATIO NK_FLOAT */ + case 309: /* explain_options ::= explain_options RATIO NK_FLOAT */ { yylhsminor.yy792 = setExplainRatio(pCxt, yymsp[-2].minor.yy792, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 311: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + case 310: /* 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.yy89, yymsp[-8].minor.yy89, &yymsp[-5].minor.yy97, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy848, yymsp[0].minor.yy20); } break; - case 312: /* cmd ::= DROP FUNCTION exists_opt function_name */ + case 311: /* cmd ::= DROP FUNCTION exists_opt function_name */ { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy97); } break; - case 317: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + case 316: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ { pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy89, &yymsp[-8].minor.yy97, yymsp[-5].minor.yy792, yymsp[-7].minor.yy792, yymsp[-3].minor.yy520, yymsp[-2].minor.yy792, yymsp[0].minor.yy792, yymsp[-4].minor.yy520); } break; - case 318: /* cmd ::= DROP STREAM exists_opt stream_name */ + case 317: /* cmd ::= DROP STREAM exists_opt stream_name */ { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy97); } break; - case 325: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 326: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==326); + case 324: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 325: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==325); { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-2].minor.yy792, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 327: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + case 326: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-3].minor.yy792, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 328: /* stream_options ::= stream_options WATERMARK duration_literal */ + case 327: /* stream_options ::= stream_options WATERMARK duration_literal */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-2].minor.yy792, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 329: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + case 328: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-3].minor.yy792, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 330: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + case 329: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-2].minor.yy792, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 331: /* stream_options ::= stream_options DELETE_MARK duration_literal */ + case 330: /* stream_options ::= stream_options DELETE_MARK duration_literal */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-2].minor.yy792, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 332: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + case 331: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ { yylhsminor.yy792 = setStreamOptions(pCxt, yymsp[-3].minor.yy792, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 334: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 523: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==523); - case 543: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==543); + case 333: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 522: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==522); + case 542: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==542); { yymsp[-3].minor.yy792 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy792); } break; - case 335: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 334: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 336: /* cmd ::= KILL QUERY NK_STRING */ + case 335: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 337: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 336: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 338: /* cmd ::= BALANCE VGROUP */ + case 337: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 339: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 338: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 340: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + case 339: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy520); } break; - case 341: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 340: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 342: /* dnode_list ::= DNODE NK_INTEGER */ + case 341: /* dnode_list ::= DNODE NK_INTEGER */ { yymsp[-1].minor.yy520 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 344: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ + case 343: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 347: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + case 346: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ { yymsp[-6].minor.yy792 = createInsertStmt(pCxt, yymsp[-4].minor.yy792, yymsp[-2].minor.yy520, yymsp[0].minor.yy792); } break; - case 348: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ + case 347: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ { yymsp[-3].minor.yy792 = createInsertStmt(pCxt, yymsp[-1].minor.yy792, NULL, yymsp[0].minor.yy792); } break; - case 349: /* literal ::= NK_INTEGER */ + case 348: /* literal ::= NK_INTEGER */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 350: /* literal ::= NK_FLOAT */ + case 349: /* literal ::= NK_FLOAT */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 351: /* literal ::= NK_STRING */ + case 350: /* literal ::= NK_STRING */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 352: /* literal ::= NK_BOOL */ + case 351: /* literal ::= NK_BOOL */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 353: /* literal ::= TIMESTAMP NK_STRING */ + case 352: /* literal ::= TIMESTAMP NK_STRING */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 354: /* literal ::= duration_literal */ - case 364: /* signed_literal ::= signed */ yytestcase(yyruleno==364); - case 385: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==385); - case 386: /* expression ::= literal */ yytestcase(yyruleno==386); - case 387: /* expression ::= pseudo_column */ yytestcase(yyruleno==387); - case 388: /* expression ::= column_reference */ yytestcase(yyruleno==388); - case 389: /* expression ::= function_expression */ yytestcase(yyruleno==389); - case 390: /* expression ::= case_when_expression */ yytestcase(yyruleno==390); - case 421: /* function_expression ::= literal_func */ yytestcase(yyruleno==421); - case 470: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==470); - case 474: /* boolean_primary ::= predicate */ yytestcase(yyruleno==474); - case 476: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==476); - case 477: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==477); - case 480: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==480); - case 482: /* table_reference ::= table_primary */ yytestcase(yyruleno==482); - case 483: /* table_reference ::= joined_table */ yytestcase(yyruleno==483); - case 487: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==487); - case 545: /* query_simple ::= query_specification */ yytestcase(yyruleno==545); - case 546: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==546); - case 549: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==549); - case 551: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==551); + case 353: /* literal ::= duration_literal */ + case 363: /* signed_literal ::= signed */ yytestcase(yyruleno==363); + case 384: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==384); + case 385: /* expression ::= literal */ yytestcase(yyruleno==385); + case 386: /* expression ::= pseudo_column */ yytestcase(yyruleno==386); + case 387: /* expression ::= column_reference */ yytestcase(yyruleno==387); + case 388: /* expression ::= function_expression */ yytestcase(yyruleno==388); + case 389: /* expression ::= case_when_expression */ yytestcase(yyruleno==389); + case 420: /* function_expression ::= literal_func */ yytestcase(yyruleno==420); + case 469: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==469); + case 473: /* boolean_primary ::= predicate */ yytestcase(yyruleno==473); + case 475: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==475); + case 476: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==476); + case 479: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==479); + case 481: /* table_reference ::= table_primary */ yytestcase(yyruleno==481); + case 482: /* table_reference ::= joined_table */ yytestcase(yyruleno==482); + case 486: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==486); + case 544: /* query_simple ::= query_specification */ yytestcase(yyruleno==544); + case 545: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==545); + case 548: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==548); + case 550: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==550); { yylhsminor.yy792 = yymsp[0].minor.yy792; } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 355: /* literal ::= NULL */ + case 354: /* literal ::= NULL */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 356: /* literal ::= NK_QUESTION */ + case 355: /* literal ::= NK_QUESTION */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 357: /* duration_literal ::= NK_VARIABLE */ + case 356: /* duration_literal ::= NK_VARIABLE */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 358: /* signed ::= NK_INTEGER */ + case 357: /* signed ::= NK_INTEGER */ { yylhsminor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 359: /* signed ::= NK_PLUS NK_INTEGER */ + case 358: /* signed ::= NK_PLUS NK_INTEGER */ { yymsp[-1].minor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 360: /* signed ::= NK_MINUS NK_INTEGER */ + case 359: /* 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; @@ -4887,14 +4875,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 361: /* signed ::= NK_FLOAT */ + case 360: /* signed ::= NK_FLOAT */ { yylhsminor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 362: /* signed ::= NK_PLUS NK_FLOAT */ + case 361: /* signed ::= NK_PLUS NK_FLOAT */ { yymsp[-1].minor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 363: /* signed ::= NK_MINUS NK_FLOAT */ + case 362: /* 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; @@ -4902,57 +4890,57 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 365: /* signed_literal ::= NK_STRING */ + case 364: /* signed_literal ::= NK_STRING */ { yylhsminor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 366: /* signed_literal ::= NK_BOOL */ + case 365: /* signed_literal ::= NK_BOOL */ { yylhsminor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 367: /* signed_literal ::= TIMESTAMP NK_STRING */ + case 366: /* signed_literal ::= TIMESTAMP NK_STRING */ { yymsp[-1].minor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 368: /* signed_literal ::= duration_literal */ - case 370: /* signed_literal ::= literal_func */ yytestcase(yyruleno==370); - case 441: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==441); - case 503: /* select_item ::= common_expression */ yytestcase(yyruleno==503); - case 513: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==513); - case 550: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==550); - case 552: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==552); - case 565: /* search_condition ::= common_expression */ yytestcase(yyruleno==565); + case 367: /* signed_literal ::= duration_literal */ + case 369: /* signed_literal ::= literal_func */ yytestcase(yyruleno==369); + case 440: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==440); + case 502: /* select_item ::= common_expression */ yytestcase(yyruleno==502); + case 512: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==512); + case 549: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==549); + case 551: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==551); + case 564: /* search_condition ::= common_expression */ yytestcase(yyruleno==564); { yylhsminor.yy792 = releaseRawExprNode(pCxt, yymsp[0].minor.yy792); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 369: /* signed_literal ::= NULL */ + case 368: /* signed_literal ::= NULL */ { yylhsminor.yy792 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 371: /* signed_literal ::= NK_QUESTION */ + case 370: /* signed_literal ::= NK_QUESTION */ { yylhsminor.yy792 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 391: /* expression ::= NK_LP expression NK_RP */ - case 475: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==475); - case 564: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==564); + case 390: /* expression ::= NK_LP expression NK_RP */ + case 474: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==474); + case 563: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==563); { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy792)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 392: /* expression ::= NK_PLUS expr_or_subquery */ + case 391: /* expression ::= NK_PLUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 393: /* expression ::= NK_MINUS expr_or_subquery */ + case 392: /* expression ::= NK_MINUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy792), NULL)); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 394: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 393: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -4960,7 +4948,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 395: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 394: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -4968,7 +4956,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 396: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 395: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -4976,7 +4964,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 397: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 396: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -4984,7 +4972,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 398: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 397: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -4992,14 +4980,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 399: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 398: /* expression ::= column_reference NK_ARROW NK_STRING */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy792), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 400: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 399: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5007,7 +4995,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 401: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 400: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5015,71 +5003,71 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 404: /* column_reference ::= column_name */ + case 403: /* column_reference ::= column_name */ { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy97, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy97)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 405: /* column_reference ::= table_name NK_DOT column_name */ + case 404: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy97, createColumnNode(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy97)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 406: /* pseudo_column ::= ROWTS */ - case 407: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==407); - case 409: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==409); - case 410: /* pseudo_column ::= QEND */ yytestcase(yyruleno==410); - case 411: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==411); - case 412: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==412); - case 413: /* pseudo_column ::= WEND */ yytestcase(yyruleno==413); - case 414: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==414); - case 415: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==415); - case 416: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==416); - case 417: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==417); - case 423: /* literal_func ::= NOW */ yytestcase(yyruleno==423); + case 405: /* pseudo_column ::= ROWTS */ + case 406: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==406); + case 408: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==408); + case 409: /* pseudo_column ::= QEND */ yytestcase(yyruleno==409); + case 410: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==410); + case 411: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==411); + case 412: /* pseudo_column ::= WEND */ yytestcase(yyruleno==412); + case 413: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==413); + case 414: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==414); + case 415: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==415); + case 416: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==416); + case 422: /* literal_func ::= NOW */ yytestcase(yyruleno==422); { yylhsminor.yy792 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 408: /* pseudo_column ::= table_name NK_DOT TBNAME */ + case 407: /* pseudo_column ::= table_name NK_DOT TBNAME */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy97)))); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 418: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 419: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==419); + case 417: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 418: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==418); { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy97, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy97, yymsp[-1].minor.yy520)); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 420: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 419: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), yymsp[-1].minor.yy848)); } yymsp[-5].minor.yy792 = yylhsminor.yy792; break; - case 422: /* literal_func ::= noarg_func NK_LP NK_RP */ + case 421: /* literal_func ::= noarg_func NK_LP NK_RP */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy97, NULL)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 437: /* star_func_para_list ::= NK_STAR */ + case 436: /* star_func_para_list ::= NK_STAR */ { yylhsminor.yy520 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy520 = yylhsminor.yy520; break; - case 442: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 506: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==506); + case 441: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 505: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==505); { yylhsminor.yy792 = createColumnNode(pCxt, &yymsp[-2].minor.yy97, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 443: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ + case 442: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy520, yymsp[-1].minor.yy792)); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 444: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + case 443: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), yymsp[-2].minor.yy520, yymsp[-1].minor.yy792)); } yymsp[-4].minor.yy792 = yylhsminor.yy792; break; - case 447: /* when_then_expr ::= WHEN common_expression THEN common_expression */ + case 446: /* when_then_expr ::= WHEN common_expression THEN common_expression */ { yymsp[-3].minor.yy792 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy792), releaseRawExprNode(pCxt, yymsp[0].minor.yy792)); } break; - case 449: /* case_when_else_opt ::= ELSE common_expression */ + case 448: /* case_when_else_opt ::= ELSE common_expression */ { yymsp[-1].minor.yy792 = releaseRawExprNode(pCxt, yymsp[0].minor.yy792); } break; - case 450: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 455: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==455); + case 449: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 454: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==454); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5087,7 +5075,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 451: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 450: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5095,7 +5083,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy792 = yylhsminor.yy792; break; - case 452: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 451: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5103,71 +5091,71 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy792 = yylhsminor.yy792; break; - case 453: /* predicate ::= expr_or_subquery IS NULL */ + case 452: /* predicate ::= expr_or_subquery IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy792), NULL)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 454: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 453: /* predicate ::= expr_or_subquery IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), NULL)); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 456: /* compare_op ::= NK_LT */ + case 455: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy396 = OP_TYPE_LOWER_THAN; } break; - case 457: /* compare_op ::= NK_GT */ + case 456: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy396 = OP_TYPE_GREATER_THAN; } break; - case 458: /* compare_op ::= NK_LE */ + case 457: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy396 = OP_TYPE_LOWER_EQUAL; } break; - case 459: /* compare_op ::= NK_GE */ + case 458: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy396 = OP_TYPE_GREATER_EQUAL; } break; - case 460: /* compare_op ::= NK_NE */ + case 459: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy396 = OP_TYPE_NOT_EQUAL; } break; - case 461: /* compare_op ::= NK_EQ */ + case 460: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy396 = OP_TYPE_EQUAL; } break; - case 462: /* compare_op ::= LIKE */ + case 461: /* compare_op ::= LIKE */ { yymsp[0].minor.yy396 = OP_TYPE_LIKE; } break; - case 463: /* compare_op ::= NOT LIKE */ + case 462: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy396 = OP_TYPE_NOT_LIKE; } break; - case 464: /* compare_op ::= MATCH */ + case 463: /* compare_op ::= MATCH */ { yymsp[0].minor.yy396 = OP_TYPE_MATCH; } break; - case 465: /* compare_op ::= NMATCH */ + case 464: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy396 = OP_TYPE_NMATCH; } break; - case 466: /* compare_op ::= CONTAINS */ + case 465: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy396 = OP_TYPE_JSON_CONTAINS; } break; - case 467: /* in_op ::= IN */ + case 466: /* in_op ::= IN */ { yymsp[0].minor.yy396 = OP_TYPE_IN; } break; - case 468: /* in_op ::= NOT IN */ + case 467: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy396 = OP_TYPE_NOT_IN; } break; - case 469: /* in_predicate_value ::= NK_LP literal_list NK_RP */ + case 468: /* in_predicate_value ::= NK_LP literal_list NK_RP */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy520)); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 471: /* boolean_value_expression ::= NOT boolean_primary */ + case 470: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy792), NULL)); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 472: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 471: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5175,7 +5163,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 473: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 472: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy792); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy792); @@ -5183,43 +5171,43 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 481: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 480: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy792 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy792, yymsp[0].minor.yy792, NULL); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 484: /* table_primary ::= table_name alias_opt */ + case 483: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy792 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy97, &yymsp[0].minor.yy97); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 485: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 484: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy792 = createRealTableNode(pCxt, &yymsp[-3].minor.yy97, &yymsp[-1].minor.yy97, &yymsp[0].minor.yy97); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 486: /* table_primary ::= subquery alias_opt */ + case 485: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy792 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy792), &yymsp[0].minor.yy97); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 488: /* alias_opt ::= */ + case 487: /* alias_opt ::= */ { yymsp[1].minor.yy97 = nil_token; } break; - case 490: /* alias_opt ::= AS table_alias */ + case 489: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy97 = yymsp[0].minor.yy97; } break; - case 491: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 492: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==492); + case 490: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 491: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==491); { yymsp[-2].minor.yy792 = yymsp[-1].minor.yy792; } break; - case 493: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 492: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy792 = createJoinTableNode(pCxt, yymsp[-4].minor.yy116, yymsp[-5].minor.yy792, yymsp[-2].minor.yy792, yymsp[0].minor.yy792); } yymsp[-5].minor.yy792 = yylhsminor.yy792; break; - case 494: /* join_type ::= */ + case 493: /* join_type ::= */ { yymsp[1].minor.yy116 = JOIN_TYPE_INNER; } break; - case 495: /* join_type ::= INNER */ + case 494: /* join_type ::= INNER */ { yymsp[0].minor.yy116 = JOIN_TYPE_INNER; } break; - case 496: /* 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 495: /* 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.yy792 = createSelectStmt(pCxt, yymsp[-10].minor.yy89, yymsp[-9].minor.yy520, yymsp[-8].minor.yy792); yymsp[-11].minor.yy792 = addWhereClause(pCxt, yymsp[-11].minor.yy792, yymsp[-7].minor.yy792); @@ -5232,82 +5220,82 @@ static YYACTIONTYPE yy_reduce( yymsp[-11].minor.yy792 = addFillClause(pCxt, yymsp[-11].minor.yy792, yymsp[-3].minor.yy792); } break; - case 499: /* set_quantifier_opt ::= ALL */ + case 498: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy89 = false; } break; - case 502: /* select_item ::= NK_STAR */ + case 501: /* select_item ::= NK_STAR */ { yylhsminor.yy792 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy792 = yylhsminor.yy792; break; - case 504: /* select_item ::= common_expression column_alias */ - case 514: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==514); + case 503: /* select_item ::= common_expression column_alias */ + case 513: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==513); { yylhsminor.yy792 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy792), &yymsp[0].minor.yy97); } yymsp[-1].minor.yy792 = yylhsminor.yy792; break; - case 505: /* select_item ::= common_expression AS column_alias */ - case 515: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==515); + case 504: /* select_item ::= common_expression AS column_alias */ + case 514: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==514); { yylhsminor.yy792 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy792), &yymsp[0].minor.yy97); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 510: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 535: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==535); - case 554: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==554); + case 509: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 534: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==534); + case 553: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==553); { yymsp[-2].minor.yy520 = yymsp[0].minor.yy520; } break; - case 517: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 516: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy792 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), releaseRawExprNode(pCxt, yymsp[-1].minor.yy792)); } break; - case 518: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + case 517: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy792 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy792)); } break; - case 519: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 518: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy792 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), NULL, yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 520: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 519: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy792 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy792), releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), yymsp[-1].minor.yy792, yymsp[0].minor.yy792); } break; - case 521: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + case 520: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ { yymsp[-6].minor.yy792 = createEventWindowNode(pCxt, yymsp[-3].minor.yy792, yymsp[0].minor.yy792); } break; - case 525: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 524: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy792 = createFillNode(pCxt, yymsp[-1].minor.yy646, NULL); } break; - case 526: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 525: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy792 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy520)); } break; - case 527: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + case 526: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy792 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy520)); } break; - case 528: /* fill_mode ::= NONE */ + case 527: /* fill_mode ::= NONE */ { yymsp[0].minor.yy646 = FILL_MODE_NONE; } break; - case 529: /* fill_mode ::= PREV */ + case 528: /* fill_mode ::= PREV */ { yymsp[0].minor.yy646 = FILL_MODE_PREV; } break; - case 530: /* fill_mode ::= NULL */ + case 529: /* fill_mode ::= NULL */ { yymsp[0].minor.yy646 = FILL_MODE_NULL; } break; - case 531: /* fill_mode ::= NULL_F */ + case 530: /* fill_mode ::= NULL_F */ { yymsp[0].minor.yy646 = FILL_MODE_NULL_F; } break; - case 532: /* fill_mode ::= LINEAR */ + case 531: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy646 = FILL_MODE_LINEAR; } break; - case 533: /* fill_mode ::= NEXT */ + case 532: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy646 = FILL_MODE_NEXT; } break; - case 536: /* group_by_list ::= expr_or_subquery */ + case 535: /* group_by_list ::= expr_or_subquery */ { yylhsminor.yy520 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy792))); } yymsp[0].minor.yy520 = yylhsminor.yy520; break; - case 537: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + case 536: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ { yylhsminor.yy520 = addNodeToList(pCxt, yymsp[-2].minor.yy520, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy792))); } yymsp[-2].minor.yy520 = yylhsminor.yy520; break; - case 541: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + case 540: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ { yymsp[-5].minor.yy792 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy792), releaseRawExprNode(pCxt, yymsp[-1].minor.yy792)); } break; - case 544: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 543: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy792 = addOrderByClause(pCxt, yymsp[-3].minor.yy792, yymsp[-2].minor.yy520); yylhsminor.yy792 = addSlimitClause(pCxt, yylhsminor.yy792, yymsp[-1].minor.yy792); @@ -5315,50 +5303,50 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 547: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + case 546: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ { yylhsminor.yy792 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy792, yymsp[0].minor.yy792); } yymsp[-3].minor.yy792 = yylhsminor.yy792; break; - case 548: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + case 547: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ { yylhsminor.yy792 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy792, yymsp[0].minor.yy792); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 556: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 560: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==560); + case 555: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 559: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==559); { yymsp[-1].minor.yy792 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 557: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 561: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==561); + case 556: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 560: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==560); { yymsp[-3].minor.yy792 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 558: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 562: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==562); + case 557: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 561: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==561); { yymsp[-3].minor.yy792 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 563: /* subquery ::= NK_LP query_expression NK_RP */ + case 562: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy792 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy792); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 568: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + case 567: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ { yylhsminor.yy792 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy792), yymsp[-1].minor.yy34, yymsp[0].minor.yy265); } yymsp[-2].minor.yy792 = yylhsminor.yy792; break; - case 569: /* ordering_specification_opt ::= */ + case 568: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy34 = ORDER_ASC; } break; - case 570: /* ordering_specification_opt ::= ASC */ + case 569: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy34 = ORDER_ASC; } break; - case 571: /* ordering_specification_opt ::= DESC */ + case 570: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy34 = ORDER_DESC; } break; - case 572: /* null_ordering_opt ::= */ + case 571: /* null_ordering_opt ::= */ { yymsp[1].minor.yy265 = NULL_ORDER_DEFAULT; } break; - case 573: /* null_ordering_opt ::= NULLS FIRST */ + case 572: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy265 = NULL_ORDER_FIRST; } break; - case 574: /* null_ordering_opt ::= NULLS LAST */ + case 573: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy265 = NULL_ORDER_LAST; } break; default: diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index c36402e8e00..6981f799142 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -742,10 +742,10 @@ TEST_F(ParserInitialCTest, createStable) { addFieldToCreateStbReq(false, "a15", TSDB_DATA_TYPE_VARCHAR, 50 + VARSTR_HEADER_SIZE); run("CREATE STABLE IF NOT EXISTS rollup_db.t1(" "ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), " - "c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " + "c8 SMALLINT, c9 SMALLINT UNSIGNED, c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " "c13 NCHAR(30), c14 VARCHAR(50)) " "TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, " - "a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, " + "a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED, a11 TINYINT, " "a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) MAX_DELAY 100s,10m WATERMARK 10a,1m " "DELETE_MARK 1000s,200m"); @@ -1005,16 +1005,16 @@ TEST_F(ParserInitialCTest, createTable) { run("CREATE TABLE IF NOT EXISTS test.t1(" "ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), " - "c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " + "c8 SMALLINT, c9 SMALLINT UNSIGNED, c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " "c13 NCHAR(30), c15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)"); run("CREATE TABLE IF NOT EXISTS rollup_db.t1(" "ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), " - "c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " + "c8 SMALLINT, c9 SMALLINT UNSIGNED, c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, " "c13 NCHAR(30), c14 VARCHAR(50)) " "TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, a8 BINARY(20), " - "a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, " + "a9 SMALLINT, a10 SMALLINT UNSIGNED, a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, " "a14 NCHAR(30), a15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN)"); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 16a5ef7bae1..8fee17d9681 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2279,7 +2279,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic if (NULL != cxt.pLastCols) { cxt.doAgg = false; lastRowScanOptSetLastTargets(pScan->pScanCols, cxt.pLastCols); - nodesWalkExprs(pScan->pScanPseudoCols, lastRowScanOptSetColDataType, &cxt); + NODES_DESTORY_LIST(pScan->pScanPseudoCols); lastRowScanOptSetLastTargets(pScan->node.pTargets, cxt.pLastCols); nodesClearList(cxt.pLastCols); } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index e9a2efaac79..e2c2e4c6556 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1089,9 +1089,15 @@ static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogic pExchange->srcStartGroupId = pExchangeLogicNode->srcStartGroupId; pExchange->srcEndGroupId = pExchangeLogicNode->srcEndGroupId; pExchange->seqRecvData = pExchangeLogicNode->seqRecvData; - *pPhyNode = (SPhysiNode*)pExchange; - return TSDB_CODE_SUCCESS; + int32_t code = setConditionsSlotId(pCxt, (const SLogicNode*)pExchangeLogicNode, (SPhysiNode*)pExchange); + if (TSDB_CODE_SUCCESS == code) { + *pPhyNode = (SPhysiNode*)pExchange; + } else { + nodesDestroyNode((SNode*)pExchange); + } + + return code; } static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, @@ -1119,6 +1125,9 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlots(pCxt, pScan->pScanCols, pScan->node.pOutputDataBlockDesc); } + if (TSDB_CODE_SUCCESS == code) { + code = setConditionsSlotId(pCxt, (const SLogicNode*)pExchangeLogicNode, (SPhysiNode*)pScan); + } if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScan; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 361cf33d58b..fd772618187 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1365,7 +1365,8 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGrou pExchange->srcEndGroupId = pCxt->groupId - 1; pExchange->node.precision = pProject->node.precision; pExchange->node.pTargets = nodesCloneList(pProject->node.pTargets); - if (NULL == pExchange->node.pTargets) { + pExchange->node.pConditions = nodesCloneNode(pProject->node.pConditions); + if (NULL == pExchange->node.pTargets || (NULL != pProject->node.pConditions && NULL == pExchange->node.pConditions)) { return TSDB_CODE_OUT_OF_MEMORY; } TSWAP(pExchange->node.pLimit, pProject->node.pLimit); diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index c68a08682c5..9d8c1700034 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -194,6 +194,8 @@ char* jobTaskStatusStr(int32_t status) { return "EXECUTING"; case JOB_TASK_STATUS_PART_SUCC: return "PARTIAL_SUCCEED"; + case JOB_TASK_STATUS_FETCH: + return "FETCHING"; case JOB_TASK_STATUS_SUCC: return "SUCCEED"; case JOB_TASK_STATUS_FAIL: diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index b8d5d2e6eee..59e63e9eae2 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -259,15 +259,26 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) { static int32_t ignoreTime = 0; if (++ignoreTime > 10 && 0 == taosRand() % 9) { + if (ctx->msgType == TDMT_SCH_FETCH) { + qwBuildAndSendErrorRsp(TDMT_SCH_LINK_BROKEN, &ctx->ctrlConnInfo, TSDB_CODE_RPC_BROKEN_LINK); + qwBuildAndSendErrorRsp(ctx->msgType + 1, &ctx->dataConnInfo, TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + *rsped = true; + + taosSsleep(3); + return; + } + +#if 0 SRpcHandleInfo *pConn = ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo - : &ctx->ctrlConnInfo); + : &ctx->ctrlConnInfo); qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK); - + qwBuildAndSendDropMsg(QW_FPARAMS(), pConn); *rsped = true; - + return; +#endif } } diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index ec4049a3eb4..92c7852dbca 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -199,7 +199,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { QW_ERR_JRET(code); } - QW_TASK_DLOG("data put into sink, rows:%d, continueExecTask:%d", pRes->info.rows, qcontinue); + QW_TASK_DLOG("data put into sink, rows:%" PRId64 ", continueExecTask:%d", pRes->info.rows, qcontinue); } if (numOfResBlock == 0 || (hasMore == false)) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 195a08525c3..1affbac613c 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1755,7 +1755,11 @@ int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { char* p = colDataGetVarData(pInput->columnData, 0); - colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows); + int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true); + if (code) { + return code; + } + pOutput->numOfRows += pInput->numOfRows; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 85b952937fb..d002b5dfa96 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -193,7 +193,7 @@ typedef struct SSchLevel { int32_t taskSucceed; int32_t taskNum; int32_t taskLaunchedNum; - int32_t taskDoneNum; + int32_t taskExecDoneNum; SArray *subTasks; // Element is SSchTask } SSchLevel; @@ -299,6 +299,7 @@ typedef struct SSchJob { SExecResult execRes; void *fetchRes; // TODO free it or not bool fetched; + bool noMoreRetry; int64_t resNumOfRows; // from int32_t to int64_t SSchResInfo userRes; char *sql; @@ -333,13 +334,16 @@ extern SSchedulerMgmt schMgmt; ((_job)->attr.localExec && SCH_IS_QUERY_JOB(_job) && (!SCH_IS_INSERT_JOB(_job)) && \ (!SCH_IS_DATA_BIND_QRY_TASK(_task))) -#define SCH_UPDATE_REDICT_CODE(job, _code) atomic_val_compare_exchange_32(&((job)->redirectCode), 0, _code) -#define SCH_GET_REDICT_CODE(job, _code) (((!NO_RET_REDIRECT_ERROR(_code)) || (job)->redirectCode == 0) ? (_code) : (job)->redirectCode) +#define SCH_UPDATE_REDIRECT_CODE(job, _code) atomic_val_compare_exchange_32(&((job)->redirectCode), 0, _code) +#define SCH_GET_REDIRECT_CODE(job, _code) (((!NO_RET_REDIRECT_ERROR(_code)) || (job)->redirectCode == 0) ? (_code) : (job)->redirectCode) #define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st) #define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status) #define SCH_GET_TASK_STATUS_STR(task) jobTaskStatusStr(SCH_GET_TASK_STATUS(task)) +#define SCH_TASK_ALREADY_LAUNCHED(task) (SCH_GET_TASK_STATUS(task) >= JOB_TASK_STATUS_EXEC) +#define SCH_TASK_EXEC_DONE(task) (SCH_GET_TASK_STATUS(task) >= JOB_TASK_STATUS_PART_SUCC) + #define SCH_GET_TASK_HANDLE(_task) ((_task) ? (_task)->handle : NULL) #define SCH_SET_TASK_HANDLE(_task, _handle) ((_task)->handle = (_handle)) @@ -361,6 +365,7 @@ extern SSchedulerMgmt schMgmt; (SCH_IS_DATA_BIND_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) #define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_BIND_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) #define SCH_TASK_NEED_FETCH(_task) ((_task)->plan->subplanType != SUBPLAN_TYPE_MODIFY) +#define SCH_MULTI_LEVEL_LAUNCHED(_job) ((_job)->levelIdx != ((_job)->levelNum - 1)) #define SCH_SET_JOB_TYPE(_job, type) \ do { \ @@ -377,16 +382,24 @@ extern SSchedulerMgmt schMgmt; #define SCH_JOB_NEED_DROP(_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 || (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) -#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \ - (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)) || (_task)->redirectCtx.inRedirect)) #define SCH_REDIRECT_MSGTYPE(_msgType) \ ((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || \ (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) -#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) \ - (SCH_REDIRECT_MSGTYPE(_msgType) && \ - (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen)))) -#define SCH_NEED_RETRY(_msgType, _code) \ - ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) +#define SCH_LOW_LEVEL_NETWORK_ERR(_job, _task, _code) \ + (SCH_NETWORK_ERR(_code) && ((_task)->level->level == (_job)->levelIdx)) +#define SCH_TOP_LEVEL_NETWORK_ERR(_job, _task, _code) \ + (SCH_NETWORK_ERR(_code) && ((_task)->level->level > (_job)->levelIdx)) +#define SCH_TASK_RETRY_NETWORK_ERR(_task, _code) \ + (SCH_NETWORK_ERR(_code) && (_task)->redirectCtx.inRedirect) + +#define SCH_JOB_NEED_RETRY(_job, _task, _msgType, _code) \ + (SCH_REDIRECT_MSGTYPE(_msgType) && SCH_TOP_LEVEL_NETWORK_ERR(_job, _task, _code)) +#define SCH_TASKSET_NEED_RETRY(_job, _task, _msgType, _code) \ + (SCH_REDIRECT_MSGTYPE(_msgType) && \ + (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_LOW_LEVEL_NETWORK_ERR((_job), (_task), (_code)) || SCH_TASK_RETRY_NETWORK_ERR((_task), (_code)))) +#define SCH_TASK_NEED_RETRY(_msgType, _code) \ + ((SCH_REDIRECT_MSGTYPE(_msgType) && SCH_NETWORK_ERR(_code)) || (_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]) @@ -510,6 +523,11 @@ extern SSchedulerMgmt schMgmt; } \ } while (0) +#define SCH_RESET_JOB_LEVEL_IDX(_job) do { \ + (_job)->levelIdx = (_job)->levelNum - 1; \ + SCH_JOB_DLOG("set job levelIdx to %d", (_job)->levelIdx); \ +} while (0) + void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask); void schCleanClusterHb(void *pTrans); int32_t schLaunchTask(SSchJob *job, SSchTask *task); @@ -562,7 +580,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq); int32_t schExecJob(SSchJob *pJob, SSchedulerReq *pReq); int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes); int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet); -int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode); +int32_t schHandleTaskSetRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode); void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq, int32_t errCode); int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq); void schProcessOnCbEnd(SSchJob *pJob, SSchTask *pTask, int32_t errCode); @@ -591,6 +609,10 @@ int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode); bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync); int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode); int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp); +int32_t schHandleJobRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode); +int32_t schChkResetJobRetry(SSchJob *pJob, int32_t rspCode); +void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask); +int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet, int32_t rspCode); extern SSchDebug gSCHDebug; diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 5e4fe4b8a1f..9cb95a6bbe7 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -282,7 +282,6 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { } int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl); - ; SCH_ERR_RET(code); return code; // to avoid compiler error diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 980a8ac6a19..e7bfe95795f 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -83,6 +83,10 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { oriStatus = SCH_GET_JOB_STATUS(pJob); if (oriStatus == newStatus) { + if (JOB_TASK_STATUS_FETCH == newStatus) { + return code; + } + SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } @@ -108,10 +112,19 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { break; case JOB_TASK_STATUS_PART_SUCC: if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC && - newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC) { + newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && + newStatus != JOB_TASK_STATUS_FETCH) { SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } + break; + case JOB_TASK_STATUS_FETCH: + if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC && + newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && + newStatus != JOB_TASK_STATUS_FETCH) { + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); + } + break; case JOB_TASK_STATUS_SUCC: case JOB_TASK_STATUS_FAIL: @@ -288,7 +301,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { } pJob->levelNum = levelNum; - pJob->levelIdx = levelNum - 1; + SCH_RESET_JOB_LEVEL_IDX(pJob); SSchLevel level = {0}; SNodeListNode *plans = NULL; @@ -550,9 +563,9 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { } SSchLevel *pLevel = pTask->level; - int32_t doneNum = atomic_add_fetch_32(&pLevel->taskDoneNum, 1); + int32_t doneNum = atomic_add_fetch_32(&pLevel->taskExecDoneNum, 1); if (doneNum == pLevel->taskNum) { - pJob->levelIdx--; + atomic_sub_fetch_32(&pJob->levelIdx, 1); pLevel = taosArrayGet(pJob->levels, pJob->levelIdx); for (int32_t i = 0; i < pLevel->taskNum; ++i) { @@ -562,6 +575,10 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { continue; } + if (SCH_TASK_ALREADY_LAUNCHED(pTask)) { + continue; + } + SCH_ERR_RET(schLaunchTask(pJob, pTask)); } } @@ -811,6 +828,75 @@ void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode) { } } +int32_t schChkResetJobRetry(SSchJob *pJob, int32_t rspCode) { + if (pJob->status >= JOB_TASK_STATUS_PART_SUCC) { + SCH_LOCK(SCH_WRITE, &pJob->resLock); + if (pJob->fetched) { + SCH_UNLOCK(SCH_WRITE, &pJob->resLock); + pJob->noMoreRetry = true; + SCH_JOB_ELOG("already fetched while got error %s", tstrerror(rspCode)); + SCH_ERR_RET(rspCode); + } + SCH_UNLOCK(SCH_WRITE, &pJob->resLock); + + schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t schResetJobForRetry(SSchJob *pJob, int32_t rspCode) { + SCH_ERR_RET(schChkResetJobRetry(pJob, rspCode)); + + int32_t numOfLevels = taosArrayGetSize(pJob->levels); + for (int32_t i = 0; i < numOfLevels; ++i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + pLevel->taskExecDoneNum = 0; + pLevel->taskLaunchedNum = 0; + + int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks); + for (int32_t j = 0; j < numOfTasks; ++j) { + SSchTask *pTask = taosArrayGet(pLevel->subTasks, j); + SCH_LOCK_TASK(pTask); + SCH_ERR_RET(schChkUpdateRedirectCtx(pJob, pTask, NULL, rspCode)); + qClearSubplanExecutionNode(pTask->plan); + schResetTaskForRetry(pJob, pTask); + SCH_UNLOCK_TASK(pTask); + } + } + + SCH_RESET_JOB_LEVEL_IDX(pJob); + + return TSDB_CODE_SUCCESS; +} + + +int32_t schHandleJobRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + + taosMemoryFreeClear(pMsg->pData); + taosMemoryFreeClear(pMsg->pEpSet); + + SCH_UNLOCK_TASK(pTask); + + SCH_TASK_DLOG("start to redirect all job tasks cause of error: %s", tstrerror(rspCode)); + + SCH_ERR_JRET(schResetJobForRetry(pJob, rspCode)); + + SCH_ERR_JRET(schLaunchJob(pJob)); + + SCH_LOCK_TASK(pTask); + + SCH_RET(code); + +_return: + + SCH_LOCK_TASK(pTask); + + SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); +} + bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync) { bool r = false; SCH_LOCK(SCH_READ, &pJob->opStatus.lock); @@ -907,7 +993,7 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq SCH_ERR_RET(TSDB_CODE_APP_ERROR); } - if (status != JOB_TASK_STATUS_PART_SUCC) { + if (status != JOB_TASK_STATUS_PART_SUCC && status != JOB_TASK_STATUS_FETCH) { SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 6f4130fd9ff..80fdc7594cc 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -36,7 +36,7 @@ int32_t schValidateRspMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_QW_MSG_ERROR); } - if (taskStatus != JOB_TASK_STATUS_PART_SUCC) { + if (taskStatus != JOB_TASK_STATUS_FETCH) { SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_QW_MSG_ERROR); @@ -137,25 +137,12 @@ int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp) { return TSDB_CODE_SUCCESS; } -// Note: no more task error processing, handled in function internal -int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { +int32_t schProcessResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; char *msg = pMsg->pData; int32_t msgSize = pMsg->len; int32_t msgType = pMsg->msgType; - bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); - if (SCH_IS_QUERY_JOB(pJob)) { - SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); - } - - SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); - - int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); - if (SCH_TASK_NEED_REDIRECT(pTask, reqType, rspCode, pMsg->len)) { - SCH_RET(schHandleRedirect(pJob, pTask, (SDataBuf *)pMsg, rspCode)); - } - pTask->redirectCtx.inRedirect = false; switch (msgType) { @@ -423,6 +410,38 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } + + +// Note: no more task error processing, handled in function internal +int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + int32_t msgType = pMsg->msgType; + char *msg = pMsg->pData; + + bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); + if (SCH_IS_QUERY_JOB(pJob)) { + SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); + } + + SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); + + int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); + if (SCH_JOB_NEED_RETRY(pJob, pTask, reqType, rspCode)) { + SCH_RET(schHandleJobRetry(pJob, pTask, (SDataBuf *)pMsg, rspCode)); + } else if (SCH_TASKSET_NEED_RETRY(pJob, pTask, reqType, rspCode)) { + SCH_RET(schHandleTaskSetRetry(pJob, pTask, (SDataBuf *)pMsg, rspCode)); + } + + pTask->redirectCtx.inRedirect = false; + + SCH_RET(schProcessResponseMsg(pJob, pTask, execId, pMsg, rspCode)); + +_return: + + taosMemoryFreeClear(msg); + + SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); +} int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; diff --git a/source/libs/scheduler/src/schStatus.c b/source/libs/scheduler/src/schStatus.c index 4c16a81a050..9d0ad30e2a4 100644 --- a/source/libs/scheduler/src/schStatus.c +++ b/source/libs/scheduler/src/schStatus.c @@ -34,6 +34,9 @@ int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) { case JOB_TASK_STATUS_PART_SUCC: SCH_ERR_JRET(schProcessOnJobPartialSuccess(pJob)); break; + case JOB_TASK_STATUS_FETCH: + SCH_ERR_JRET(schJobFetchRows(pJob)); + break; case JOB_TASK_STATUS_SUCC: break; case JOB_TASK_STATUS_FAIL: diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index bdab7393277..207753ae257 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -378,7 +378,8 @@ int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet, if (lastTime > tsMaxRetryWaitTime) { SCH_TASK_DLOG("task no more redirect retry since timeout, now:%" PRId64 ", start:%" PRId64 ", max:%d, total:%d", nowTs, pCtx->startTs, tsMaxRetryWaitTime, pCtx->totalTimes); - SCH_ERR_RET(SCH_GET_REDICT_CODE(pJob, rspCode)); + pJob->noMoreRetry = true; + SCH_ERR_RET(SCH_GET_REDIRECT_CODE(pJob, rspCode)); } pCtx->periodMs *= tsRedirectFactor; @@ -404,32 +405,35 @@ int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet, return TSDB_CODE_SUCCESS; } -int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { - int32_t code = 0; - - SCH_TASK_DLOG("task will be redirected now, status:%s, code:%s", SCH_GET_TASK_STATUS_STR(pTask), tstrerror(rspCode)); - - if (NULL == pData) { - pTask->retryTimes = 0; - } - - if (!NO_RET_REDIRECT_ERROR(rspCode)) { - SCH_UPDATE_REDICT_CODE(pJob, rspCode); - } - - SCH_ERR_JRET(schChkUpdateRedirectCtx(pJob, pTask, pData ? pData->pEpSet : NULL, rspCode)); - +void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) { pTask->waitRetry = true; schDropTaskOnExecNode(pJob, pTask); + if (pTask->delayTimer) { + taosTmrStopA(&pTask->delayTimer); + } taosHashClear(pTask->execNodes); schRemoveTaskFromExecList(pJob, pTask); schDeregisterTaskHb(pJob, pTask); - atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1); taosMemoryFreeClear(pTask->msg); pTask->msgLen = 0; pTask->lastMsgType = 0; + pTask->childReady = 0; memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr)); +} + +int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { + int32_t code = 0; + + SCH_TASK_DLOG("task will be redirected now, status:%s, code:%s", SCH_GET_TASK_STATUS_STR(pTask), tstrerror(rspCode)); + + if (!NO_RET_REDIRECT_ERROR(rspCode)) { + SCH_UPDATE_REDIRECT_CODE(pJob, rspCode); + } + + SCH_ERR_JRET(schChkUpdateRedirectCtx(pJob, pTask, pData ? pData->pEpSet : NULL, rspCode)); + + schResetTaskForRetry(pJob, pTask); if (SCH_IS_DATA_BIND_TASK(pTask)) { if (pData && pData->pEpSet) { @@ -445,12 +449,6 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 SCH_TASK_DLOG("switch task target node %d epset to %d/%d", addr->nodeId, addr->epSet.inUse, addr->epSet.numOfEps); } - if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { - if (JOB_TASK_STATUS_EXEC == SCH_GET_TASK_STATUS(pTask)) { - SCH_ERR_JRET(schLaunchTasksInFlowCtrlList(pJob, pTask)); - } - } - SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); SCH_ERR_JRET(schDelayLaunchTask(pJob, pTask)); @@ -486,20 +484,10 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } -int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { +int32_t schHandleTaskSetRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { int32_t code = 0; - if (JOB_TASK_STATUS_PART_SUCC == pJob->status) { - SCH_LOCK(SCH_WRITE, &pJob->resLock); - if (pJob->fetched) { - SCH_UNLOCK(SCH_WRITE, &pJob->resLock); - SCH_TASK_ELOG("already fetched while got error %s", tstrerror(rspCode)); - SCH_ERR_JRET(rspCode); - } - SCH_UNLOCK(SCH_WRITE, &pJob->resLock); - - schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC); - } + SCH_ERR_JRET(schChkResetJobRetry(pJob, rspCode)); if (SYNC_OTHER_LEADER_REDIRECT_ERROR(rspCode)) { if (NULL == pData->pEpSet) { @@ -509,7 +497,19 @@ int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 } } + SCH_TASK_DLOG("start to redirect current task set cause of error: %s", tstrerror(rspCode)); + + for (int32_t i = 0; i < pJob->levelNum; ++i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + pLevel->taskExecDoneNum = 0; + pLevel->taskLaunchedNum = 0; + } + + SCH_RESET_JOB_LEVEL_IDX(pJob); + code = schDoTaskRedirect(pJob, pTask, pData, rspCode); + taosMemoryFreeClear(pData->pData); taosMemoryFreeClear(pData->pEpSet); @@ -621,6 +621,13 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { */ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) { + if (pJob->noMoreRetry) { + *needRetry = false; + SCH_TASK_DLOG("task no more retry since job no more retry, retryTimes:%d/%d", pTask->retryTimes, + pTask->maxRetryTimes); + return TSDB_CODE_SUCCESS; + } + if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) { pTask->maxExecTimes++; pTask->maxRetryTimes++; @@ -645,7 +652,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo return TSDB_CODE_SUCCESS; } - if (!SCH_NEED_RETRY(pTask->lastMsgType, errCode)) { + if (!SCH_TASK_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; @@ -1067,7 +1074,6 @@ int32_t schLaunchTaskImpl(void *param) { SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } - // NOTE: race condition: the task should be put into the hash table before send msg to server if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXEC) { SCH_ERR_JRET(schPushTaskToExecList(pJob, pTask)); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_EXEC); @@ -1272,6 +1278,8 @@ int32_t schLaunchFetchTask(SSchJob *pJob) { return TSDB_CODE_SUCCESS; } + SCH_SET_TASK_STATUS(pJob->fetchTask, JOB_TASK_STATUS_FETCH); + if (SCH_IS_LOCAL_EXEC_TASK(pJob, pJob->fetchTask)) { SCH_ERR_JRET(schExecLocalFetch(pJob, pJob->fetchTask)); } else { diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 7cd5e957b6b..2b46a4710e2 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -91,7 +91,7 @@ int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq *pReq) { SCH_ERR_JRET(schHandleOpBeginEvent(jobId, &pJob, SCH_OP_FETCH, pReq)); - SCH_ERR_JRET(schJobFetchRows(pJob)); + SCH_ERR_JRET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_FETCH, pReq)); _return: diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 60729c4d0e5..361cd2cacc1 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -68,7 +68,7 @@ void streamSchedByTimer(void* param, void* tmrId) { atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__INACTIVE); - if (streamTaskInput(pTask, (SStreamQueueItem*)trigger) < 0) { + if (tAppendDataForStream(pTask, (SStreamQueueItem*)trigger) < 0) { taosFreeQitem(trigger); taosTmrReset(streamSchedByTimer, (int32_t)pTask->triggerParam, pTask, streamEnv.timer, &pTask->timer); return; @@ -92,22 +92,22 @@ int32_t streamSetupTrigger(SStreamTask* pTask) { int32_t streamSchedExec(SStreamTask* pTask) { int8_t schedStatus = atomic_val_compare_exchange_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE, TASK_SCHED_STATUS__WAITING); + if (schedStatus == TASK_SCHED_STATUS__INACTIVE) { SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq)); if (pRunReq == NULL) { atomic_store_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE); return -1; } + pRunReq->head.vgId = pTask->nodeId; pRunReq->streamId = pTask->streamId; pRunReq->taskId = pTask->taskId; - SRpcMsg msg = { - .msgType = TDMT_STREAM_TASK_RUN, - .pCont = pRunReq, - .contLen = sizeof(SStreamTaskRunReq), - }; + + SRpcMsg msg = { .msgType = TDMT_STREAM_TASK_RUN, .pCont = pRunReq, .contLen = sizeof(SStreamTaskRunReq) }; tmsgPutToQueue(pTask->pMsgCb, STREAM_QUEUE, &msg); } + return 0; } @@ -123,7 +123,7 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, const SStreamDispatchReq* pReq, SR /*pData->blocks = pReq->data;*/ /*pBlock->sourceVer = pReq->sourceVer;*/ streamDispatchReqToData(pReq, pData); - if (streamTaskInput(pTask, (SStreamQueueItem*)pData) == 0) { + if (tAppendDataForStream(pTask, (SStreamQueueItem*)pData) == 0) { status = TASK_INPUT_STATUS__NORMAL; } else { status = TASK_INPUT_STATUS__FAILED; @@ -164,7 +164,7 @@ int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, /*pData->blocks = pReq->data;*/ /*pBlock->sourceVer = pReq->sourceVer;*/ streamRetrieveReqToData(pReq, pData); - if (streamTaskInput(pTask, (SStreamQueueItem*)pData) == 0) { + if (tAppendDataForStream(pTask, (SStreamQueueItem*)pData) == 0) { status = TASK_INPUT_STATUS__NORMAL; } else { status = TASK_INPUT_STATUS__FAILED; @@ -275,7 +275,57 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S return 0; } -int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp) { - // +int32_t tAppendDataForStream(SStreamTask* pTask, SStreamQueueItem* pItem) { + int8_t type = pItem->type; + + if (type == STREAM_INPUT__DATA_SUBMIT) { + SStreamDataSubmit2* pSubmitBlock = streamSubmitBlockClone((SStreamDataSubmit2*)pItem); + if (pSubmitBlock == NULL) { + qDebug("task %d %p submit enqueue failed since out of memory", pTask->taskId, pTask); + terrno = TSDB_CODE_OUT_OF_MEMORY; + atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED); + return -1; + } + + int32_t total = taosQueueItemSize(pTask->inputQueue->queue) + 1; + qDebug("stream task:%d %p submit enqueue %p %p %p msgLen:%d ver:%" PRId64 ", total in queue:%d", pTask->taskId, + pTask, pItem, pSubmitBlock, pSubmitBlock->submit.msgStr, pSubmitBlock->submit.msgLen, + pSubmitBlock->submit.ver, total); + + taosWriteQitem(pTask->inputQueue->queue, pSubmitBlock); + } else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE || + type == STREAM_INPUT__REF_DATA_BLOCK) { + taosWriteQitem(pTask->inputQueue->queue, pItem); + } else if (type == STREAM_INPUT__CHECKPOINT) { + taosWriteQitem(pTask->inputQueue->queue, pItem); + } else if (type == STREAM_INPUT__GET_RES) { + taosWriteQitem(pTask->inputQueue->queue, pItem); + } + + if (type != STREAM_INPUT__GET_RES && type != STREAM_INPUT__CHECKPOINT && pTask->triggerParam != 0) { + atomic_val_compare_exchange_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__INACTIVE, TASK_TRIGGER_STATUS__ACTIVE); + } + +#if 0 + // TODO: back pressure + atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL); +#endif + return 0; } + +void* streamQueueNextItem(SStreamQueue* queue) { + int8_t dequeueFlag = atomic_exchange_8(&queue->status, STREAM_QUEUE__PROCESSING); + if (dequeueFlag == STREAM_QUEUE__FAILED) { + ASSERT(queue->qItem != NULL); + return streamQueueCurItem(queue); + } else { + queue->qItem = NULL; + taosGetQitem(queue->qall, &queue->qItem); + if (queue->qItem == NULL) { + taosReadAllQitems(queue->queue, queue->qall); + taosGetQitem(queue->qall, &queue->qItem); + } + return streamQueueCurItem(queue); + } +} \ No newline at end of file diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index 8baebaee422..3fba1cb556a 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -48,10 +48,12 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock if (pArray == NULL) { return -1; } + taosArrayPush(pArray, &(SSDataBlock){0}); SRetrieveTableRsp* pRetrieve = pReq->pRetrieve; SSDataBlock* pDataBlock = taosArrayGet(pArray, 0); blockDecode(pDataBlock, pRetrieve->data); + // TODO: refactor pDataBlock->info.window.skey = be64toh(pRetrieve->skey); pDataBlock->info.window.ekey = be64toh(pRetrieve->ekey); @@ -68,32 +70,51 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock SStreamDataSubmit2* streamDataSubmitNew(SPackedData submit) { SStreamDataSubmit2* pDataSubmit = (SStreamDataSubmit2*)taosAllocateQitem(sizeof(SStreamDataSubmit2), DEF_QITEM, 0); - if (pDataSubmit == NULL) return NULL; + if (pDataSubmit == NULL) { + return NULL; + } + pDataSubmit->dataRef = (int32_t*)taosMemoryMalloc(sizeof(int32_t)); - if (pDataSubmit->dataRef == NULL) goto FAIL; + if (pDataSubmit->dataRef == NULL) { + taosFreeQitem(pDataSubmit); + return NULL; + } + pDataSubmit->submit = submit; - *pDataSubmit->dataRef = 1; + *pDataSubmit->dataRef = 1; // initialize the reference count to be 1 pDataSubmit->type = STREAM_INPUT__DATA_SUBMIT; + return pDataSubmit; -FAIL: - taosFreeQitem(pDataSubmit); - return NULL; +} + +void streamDataSubmitDestroy(SStreamDataSubmit2* pDataSubmit) { + int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1); + ASSERT(ref >= 0 && pDataSubmit->type == STREAM_INPUT__DATA_SUBMIT); + + if (ref == 0) { + taosMemoryFree(pDataSubmit->submit.msgStr); + taosMemoryFree(pDataSubmit->dataRef); + } } SStreamMergedSubmit2* streamMergedSubmitNew() { SStreamMergedSubmit2* pMerged = (SStreamMergedSubmit2*)taosAllocateQitem(sizeof(SStreamMergedSubmit2), DEF_QITEM, 0); + if (pMerged == NULL) { + return NULL; + } - if (pMerged == NULL) return NULL; pMerged->submits = taosArrayInit(0, sizeof(SPackedData)); pMerged->dataRefs = taosArrayInit(0, sizeof(void*)); - if (pMerged->dataRefs == NULL || pMerged->submits == NULL) goto FAIL; + + if (pMerged->dataRefs == NULL || pMerged->submits == NULL) { + taosArrayDestroy(pMerged->submits); + taosArrayDestroy(pMerged->dataRefs); + taosFreeQitem(pMerged); + return NULL; + } + pMerged->type = STREAM_INPUT__MERGED_SUBMIT; return pMerged; -FAIL: - if (pMerged->submits) taosArrayDestroy(pMerged->submits); - if (pMerged->dataRefs) taosArrayDestroy(pMerged->dataRefs); - taosFreeQitem(pMerged); - return NULL; } int32_t streamMergeSubmit(SStreamMergedSubmit2* pMerged, SStreamDataSubmit2* pSubmit) { @@ -107,26 +128,17 @@ static FORCE_INLINE void streamDataSubmitRefInc(SStreamDataSubmit2* pDataSubmit) atomic_add_fetch_32(pDataSubmit->dataRef, 1); } -SStreamDataSubmit2* streamSubmitRefClone(SStreamDataSubmit2* pSubmit) { +SStreamDataSubmit2* streamSubmitBlockClone(SStreamDataSubmit2* pSubmit) { SStreamDataSubmit2* pSubmitClone = taosAllocateQitem(sizeof(SStreamDataSubmit2), DEF_QITEM, 0); - if (pSubmitClone == NULL) { return NULL; } + streamDataSubmitRefInc(pSubmit); memcpy(pSubmitClone, pSubmit, sizeof(SStreamDataSubmit2)); return pSubmitClone; } -void streamDataSubmitRefDec(SStreamDataSubmit2* pDataSubmit) { - int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1); - ASSERT(ref >= 0); - if (ref == 0) { - taosMemoryFree(pDataSubmit->submit.msgStr); - taosMemoryFree(pDataSubmit->dataRef); - } -} - SStreamQueueItem* streamMergeQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem) { ASSERT(elem); if (dst->type == STREAM_INPUT__DATA_BLOCK && elem->type == STREAM_INPUT__DATA_BLOCK) { @@ -164,7 +176,7 @@ void streamFreeQitem(SStreamQueueItem* data) { taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)blockDataFreeRes); taosFreeQitem(data); } else if (type == STREAM_INPUT__DATA_SUBMIT) { - streamDataSubmitRefDec((SStreamDataSubmit2*)data); + streamDataSubmitDestroy((SStreamDataSubmit2*)data); taosFreeQitem(data); } else if (type == STREAM_INPUT__MERGED_SUBMIT) { SStreamMergedSubmit2* pMerge = (SStreamMergedSubmit2*)data; diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 25b26563658..6ef327049c9 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -34,7 +34,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray* } else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { ASSERT(pTask->taskLevel == TASK_LEVEL__SOURCE); const SStreamDataSubmit2* pSubmit = (const SStreamDataSubmit2*)data; - qDebug("task %d %p set submit input %p %p %d %" PRId64, pTask->taskId, pTask, pSubmit, pSubmit->submit.msgStr, + qDebug("stream task:%d %p set submit input %p %p %d %" PRId64, pTask->taskId, pTask, pSubmit, pSubmit->submit.msgStr, pSubmit->submit.msgLen, pSubmit->submit.ver); qSetMultiStreamInput(exec, &pSubmit->submit, 1, STREAM_INPUT__DATA_SUBMIT); } else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) { @@ -268,9 +268,10 @@ int32_t streamExecForAll(SStreamTask* pTask) { SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); - qDebug("stream task %d exec begin, msg batch: %d", pTask->taskId, batchCnt); + qDebug("stream task:%d exec begin, msg batch: %d", pTask->taskId, batchCnt); streamTaskExecImpl(pTask, input, pRes); - qDebug("stream task %d exec end", pTask->taskId); + + qDebug("stream task:%d exec end", pTask->taskId); if (taosArrayGetSize(pRes) != 0) { SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0); diff --git a/source/libs/sync/inc/syncPipeline.h b/source/libs/sync/inc/syncPipeline.h index a1de2ee71ac..68db811b127 100644 --- a/source/libs/sync/inc/syncPipeline.h +++ b/source/libs/sync/inc/syncPipeline.h @@ -59,36 +59,36 @@ typedef struct SSyncLogBuffer { } SSyncLogBuffer; // SSyncLogRepMgr -SSyncLogReplMgr* syncLogReplMgrCreate(); -void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr); -void syncLogReplMgrReset(SSyncLogReplMgr* pMgr); +SSyncLogReplMgr* syncLogReplCreate(); +void syncLogReplDestroy(SSyncLogReplMgr* pMgr); +void syncLogReplReset(SSyncLogReplMgr* pMgr); -int32_t syncNodeLogReplMgrInit(SSyncNode* pNode); -void syncNodeLogReplMgrDestroy(SSyncNode* pNode); +int32_t syncNodeLogReplInit(SSyncNode* pNode); +void syncNodeLogReplDestroy(SSyncNode* pNode); // access -static FORCE_INLINE int64_t syncLogGetRetryBackoffTimeMs(SSyncLogReplMgr* pMgr) { +static FORCE_INLINE int64_t syncLogReplGetRetryBackoffTimeMs(SSyncLogReplMgr* pMgr) { return ((int64_t)1 << pMgr->retryBackoff) * SYNC_LOG_REPL_RETRY_WAIT_MS; } -static FORCE_INLINE int32_t syncLogGetNextRetryBackoff(SSyncLogReplMgr* pMgr) { +static FORCE_INLINE int32_t syncLogReplGetNextRetryBackoff(SSyncLogReplMgr* pMgr) { return TMIN(pMgr->retryBackoff + 1, SYNC_MAX_RETRY_BACKOFF); } -SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); +SyncTerm syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); -int32_t syncLogReplMgrReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode); -int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, - SRaftId* pDestId, bool* pBarrier); -int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode); -int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); +int32_t syncLogReplReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode); +int32_t syncLogReplReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, + SRaftId* pDestId, bool* pBarrier); +int32_t syncLogReplReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode); +int32_t syncLogReplReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); -int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); -int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); -int32_t syncLogReplMgrProcessReplyAsNormal(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); +int32_t syncLogReplProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); +int32_t syncLogReplProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); +int32_t syncLogReplProcessReplyAsNormal(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); -int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg); -int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode); +int32_t syncLogReplProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg); +int32_t syncLogReplRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode); // SSyncLogBuffer SSyncLogBuffer* syncLogBufferCreate(); @@ -111,8 +111,8 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode, int32_t syncLogBufferValidate(SSyncLogBuffer* pBuf); int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex toIndex); -int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, - int32_t applyCode); +int32_t syncFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, + int32_t applyCode); #ifdef __cplusplus } #endif diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index bd1dae54d95..9ab545075cf 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -105,6 +105,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SRpcMsg rpcRsp = {0}; bool accepted = false; SSyncRaftEntry* pEntry = NULL; + bool resetElect = false; // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) { @@ -137,7 +138,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } syncNodeStepDown(ths, pMsg->term); - syncNodeResetElectTimer(ths); + resetElect = true; if (pMsg->dataLen < sizeof(SSyncRaftEntry)) { sError("vgId:%d, incomplete append entries received. prev index:%" PRId64 ", term:%" PRId64 ", datalen:%d", @@ -184,10 +185,9 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // commit index, i.e. leader notice me if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { sError("vgId:%d, failed to commit raft fsm log since %s.", ths->vgId, terrstr()); - goto _out; } -_out: + if (resetElect) syncNodeResetElectTimer(ths); return 0; _IGNORE: diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index a60f43cd5ed..7c343c0e5d3 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -85,7 +85,7 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { sError("vgId:%d, failed to get log repl mgr for src addr: 0x%016" PRIx64, ths->vgId, pMsg->srcId.addr); return -1; } - (void)syncLogReplMgrProcessReply(pMgr, ths, pMsg); + (void)syncLogReplProcessReply(pMgr, ths, pMsg); } return 0; } diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index e53b8ade1ca..3699efbc594 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -115,6 +115,5 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { ASSERT(ret == 0); syncNodeResetElectTimer(pSyncNode); - return ret; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index e5fe4a23695..c25ea24249b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -182,6 +182,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) { case TDMT_SYNC_TIMEOUT: code = syncNodeOnTimeout(pSyncNode, pMsg); break; + case TDMT_SYNC_TIMEOUT_ELECTION: + code = syncNodeOnTimeout(pSyncNode, pMsg); + break; case TDMT_SYNC_CLIENT_REQUEST: code = syncNodeOnClientRequest(pSyncNode, pMsg, NULL); break; @@ -946,7 +949,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->changing = false; // replication mgr - if (syncNodeLogReplMgrInit(pSyncNode) < 0) { + if (syncNodeLogReplInit(pSyncNode) < 0) { sError("vgId:%d, failed to init repl mgr since %s.", pSyncNode->vgId, terrstr()); goto _error; } @@ -1119,7 +1122,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { syncNodeStopPingTimer(pSyncNode); syncNodeStopElectTimer(pSyncNode); syncNodeStopHeartbeatTimer(pSyncNode); - syncNodeLogReplMgrDestroy(pSyncNode); + syncNodeLogReplDestroy(pSyncNode); syncRespMgrDestroy(pSyncNode->pSyncRespMgr); pSyncNode->pSyncRespMgr = NULL; @@ -1593,8 +1596,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; syncNodeStopHeartbeatTimer(pSyncNode); - // reset elect timer - syncNodeResetElectTimer(pSyncNode); + // trace log + sNTrace(pSyncNode, "become follower %s", debugStr); // send rsp to client syncNodeLeaderChangeRsp(pSyncNode); @@ -1610,8 +1613,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // reset log buffer syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); - // trace log - sNTrace(pSyncNode, "become follower %s", debugStr); + // reset elect timer + syncNodeResetElectTimer(pSyncNode); } // TLA+ Spec @@ -2161,7 +2164,7 @@ int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { if (syncLogBufferAppend(ths->pLogBuf, ths, pEntry) < 0) { sError("vgId:%d, failed to enqueue sync log buffer, index:%" PRId64, ths->vgId, pEntry->index); ASSERT(terrno != 0); - (void)syncLogFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, terrno); + (void)syncFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, terrno); syncEntryDestroy(pEntry); return -1; } @@ -2277,6 +2280,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) { int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SyncHeartbeat* pMsg = pRpcMsg->pCont; + bool resetElect = false; const STraceId* trace = &pRpcMsg->info.traceId; char tbuf[40] = {0}; @@ -2300,12 +2304,11 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (pMsg->term == currentTerm && ths->state != TAOS_SYNC_STATE_LEADER) { syncIndexMgrSetRecvTime(ths->pNextIndex, &(pMsg->srcId), tsMs); + resetElect = true; - syncNodeResetElectTimer(ths); ths->minMatchIndex = pMsg->minMatchIndex; if (ths->state == TAOS_SYNC_STATE_FOLLOWER) { - // syncNodeFollowerCommit(ths, pMsg->commitIndex); SRpcMsg rpcMsgLocalCmd = {0}; (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); @@ -2328,7 +2331,6 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } if (pMsg->term >= currentTerm && ths->state != TAOS_SYNC_STATE_FOLLOWER) { - // syncNodeStepDown(ths, pMsg->term); SRpcMsg rpcMsgLocalCmd = {0}; (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); @@ -2348,15 +2350,10 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } } - /* - // htonl - SMsgHead* pHead = rpcMsg.pCont; - pHead->contLen = htonl(pHead->contLen); - pHead->vgId = htonl(pHead->vgId); - */ - // reply syncNodeSendMsgById(&pMsgReply->destId, ths, &rpcMsg); + + if (resetElect) syncNodeResetElectTimer(ths); return 0; } @@ -2377,7 +2374,7 @@ int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { syncIndexMgrSetRecvTime(ths->pMatchIndex, &pMsg->srcId, tsMs); - return syncLogReplMgrProcessHeartbeatReply(pMgr, ths, pMsg); + return syncLogReplProcessHeartbeatReply(pMgr, ths, pMsg); } int32_t syncNodeOnHeartbeatReplyOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) { diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 2a44588eefc..72c8887803c 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -22,7 +22,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l SSyncNode* pNode) { int32_t bytes = sizeof(SyncTimeout); pMsg->pCont = rpcMallocCont(bytes); - pMsg->msgType = TDMT_SYNC_TIMEOUT; + pMsg->msgType = (timeoutType == SYNC_TIMEOUT_ELECTION) ? TDMT_SYNC_TIMEOUT_ELECTION : TDMT_SYNC_TIMEOUT; pMsg->contLen = bytes; if (pMsg->pCont == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -31,7 +31,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l SyncTimeout* pTimeout = pMsg->pCont; pTimeout->bytes = bytes; - pTimeout->msgType = TDMT_SYNC_TIMEOUT; + pTimeout->msgType = pMsg->msgType; pTimeout->vgId = pNode->vgId; pTimeout->timeoutType = timeoutType; pTimeout->logicClock = logicClock; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index 6600b505c18..04e52b3f493 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -86,7 +86,7 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt return -1; } -SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { +SyncTerm syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { SSyncLogBuffer* pBuf = pNode->pLogBuf; SSyncRaftEntry* pEntry = NULL; SyncIndex prevIndex = index - 1; @@ -316,7 +316,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); - SyncTerm term = syncLogReplMgrGetPrevLogTerm(NULL, pNode, index + 1); + SyncTerm term = syncLogReplGetPrevLogTerm(NULL, pNode, index + 1); ASSERT(pEntry->term >= 0); if (term == pEntry->term) { ret = 0; @@ -351,7 +351,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); - SyncTerm existPrevTerm = syncLogReplMgrGetPrevLogTerm(NULL, pNode, index); + SyncTerm existPrevTerm = syncLogReplGetPrevLogTerm(NULL, pNode, index); ASSERT(pEntry->term == pExist->term && (pEntry->index > pBuf->matchIndex || prevTerm == existPrevTerm)); ret = 0; goto _out; @@ -482,8 +482,8 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p return matchIndex; } -int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, - int32_t applyCode) { +int32_t syncFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, + int32_t applyCode) { if (pNode->replicaNum == 1 && pNode->restoreFinish && pNode->vgId != 1) { return 0; } @@ -564,7 +564,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm pEntry->term, TMSG_INFO(pEntry->originalRpcType)); } - if (syncLogFsmExecute(pNode, pFsm, role, currentTerm, pEntry, 0) != 0) { + if (syncFsmExecute(pNode, pFsm, role, currentTerm, pEntry, 0) != 0) { sError("vgId:%d, failed to execute sync log entry. index:%" PRId64 ", term:%" PRId64 ", role:%d, current term:%" PRId64, vgId, pEntry->index, pEntry->term, role, currentTerm); @@ -611,7 +611,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm return ret; } -void syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { +void syncLogReplReset(SSyncLogReplMgr* pMgr) { if (pMgr == NULL) return; ASSERT(pMgr->startIndex >= 0); @@ -625,14 +625,14 @@ void syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { pMgr->retryBackoff = 0; } -int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { +int32_t syncLogReplRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { if (pMgr->endIndex <= pMgr->startIndex) { return 0; } SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; if (pMgr->retryBackoff == SYNC_MAX_RETRY_BACKOFF) { - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); sWarn("vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer:%" PRIx64, pNode->vgId, pDestId->addr); return -1; @@ -640,7 +640,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { int32_t ret = -1; bool retried = false; - int64_t retryWaitMs = syncLogGetRetryBackoffTimeMs(pMgr); + int64_t retryWaitMs = syncLogReplGetRetryBackoffTimeMs(pMgr); int64_t nowMs = taosGetMonoTimestampMs(); int count = 0; int64_t firstIndex = -1; @@ -657,7 +657,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { if (pMgr->states[pos].acked) { if (pMgr->matchIndex < index && pMgr->states[pos].timeMs + (syncGetRetryMaxWaitMs() << 3) < nowMs) { - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); sWarn("vgId:%d, reset sync log repl mgr since stagnation. index:%" PRId64 ", peer:%" PRIx64, pNode->vgId, index, pDestId->addr); goto _out; @@ -666,7 +666,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { } bool barrier = false; - if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { + if (syncLogReplReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { sError("vgId:%d, failed to replicate sync log entry since %s. index:%" PRId64 ", dest:%" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); goto _out; @@ -687,7 +687,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { ret = 0; _out: if (retried) { - pMgr->retryBackoff = syncLogGetNextRetryBackoff(pMgr); + pMgr->retryBackoff = syncLogReplGetNextRetryBackoff(pMgr); SSyncLogBuffer* pBuf = pNode->pLogBuf; sInfo("vgId:%d, resend %d sync log entries. dest:%" PRIx64 ", indexes:%" PRId64 " ..., terms: ... %" PRId64 ", retryWaitMs:%" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 @@ -698,7 +698,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { return ret; } -int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { +int32_t syncLogReplProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { SSyncLogBuffer* pBuf = pNode->pLogBuf; SRaftId destId = pMsg->srcId; ASSERT(pMgr->restored == false); @@ -716,7 +716,7 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p } } else { if (pMsg->lastSendIndex < pMgr->startIndex || pMsg->lastSendIndex >= pMgr->endIndex) { - syncLogReplMgrRetryOnNeed(pMgr, pNode); + syncLogReplRetryOnNeed(pMgr, pNode); return 0; } @@ -750,7 +750,7 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p SyncIndex index = TMIN(pMsg->matchIndex, pNode->pLogBuf->matchIndex); if (pMsg->matchIndex < pNode->pLogBuf->matchIndex) { - term = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index + 1); + term = syncLogReplGetPrevLogTerm(pMgr, pNode, index + 1); if ((index + 1 < firstVer) || (term < 0) || (term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) { ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); @@ -773,53 +773,53 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p } // attempt to replicate the raft log at index - (void)syncLogReplMgrReset(pMgr); - return syncLogReplMgrReplicateProbe(pMgr, pNode, index); + (void)syncLogReplReset(pMgr); + return syncLogReplReplicateProbe(pMgr, pNode, index); } -int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg) { +int32_t syncLogReplProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg) { SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); if (pMsg->startTime != 0 && pMsg->startTime != pMgr->peerStartTime) { sInfo("vgId:%d, reset sync log repl mgr in heartbeat. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "", pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); pMgr->peerStartTime = pMsg->startTime; } taosThreadMutexUnlock(&pBuf->mutex); return 0; } -int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { +int32_t syncLogReplProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); if (pMsg->startTime != pMgr->peerStartTime) { sInfo("vgId:%d, reset sync log repl mgr in appendlog reply. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64, pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); pMgr->peerStartTime = pMsg->startTime; } if (pMgr->restored) { - (void)syncLogReplMgrProcessReplyAsNormal(pMgr, pNode, pMsg); + (void)syncLogReplProcessReplyAsNormal(pMgr, pNode, pMsg); } else { - (void)syncLogReplMgrProcessReplyAsRecovery(pMgr, pNode, pMsg); + (void)syncLogReplProcessReplyAsRecovery(pMgr, pNode, pMsg); } taosThreadMutexUnlock(&pBuf->mutex); return 0; } -int32_t syncLogReplMgrReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { +int32_t syncLogReplReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { if (pMgr->restored) { - (void)syncLogReplMgrReplicateAttempt(pMgr, pNode); + (void)syncLogReplReplicateAttempt(pMgr, pNode); } else { - (void)syncLogReplMgrReplicateProbe(pMgr, pNode, pNode->pLogBuf->matchIndex); + (void)syncLogReplReplicateProbe(pMgr, pNode, pNode->pLogBuf->matchIndex); } return 0; } -int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { +int32_t syncLogReplReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { ASSERT(!pMgr->restored); ASSERT(pMgr->startIndex >= 0); int64_t retryMaxWaitMs = syncGetRetryMaxWaitMs(); @@ -829,12 +829,12 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy nowMs < pMgr->states[pMgr->startIndex % pMgr->size].timeMs + retryMaxWaitMs) { return 0; } - (void)syncLogReplMgrReset(pMgr); + (void)syncLogReplReset(pMgr); SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; bool barrier = false; SyncTerm term = -1; - if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { + if (syncLogReplReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); return -1; @@ -857,7 +857,7 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy return 0; } -int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { +int32_t syncLogReplReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { ASSERT(pMgr->restored); SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; @@ -879,7 +879,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; bool barrier = false; SyncTerm term = -1; - if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { + if (syncLogReplReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); return -1; @@ -902,7 +902,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) } } - syncLogReplMgrRetryOnNeed(pMgr, pNode); + syncLogReplRetryOnNeed(pMgr, pNode); SSyncLogBuffer* pBuf = pNode->pLogBuf; sTrace("vgId:%d, replicated %d msgs to peer:%" PRIx64 ". indexes:%" PRId64 "..., terms: ...%" PRId64 @@ -913,7 +913,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) return 0; } -int32_t syncLogReplMgrProcessReplyAsNormal(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { +int32_t syncLogReplProcessReplyAsNormal(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { ASSERT(pMgr->restored == true); if (pMgr->startIndex <= pMsg->lastSendIndex && pMsg->lastSendIndex < pMgr->endIndex) { if (pMgr->startIndex < pMgr->matchIndex && pMgr->retryBackoff > 0) { @@ -932,10 +932,10 @@ int32_t syncLogReplMgrProcessReplyAsNormal(SSyncLogReplMgr* pMgr, SSyncNode* pNo pMgr->startIndex = pMgr->matchIndex; } - return syncLogReplMgrReplicateAttempt(pMgr, pNode); + return syncLogReplReplicateAttempt(pMgr, pNode); } -SSyncLogReplMgr* syncLogReplMgrCreate() { +SSyncLogReplMgr* syncLogReplCreate() { SSyncLogReplMgr* pMgr = taosMemoryCalloc(1, sizeof(SSyncLogReplMgr)); if (pMgr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -949,7 +949,7 @@ SSyncLogReplMgr* syncLogReplMgrCreate() { return pMgr; } -void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr) { +void syncLogReplDestroy(SSyncLogReplMgr* pMgr) { if (pMgr == NULL) { return; } @@ -957,10 +957,10 @@ void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr) { return; } -int32_t syncNodeLogReplMgrInit(SSyncNode* pNode) { +int32_t syncNodeLogReplInit(SSyncNode* pNode) { for (int i = 0; i < TSDB_MAX_REPLICA; i++) { ASSERT(pNode->logReplMgrs[i] == NULL); - pNode->logReplMgrs[i] = syncLogReplMgrCreate(); + pNode->logReplMgrs[i] = syncLogReplCreate(); if (pNode->logReplMgrs[i] == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -970,9 +970,9 @@ int32_t syncNodeLogReplMgrInit(SSyncNode* pNode) { return 0; } -void syncNodeLogReplMgrDestroy(SSyncNode* pNode) { +void syncNodeLogReplDestroy(SSyncNode* pNode) { for (int i = 0; i < TSDB_MAX_REPLICA; i++) { - syncLogReplMgrDestroy(pNode->logReplMgrs[i]); + syncLogReplDestroy(pNode->logReplMgrs[i]); pNode->logReplMgrs[i] = NULL; } } @@ -1103,7 +1103,7 @@ int32_t syncLogBufferReset(SSyncLogBuffer* pBuf, SSyncNode* pNode) { // reset repl mgr for (int i = 0; i < pNode->replicaNum; i++) { SSyncLogReplMgr* pMgr = pNode->logReplMgrs[i]; - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); } syncLogBufferValidate(pBuf); taosThreadMutexUnlock(&pBuf->mutex); @@ -1127,8 +1127,8 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode, return pEntry; } -int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, - SRaftId* pDestId, bool* pBarrier) { +int32_t syncLogReplReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, + SRaftId* pDestId, bool* pBarrier) { SSyncRaftEntry* pEntry = NULL; SRpcMsg msgOut = {0}; bool inBuf = false; @@ -1143,14 +1143,14 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy if (pMgr) { sInfo("vgId:%d, reset sync log repl mgr of peer:%" PRIx64 " since %s. index:%" PRId64, pNode->vgId, pDestId->addr, terrstr(), index); - (void)syncLogReplMgrReset(pMgr); + (void)syncLogReplReset(pMgr); } } goto _err; } *pBarrier = syncLogIsReplicationBarrier(pEntry); - prevLogTerm = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index); + prevLogTerm = syncLogReplGetPrevLogTerm(pMgr, pNode, index); if (prevLogTerm < 0) { sError("vgId:%d, failed to get prev log term since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index); goto _err; diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 1d94b288d3a..43d2bc839be 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -52,7 +52,7 @@ int32_t syncNodeReplicateReset(SSyncNode* pNode, SRaftId* pDestId) { SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(pNode, pDestId); - syncLogReplMgrReset(pMgr); + syncLogReplReset(pMgr); taosThreadMutexUnlock(&pBuf->mutex); return 0; } @@ -74,7 +74,7 @@ int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { continue; } SSyncLogReplMgr* pMgr = pNode->logReplMgrs[i]; - (void)syncLogReplMgrReplicateOnce(pMgr, pNode); + (void)syncLogReplReplicateOnce(pMgr, pNode); } return 0; } diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 2fda2a19b8d..40b747b7117 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -89,6 +89,7 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { int32_t ret = 0; SyncRequestVote* pMsg = pRpcMsg->pCont; + bool resetElect = false; // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &pMsg->srcId)) { @@ -115,7 +116,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { syncNodeStepDown(ths, currentTerm); // forbid elect for this round - syncNodeResetElectTimer(ths); + resetElect = true; } // send msg @@ -134,5 +135,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, ""); syncLogSendRequestVoteReply(ths, pReply, ""); syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + + if (resetElect) syncNodeResetElectTimer(ths); return 0; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 413d6adf057..a9d0ddad17d 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -798,7 +798,6 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->term > raftStoreGetTerm(pSyncNode)) { syncNodeStepDown(pSyncNode, pMsg->term); } - syncNodeResetElectTimer(pSyncNode); // state, term, seq/ack int32_t code = 0; @@ -840,6 +839,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { code = -1; } + syncNodeResetElectTimer(pSyncNode); return code; } diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 859183db952..a27be2853e5 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -120,9 +120,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) { if (atomic_load_64(&ths->pingTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->pingTimerCounter); - // syncNodePingAll(ths); - // syncNodePingPeers(ths); - syncNodeTimerRoutine(ths); } @@ -138,8 +135,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) { ++(ths->heartbeatTimerCounter); sTrace("vgId:%d, sync timer, type:replicate count:%" PRIu64 ", lc-user:%" PRIu64, ths->vgId, ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); - - // syncNodeReplicate(ths, true); } } else { diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index a519c76cda5..056a5977770 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -125,7 +125,7 @@ static void syncLogBufferStates2Str(SSyncNode* pSyncNode, char* buf, int32_t buf pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); } -static void syncLogReplMgrStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { +static void syncLogReplStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { int len = 0; len += snprintf(buf + len, bufLen - len, "%s", "{"); for (int32_t i = 0; i < pSyncNode->replicaNum; i++) { @@ -178,7 +178,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); char replMgrStatesStr[1024] = ""; - syncLogReplMgrStates2Str(pNode, replMgrStatesStr, sizeof(replMgrStatesStr)); + syncLogReplStates2Str(pNode, replMgrStatesStr, sizeof(replMgrStatesStr)); char bufferStatesStr[256] = ""; syncLogBufferStates2Str(pNode, bufferStatesStr, sizeof(bufferStatesStr)); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 50ed9fa61b1..c23d6d0a1f4 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -462,6 +462,7 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) { if (transQueueEmpty(&pConn->cliMsgs)) { if (pConn->broken == true && CONN_NO_PERSIST_BY_APP(pConn)) { tTrace("%s conn %p handle except, persist:0", CONN_GET_INST_LABEL(pConn), pConn); + if (T_REF_VAL_GET(pConn) > 1) transUnrefCliHandle(pConn); transUnrefCliHandle(pConn); return; } @@ -521,6 +522,7 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) { destroyCmsg(pMsg); tTrace("%s conn %p start to destroy, ref:%d", CONN_GET_INST_LABEL(pConn), pConn, T_REF_VAL_GET(pConn)); } while (!transQueueEmpty(&pConn->cliMsgs)); + if (T_REF_VAL_GET(pConn) > 1) transUnrefCliHandle(pConn); transUnrefCliHandle(pConn); } void cliHandleExcept(SCliConn* conn) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 3e1e36ccc1e..ad6127ead23 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -33,7 +33,6 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) { pReader->pLogFile = NULL; pReader->curVersion = -1; pReader->curFileFirstVer = -1; - pReader->curInvalid = 1; pReader->capacity = 0; if (cond) { pReader->cond = *cond; @@ -81,7 +80,6 @@ int32_t walNextValidMsg(SWalReader *pReader) { wDebug("vgId:%d, wal start to fetch, index:%" PRId64 ", last index:%" PRId64 " commit index:%" PRId64 ", applied index:%" PRId64 ", end index:%" PRId64, pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer, endVer); - pReader->curStopped = 0; while (fetchVer <= endVer) { if (walFetchHeadNew(pReader, fetchVer) < 0) { return -1; @@ -99,7 +97,6 @@ int32_t walNextValidMsg(SWalReader *pReader) { fetchVer = pReader->curVersion; } } - pReader->curStopped = 1; return -1; } @@ -196,17 +193,16 @@ int32_t walReadSeekVerImpl(SWalReader *pReader, int64_t ver) { return -1; } - wDebug("vgId:%d, wal version reset from %" PRId64 "(invalid:%d) to %" PRId64, pReader->pWal->cfg.vgId, - pReader->curVersion, pReader->curInvalid, ver); + wDebug("vgId:%d, wal version reset from %" PRId64 " to %" PRId64, pReader->pWal->cfg.vgId, + pReader->curVersion, ver); pReader->curVersion = ver; - pReader->curInvalid = 0; return 0; } int32_t walReadSeekVer(SWalReader *pReader, int64_t ver) { SWal *pWal = pReader->pWal; - if (!pReader->curInvalid && ver == pReader->curVersion) { + if (ver == pReader->curVersion) { wDebug("vgId:%d, wal index:%" PRId64 " match, no need to reset", pReader->pWal->cfg.vgId, ver); return 0; } @@ -238,7 +234,7 @@ static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer) { wDebug("vgId:%d, wal starts to fetch head, index:%" PRId64, pRead->pWal->cfg.vgId, fetchVer); - if (pRead->curInvalid || pRead->curVersion != fetchVer) { + if (pRead->curVersion != fetchVer) { if (walReadSeekVer(pRead, fetchVer) < 0) { // pRead->curVersion = fetchVer; // pRead->curInvalid = 1; @@ -344,7 +340,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) { return -1; } - if (pRead->curInvalid || pRead->curVersion != ver) { + if (pRead->curVersion != ver) { code = walReadSeekVer(pRead, ver); if (code < 0) { // pRead->curVersion = ver; @@ -479,7 +475,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { taosThreadMutexLock(&pReader->mutex); - if (pReader->curInvalid || pReader->curVersion != ver) { + if (pReader->curVersion != ver) { if (walReadSeekVer(pReader, ver) < 0) { wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since %s", pReader->pWal->cfg.vgId, ver, terrstr()); taosThreadMutexUnlock(&pReader->mutex); @@ -575,7 +571,6 @@ void walReadReset(SWalReader *pReader) { taosThreadMutexLock(&pReader->mutex); taosCloseFile(&pReader->pIdxFile); taosCloseFile(&pReader->pLogFile); - pReader->curInvalid = 1; pReader->curFileFirstVer = -1; pReader->curVersion = -1; taosThreadMutexUnlock(&pReader->mutex); diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 52309a7b35c..84004ed3c18 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -17,6 +17,10 @@ #include "os.h" #include "taoserror.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #define PROCESS_ITEM 12 #define UUIDLEN37 37 @@ -252,7 +256,11 @@ int32_t taosGetEmail(char *email, int32_t maxLen) { #ifdef WINDOWS // ASSERT(0); #elif defined(_TD_DARWIN_64) +#ifdef CUS_PROMPT + const char *filepath = "/usr/local/"CUS_PROMPT"/email"; +#else const char *filepath = "/usr/local/taos/email"; +#endif // CUS_PROMPT TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); if (pFile == NULL) return false; @@ -264,8 +272,12 @@ int32_t taosGetEmail(char *email, int32_t maxLen) { taosCloseFile(&pFile); return 0; +#else +#ifdef CUS_PROMPT + const char *filepath = "/usr/local/"CUS_PROMPT"/email"; #else const char *filepath = "/usr/local/taos/email"; +#endif // CUS_PROMPT TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); if (pFile == NULL) return false; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index c7ef5d82913..bab80a8e74c 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -629,6 +629,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_INVALID_FILE, "Index file is inval TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_MSG, "Invalid message") TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_MISMATCH, "Consumer mismatch") TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_CLOSED, "Consumer closed") +TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_ERROR, "Consumer error, to see log") // stream TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_TASK_NOT_EXIST, "Stream task not exist") diff --git a/source/util/src/tsimplehash.c b/source/util/src/tsimplehash.c index 70acffed5d6..ec1991923fa 100644 --- a/source/util/src/tsimplehash.c +++ b/source/util/src/tsimplehash.c @@ -28,19 +28,23 @@ #define HASH_INDEX(v, c) ((v) & ((c)-1)) -#define FREE_HASH_NODE(_n) \ - do { \ - taosMemoryFreeClear(_n); \ +#define FREE_HASH_NODE(_n, fp) \ + do { \ + if (fp) { \ + fp((_n)->data); \ + } \ + taosMemoryFreeClear(_n); \ } while (0); struct SSHashObj { - SHNode **hashList; - size_t capacity; // number of slots - int64_t size; // number of elements in hash table - _hash_fn_t hashFp; // hash function - _equal_fn_t equalFp; // equal function - SArray* pHashNodeBuf;// hash node allocation buffer, 1k size of each page by default - int32_t offset; // allocation offset in current page + SHNode **hashList; + size_t capacity; // number of slots + int64_t size; // number of elements in hash table + _hash_fn_t hashFp; // hash function + _equal_fn_t equalFp; // equal function + _hash_free_fn_t freeFp; // free function + SArray *pHashNodeBuf; // hash node allocation buffer, 1k size of each page by default + int32_t offset; // allocation offset in current page }; static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { @@ -71,7 +75,7 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) { pHashObj->capacity = taosHashCapacity((int32_t)capacity); pHashObj->equalFp = memcmp; - pHashObj->pHashNodeBuf = taosArrayInit(10, sizeof(void*)); + pHashObj->freeFp = NULL; pHashObj->offset = 0; pHashObj->size = 0; @@ -92,6 +96,10 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) { return (int32_t) pHashObj->size; } +void tSimpleHashSetFreeFp(SSHashObj* pHashObj, _hash_free_fn_t freeFp) { + pHashObj->freeFp = freeFp; +} + static void* doInternalAlloc(SSHashObj* pHashObj, int32_t size) { #if 0 void** p = taosArrayGetLast(pHashObj->pHashNodeBuf); @@ -306,7 +314,8 @@ int32_t tSimpleHashRemove(SSHashObj *pHashObj, const void *key, size_t keyLen) { } else { pPrev->next = pNode->next; } - FREE_HASH_NODE(pNode); + + FREE_HASH_NODE(pNode, pHashObj->freeFp); pHashObj->size -= 1; code = TSDB_CODE_SUCCESS; break; @@ -341,7 +350,7 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke *pIter = pPrev ? GET_SHASH_NODE_DATA(pPrev) : NULL; } - FREE_HASH_NODE(pNode); + FREE_HASH_NODE(pNode, pHashObj->freeFp); pHashObj->size -= 1; break; } @@ -370,14 +379,13 @@ void tSimpleHashClear(SSHashObj *pHashObj) { while (pNode) { pNext = pNode->next; - FREE_HASH_NODE(pNode); + FREE_HASH_NODE(pNode, pHashObj->freeFp); pNode = pNext; } pHashObj->hashList[i] = NULL; } - taosArrayClearEx(pHashObj->pHashNodeBuf, destroyItems); pHashObj->offset = 0; pHashObj->size = 0; } @@ -388,7 +396,6 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) { } tSimpleHashClear(pHashObj); - taosArrayDestroy(pHashObj->pHashNodeBuf); taosMemoryFreeClear(pHashObj->hashList); taosMemoryFree(pHashObj); } diff --git a/source/util/src/tversion.c b/source/util/src/tversion.c index dc357c61a10..0f84f6bafa9 100644 --- a/source/util/src/tversion.c +++ b/source/util/src/tversion.c @@ -26,8 +26,9 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) { int32_t vnum[4] = {0}; int32_t len = strlen(vstr); char tmp[16] = {0}; + int32_t vpos = 0; - for (int32_t spos = 0, tpos = 0, vpos = 0; spos < len && vpos < 4; ++spos) { + for (int32_t spos = 0, tpos = 0; spos < len && vpos < 4; ++spos) { if (vstr[spos] != '.') { tmp[spos - tpos] = vstr[spos]; } else { @@ -38,6 +39,10 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) { } } + if ('\0' != tmp[0] && vpos < 4) { + vnum[vpos] = atoi(tmp); + } + if (vnum[0] <= 0) { terrno = TSDB_CODE_INVALID_VERSION_STRING; return -1; @@ -66,16 +71,16 @@ int32_t taosCheckVersionCompatible(int32_t clientVer, int32_t serverVer, int32_t case 4: break; case 3: - clientVer %= 100; - serverVer %= 100; + clientVer /= 100; + serverVer /= 100; break; case 2: - clientVer %= 10000; - serverVer %= 10000; + clientVer /= 10000; + serverVer /= 10000; break; case 1: - clientVer %= 1000000; - serverVer %= 1000000; + clientVer /= 1000000; + serverVer /= 1000000; break; default: terrno = TSDB_CODE_INVALID_VERSION_NUMBER; diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py index 7599c824835..f5aa181aed0 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py @@ -61,9 +61,9 @@ def run(self): os.system("%s" % cmd) tdSql.execute("reset query cache") tdSql.query("show db.tables") - tdSql.checkRows(10) + tdSql.checkRows(8) tdSql.query("select count(*) from db.stb") - tdSql.checkData(0, 0, 100) + tdSql.checkData(0, 0, 80) def stop(self): tdSql.close() diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json index da22ef75e2a..c841e90b516 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json @@ -15,13 +15,18 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db" + "name": "db", + "drop": "yes" + }, "super_tables": [{ + "child_table_exists":"no", "name": "stb", "childtable_prefix": "stb_", "childtable_count": 10, "insert_rows": 10, + "childtable_from": 1, + "childtable_to": 9, "columns": [{"type": "INT"}], "tags": [{"type": "INT"}] }] diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json index 9e1241397fe..e609fcfebdf 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json @@ -16,7 +16,7 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db", + "name": "opentsdb_telnet", "drop": "yes" }, "super_tables": [{ diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c2f8e75e79d..d1fbacdadf0 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -10,18 +10,21 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py @@ -43,6 +46,11 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 @@ -86,7 +94,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStbCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot0.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf.py +#,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot0.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py @@ -865,6 +873,8 @@ ,,y,script,./test.sh -f tsim/query/session.sim ,,y,script,./test.sh -f tsim/query/udf.sim ,,y,script,./test.sh -f tsim/query/udf_with_const.sim +,,y,script,./test.sh -f tsim/query/join_interval.sim +,,y,script,./test.sh -f tsim/query/unionall_as_table.sim ,,y,script,./test.sh -f tsim/query/sys_tbname.sim ,,y,script,./test.sh -f tsim/query/groupby.sim ,,y,script,./test.sh -f tsim/query/event.sim @@ -1103,9 +1113,9 @@ ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py -#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py +,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R -#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R +,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R #docs-examples test ,,n,docs-examples-test,bash python.sh diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 0903095dc98..99507ef5c3a 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -122,9 +122,11 @@ int insertAUTOTest2(TAOS_STMT *stmt, TAOS *taos); int insertAUTOTest3(TAOS_STMT *stmt, TAOS *taos); int queryColumnTest(TAOS_STMT *stmt, TAOS *taos); int queryMiscTest(TAOS_STMT *stmt, TAOS *taos); +int insertNonExistsTb(TAOS_STMT *stmt, TAOS *taos); enum { TTYPE_INSERT = 1, + TTYPE_INSERT_NG, TTYPE_QUERY, }; @@ -187,6 +189,8 @@ CaseCfg gCase[] = { {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 10, 10, 1, 3, 0, 0, 1, 2}, {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 10, 10, 1, 3, 0, 0, 1, 2}, + {"query:NG-TBNEXISTS",tListLen(fullColList), fullColList, TTYPE_INSERT_NG,0, false, false, insertNonExistsTb, 10, 10, 1, 3, 0, 0, 1, -1}, + // {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 1, 10, 1, 1, 0, 0, 1, 2}, // {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 2, 10, 1, 1, 0, 0, 1, 2}, @@ -250,7 +254,7 @@ CaseCtrl gCaseCtrl = { .funcIdxList = NULL, .checkParamNum = false, .runTimes = 0, - .caseIdx = 24, + .caseIdx = 26, .caseNum = 1, .caseRunIdx = -1, .caseRunNum = -1, @@ -2191,6 +2195,47 @@ int queryMiscTest(TAOS_STMT *stmt, TAOS *taos) { } +int insertNonExistsTb(TAOS_STMT *stmt, TAOS *taos) { + BindData data = {0}; + prepareInsertData(&data); + + int code = taos_stmt_prepare(stmt, data.sql, 0); + if (code != 0){ + printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + bpCheckIsInsert(stmt, 1); + + char *buf = "tbnexist"; + code = bpSetTableNameTags(&data, 0, buf, stmt); + if (code == 0){ + printf("!!!taos_stmt_set_tbname expected error not occurred\n"); + exit(1); + } + + if (0 == taos_stmt_bind_param_batch(stmt, data.pBind)) { + printf("!!!taos_stmt_bind_param_batch expected error not occurred\n"); + exit(1); + } + + if (0 == taos_stmt_add_batch(stmt)) { + printf("!!!taos_stmt_add_batch expected error not occurred\n"); + exit(1); + } + + if (0 == taos_stmt_execute(stmt)) { + printf("!!!taos_stmt_execute expected error not occurred\n"); + exit(1); + } + + destroyData(&data); + + return 0; +} + + + int errorSQLTest1(TAOS_STMT *stmt, TAOS *taos) { BindData data = {0}; @@ -2213,6 +2258,10 @@ int errorSQLTest1(TAOS_STMT *stmt, TAOS *taos) { } void prepareCheckResultImpl(TAOS * taos, char *tname, bool printr, int expected, bool silent) { + if (TTYPE_INSERT_NG == gCurCase->testType) { + return; + } + char sql[255] = "SELECT * FROM "; int32_t rows = 0; diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index f4d95df083c..0d796af0a0e 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -212,10 +212,10 @@ print ===> rows2: $data20 $data21 $data22 $data23 $data24 if $rows != 3 then return -1 endi -if $data01 != 2 then +if $data01 != 4 then return -1 endi -if $data04 != 2 then +if $data04 != 4 then return -1 endi diff --git a/tests/script/tsim/query/join_interval.sim b/tests/script/tsim/query/join_interval.sim new file mode 100644 index 00000000000..14994a5cc1b --- /dev/null +++ b/tests/script/tsim/query/join_interval.sim @@ -0,0 +1,42 @@ + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c udf -v 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step create databases +sql create database d1 +sql create database d2 +sql create table d1.t1(ts timestamp, i int) tags(t int); +sql create table d2.t1(ts timestamp, i int); +sql insert into d1.t11 using d1.t1 tags(1) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) +sql insert into d1.t12 using d1.t1 tags(2) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) +sql insert into d1.t13 using d1.t1 tags(3) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) + +sql insert into d2.t1 values(1500000000000,0)(1500000000001,1)(1500000000002,2) + +sql select _wstart,_wend,count((a.ts)),count(b.ts) from d1.t1 a, d2.t1 b where a.ts is not null and a.ts = b.ts interval(1a) ; +if $data02 != 3 then + return -1 +endi + +if $data03 != 3 then + return -1 +endi + +if $data12 != 3 then + return -1 +endi + +if $data13 != 3 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +if $data23 != 3 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/unionall_as_table.sim b/tests/script/tsim/query/unionall_as_table.sim new file mode 100644 index 00000000000..dc3d2cbec4e --- /dev/null +++ b/tests/script/tsim/query/unionall_as_table.sim @@ -0,0 +1,28 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database test; +sql use test; +sql CREATE STABLE bw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql CREATE STABLE aw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql CREATE STABLE dw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql insert into t1 using dw_yc_h_substation_mea tags('1234567890','testa','0021001','abc01') values(now,'2023-03-27','00:01:00',now,2.3,3.3,4.4,5.5); +sql insert into t2 using dw_yc_h_substation_mea tags('2234567890','testb','0022001','abc02') values(now,'2023-03-27','00:01:00',now,2.3,2.3,2.4,2.5); +sql insert into t3 using aw_yc_h_substation_mea tags('2234567890','testc','0023001','abc03') values(now,'2023-03-27','00:15:00',now,2.3,2.3,2.4,2.5); +sql insert into t4 using bw_yc_h_substation_mea tags('4234567890','testd','0021001','abc03') values(now,'2023-03-27','00:45:00',now,2.3,2.3,2.4,2.5); +sql insert into t5 using bw_yc_h_substation_mea tags('5234567890','testd','0021001','abc03') values(now,'2023-03-27','00:00:00',now,2.3,2.3,2.4,2.5); +sql select t.ts,t.id,t.name,t.create_date,t.create_time,t.datasource,t.sum_p_value from (select ts,id,name,create_date,create_time,datasource,sum_p_value from bw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45') union all select ts,id,name,create_date,create_time,datasource,sum_p_value from aw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45') union all select ts,id,name,create_date,create_time,datasource,sum_p_value from dw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45')) t where t.datasource='0021001' and t.id='4234567890' order by t.create_time; + +if $rows != 1 then + return -1 +endi +if $data01 != @4234567890@ then + return -1 +endi +if $data05 != @0021001@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index de1c72f8dce..1559d3d32b5 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -284,7 +284,7 @@ sql create table ccc using st tags(3,2,2); sql create table ddd using st tags(4,2,2); -sql create stream streams1 ignore expired 0 fill_history 0 watermark 3s into streamst subtable(c) as select _wstart, c , count(*) c1 from st partition by c interval(1s) ; +sql create stream streams1 ignore expired 0 fill_history 0 watermark 3s into streamst subtable(c) as select _wstart, c , count(*) c1, last_row(b) c2 from st partition by c interval(1s) ; sql insert into aaa values(1648791221001,2,2,"/a1/aa/aa"); sql insert into bbb values(1648791221001,2,2,"/a1/aa/aa"); diff --git a/tests/script/tsim/stream/distributeIntervalRetrive0.sim b/tests/script/tsim/stream/distributeIntervalRetrive0.sim index 529a2a1b309..a2d9c4ab458 100644 --- a/tests/script/tsim/stream/distributeIntervalRetrive0.sim +++ b/tests/script/tsim/stream/distributeIntervalRetrive0.sim @@ -3,7 +3,6 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/exec.sh -n dnode1 -s start -#==system sh/exec.sh -n dnode1 -s start -v sleep 50 sql connect @@ -11,7 +10,6 @@ sql connect sql create dnode $hostname2 port 7200 system sh/exec.sh -n dnode2 -s start -#==system sh/exec.sh -n dnode2 -s start -v print ===== step1 $x = 0 @@ -37,14 +35,14 @@ endi print ===== step2 -sql create database test vgroups 4; +sql create database test vgroups 10; sql use test; sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); -sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); +sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 delete_mark 10s into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sleep 1000 @@ -235,6 +233,29 @@ endi print loop3 over +sql insert into ts1 values(1648791200001,1,12,3,1.0); +sql insert into ts2 values(1648791200001,1,12,3,1.0); +sql insert into ts3 values(1648791200001,1,12,3,1.0); +sql insert into ts4 values(1648791200001,1,12,3,1.0); + +$loop_count = 0 +loop31: +sleep 1000 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamtST1; + +if $rows <= 4 then + print =====rows=$rows + goto loop31 +endi + +print loop31 over + sql drop stream if exists streams1; sql drop database if exists test1; @@ -243,7 +264,7 @@ sql use test1; sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); -sql create stream streams1 trigger at_once IGNORE EXPIRED 0 into streamt1 as select _wstart as c0, count(*) c1, count(a) c2 from st interval(10s) ; +sql create stream streams1 trigger at_once IGNORE EXPIRED 0 delete_mark 20s into streamt1 as select _wstart as c0, count(*) c1, count(a) c2 from st interval(10s) ; sql insert into t1 values(1648791211000,1,2,3); diff --git a/tests/script/tsim/stream/state1.sim b/tests/script/tsim/stream/state1.sim index 2ae5739642b..67e02c08908 100644 --- a/tests/script/tsim/stream/state1.sim +++ b/tests/script/tsim/stream/state1.sim @@ -4,6 +4,7 @@ system sh/exec.sh -n dnode1 -s start sleep 50 sql connect +print step 1 print =============== create database sql create database test vgroups 4; sql select * from information_schema.ins_databases; @@ -33,8 +34,8 @@ if $loop_count == 10 then endi sql select * from streamt1; -print data00 data01 -print data10 data11 +print $data00 $data01 +print $data10 $data11 if $rows != 0 then print =====rows=$rows @@ -52,8 +53,8 @@ if $loop_count == 10 then endi sql select * from streamt1; -print data00 data01 -print data10 data11 +print $data00 $data01 +print $data10 $data11 if $rows != 1 then print =====rows=$rows @@ -92,9 +93,64 @@ endi sql select * from streamt1; if $rows != 2 then print =====rows=$rows - goto loop2 + goto loop3 +endi + +print step 1 over +print step 2 + +sql create database test2 vgroups 1; +sql use test2; +sql create table t1(ts timestamp, a int, b int , c int, d double); +print create stream streams2 trigger at_once watermark 1000s into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a) +sql create stream streams2 trigger at_once watermark 1000s into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a); + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t1 values(1648791213010,1,2,3,1.1); + +$loop_count = 0 +loop4: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt2; +print $data00 $data01 +print $data10 $data11 + +if $rows != 1 then + print =====rows=$rows + goto loop4 +endi + +print insert into t1 values(1648791213005,2,2,3,1.1) +sql insert into t1 values(1648791213005,2,2,3,1.1); + +$loop_count = 0 +loop5: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +print select * from streamt2 +sql select * from streamt2; +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 +print $data30 $data31 + +if $rows != 3 then + print =====rows=$rows + goto loop5 endi +print step 2 over print state1 end diff --git a/tests/script/tsim/tmq/basic1.sim b/tests/script/tsim/tmq/basic1.sim index 6880f290f5f..80a05ba45ce 100644 --- a/tests/script/tsim/tmq/basic1.sim +++ b/tests/script/tsim/tmq/basic1.sim @@ -111,8 +111,8 @@ endi $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -134,7 +134,7 @@ if $data[0][2] != $expectmsgcnt then print expect $expectmsgcnt , actual $data02 return -1 endi -if $data[0][3] != $expectmsgcnt then +if $data[0][3] != $totalMsgOfStb then return -1 endi $loop_cnt = $loop_cnt + 1 @@ -183,8 +183,8 @@ endi $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -202,7 +202,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfCtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfCtb then @@ -254,8 +254,8 @@ endi $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -273,7 +273,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfNtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfNtb then diff --git a/tests/script/tsim/tmq/basic1Of2Cons.sim b/tests/script/tsim/tmq/basic1Of2Cons.sim index 11b645c4d1a..21883418048 100644 --- a/tests/script/tsim/tmq/basic1Of2Cons.sim +++ b/tests/script/tsim/tmq/basic1Of2Cons.sim @@ -111,11 +111,11 @@ endi $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -142,14 +142,14 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfStb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfStb -if $data[0][2] == $totalMsgOfStb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_0 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfStb then + if $data[1][2] == $expectmsgcnt then goto check_ok_0 endi endi @@ -214,10 +214,10 @@ endi $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -244,14 +244,14 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfCtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfCtb -if $data[0][2] == $totalMsgOfCtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_2 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfCtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_2 endi endi @@ -316,10 +316,10 @@ endi $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -346,14 +346,14 @@ if $data[1][1] == 0 then endi endi -# either $data[0][2] == $totalMsgOfNtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfNtb -if $data[0][2] == $totalMsgOfNtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_4 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfNtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_4 endi endi diff --git a/tests/script/tsim/tmq/basic2.sim b/tests/script/tsim/tmq/basic2.sim index dce73be592e..a9656456609 100644 --- a/tests/script/tsim/tmq/basic2.sim +++ b/tests/script/tsim/tmq/basic2.sim @@ -83,8 +83,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb $totalMsgOfStb = $totalMsgOfStb * $topicNum -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $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 @@ -105,7 +105,7 @@ endi if $data[0][2] != $expectmsgcnt then return -1 endi -if $data[0][3] != $expectmsgcnt then +if $data[0][3] != $totalMsgOfStb then return -1 endi @@ -140,8 +140,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -159,7 +159,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfCtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfCtb then @@ -197,8 +197,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -216,7 +216,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfNtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfNtb then diff --git a/tests/script/tsim/tmq/basic2Of2Cons.sim b/tests/script/tsim/tmq/basic2Of2Cons.sim index 87559305ba1..fd61c4b40f9 100644 --- a/tests/script/tsim/tmq/basic2Of2Cons.sim +++ b/tests/script/tsim/tmq/basic2Of2Cons.sim @@ -82,10 +82,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb $totalMsgOfStb = $totalMsgOfStb * $topicNum -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfStb , $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 @@ -112,14 +112,14 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfStb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfStb -if $data[0][2] == $totalMsgOfStb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_0 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfStb then + if $data[1][2] == $expectmsgcnt then goto check_ok_0 endi endi @@ -169,10 +169,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -199,14 +199,14 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfCtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfCtb -if $data[0][2] == $totalMsgOfCtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_2 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfCtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_2 endi endi @@ -256,10 +256,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -286,14 +286,14 @@ if $data[1][1] == 0 then endi endi -# either $data[0][2] == $totalMsgOfNtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfNtb -if $data[0][2] == $totalMsgOfNtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_4 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfNtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_4 endi endi diff --git a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim index dda5e0059e5..180c8947db3 100644 --- a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim +++ b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim @@ -80,8 +80,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfOneTopic = $ctbNum * $rowsPerCtb $totalMsgOfStb = $totalMsgOfOneTopic * $topicNum -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 3 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) $topicList = ' . topic_stb_all @@ -89,7 +89,7 @@ $topicList = $topicList . , $topicList = $topicList . topic_stb_function $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now +1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now +1s , $consumerId , $topicList , $keyList , $totalMsgOfStb , $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 @@ -118,40 +118,40 @@ endi # $data[0][2]/$data[1][2] should be between $totalMsgOfOneTopic and $totalMsgOfStb. -if $data[0][2] < $totalMsgOfOneTopic then - return -1 -endi -if $data[0][2] > $totalMsgOfStb then - return -1 -endi -if $data[1][2] < $totalMsgOfOneTopic then +#if $data[0][2] < $totalMsgOfOneTopic then +# return -1 +#endi +if $data[0][2] > $expectmsgcnt then return -1 endi -if $data[1][2] > $totalMsgOfStb then +#if $data[1][2] < $totalMsgOfOneTopic then +# return -1 +#endi +if $data[1][2] > $expectmsgcnt then return -1 endi -$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb +#$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb $sumOfMsgCnt = $data[0][2] + $data[1][2] -if $sumOfMsgCnt != $totalMsgCons then - print total: $totalMsgCons +if $sumOfMsgCnt != $expectmsgcnt then + print total: $expectmsgcnt print sum: $sumOfMsgCnt return -1 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 +#if $data[0][3] < $totalMsgOfStb then +# return -1 +#endi +#if $data[0][3] > $totalMsgOfStb then +# return -1 +#endi +#if $data[1][3] < $totalMsgOfStb then +# return -1 +#endi +#if $data[1][3] > $totalMsgOfStb then +# return -1 +#endi $totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb $sumOfRows = $data[0][3] + $data[1][3] @@ -189,15 +189,15 @@ $consumerId = 0 $totalMsgOfOneTopic = $rowsPerCtb $totalMsgOfCtb = $totalMsgOfOneTopic * $topicNum -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) $topicList = ' . topic_ctb_function $topicList = $topicList . , $topicList = $topicList . topic_ctb_all $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now +1s, $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now +1s, $consumerId , $topicList , $keyList , $totalMsgOfCtb , $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 @@ -226,24 +226,24 @@ endi # either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfCtb # or $data[0][2] $totalMsgOfCtb and $data[1][2] == $totalMsgOfOneTopic -if $data[0][2] == $totalMsgOfOneTopic then - if $data[1][2] == $totalMsgOfCtb then +if $data[0][2] == $topicNum then + if $data[1][2] == 1 then goto check_ok_0 endi -elif $data[1][2] == $totalMsgOfOneTopic then - if $data[0][2] == $totalMsgOfCtb then +elif $data[0][2] == 1 then + if $data[1][2] == $topicNum then goto check_ok_0 endi endi return -1 check_ok_0: -if $data[0][3] == $totalMsgOfOneTopic then - if $data[1][3] == $totalMsgOfCtb then +if $data[0][3] == $totalMsgOfCtb then + if $data[1][3] == $totalMsgOfOneTopic then goto check_ok_1 endi -elif $data[1][3] == $totalMsgOfOneTopic then - if $data[0][3] == $totalMsgOfCtb then +elif $data[0][3] == $totalMsgOfOneTopic then + if $data[1][3] == $totalMsgOfCtb then goto check_ok_1 endi endi @@ -280,8 +280,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfOneTopic = $rowsPerCtb $totalMsgOfNtb = $totalMsgOfOneTopic * $topicNum -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $ifcheckdata , $ifmanualcommit ) $topicList = ' . topic_ntb_function @@ -289,7 +289,7 @@ $topicList = $topicList . , $topicList = $topicList . topic_ntb_all $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -318,12 +318,12 @@ endi # either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfNtb # or $data[0][2] $totalMsgOfNtb and $data[1][2] == $totalMsgOfOneTopic -if $data[0][2] == $totalMsgOfOneTopic then - if $data[1][2] == $totalMsgOfNtb then +if $data[0][2] == $expectmsgcnt then + if $data[1][2] == 1 then goto check_ok_2 endi -elif $data[1][2] == $totalMsgOfOneTopic then - if $data[0][2] == $totalMsgOfNtb then +elif $data[0][2] == 1 then + if $data[1][2] == $expectmsgcnt then goto check_ok_2 endi endi @@ -334,8 +334,8 @@ 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 +elif $data[0][3] == $totalMsgOfNtb then + if $data[1][3] == $totalMsgOfOneTopic then goto check_ok_3 endi endi diff --git a/tests/script/tsim/tmq/basic3.sim b/tests/script/tsim/tmq/basic3.sim index 8d677766d74..63b3665cd04 100644 --- a/tests/script/tsim/tmq/basic3.sim +++ b/tests/script/tsim/tmq/basic3.sim @@ -111,8 +111,8 @@ endi $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -130,10 +130,10 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $expectmsgcnt then - return -1 -endi -if $data[0][3] != $expectmsgcnt then +#if $data[0][2] != $expectmsgcnt then +# return -1 +#endi +if $data[0][3] != $totalMsgOfStb then return -1 endi $loop_cnt = $loop_cnt + 1 @@ -182,8 +182,8 @@ endi $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -201,7 +201,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfCtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfCtb then @@ -253,8 +253,8 @@ endi $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -272,7 +272,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfNtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfNtb then diff --git a/tests/script/tsim/tmq/basic3Of2Cons.sim b/tests/script/tsim/tmq/basic3Of2Cons.sim index 4921c86c457..fb3091642c7 100644 --- a/tests/script/tsim/tmq/basic3Of2Cons.sim +++ b/tests/script/tsim/tmq/basic3Of2Cons.sim @@ -110,10 +110,10 @@ endi $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 3 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -163,19 +163,19 @@ endi if $data[0][3] <= 0 then return -1 endi -if $data[0][3] >= $expectmsgcnt then +if $data[0][3] >= $totalMsgOfStb then return -1 endi if $data[1][3] <= 0 then return -1 endi -if $data[1][3] >= $expectmsgcnt then +if $data[1][3] >= $totalMsgOfStb then return -1 endi $sumOfMsgRows = $data[0][3] + $data[1][3] -if $sumOfMsgRows != $expectmsgcnt then +if $sumOfMsgRows != $totalMsgOfStb then return -1 endi @@ -225,10 +225,10 @@ endi $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -255,13 +255,13 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfCtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfCtb -if $data[0][2] == $totalMsgOfCtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_0 endi -elif $data[1][2] == $totalMsgOfCtb then +elif $data[1][2] == $expectmsgcnt then if $data[0][2] == 0 then goto check_ok_0 endi @@ -327,10 +327,10 @@ endi $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 1 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -357,13 +357,13 @@ if $data[1][1] == 0 then endi endi -# either $data[0][2] == $totalMsgOfNtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfNtb -if $data[0][2] == $totalMsgOfNtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_2 endi -elif $data[1][2] == $totalMsgOfNtb then +elif $data[1][2] == $expectmsgcnt then if $data[0][2] == 0 then goto check_ok_2 endi diff --git a/tests/script/tsim/tmq/basic4.sim b/tests/script/tsim/tmq/basic4.sim index 9b418f12f2b..2cac9beea6b 100644 --- a/tests/script/tsim/tmq/basic4.sim +++ b/tests/script/tsim/tmq/basic4.sim @@ -80,8 +80,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb $totalMsgOfStb = $totalMsgOfStb * $topicNum -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 9 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $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 @@ -102,7 +102,7 @@ endi if $data[0][2] != $expectmsgcnt then return -1 endi -if $data[0][3] != $expectmsgcnt then +if $data[0][3] != $totalMsgOfStb then return -1 endi @@ -137,8 +137,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -156,7 +156,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfCtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfCtb then @@ -194,8 +194,8 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -213,7 +213,7 @@ endi if $data[0][1] != $consumerId then return -1 endi -if $data[0][2] != $totalMsgOfNtb then +if $data[0][2] != $expectmsgcnt then return -1 endi if $data[0][3] != $totalMsgOfNtb then diff --git a/tests/script/tsim/tmq/basic4Of2Cons.sim b/tests/script/tsim/tmq/basic4Of2Cons.sim index f1755f732ba..1d0b8f17a3b 100644 --- a/tests/script/tsim/tmq/basic4Of2Cons.sim +++ b/tests/script/tsim/tmq/basic4Of2Cons.sim @@ -79,10 +79,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfStb = $ctbNum * $rowsPerCtb $totalMsgOfStb = $totalMsgOfStb * $topicNum -$expectmsgcnt = $totalMsgOfStb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = 9 +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfStb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfStb , $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 @@ -131,19 +131,19 @@ endi if $data[0][3] <= 0 then return -1 endi -if $data[0][3] >= $expectmsgcnt then +if $data[0][3] >= $totalMsgOfStb then return -1 endi if $data[1][3] <= 0 then return -1 endi -if $data[1][3] >= $expectmsgcnt then +if $data[1][3] >= $totalMsgOfStb then return -1 endi $sumOfConsRow = $data[0][3] + $data[1][3] -if $sumOfConsRow != $expectmsgcnt then +if $sumOfConsRow != $totalMsgOfStb then return -1 endi @@ -178,10 +178,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfCtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfCtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfCtb , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -208,14 +208,14 @@ if $data[0][1] == 1 then endi endi -# either $data[0][2] == $totalMsgOfCtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfCtb -if $data[0][2] == $totalMsgOfCtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_0 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfCtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_0 endi endi @@ -266,10 +266,10 @@ $topicList = $topicList . ' $consumerId = 0 $totalMsgOfNtb = $rowsPerCtb * $topicNum -$expectmsgcnt = $totalMsgOfNtb -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +$expectmsgcnt = $topicNum +sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $totalMsgOfNtb , $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 @@ -296,14 +296,14 @@ if $data[1][1] == 0 then endi endi -# either $data[0][2] == $totalMsgOfNtb and $data[1][2] == 0 -# or $data[0][2] == 0 and $data[1][2] == $totalMsgOfNtb -if $data[0][2] == $totalMsgOfNtb then +# either $data[0][2] == $expectmsgcnt and $data[1][2] == 0 +# or $data[0][2] == 0 and $data[1][2] == $expectmsgcnt +if $data[0][2] == $expectmsgcnt then if $data[1][2] == 0 then goto check_ok_2 endi elif $data[0][2] == 0 then - if $data[1][2] == $totalMsgOfNtb then + if $data[1][2] == $expectmsgcnt then goto check_ok_2 endi endi diff --git a/tests/system-test/0-others/taosdMonitor.py b/tests/system-test/0-others/taosdMonitor.py index 944ff52d5ba..195f1ba5bcc 100644 --- a/tests/system-test/0-others/taosdMonitor.py +++ b/tests/system-test/0-others/taosdMonitor.py @@ -292,7 +292,7 @@ def init(self, conn, logSql, replicaVar=1): def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) - vgroups = "30" + vgroups = "8" sql = "create database db3 vgroups " + vgroups tdSql.query(sql) sql = "create table db3.stb (ts timestamp, f int) tags (t int)" diff --git a/tests/system-test/0-others/telemetry.py b/tests/system-test/0-others/telemetry.py index bc5d276faa9..c62e3c2487e 100644 --- a/tests/system-test/0-others/telemetry.py +++ b/tests/system-test/0-others/telemetry.py @@ -181,7 +181,7 @@ def init(self, conn, logSql, replicaVar=1): def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) - vgroups = "30" + vgroups = "8" sql = "create database db3 vgroups " + vgroups tdSql.query(sql) diff --git a/tests/system-test/0-others/tmqBasic.json b/tests/system-test/0-others/tmqBasic.json index 24e815708ae..d716bff3ac2 100644 --- a/tests/system-test/0-others/tmqBasic.json +++ b/tests/system-test/0-others/tmqBasic.json @@ -14,7 +14,6 @@ "auto.offset.reset": "earliest", "enable.auto.commit": "true", "auto.commit.interval.ms": 1000, - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "false", "topic_list": [ diff --git a/tests/system-test/2-query/columnLenUpdated.py b/tests/system-test/2-query/columnLenUpdated.py new file mode 100644 index 00000000000..e43b32a7160 --- /dev/null +++ b/tests/system-test/2-query/columnLenUpdated.py @@ -0,0 +1,215 @@ + +import taos +import sys +import time +import socket +import os +import platform +if platform.system().lower() == 'windows': + import wexpect as taosExpect +else: + import pexpect as taosExpect + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +def taos_command (buildPath, key, value, expectString, sqlString=''): + if len(key) == 0: + tdLog.exit("taos test key is null!") + + if platform.system().lower() == 'windows': + taosCmd = buildPath + '\\build\\bin\\taos.exe ' + taosCmd = taosCmd.replace('\\','\\\\') + else: + taosCmd = buildPath + '/build/bin/taos ' + + cfgPath = buildPath + "/../sim/psim/cfg" + taosCmd = taosCmd + ' -c' + cfgPath + ' -' + key + if len(value) != 0: + taosCmd = taosCmd + ' ' + value + + tdLog.info ("taos cmd: %s" % taosCmd) + + child = taosExpect.spawn(taosCmd, timeout=20) + #output = child.readline() + #print (output.decode()) + if len(expectString) != 0: + i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) + else: + i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) + + if platform.system().lower() == 'windows': + retResult = child.before + else: + retResult = child.before.decode() + print(retResult) + #print(child.after.decode()) + if i == 0: + print ('taos login success! Here can run sql, taos> ') + return "TAOS_OK" + else: + return "TAOS_FAIL" + +class TDTestCase: + #updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\ + # 'serverPort': 7080, 'firstEp': 'trd02:7080'} + hostname = socket.gethostname() + if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""): + try: + config = eval(tdDnodes.dnodes[0].remoteIP) + hostname = config["host"] + except Exception: + hostname = tdDnodes.dnodes[0].remoteIP + serverPort = '7080' + rpcDebugFlagVal = '143' + clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + clientCfgDict["serverPort"] = serverPort + clientCfgDict["firstEp"] = hostname + ':' + serverPort + clientCfgDict["secondEp"] = hostname + ':' + serverPort + clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal + clientCfgDict["fqdn"] = hostname + + updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + updatecfgDict["clientCfg"] = clientCfgDict + updatecfgDict["serverPort"] = serverPort + updatecfgDict["firstEp"] = hostname + ':' + serverPort + updatecfgDict["secondEp"] = hostname + ':' + serverPort + updatecfgDict["fqdn"] = hostname + + print ("===================: ", updatecfgDict) + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + tdSql.prepare() + # time.sleep(2) + tdSql.query("create user testpy pass 'testpy'") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + tdLog.info("cfgPath: %s" % cfgPath) + + checkNetworkStatus = ['0: unavailable', '1: network ok', '2: service ok', '3: service degraded', '4: exiting'] + netrole = ['client', 'server'] + + keyDict = {'h':'', 'P':'6030', 'p':'testpy', 'u':'testpy', 'a':'', 'A':'', 'c':'', 'C':'', 's':'', 'r':'', 'f':'', \ + 'k':'', 't':'', 'n':'', 'l':'1024', 'N':'100', 'V':'', 'd':'db', 'w':'30', '-help':'', '-usage':'', '?':''} + + keyDict['h'] = self.hostname + keyDict['c'] = cfgPath + keyDict['P'] = self.serverPort + + tdSql.query("drop database if exists db1") + tdSql.query("create database if not exists db1 vgroups 1") + tdSql.query("use db1") + tdSql.query("create table tba (ts timestamp, f1 binary(2))") + tdSql.query("insert into tba values (now, '22')") + tdSql.query("select * from tba") + tdSql.checkData(0, 1, '22') + + keyDict['s'] = "\"alter table db1.tba modify column f1 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tba values (now, '55555')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select * from tba order by ts") + tdSql.checkData(0, 1, '22') + tdSql.checkData(1, 1, '55555') + + + + keyDict['s'] = "\"alter table db1.tba add column f2 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select * from tba order by ts") + tdSql.query("select * from tba order by ts") + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 2, None) + + + + + keyDict['s'] = "\"alter table db1.tba add column f3 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select f3 from tba order by ts") + tdSql.checkData(0, 0, None) + tdSql.checkData(1, 0, None) + + + tdSql.query("create table stb (ts timestamp, f1 int, f2 binary(2)) tags (tg1 binary(2))") + tdSql.query("create table tb1 using stb tags('bb')") + tdSql.query("insert into tb1 values (now, 2,'22')") + tdSql.query("select count(*) from stb group by tg1") + tdSql.checkData(0, 0, 1) + + keyDict['s'] = "\"alter table db1.stb modify tag tg1 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"create table db1.tb2 using db1.stb tags('bbbbb')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tb2 values (now, 2,'22')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"alter table db1.stb modify column f2 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tb2 values (now, 3,'55555')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select count(*) from stb group by tg1") + tdSql.checkData(0, 0, 2) + tdSql.checkData(1, 0, 1) + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index d7344c631f5..71dab8fe707 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -2040,6 +2040,8 @@ def run(self): #tdSql.query(f"select _irowts,interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1h) fill(prev)") #tdSql.query(f"select tbname,_irowts,interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1h) fill(prev)") + tdLog.printNoPrefix("======step 14: test interp pseudo columns") + tdSql.error(f"select _irowts, c6 from {dbname}.{tbname}") def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/nestedQuery.py b/tests/system-test/2-query/nestedQuery.py index 6557aad05f7..1b843defcef 100755 --- a/tests/system-test/2-query/nestedQuery.py +++ b/tests/system-test/2-query/nestedQuery.py @@ -6144,7 +6144,7 @@ def run(self): startTime = time.time() - self.function_before_26() + #self.function_before_26() self.math_nest(['UNIQUE']) self.math_nest(['MODE']) @@ -6157,9 +6157,9 @@ def run(self): # self.math_nest(['MAVG']) # self.math_nest(['HYPERLOGLOG']) # self.math_nest(['TAIL']) - # self.math_nest(['CSUM']) - # self.math_nest(['statecount','stateduration']) - # self.math_nest(['HISTOGRAM']) + self.math_nest(['CSUM']) + self.math_nest(['statecount','stateduration']) + self.math_nest(['HISTOGRAM']) # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) # self.str_nest(['LENGTH','CHAR_LENGTH']) diff --git a/tests/system-test/2-query/nestedQuery_26.py b/tests/system-test/2-query/nestedQuery_26.py new file mode 100755 index 00000000000..9d5f31d1e06 --- /dev/null +++ b/tests/system-test/2-query/nestedQuery_26.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.cases import tdCases +from .nestedQuery import * + +class TDTestCase(TDTestCase): + + + def run(self): + tdSql.prepare() + + startTime = time.time() + + self.function_before_26() + + # self.math_nest(['UNIQUE']) + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + # self.str_nest(['LENGTH','CHAR_LENGTH']) + # self.str_nest(['SUBSTR']) + # self.str_nest(['CONCAT']) + # self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + # self.time_nest(['NOW','TODAY']) + # self.time_nest(['TIMEZONE']) + # self.time_nest(['TIMETRUNCATE']) + # self.time_nest(['TO_ISO8601']) + # self.time_nest(['TO_UNIXTIMESTAMP']) + # self.time_nest(['ELAPSED']) + #self.time_nest(['TIMEDIFF_1']) + #self.time_nest(['TIMEDIFF_2']) + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/nestedQuery_math.py b/tests/system-test/2-query/nestedQuery_math.py index 2d0bbcb352a..3e37a2c15e6 100755 --- a/tests/system-test/2-query/nestedQuery_math.py +++ b/tests/system-test/2-query/nestedQuery_math.py @@ -34,9 +34,9 @@ def run(self): self.math_nest(['MAVG']) self.math_nest(['HYPERLOGLOG']) self.math_nest(['TAIL']) - self.math_nest(['CSUM']) - self.math_nest(['statecount','stateduration']) - self.math_nest(['HISTOGRAM']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) # self.str_nest(['LENGTH','CHAR_LENGTH']) diff --git a/tests/system-test/2-query/out_of_order.py b/tests/system-test/2-query/out_of_order.py index 148b89fc58b..ff2b71193b6 100644 --- a/tests/system-test/2-query/out_of_order.py +++ b/tests/system-test/2-query/out_of_order.py @@ -162,19 +162,18 @@ def check_sub(self,dbname): sql = "select count(*) from (select distinct(tbname) from %s.meters)" %dbname tdSql.query(sql) - num = tdSql.getData(0,0) + # 目前不需要了 + # num = tdSql.getData(0,0) - for i in range(0,num): - sql1 = "select count(*) from %s.d%d" %(dbname,i) - tdSql.query(sql1) - sql1_result = tdSql.getData(0,0) - tdLog.info("sql:%s , result: %s" %(sql1,sql1_result)) + # for i in range(0,num): + # sql1 = "select count(*) from %s.d%d" %(dbname,i) + # tdSql.query(sql1) + # sql1_result = tdSql.getData(0,0) + # tdLog.info("sql:%s , result: %s" %(sql1,sql1_result)) + def check_out_of_order(self,dbname,tables,per_table_num,order,replica): self.run_benchmark(dbname,tables,per_table_num,order,replica) - print("sleep 10 seconds") - #time.sleep(10) - print("sleep 10 seconds finish") self.run_sql(dbname) @@ -182,7 +181,7 @@ def run(self): startTime = time.time() #self.check_out_of_order('db1',10,random.randint(10000,50000),random.randint(1,10),1) - self.check_out_of_order('db1',random.randint(50,200),random.randint(10000,20000),random.randint(1,5),1) + self.check_out_of_order('db1',random.randint(50,100),random.randint(10000,20000),random.randint(1,5),1) # self.check_out_of_order('db2',random.randint(50,200),random.randint(10000,50000),random.randint(5,50),1) diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index 0fa9bcfbd46..41db943f835 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -13,11 +13,11 @@ class TDTestCase: hostname = socket.gethostname() - #rpcDebugFlagVal = '143' + # rpcDebugFlagVal = '143' #clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} #clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal #updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} - #updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal + # updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal #print ("===================: ", updatecfgDict) def init(self, conn, logSql, replicaVar=1): diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 3ff0b25ff6b..b9a6e7667de 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -226,7 +226,7 @@ def tmqCase1(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -307,7 +307,7 @@ def tmqCase2(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) diff --git a/tests/system-test/7-tmq/subscribeStb0.py b/tests/system-test/7-tmq/subscribeStb0.py index 1463cad627a..bac16464578 100644 --- a/tests/system-test/7-tmq/subscribeStb0.py +++ b/tests/system-test/7-tmq/subscribeStb0.py @@ -228,7 +228,7 @@ def tmqCase3(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -303,7 +303,7 @@ def tmqCase4(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -315,7 +315,7 @@ def tmqCase4(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: + if totalConsumeRows < expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -333,7 +333,7 @@ def tmqCase4(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt: + if totalConsumeRows < expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -386,7 +386,7 @@ def tmqCase5(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -398,7 +398,7 @@ def tmqCase5(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: + if totalConsumeRows < expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -416,7 +416,7 @@ def tmqCase5(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != (expectrowcnt * (1 + 1/4)): + if totalConsumeRows < (expectrowcnt * (1 + 1/4)): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py index 3dc3528d047..63ba2c8c164 100644 --- a/tests/system-test/7-tmq/subscribeStb1.py +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -233,7 +233,7 @@ def tmqCase6(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -320,7 +320,7 @@ def tmqCase7(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) diff --git a/tests/system-test/7-tmq/subscribeStb2.py b/tests/system-test/7-tmq/subscribeStb2.py index 6c3e122902c..dbfbc6f7bc1 100644 --- a/tests/system-test/7-tmq/subscribeStb2.py +++ b/tests/system-test/7-tmq/subscribeStb2.py @@ -233,7 +233,7 @@ def tmqCase8(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume 0 processor") - pollDelay = 100 + pollDelay = 10 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -251,6 +251,7 @@ def tmqCase8(self, cfgPath, buildPath): tdLog.info("start consume 1 processor") self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + tdLog.sleep(2) tdLog.info("start one new thread to insert data") parameterDict['actionType'] = actionType.INSERT_DATA @@ -271,6 +272,7 @@ def tmqCase8(self, cfgPath, buildPath): tdLog.info("start consume 2 processor") self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + tdLog.sleep(2) tdLog.info("start one new thread to insert data") parameterDict['actionType'] = actionType.INSERT_DATA @@ -338,7 +340,7 @@ def tmqCase9(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume 0 processor") - pollDelay = 100 + pollDelay = 20 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -380,6 +382,7 @@ def tmqCase9(self, cfgPath, buildPath): tdLog.info("start consume 2 processor") self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + tdLog.sleep(2) tdLog.info("start one new thread to insert data") parameterDict['actionType'] = actionType.INSERT_DATA @@ -394,7 +397,7 @@ def tmqCase9(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt*2: + if totalConsumeRows < expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb3.py b/tests/system-test/7-tmq/subscribeStb3.py index 025f403282e..ef7ca8ff5d7 100644 --- a/tests/system-test/7-tmq/subscribeStb3.py +++ b/tests/system-test/7-tmq/subscribeStb3.py @@ -215,7 +215,8 @@ def tmqCase10(self, cfgPath, buildPath): parameterDict["stbName"],\ parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ - parameterDict["batchNum"]) + parameterDict["batchNum"],\ + parameterDict["startTs"]) tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' @@ -233,7 +234,7 @@ def tmqCase10(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume 0 processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -269,7 +270,7 @@ def tmqCase10(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt-10000: + if totalConsumeRows < expectrowcnt-10000: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt-10000)) tdLog.exit("tmq consume rows error!") @@ -328,7 +329,8 @@ def tmqCase11(self, cfgPath, buildPath): parameterDict["stbName"],\ parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ - parameterDict["batchNum"]) + parameterDict["batchNum"],\ + parameterDict["startTs"]) tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' @@ -346,7 +348,7 @@ def tmqCase11(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -415,7 +417,8 @@ def tmqCase12(self, cfgPath, buildPath): parameterDict["stbName"],\ parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ - parameterDict["batchNum"]) + parameterDict["batchNum"],\ + parameterDict["startTs"]) tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' @@ -433,7 +436,7 @@ def tmqCase12(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -445,7 +448,7 @@ def tmqCase12(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: + if totalConsumeRows < expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -467,7 +470,7 @@ def tmqCase12(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: + if totalConsumeRows < expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -502,7 +505,8 @@ def tmqCase13(self, cfgPath, buildPath): parameterDict["stbName"],\ parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ - parameterDict["batchNum"]) + parameterDict["batchNum"],\ + parameterDict["startTs"]) tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' @@ -520,7 +524,7 @@ def tmqCase13(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -532,7 +536,7 @@ def tmqCase13(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: + if totalConsumeRows < expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -555,7 +559,7 @@ def tmqCase13(self, cfgPath, buildPath): for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt*(1/2+1/4): + if totalConsumeRows < expectrowcnt*(1/2+1/4): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*(1/2+1/4))) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb4.py b/tests/system-test/7-tmq/subscribeStb4.py index 6aa3da66a46..c0feb8fdbae 100644 --- a/tests/system-test/7-tmq/subscribeStb4.py +++ b/tests/system-test/7-tmq/subscribeStb4.py @@ -231,7 +231,7 @@ def tmqCase1(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) @@ -305,7 +305,7 @@ def tmqCase2(self, cfgPath, buildPath): self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 5 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py index cdcdadbcbb3..7c95f7a3dbd 100644 --- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -211,7 +211,7 @@ def tmqCase1(self): # 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"] + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 # because taosd switch, may be consume duplication data topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 @@ -251,11 +251,12 @@ def tmqCase1(self): 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.info("expect consume rows: %d should less/equal than act consume rows: %d"%(expectRowsList[0], resultList[0])) + if expectRowsList[0] > resultList[0]: tdLog.exit("0 tmq consume rows error!") - self.checkFileContent(consumerId, queryString) + if expectRowsList[0] == resultList[0]: + self.checkFileContent(consumerId, queryString) time.sleep(10) for i in range(len(topicNameList)): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py index 87832ac0ef2..11fc7dbcc05 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py @@ -16,6 +16,8 @@ from tmqCommon import * class TDTestCase: + updatecfgDict = {"tsdbDebugFlag":135} + def __init__(self): self.vgroups = 4 self.ctbNum = 10 diff --git a/tests/system-test/7-tmq/tmqDelete-1ctb.py b/tests/system-test/7-tmq/tmqDelete-1ctb.py index 69d2f5e3472..16aa402a6d2 100644 --- a/tests/system-test/7-tmq/tmqDelete-1ctb.py +++ b/tests/system-test/7-tmq/tmqDelete-1ctb.py @@ -53,7 +53,7 @@ def prepareTestEnv(self): paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -237,10 +237,10 @@ def tmqCase2(self): if self.snapshot == 0: consumerId = 2 - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) elif self.snapshot == 1: consumerId = 3 - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4)) topicList = topicFromStb1 ifcheckdata = 1 @@ -270,7 +270,7 @@ def tmqCase2(self): if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: - if totalConsumeRows != totalRowsFromQuery: + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 1!") # tmqCom.checkFileContent(consumerId, queryString) @@ -323,7 +323,7 @@ def tmqCase3(self): if self.snapshot == 0: consumerId = 4 - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/4 + 3/4)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) elif self.snapshot == 1: consumerId = 5 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) @@ -369,11 +369,7 @@ def tmqCase3(self): tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) if self.snapshot == 0: - # If data writing is completed before consumer get snapshot, will consume 7500 from wal; - # If data writing has not started before consumer get snapshot, will consume 10000 from wal; - minRows = int(expectrowcnt * (1 - 1/4)) # 7500 - tdLog.info("consume rows should be between %d and %d, "%(minRows, expectrowcnt)) - if not ((totalConsumeRows >= minRows) and (totalConsumeRows <= expectrowcnt)): + if (totalConsumeRows != expectrowcnt): tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: tdLog.info("consume rows should be between %d and %d, "%(totalRowsFromQuery, expectrowcnt)) @@ -494,7 +490,7 @@ def tmqCase4(self): tdLog.printNoPrefix("======== test case 4 end ...... ") def run(self): - # tdSql.prepare() + tdSql.prepare() tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 @@ -520,11 +516,11 @@ def run(self): self.prepareTestEnv() self.tmqCase3() - tdLog.printNoPrefix("=============================================") - tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") - self.snapshot = 0 - self.prepareTestEnv() - self.tmqCase4() + # tdLog.printNoPrefix("=============================================") + # tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") + # self.snapshot = 0 + # self.prepareTestEnv() + # self.tmqCase4() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 600e33feab1..7b1dc3a5414 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -26,10 +26,6 @@ ELSE () SET(LINK_WEBSOCKET "") ENDIF () -IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) - ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging) -ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) - IF (TD_LINUX AND TD_ALPINE) SET(LINK_ARGP "/usr/lib/libargp.a") ELSE () diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 8111ccc0b11..0f5585991e5 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -59,8 +59,8 @@ char cusEmail[] = ""; #define SHELL_VERSION "Print program version." #ifdef WEBSOCKET -#define SHELL_DSN "The dsn to use when connecting to cloud server." -#define SHELL_REST "Use restful mode when connecting." +#define SHELL_DSN "Use dsn to connect to the cloud server or to a remote server which provides WebSocket connection." +#define SHELL_REST "Use RESTful mode when connecting." #define SHELL_TIMEOUT "Set the timeout for websocket query in seconds, default is 30." #endif @@ -93,7 +93,11 @@ void shellPrintHelp() { #endif printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH); printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION); - printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail); +#ifdef CUS_EMAIL + printf("\r\n\r\nReport bugs to %s.\r\n", CUS_EMAIL); +#else + printf("\r\n\r\nReport bugs to %s.\r\n", "support@taosdata.com"); +#endif } #ifdef LINUX @@ -105,7 +109,11 @@ void shellPrintHelp() { #endif const char *argp_program_version = version; -const char *argp_program_bug_address = cusEmail; +#ifdef CUS_EMAIL +const char *argp_program_bug_address = CUS_EMAIL; +#else +const char *argp_program_bug_address = "support@taosdata.com"; +#endif static struct argp_option shellOptions[] = { {"host", 'h', "HOST", 0, SHELL_HOST}, @@ -411,10 +419,19 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { shell.info.clientVersion = "Welcome to the %s Command Line Interface, Client Version:%s\r\n" "Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n"; - strcpy(shell.info.cusName, cusName); - sprintf(shell.info.promptHeader, "%s> ", cusPrompt); +#ifdef CUS_NAME + strcpy(shell.info.cusName, CUS_NAME); +#else + strcpy(shell.info.cusName, "TDengine"); +#endif char promptContinueFormat[32] = {0}; - sprintf(promptContinueFormat, "%%%zus> ", strlen(cusPrompt)); +#ifdef CUS_PROMPT + sprintf(shell.info.promptHeader, "%s> ", CUS_PROMPT); + sprintf(promptContinueFormat, "%%%zus> ", strlen(CUS_PROMPT)); +#else + sprintf(shell.info.promptHeader, "taos> "); + sprintf(promptContinueFormat, "%%%zus> ", strlen("taos")); +#endif sprintf(shell.info.promptContinue, promptContinueFormat, " "); shell.info.promptSize = strlen(shell.info.promptHeader); #ifdef TD_ENTERPRISE diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index 873946121bf..755ab556251 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -773,26 +773,26 @@ int sml_dup_time_Test() { taos_free_result(pRes); const char *sql[] = {//"test_ms,t0=t c0=f 1626006833641", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." - "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " - "c0=f,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." - "123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." - "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " - "c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." - "123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006834639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." - "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " - "c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." - "123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006835639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." - "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " - "c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." - "123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006836639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." - "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " - "c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." - "123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006837639000000"}; + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=f,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006834639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006835639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006836639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006837639000000"}; pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); @@ -850,7 +850,7 @@ int smlProcess_18784_Test() { taos_free_result(pRes); const char *sql[] = { - "disk,device=sdc inodes_used=176059i,total=1081101176832i 1661943960000000000", + "disk,device=sdc inodes_used=176059i,total=1076048383523889174i 1661943960000000000", "disk,device=sdc inodes_free=66932805i 1661943960000000000", }; pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); @@ -875,7 +875,7 @@ int smlProcess_18784_Test() { if (rowIndex == 0) { ASSERT(ts == 1661943960000); ASSERT(used == 176059); - ASSERT(total == 1081101176832); + ASSERT(total == 1076048383523889174); ASSERT(freed == 66932805); // ASSERT_EQ(latitude, 24.5208); // ASSERT_EQ(longitude, 28.09377); @@ -939,6 +939,11 @@ int sml_ts2164_Test() { // "meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27", "meters,location=la,groupid=ca current=11.8,voltage=221", "meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27", + "ts3038,location=l2a,groupid=ca current=L\"11.8\"", + "ts3038,location=l2a,groupid=ca voltage=L\"221\"", + "ts3038,location=l2a,groupid=ca phase=L\"221\"", +// "qgyltizmkq,id=sub_table_0123456,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64", +// "qgyltizmkq,id=sub_table_0123456,t=3,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64" // "meters,location=la,groupid=cb current=11.8,voltage=221,phase=0.27", }; diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c index 1f25eae366a..6661d6d14a9 100644 --- a/utils/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -542,7 +542,6 @@ tmq_t* build_consumer() { tmq_conf_set(conf, "td.connect.pass", "taosdata"); tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "enable.heartbeat.background", "true"); if (g_conf.snapShot) { tmq_conf_set(conf, "experimental.snapshot.enable", "true");