diff --git a/cmake/cmake.define b/cmake/cmake.define index d32200bb91..a739a77d21 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.0) set(CMAKE_VERBOSE_MAKEFILE OFF) +set(TD_BUILD_TAOSA_INTERNAL FALSE) #set output directory SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib) diff --git a/docs/en/12-taos-sql/24-show.md b/docs/en/12-taos-sql/24-show.md index 08e8df6252..2db3e7cb31 100644 --- a/docs/en/12-taos-sql/24-show.md +++ b/docs/en/12-taos-sql/24-show.md @@ -178,76 +178,138 @@ SHOW TABLE DISTRIBUTED table_name; Shows how table data is distributed. -Examples: show table distributed d0\G; Display the block distribution of table `d0` in detailed format. +Examples: Below is an example of this command to display the block distribution of table `d0` in detailed format. +```sql +show table distributed d0\G; +``` + +
+ Show Example +

 *************************** 1.row ***************************
 _block_dist: Total_Blocks=[5] Total_Size=[93.65 Kb] Average_size=[18.73 Kb] Compression_Ratio=[23.98 %]
 
 Total_Blocks :  Table `d0` contains total 5 blocks
+
 Total_Size:  The total size of all the data blocks in table `d0` is 93.65 KB 
+
 Average_size:  The average size of each block is 18.73 KB
+
 Compression_Ratio: The data compression rate is 23.98%
  
 *************************** 2.row ***************************
 _block_dist: Total_Rows=[20000] Inmem_Rows=[0] MinRows=[3616] MaxRows=[4096] Average_Rows=[4000]
 
 Total_Rows: Table `d0` contains 20,000 rows
+
 Inmem_Rows: The rows still in memory, i.e. not committed in disk, is 0, i.e. none such rows
+
 MinRows:  The minimum number of rows in a block is 3,616 
+
 MaxRows: The maximum number of rows in a block is 4,096B
+
 Average_Rows: The average number of rows in a block is 4,000
 
 *************************** 3.row ***************************
 _block_dist: Total_Tables=[1] Total_Files=[2]
 
 Total_Tables:  The number of child tables, 1 in this example
+
 Total_Files:   The number of files storing the table's data, 2 in this example
 
 *************************** 4.row ***************************
+
 _block_dist: --------------------------------------------------------------------------------
+
 *************************** 5.row ***************************
+
 _block_dist: 0100 |
+
 *************************** 6.row ***************************
+
 _block_dist: 0299 |
+
 *************************** 7.row ***************************
+
 _block_dist: 0498 |
+
 *************************** 8.row ***************************
+
 _block_dist: 0697 |
+
 *************************** 9.row ***************************
+
 _block_dist: 0896 |
+
 *************************** 10.row ***************************
+
 _block_dist: 1095 |
+
 *************************** 11.row ***************************
+
 _block_dist: 1294 |
+
 *************************** 12.row ***************************
+
 _block_dist: 1493 |
+
 *************************** 13.row ***************************
+
 _block_dist: 1692 |
+
 *************************** 14.row ***************************
+
 _block_dist: 1891 |
+
 *************************** 15.row ***************************
+
 _block_dist: 2090 |
+
 *************************** 16.row ***************************
+
 _block_dist: 2289 |
+
 *************************** 17.row ***************************
+
 _block_dist: 2488 |
+
 *************************** 18.row ***************************
+
 _block_dist: 2687 |
+
 *************************** 19.row ***************************
+
 _block_dist: 2886 |
+
 *************************** 20.row ***************************
+
 _block_dist: 3085 |
+
 *************************** 21.row ***************************
+
 _block_dist: 3284 |
+
 *************************** 22.row ***************************
+
 _block_dist: 3483 |||||||||||||||||  1 (20.00%)
+
 *************************** 23.row ***************************
+
 _block_dist: 3682 |
+
 *************************** 24.row ***************************
+
 _block_dist: 3881 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  4 (80.00%)
+
 Query OK, 24 row(s) in set (0.002444s)
 
-  The above show the block distribution percentage according to the number of rows in each block. In the above example, `_block_dist: 3483 |||||||||||||||||  1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681. `_block_dist: 3881 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. The number of blocks whose rows fall in other range is zero.
+
+
+ + The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information: + - `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681. + - `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero. ## SHOW TAGS diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md index bcfcaf9ffb..9b83c5fd65 100644 --- a/docs/en/28-releases/01-tdengine.md +++ b/docs/en/28-releases/01-tdengine.md @@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w import Release from "/components/ReleaseV3"; +## 3.0.2.2 + + + ## 3.0.2.1 diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md index 6013aacc35..dd44e43ab6 100644 --- a/docs/en/28-releases/02-tools.md +++ b/docs/en/28-releases/02-tools.md @@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat import Release from "/components/ReleaseV3"; +## 2.4.0 + + + ## 2.3.3 diff --git a/docs/zh/12-taos-sql/24-show.md b/docs/zh/12-taos-sql/24-show.md index a65746e7f9..2b875199b5 100644 --- a/docs/zh/12-taos-sql/24-show.md +++ b/docs/zh/12-taos-sql/24-show.md @@ -183,6 +183,10 @@ SHOW TABLE DISTRIBUTED table_name; 语句: show table distributed d0\G; 竖行显示表 d0 的 BLOCK 分布情况 +
+ 显示示例 +

+
 *************************** 1.row ***************************
 
 _block_dist: Total_Blocks=[5] Total_Size=[93.65 Kb] Average_size=[18.73 Kb] Compression_Ratio=[23.98 %]
@@ -244,6 +248,8 @@ _block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
 Query OK, 24 row(s) in set (0.002444s)
 
+
+
上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。 diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md index 0fe6555162..e19b2133e4 100644 --- a/docs/zh/28-releases/01-tdengine.md +++ b/docs/zh/28-releases/01-tdengine.md @@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do import Release from "/components/ReleaseV3"; +## 3.0.2.2 + + + ## 3.0.2.1 diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md index 331f6832c0..b2ead5b264 100644 --- a/docs/zh/28-releases/02-tools.md +++ b/docs/zh/28-releases/02-tools.md @@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下: import Release from "/components/ReleaseV3"; +## 2.4.0 + + + ## 2.3.3 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 27ca81fc57..94f26ebae1 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -300,7 +300,7 @@ typedef struct SShowTableTagsStmt { SNodeList* pTags; } SShowTableTagsStmt; -typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType; +typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType; typedef struct SIndexOptions { ENodeType type; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 4bd23082c4..bbf332c4d4 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -286,7 +286,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR) #define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND) -#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) +#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) #define NEED_REDIRECT_ERROR(_code) \ (NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \ diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 7765a60f88..dbe4d6801e 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -70,6 +70,7 @@ typedef struct { SysNameInfo taosGetSysNameInfo(); bool taosCheckCurrentInDll(); +int taosGetlocalhostname(char *hostname, size_t maxLen); #ifdef __cplusplus } diff --git a/include/util/taoserror.h b/include/util/taoserror.h index e76f023ab7..1bfcae5681 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -65,6 +65,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) // #define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) // #define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) // +#define TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED TAOS_DEF_ERROR_CODE(0, 0x0020) // "Vgroup could not be connected" +#define TSDB_CODE_RPC_SOMENODE_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0021) // //common & util #define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) // @@ -518,6 +520,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912) #define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913) #define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914) +#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal +#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) // #define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF) // tq diff --git a/include/util/tdef.h b/include/util/tdef.h index 7cd4f57771..4cf4f73b9b 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -255,7 +255,7 @@ typedef enum ELogicConditionType { #define TSDB_EP_LEN (TSDB_FQDN_LEN + 6) #define TSDB_IPv4ADDR_LEN 16 #define TSDB_FILENAME_LEN 128 -#define TSDB_SHOW_SQL_LEN 1024 +#define TSDB_SHOW_SQL_LEN 2048 #define TSDB_SLOW_QUERY_SQL_LEN 512 #define TSDB_SHOW_SUBQUERY_LEN 1000 diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index 8853a014f9..bf7418ad79 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -58,7 +58,7 @@ if exist %binary_dir%\\build\\lib\\taosws.dll ( if exist %binary_dir%\\build\\bin\\taosdump.exe ( copy %binary_dir%\\build\\bin\\taosdump.exe %target_dir% > nul ) -if %Enterprise% ( +if %Enterprise% == TRUE ( if exist %binary_dir%\\build\\bin\\taosx.exe ( copy %binary_dir%\\build\\bin\\taosx.exe %target_dir% > nul ) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index bc2c2846fb..6f61d59846 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1403,6 +1403,21 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet)); } + // pMsg is response msg + if (pMsg->msgType == TDMT_MND_CONNECT + 1) { + // restore origin code + if (pMsg->code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) { + pMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + } else if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) { + pMsg->code = TSDB_CODE_RPC_BROKEN_LINK; + } + } else { + // uniform to one error code: TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED + if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) { + pMsg->code = TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED; + } + } + AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg)); arg->msg = *pMsg; arg->pEpset = tEpSet; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 9caf0cc33e..d3fd625a91 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1316,12 +1316,17 @@ void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal, if (pItem != NULL && (rewrite || pItem->i32 == 0)) { pItem->i32 = flagVal; } - *pFlagPtr = flagVal; + if (pFlagPtr != NULL) { + *pFlagPtr = flagVal; + } } void taosSetAllDebugFlag(int32_t flag, bool rewrite) { if (flag <= 0) return; + taosSetDebugFlag(NULL, "debugFlag", flag, rewrite); + taosSetDebugFlag(NULL, "simDebugFlag", flag, rewrite); + taosSetDebugFlag(NULL, "tmrDebugFlag", flag, rewrite); taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, rewrite); taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, rewrite); taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, rewrite); @@ -1340,6 +1345,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) { taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, rewrite); taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, rewrite); taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite); - taosSetDebugFlag(&metaDebugFlag, "tmrDebugFlag", flag, rewrite); uInfo("all debug flag are set to %d", flag); } diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index a8103351b4..a432201413 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -268,6 +268,11 @@ int mainWindows(int argc, char **argv) { if (dmInit() != 0) { dError("failed to init dnode since %s", terrstr()); + + taosCleanupCfg(); + taosCloseLog(); + taosCleanupArgs(); + taosConvDestroy(); return -1; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 7e3915f3d1..5afb9a0512 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -140,6 +140,12 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) { const STraceId *trace = &pMsg->info.traceId; + if (pMsg->contLen < sizeof(SMsgHead)) { + dGError("invalid rpc msg with no msg head at pCont. pMsg:%p, type:%s, contLen:%d", pMsg, TMSG_INFO(pMsg->msgType), + pMsg->contLen); + return -1; + } + SMsgHead *pHead = pMsg->pCont; int32_t code = 0; @@ -233,6 +239,14 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { + if (pRpc->contLen < sizeof(SMsgHead)) { + dError("invalid rpc msg with no msg head at pCont. pRpc:%p, type:%s, len:%d", pRpc, TMSG_INFO(pRpc->msgType), + pRpc->contLen); + rpcFreeCont(pRpc->pCont); + pRpc->pCont = NULL; + return -1; + } + SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen); if (pMsg == NULL) { rpcFreeCont(pRpc->pCont); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index f11378f84c..756f97d1d0 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -248,6 +248,7 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcRe static bool rpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND || + code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED || code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) { if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 67d3f7e119..718fc5c73f 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -957,7 +957,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { for (int32_t i = 0; i < size; ++i) { SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i); if (pInfo->handle != NULL) { - if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) { code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL; } if (code == TSDB_CODE_SYN_TIMEOUT) { diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index 513ee5a1c2..d68658b0d9 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -57,7 +57,6 @@ struct SMetaCache { TdThreadMutex lock; SHashObj* pTableEntry; SLRUCache* pUidResCache; - uint64_t keyBuf[3]; } sTagFilterResCache; }; @@ -429,20 +428,20 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK bool* acquireRes) { // generate the composed key for LRU cache SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache; - uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf; SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; + uint64_t buf[3] = {0}; uint32_t times = 0; *acquireRes = 0; - pBuf[0] = suid; - memcpy(&pBuf[1], pKey, keyLen); + buf[0] = suid; + memcpy(&buf[1], pKey, keyLen); taosThreadMutexLock(pLock); int32_t len = keyLen + sizeof(uint64_t); - LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len); + LRUHandle* pHandle = taosLRUCacheLookup(pCache, buf, len); if (pHandle == NULL) { taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; @@ -476,10 +475,10 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK SListNode* pNode = NULL; while ((pNode = tdListNext(&iter)) != NULL) { - memcpy(&pBuf[1], pNode->data, keyLen); + memcpy(&buf[1], pNode->data, keyLen); // check whether it is existed in LRU cache, and remove it from linked list if not. - LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len); + LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len); if (pRes == NULL) { // remove the item in the linked list taosArrayPush(pInvalidRes, &pNode); } else { @@ -547,14 +546,14 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int tdListAppend(&(*pEntry)->list, pKey); } - uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf; - pBuf[0] = suid; + uint64_t buf[3] = {0}; + buf[0] = suid; - memcpy(&pBuf[1], pKey, keyLen); + memcpy(&buf[1], pKey, keyLen); ASSERT(sizeof(uint64_t) + keyLen == 24); // add to cache. - taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, + taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, TAOS_LRU_PRIORITY_LOW); taosThreadMutexUnlock(pLock); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 054e785980..63d044df6e 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -113,8 +113,8 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) { pHdr->size = nData; memcpy(pHdr->data, pData, nData); - metaInfo("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " nData:%d", - TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData); + metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d", + TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData); _exit: return code; diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index c64f666ec3..d0017e4ba2 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -1014,6 +1014,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) { tqError("unable to encode rsp %d", __LINE__); return -1; } + void* buf = rpcMallocCont(sizeof(SMsgHead) + len); ((SMsgHead*)buf)->vgId = htonl(req.upstreamNodeId); diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 071fa6c1e0..1f99444cf3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -567,7 +567,6 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead pMTree->pLoadInfo = pBlockLoadInfo; pMTree->destroyLoadInfo = destroyLoadInfo; - ASSERT(pMTree->pLoadInfo != NULL); for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file struct SLDataIter *pIter = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index aeec35f0a7..d629be2fef 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -244,7 +244,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC return TSDB_CODE_SUCCESS; } -static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) { +static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) { int32_t i = 0, j = 0; while (i < pSchema->numOfCols && j < pSupInfo->numOfCols) { @@ -252,7 +252,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) if (pTCol->colId == pSupInfo->colId[j]) { if (!IS_BSMA_ON(pTCol)) { pSupInfo->smaValid = false; - return; + return TSDB_CODE_SUCCESS; } i += 1; @@ -261,9 +261,11 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) // do nothing i += 1; } else { - ASSERT(0); + return TSDB_CODE_INVALID_PARA; } } + + return TSDB_CODE_SUCCESS; } static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { @@ -581,7 +583,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd } if (VND_IS_TSMA(pVnode)) { - tsdbDebug("vgId:%d, tsma is selected to query", TD_VID(pVnode)); + tsdbDebug("vgId:%d, tsma is selected to query, %s", TD_VID(pVnode), idstr); } initReaderStatus(&pReader->status); @@ -596,7 +598,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pReader->type = pCond->type; pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket - ASSERT(pCond->numOfCols > 0); if (pReader->pResBlock == NULL) { pReader->freeBlock = true; @@ -607,6 +608,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd } } + if (pCond->numOfCols <= 0) { + tsdbError("vgId:%d, invalid column number %d in query cond, %s", TD_VID(pVnode), pCond->numOfCols, idstr); + code = TSDB_CODE_INVALID_PARA; + goto _end; + } + // todo refactor. limitOutputBufferSize(pCond, &pReader->capacity); @@ -795,8 +802,9 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_ } static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { - if (taosArrayGetSize(pBlockIter->blockList) == 0) { - ASSERT(pBlockIter->numOfBlocks == taosArrayGetSize(pBlockIter->blockList)); + size_t num = taosArrayGetSize(pBlockIter->blockList); + if (num == 0) { + ASSERT(pBlockIter->numOfBlocks == num); return NULL; } @@ -806,73 +814,6 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; } -int32_t binarySearchForTs(char* pValue, int num, TSKEY key, int order) { - int32_t midPos = -1; - int32_t numOfRows; - - ASSERT(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC); - - TSKEY* keyList = (TSKEY*)pValue; - int32_t firstPos = 0; - int32_t lastPos = num - 1; - - if (order == TSDB_ORDER_DESC) { - // find the first position which is smaller than the key - while (1) { - if (key >= keyList[firstPos]) return firstPos; - if (key == keyList[lastPos]) return lastPos; - - if (key < keyList[lastPos]) { - lastPos += 1; - if (lastPos >= num) { - return -1; - } else { - return lastPos; - } - } - - numOfRows = lastPos - firstPos + 1; - midPos = (numOfRows >> 1) + firstPos; - - if (key < keyList[midPos]) { - firstPos = midPos + 1; - } else if (key > keyList[midPos]) { - lastPos = midPos - 1; - } else { - break; - } - } - - } else { - // find the first position which is bigger than the key - while (1) { - if (key <= keyList[firstPos]) return firstPos; - if (key == keyList[lastPos]) return lastPos; - - if (key > keyList[lastPos]) { - lastPos = lastPos + 1; - if (lastPos >= num) - return -1; - else - return lastPos; - } - - numOfRows = lastPos - firstPos + 1; - midPos = (numOfRows >> 1u) + firstPos; - - if (key < keyList[midPos]) { - lastPos = midPos - 1; - } else if (key > keyList[midPos]) { - firstPos = midPos + 1; - } else { - break; - } - } - } - - return midPos; -} - static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int order) { // start end position int s, e; @@ -973,8 +914,8 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo int32_t step = asc ? 1 : -1; - // make sure it is aligned to 8bit - ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0); + // make sure it is aligned to 8bit, the allocated memory address is aligned to 256bit +// ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0); // 1. copy data in a batch model memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes); @@ -1072,11 +1013,20 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn // pDumpInfo->rowIndex = 0; } else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) { // pDumpInfo->rowIndex = pBlock->nRow - 1; - } else { + } else { // find the appropriate the start position in current block, and set it to be the current rowIndex int32_t pos = asc ? pBlock->nRow - 1 : 0; int32_t order = asc ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; int64_t key = asc ? pReader->window.skey : pReader->window.ekey; pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, order); + + if (pDumpInfo->rowIndex < 0) { + tsdbError( + "%p failed to locate the start position in current block, global index:%d, table index:%d, brange:%" PRId64 + "-%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 " %s", + pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->minVer, + pBlock->maxVer, pReader->idStr); + return TSDB_CODE_INVALID_PARA; + } } } @@ -1185,7 +1135,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - ASSERT(pBlockInfo != NULL); SDataBlk* pBlock = getCurrentBlock(pBlockIter); code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData); @@ -1223,8 +1172,6 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) { } static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) { - ASSERT(numOfTables >= 1); - pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); pSup->pDataBlockInfo = taosMemoryCalloc(1, POINTER_BYTES * numOfTables); @@ -1331,7 +1278,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte sup.numOfTables += 1; } - ASSERT(numOfBlocks == cnt); + if (numOfBlocks != cnt && sup.numOfTables != numOfTables) { + cleanupBlockOrderSupporter(&sup); + return TSDB_CODE_INVALID_PARA; + } // since there is only one table qualified, blocks are not sorted if (sup.numOfTables == 1) { @@ -1353,10 +1303,9 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %s", pReader, cnt, sup.numOfTables, pReader->idStr); - ASSERT(cnt <= numOfBlocks && sup.numOfTables <= numOfTables); - SMultiwayMergeTreeInfo* pTree = NULL; - uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar); + + uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar); if (ret != TSDB_CODE_SUCCESS) { cleanupBlockOrderSupporter(&sup); return TSDB_CODE_OUT_OF_MEMORY; @@ -1434,8 +1383,6 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl } static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) { - ASSERT(pBlockIter != NULL && pFBlockInfo != NULL); - int32_t step = ASCENDING_TRAVERSE(pBlockIter->order) ? 1 : -1; int32_t index = pBlockIter->index; @@ -1926,7 +1873,6 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, } doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge, &pReader->verRange); - ASSERT(mergeBlockData); // merge with block data if ts == key if (tsLastBlock == pBlockData->aTSKEY[pDumpInfo->rowIndex]) { @@ -1992,7 +1938,6 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader tsdbRowMergerClear(&merge); return code; } else { - ASSERT(0); return TSDB_CODE_SUCCESS; } } else { // desc order @@ -2013,7 +1958,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader); TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader); - ASSERT(pRow != NULL && piRow != NULL); int64_t tsLast = INT64_MIN; if (hasDataInLastBlock(pLastBlockReader)) { @@ -2237,7 +2181,6 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea if (pReader->pReadSnap->pMem != NULL) { d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid); if (d != NULL) { - ASSERT(pBlockScanInfo->iter.iter == NULL); code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter); if (code == TSDB_CODE_SUCCESS) { pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL); @@ -2351,10 +2294,9 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) { static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; } bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) { - if (pBlockData->nRow > 0) { - ASSERT(pBlockData->nRow == pDumpInfo->totalRows); + if ((pBlockData->nRow > 0) && (pBlockData->nRow != pDumpInfo->totalRows)) { + return false; // this is an invalid result. } - return pBlockData->nRow > 0 && (!pDumpInfo->allDumped); } @@ -2585,7 +2527,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* int32_t code = 0; SArray* pDelData = taosArrayInit(4, sizeof(SDelData)); - ASSERT(pReader->pReadSnap != NULL); SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile; if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) { @@ -2869,7 +2810,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader); if (pBlockInfo == NULL) { // build data block from last data file - ASSERT(pBlockIter->numOfBlocks == 0); code = buildComposedDataBlock(pReader); } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) { code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid); @@ -3872,15 +3812,16 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } if (pReader->pSchema != NULL) { - updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo); + code = updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo); + if (code != TSDB_CODE_SUCCESS) { + goto _err; + } } STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader; pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables); if (pReader->status.pTableMap == NULL) { - tsdbReaderClose(p); *ppReader = NULL; - code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -4146,25 +4087,27 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_ } int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) { + SColumnDataAgg*** pBlockSMA = &pDataBlock->pBlockAgg; + int32_t code = 0; - SColumnDataAgg ***pBlockSMA = &pDataBlock->pBlockAgg; *allHave = false; + *pBlockSMA = NULL; if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { - *pBlockSMA = NULL; return TSDB_CODE_SUCCESS; } // there is no statistics data for composed block if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) { - *pBlockSMA = NULL; return TSDB_CODE_SUCCESS; } SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); SBlockLoadSuppInfo* pSup = &pReader->suppInfo; - ASSERT(pReader->pResBlock->info.id.uid == pFBlock->uid); + if (pReader->pResBlock->info.id.uid != pFBlock->uid) { + return TSDB_CODE_SUCCESS; + } SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); if (tDataBlkHasSma(pBlock)) { @@ -4192,13 +4135,10 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, // update the number of NULL data rows size_t numOfCols = pSup->numOfCols; - int32_t i = 0, j = 0; - size_t size = taosArrayGetSize(pSup->pColAgg); - // ensure capacity - if(pDataBlock->pDataBlock) { - size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock); - taosArrayEnsureCap(pSup->pColAgg, colsNum); + if (pDataBlock->pDataBlock) { + size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock); + taosArrayEnsureCap(pSup->pColAgg, colsNum); } SSDataBlock* pResBlock = pReader->pResBlock; @@ -4209,8 +4149,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, // do fill all null column value SMA info doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg); + size_t size = taosArrayGetSize(pSup->pColAgg); - i = 0, j = 0; + int32_t i = 0, j = 0; while (j < numOfCols && i < size) { SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i); if (pAgg->colId == pSup->colId[j]) { @@ -4220,15 +4161,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, } else if (pAgg->colId < pSup->colId[j]) { i += 1; } else if (pSup->colId[j] < pAgg->colId) { - if (pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID) { - pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg; - } else { - // all date in this block are null - SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = pBlock->nRow}; - taosArrayPush(pSup->pColAgg, &nullColAgg); - - pResBlock->pBlockAgg[pSup->slotId[j]] = taosArrayGetLast(pSup->pColAgg); - } + // ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID); + pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg; j += 1; } } @@ -4460,9 +4394,12 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6 return terrno; } sversion = mr.me.stbEntry.schemaRow.version; - } else { - ASSERT(mr.me.type == TSDB_NORMAL_TABLE); + } else if (mr.me.type == TSDB_NORMAL_TABLE) { sversion = mr.me.ntbEntry.schemaRow.version; + } else { + terrno = TSDB_CODE_INVALID_PARA; + metaReaderClear(&mr); + return terrno; } metaReaderClear(&mr); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index ebe9d56dad..bfe6e469ff 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -184,18 +184,51 @@ _err: return -1; } -int32_t vnodePrepareCommit(SVnode *pVnode) { +int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { int32_t code = 0; + int32_t lino = 0; + char dir[TSDB_FILENAME_LEN] = {0}; + tsem_wait(&pVnode->canCommit); + pVnode->state.commitTerm = pVnode->state.applyTerm; + + pInfo->info.config = pVnode->config; + pInfo->info.state.committed = pVnode->state.applied; + pInfo->info.state.commitTerm = pVnode->state.applyTerm; + pInfo->info.state.commitID = pVnode->state.commitID; + pInfo->pVnode = pVnode; + pInfo->txn = metaGetTxn(pVnode->pMeta); + + // save info + if (pVnode->pTfs) { + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path); + } else { + snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path); + } + if (vnodeSaveInfo(dir, &pInfo->info) < 0) { + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); + } + tsdbPrepareCommit(pVnode->pTsdb); + metaPrepareAsyncCommit(pVnode->pMeta); + code = smaPrepareAsyncCommit(pVnode->pSma); if (code) goto _exit; -_exit: vnodeBufPoolUnRef(pVnode->inUse); pVnode->inUse = NULL; + +_exit: + if (code) { + vError("vgId:%d, %s failed at line %d since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, lino, + tstrerror(code), pVnode->state.commitID); + } else { + vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__); + } + return code; } @@ -217,33 +250,32 @@ _exit: int vnodeAsyncCommit(SVnode *pVnode) { int32_t code = 0; - // prepare to commit - code = vnodePrepareCommit(pVnode); - if (code) goto _exit; - - // schedule the task - pVnode->state.commitTerm = pVnode->state.applyTerm; - SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo)); if (NULL == pInfo) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - pInfo->info.config = pVnode->config; - pInfo->info.state.committed = pVnode->state.applied; - pInfo->info.state.commitTerm = pVnode->state.applyTerm; - pInfo->info.state.commitID = pVnode->state.commitID; - pInfo->pVnode = pVnode; - pInfo->txn = metaGetTxn(pVnode->pMeta); + + // prepare to commit + code = vnodePrepareCommit(pVnode, pInfo); + if (TSDB_CODE_SUCCESS != code) { + goto _exit; + } + + // schedule the task code = vnodeScheduleTask(vnodeCommitTask, pInfo); _exit: if (code) { + if (NULL != pInfo) { + taosMemoryFree(pInfo); + } tsem_post(&pVnode->canCommit); vError("vgId:%d, %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code), pVnode->state.commitID); } else { - vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__); + vInfo("vgId:%d, vnode async commit done, commitId:%" PRId64 " term:%" PRId64 " applied:%" PRId64, TD_VID(pVnode), + pVnode->state.commitID, pVnode->state.applyTerm, pVnode->state.applied); } return code; } @@ -262,7 +294,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { char dir[TSDB_FILENAME_LEN] = {0}; SVnode *pVnode = pInfo->pVnode; - vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode), + vInfo("vgId:%d, start to commit, commitId:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode), pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm); // persist wal before starting @@ -271,16 +303,11 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - // save info if (pVnode->pTfs) { snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path); } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path); } - if (vnodeSaveInfo(dir, &pInfo->info) < 0) { - code = terrno; - TSDB_CHECK_CODE(code, lino, _exit); - } // walBeginSnapshot(pVnode->pWal, pVnode->state.applied); syncBeginSnapshot(pVnode->sync, pVnode->state.applied); diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index fcfacd1ca9..2fc06fba86 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -257,8 +257,8 @@ _exit: pReader->index++; *nData = sizeof(SSnapDataHdr) + pHdr->size; pHdr->index = pReader->index; - vInfo("vgId:%d, vnode snapshot read data,index:%" PRId64 " type:%d nData:%d ", TD_VID(pReader->pVnode), - pReader->index, pHdr->type, *nData); + vDebug("vgId:%d, vnode snapshot read data, index:%" PRId64 " type:%d blockLen:%d ", TD_VID(pReader->pVnode), + pReader->index, pHdr->type, *nData); } else { vInfo("vgId:%d, vnode snapshot read data end, index:%" PRId64, TD_VID(pReader->pVnode), pReader->index); } @@ -423,8 +423,8 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) { ASSERT(pHdr->index == pWriter->index + 1); pWriter->index = pHdr->index; - vInfo("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode), pHdr->index, - pHdr->type, nData); + vDebug("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d blockLen:%d", TD_VID(pVnode), pHdr->index, + pHdr->type, nData); switch (pHdr->type) { case SNAP_DATA_CFG: { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d98ccbd718..2669ad600e 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -218,7 +218,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp if (!syncUtilUserCommit(pMsg->msgType)) goto _exit; - if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE) { + if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE || pMsg->msgType == TDMT_STREAM_TASK_CHECK_RSP) { if (tqCheckLogInWal(pVnode->pTq, version)) return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 5caaae502f..5697487743 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -391,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm const STraceId *trace = &pMsg->info.traceId; vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64 - ", weak:%d, code:%d, state:%d %s, type:%s", + ", weak:%d, code:%d, state:%d %s, type:%s code:0x%x", pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code, - pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType)); + pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType), pMsg->code); return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg); } @@ -465,9 +465,9 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { SVnode *pVnode = pFsm->data; - vDebug("vgId:%d, continue write vnode snapshot, len:%d", pVnode->config.vgId, len); + vDebug("vgId:%d, continue write vnode snapshot, blockLen:%d", pVnode->config.vgId, len); int32_t code = vnodeSnapWrite(pWriter, pBuf, len); - vDebug("vgId:%d, continue write vnode snapshot finished, len:%d", pVnode->config.vgId, len); + vDebug("vgId:%d, continue write vnode snapshot finished, blockLen:%d", pVnode->config.vgId, len); return code; } diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index acd18fcca5..b8590c9255 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -471,17 +471,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con } int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { + int32_t code = 0; int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1); CTG_LOCK(CTG_WRITE, &pJob->taskLock); - CTG_ERR_RET((*gCtgAsyncFps[type].initFp)(pJob, tid, param)); - CTG_UNLOCK(CTG_WRITE, &pJob->taskLock); + CTG_ERR_JRET((*gCtgAsyncFps[type].initFp)(pJob, tid, param)); if (taskId) { *taskId = tid; } - return TSDB_CODE_SUCCESS; +_return: + CTG_UNLOCK(CTG_WRITE, &pJob->taskLock); + + return code; } int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index fe83854a91..c266cc1df9 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -2500,6 +2500,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe CTG_LOCK(CTG_READ, &pCache->metaLock); if (NULL == pCache->pMeta) { + CTG_UNLOCK(CTG_READ, &pCache->metaLock); ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index eff7a5ef93..a8051ea7c3 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock); pEntry->dataLen = sizeof(SDeleterRes); - ASSERT(1 == pEntry->numOfRows); - ASSERT(3 == pEntry->numOfCols); +// ASSERT(1 == pEntry->numOfRows); +// ASSERT(3 == pEntry->numOfCols); pBuf->useSize = sizeof(SDataCacheEntry); @@ -167,7 +167,6 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE SDataDeleterBuf* pBuf = NULL; taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); - ASSERT(NULL != pBuf); memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf)); taosFreeQitem(pBuf); diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index c2fa438c80..a603bffba5 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn pBuf->useSize = sizeof(SDataCacheEntry); pEntry->dataLen = blockEncode(pInput->pData, pEntry->data, numOfCols); - ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); - ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); +// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); +// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); pBuf->useSize += pEntry->dataLen; @@ -162,15 +162,14 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE SDataDispatchBuf* pBuf = NULL; taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf); - ASSERT(NULL != pBuf); memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf)); taosFreeQitem(pBuf); SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData; *pLen = pEntry->dataLen; - ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); - ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); +// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); +// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); *pQueryEnd = pDispatcher->queryEnd; qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, @@ -193,8 +192,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { pOutput->numOfCols = pEntry->numOfCols; pOutput->compressed = pEntry->compressed; - ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); - ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); +// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); +// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen); atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index 4103ca82dc..9873c52006 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -373,7 +373,6 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { pRsp->useconds = htobe64(pRsp->useconds); pRsp->numOfBlocks = htonl(pRsp->numOfBlocks); - ASSERT(pRsp != NULL); qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%" PRId64 ", %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, pRsp->numOfRows, pExchangeInfo); } else { diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index bab5afe5e1..0a2802ba37 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -942,7 +942,6 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) { } return 0; } - bool qStreamRecoverScanFinished(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; return pTaskInfo->streamInfo.recoverScanFinished; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index fecdcd8fa3..149efef884 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -104,8 +104,6 @@ static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, void setOperatorCompleted(SOperatorInfo* pOperator) { pOperator->status = OP_EXEC_DONE; - ASSERT(pOperator->pTaskInfo != NULL); - pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start) / 1000.0; setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); } @@ -524,7 +522,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx) { return true; } -static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type, +static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type, int32_t paramIndex, int32_t numOfRows) { if (pInput->pData[paramIndex] == NULL) { pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData)); @@ -548,8 +546,6 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF da = pInput->pColumnDataAgg[paramIndex]; } - ASSERT(!IS_VAR_DATA_TYPE(type)); - if (type == TSDB_DATA_TYPE_BIGINT) { int64_t v = pFuncParam->param.i; *da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows}; @@ -570,7 +566,7 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF } else if (type == TSDB_DATA_TYPE_TIMESTAMP) { // do nothing } else { - ASSERT(0); + qError("invalid constant type for sma info"); } return TSDB_CODE_SUCCESS; @@ -600,7 +596,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB // the data in the corresponding SColumnInfoData will not be used. pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId); } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { - doCreateConstantValColumnAggInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows); + doCreateConstantValColumnSMAInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows); } } } else { @@ -1577,8 +1573,7 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) { // each operator should be set their own function to return total cost buffer int32_t optrDefaultBufFn(SOperatorInfo* pOperator) { if (pOperator->blocking) { - ASSERT(0); - return 0; + return -1; } else { return 0; } @@ -2205,7 +2200,6 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo); } else { SStreamScanInfo* pInfo = pOperator->info; - ASSERT(pInfo->pTableScanOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); *ppInfo = pInfo->pTableScanOp->info; return 0; } @@ -2217,13 +2211,11 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { *ppNode = (STableScanPhysiNode*)pNode; return 0; } else { - ASSERT(0); terrno = TSDB_CODE_APP_ERROR; return -1; } } else { if (LIST_LENGTH(pNode->pChildren) != 1) { - ASSERT(0); terrno = TSDB_CODE_APP_ERROR; return -1; } @@ -2233,32 +2225,6 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { return -1; } -#if 0 -int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle, int64_t uid, int64_t ts) { - STableScanInfo* pTableScanInfo = NULL; - if (extractTbscanInStreamOpTree(pOperator, &pTableScanInfo) < 0) { - return -1; - } - - STableScanPhysiNode* pNode = NULL; - if (extractTableScanNode(plan->pNode, &pNode) < 0) { - ASSERT(0); - } - - tsdbReaderClose(pTableScanInfo->dataReader); - - STableListInfo info = {0}; - pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, NULL); - if (pTableScanInfo->dataReader == NULL) { - ASSERT(0); - qError("failed to create data reader"); - return TSDB_CODE_APP_ERROR; - } - // TODO: set uid and ts to data reader - return 0; -} -#endif - int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) { SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo; diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index 8a097a23ce..88ed9eccb3 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -42,38 +42,40 @@ typedef struct SJoinOperatorInfo { static void setJoinColumnInfo(SColumnInfo* pColumn, const SColumnNode* pColumnNode); static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator); static void destroyMergeJoinOperator(void* param); -static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream, - SSortMergeJoinPhysiNode* pJoinNode); +static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t num, + SSortMergeJoinPhysiNode* pJoinNode, const char* idStr); -static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream, - SSortMergeJoinPhysiNode* pJoinNode) { +static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t num, + SSortMergeJoinPhysiNode* pJoinNode, const char* idStr) { SNode* pMergeCondition = pJoinNode->pMergeCondition; - if (nodeType(pMergeCondition) == QUERY_NODE_OPERATOR) { - SOperatorNode* pNode = (SOperatorNode*)pMergeCondition; - SColumnNode* col1 = (SColumnNode*)pNode->pLeft; - SColumnNode* col2 = (SColumnNode*)pNode->pRight; - SColumnNode* leftTsCol = NULL; - SColumnNode* rightTsCol = NULL; - if (col1->dataBlockId == col2->dataBlockId ) { + if (nodeType(pMergeCondition) != QUERY_NODE_OPERATOR) { + qError("not support this in join operator, %s", idStr); + return; // do not handle this + } + + SOperatorNode* pNode = (SOperatorNode*)pMergeCondition; + SColumnNode* col1 = (SColumnNode*)pNode->pLeft; + SColumnNode* col2 = (SColumnNode*)pNode->pRight; + SColumnNode* leftTsCol = NULL; + SColumnNode* rightTsCol = NULL; + if (col1->dataBlockId == col2->dataBlockId) { + leftTsCol = col1; + rightTsCol = col2; + } else { + if (col1->dataBlockId == pDownstream[0]->resultDataBlockId) { + ASSERT(col2->dataBlockId == pDownstream[1]->resultDataBlockId); leftTsCol = col1; rightTsCol = col2; } else { - if (col1->dataBlockId == pDownstream[0]->resultDataBlockId) { - ASSERT(col2->dataBlockId == pDownstream[1]->resultDataBlockId); - leftTsCol = col1; - rightTsCol = col2; - } else { - ASSERT(col1->dataBlockId == pDownstream[1]->resultDataBlockId); - ASSERT(col2->dataBlockId == pDownstream[0]->resultDataBlockId); - leftTsCol = col2; - rightTsCol = col1; - } + ASSERT(col1->dataBlockId == pDownstream[1]->resultDataBlockId); + ASSERT(col2->dataBlockId == pDownstream[0]->resultDataBlockId); + leftTsCol = col2; + rightTsCol = col1; } - setJoinColumnInfo(&pInfo->leftCol, leftTsCol); - setJoinColumnInfo(&pInfo->rightCol, rightTsCol); - } else { - ASSERT(false); - }} + } + setJoinColumnInfo(&pInfo->leftCol, leftTsCol); + setJoinColumnInfo(&pInfo->rightCol, rightTsCol); +} SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo) { @@ -97,7 +99,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t pOperator->exprSupp.pExprInfo = pExprInfo; pOperator->exprSupp.numOfExprs = numOfCols; - extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode); + extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode, GET_TASKID(pTaskInfo)); if (pJoinNode->pOnConditions != NULL && pJoinNode->node.pConditions != NULL) { pInfo->pCondAfterMerge = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); @@ -364,8 +366,6 @@ static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos); *pRightTs = *(int64_t*)pRightVal; - ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); - ASSERT(pRightCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); return true; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index e3a9f14e7e..b2aa2269a2 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -232,30 +232,6 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, if (!allColumnsHaveAgg) { return false; } - -#if 0 - // if (allColumnsHaveAgg == true) { - int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - - // todo create this buffer during creating operator - if (pBlock->pBlockAgg == NULL) { - pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES); - if (pBlock->pBlockAgg == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); - } - } - - size_t num = taosArrayGetSize(pTableScanInfo->matchInfo.pList); - for (int32_t i = 0; i < num; ++i) { - SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i); - if (!pColMatchInfo->needOutput) { - continue; - } - - pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i]; - } -#endif - return true; } @@ -2251,6 +2227,7 @@ static void destroyStreamScanOperatorInfo(void* param) { SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, SExecTaskInfo* pTaskInfo) { + SArray* pColIds = NULL; SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -2273,7 +2250,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys } int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList); - SArray* pColIds = taosArrayInit(numOfOutput, sizeof(int16_t)); + pColIds = taosArrayInit(numOfOutput, sizeof(int16_t)); for (int32_t i = 0; i < numOfOutput; ++i) { SColMatchItem* id = taosArrayGet(pInfo->matchInfo.pList, i); @@ -2370,6 +2347,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond)); } else { taosArrayDestroy(pColIds); + pColIds = NULL; } // create the pseduo columns info diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 7ac007b7cb..f5dc6cc623 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -46,13 +46,15 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pOperator->pTaskInfo = pTaskInfo; SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc; - int32_t numOfCols = 0; - SSDataBlock* pResBlock = createDataBlockFromDescNode(pDescNode); - SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols); + int32_t numOfCols = 0; + SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols); int32_t numOfOutputCols = 0; int32_t code = extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset); initResultSizeInfo(&pOperator->resultInfo, 1024); @@ -61,7 +63,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* goto _error; } - pInfo->binfo.pRes = pResBlock; + pInfo->binfo.pRes = createDataBlockFromDescNode(pDescNode); pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys); initLimitInfo(pSortNode->node.pLimit, pSortNode->node.pSlimit, &pInfo->limitInfo); @@ -86,7 +88,10 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* _error: pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; - taosMemoryFree(pInfo); + if (pInfo != NULL) { + destroySortOperatorInfo(pInfo); + } + taosMemoryFree(pOperator); return NULL; } @@ -139,7 +144,6 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i); - // ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId); @@ -272,7 +276,6 @@ void destroySortOperatorInfo(void* param) { } int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { - ASSERT(pOptr != NULL); SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo)); SSortOperatorInfo* pOperatorInfo = (SSortOperatorInfo*)pOptr->info; @@ -329,7 +332,6 @@ SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i); - // ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId); @@ -746,7 +748,6 @@ void destroyMultiwayMergeOperatorInfo(void* param) { } int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { - ASSERT(pOptr != NULL); SSortExecInfo* pSortExecInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo)); SMultiwayMergeOperatorInfo* pInfo = (SMultiwayMergeOperatorInfo*)pOptr->info; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 8107cea4a0..0de38fe500 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -907,7 +907,7 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) { } bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) { - ASSERT(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0); + ASSERTS(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0, "maxts should greater than 0"); return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark; } @@ -1396,7 +1396,6 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) { while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) { void* key = tSimpleHashGetKey(pIte, &keyLen); uint64_t groupId = *(uint64_t*)key; - ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))); TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); SResultRowPosition* pPos = (SResultRowPosition*)pIte; int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, resWins); @@ -1547,7 +1546,7 @@ static void closeChildIntervalWindow(SOperatorInfo* pOperator, SArray* pChildren for (int32_t i = 0; i < size; i++) { SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); SStreamIntervalOperatorInfo* pChInfo = pChildOp->info; - ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE); + ASSERTS(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE, "children trigger type should be at once"); pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); closeStreamIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL, NULL, pOperator); @@ -1767,8 +1766,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh .maxTs = INT64_MIN, }; - ASSERT(as.calTrigger != STREAM_TRIGGER_MAX_DELAY); - pInfo->win = pTaskInfo->window; pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; @@ -2252,7 +2249,6 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB return; } blockDataEnsureCapacity(pBlock, size - (*pIndex)); - ASSERT(3 <= taosArrayGetSize(pBlock->pDataBlock)); SColumnInfoData* pStartTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pEndTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); SColumnInfoData* pGroupId = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); @@ -2346,6 +2342,17 @@ void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* buildDataBlockFromGroupRes(pOperator, pState, pBlock, &pOperator->exprSupp, pGroupResInfo); } +static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo, + TSKEY* primaryKeys, int32_t prevPosition) { + int32_t startPos = prevPosition + 1; + if (startPos == pDataBlockInfo->rows) { + startPos = -1; + } else { + *pNext = getFinalTimeWindow(primaryKeys[startPos], pInterval); + } + return startPos; +} + static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t groupId, SHashObj* pUpdatedMap) { SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info; @@ -2359,7 +2366,6 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p SResultRow* pResult = NULL; int32_t forwardRows = 0; - ASSERT(pSDataBlock->pDataBlock != NULL); SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); tsCols = (int64_t*)pColDataInfo->pData; @@ -2456,8 +2462,12 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p } int32_t prevEndPos = (forwardRows - 1) * step + startPos; ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); - startPos = - getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC); + if (IS_FINAL_OP(pInfo)) { + startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos); + } else { + startPos = + getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC); + } if (startPos < 0) { break; } @@ -2482,7 +2492,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes); if (pInfo->pPullDataRes->info.rows != 0) { // process the rest of the data - ASSERT(IS_FINAL_OP(pInfo)); printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pPullDataRes; } @@ -2543,7 +2552,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->numOfDatapack++; printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv"); - ASSERT(pBlock->info.type != STREAM_INVERT); if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA) { pInfo->binfo.pRes->info.type = pBlock->info.type; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || @@ -2633,7 +2641,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes); if (pInfo->pPullDataRes->info.rows != 0) { // process the rest of the data - ASSERT(IS_FINAL_OP(pInfo)); printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pPullDataRes; } @@ -2688,7 +2695,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, .deleteMarkSaved = 0, .calTriggerSaved = 0, }; - ASSERT(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY); + ASSERTS(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay"); pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; initResultSizeInfo(&pOperator->resultInfo, 4096); @@ -2713,7 +2720,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, initStreamFunciton(pOperator->exprSupp.pCtx, pOperator->exprSupp.numOfExprs); - ASSERT(numOfCols > 0); initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState)); @@ -2724,6 +2730,9 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pChildren = NULL; if (numOfChild > 0) { pInfo->pChildren = taosArrayInit(numOfChild, sizeof(void*)); + if (!pInfo->pChildren) { + goto _error; + } for (int32_t i = 0; i < numOfChild; i++) { SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pPhyNode, pTaskInfo, 0); if (pChildOp) { @@ -2746,7 +2755,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, // semi interval operator does not catch result pInfo->isFinal = false; pOperator->name = "StreamSemiIntervalOperator"; - ASSERT(pInfo->aggSup.currentPageId == -1); } if (!IS_FINAL_OP(pInfo) || numOfChild == 0) { @@ -3162,15 +3170,6 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData } } -void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) { - ASSERT(index >= 0 && index < taosArrayGetSize(pWinInfos)); - if (fp) { - void* ptr = taosArrayGet(pWinInfos, index); - fp(ptr); - } - taosArrayRemove(pWinInfos, index); -} - static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result) { SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* startDatas = (TSKEY*)pStartTsCol->pData; @@ -3218,7 +3217,6 @@ static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) { int32_t iter = 0; while ((pIte = tSimpleHashIterate(pStUpdated, pIte, &iter)) != NULL) { void* key = tSimpleHashGetKey(pIte, &keyLen); - ASSERT(keyLen == sizeof(SSessionKey)); taosArrayPush(pUpdated, key); } taosArraySort(pUpdated, sessionKeyCompareAsc); @@ -3279,7 +3277,6 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; int32_t numOfOutput = pSup->numOfExprs; int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); - ASSERT(pInfo->pChildren); for (int32_t i = 0; i < size; i++) { SSessionKey* pWinKey = taosArrayGet(pWinArray, i); @@ -3380,7 +3377,6 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) { void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) { pGroupResInfo->pRows = pArrayList; pGroupResInfo->index = 0; - ASSERT(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); } void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroupResInfo* pGroupResInfo, @@ -4811,7 +4807,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys int32_t code = TSDB_CODE_SUCCESS; int32_t numOfCols = 0; SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols); - ASSERT(numOfCols > 0); SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc); SInterval interval = { @@ -4831,7 +4826,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys .deleteMark = getDeleteMark(pIntervalPhyNode), }; - ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY); + ASSERTS(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay"); pOperator->pTaskInfo = pTaskInfo; pInfo->interval = interval; diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index 484d917069..fd6215e3a1 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -49,7 +49,9 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { } SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) { - ASSERT(fn != NULL); + if (fn == NULL) { + return NULL; + } if (capacity == 0) { capacity = 4; @@ -66,7 +68,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) { pHashObj->equalFp = memcmp; pHashObj->hashFp = fn; - ASSERT((pHashObj->capacity & (pHashObj->capacity - 1)) == 0); pHashObj->hashList = (SHNode **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *)); if (!pHashObj->hashList) { diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 30911887bb..fa0cdb3943 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -800,6 +800,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) { } } + // all sources are completed. if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) { return NULL; } diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 40c75ce6ba..6c88e4d5c8 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -606,6 +606,7 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { } static bool udfdRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER || + code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) { if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 1f761388d1..3d91c20dce 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -198,7 +198,7 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery); SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - const SToken* pSubDbName, bool withMeta); + SToken* pSubDbName, bool withMeta); SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pRealTable, bool withMeta); SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h index 86d98c5515..7b816359f9 100644 --- a/source/libs/parser/inc/parInsertUtil.h +++ b/source/libs/parser/inc/parInsertUtil.h @@ -35,128 +35,27 @@ struct SToken; } \ } while (0) -#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) - -typedef enum EOrderStatus { - ORDER_STATUS_UNKNOWN = 0, - ORDER_STATUS_ORDERED = 1, - ORDER_STATUS_DISORDERED = 2, -} EOrderStatus; - -typedef enum EValStat { - VAL_STAT_HAS = 0x0, // 0 means has val - VAL_STAT_NONE = 0x01, // 1 means no val -} EValStat; - -typedef struct SBoundColumn { - int32_t offset; // all column offset value - int32_t toffset; // first part offset for SDataRow TODO: get offset from STSchema on future - uint8_t valStat; // EValStat. denote if current column bound or not(0 means has val, 1 means no val) -} SBoundColumn; - -typedef struct { - col_id_t schemaColIdx; - col_id_t boundIdx; - col_id_t finalIdx; -} SBoundIdxInfo; - -typedef struct SParsedDataColInfo { - col_id_t numOfCols; - col_id_t numOfBound; - uint16_t flen; // TODO: get from STSchema - uint16_t allNullLen; // TODO: get from STSchema(base on SDataRow) - uint16_t extendedVarLen; - uint16_t boundNullLen; // bound column len with all NULL value(without VarDataOffsetT/SColIdx part) - col_id_t *boundColumns; // bound column idx according to schema - SBoundColumn *cols; - SBoundIdxInfo *colIdxInfo; - int8_t orderStatus; // bound columns -} SParsedDataColInfo; - -typedef struct SInsertParseBaseContext { - SParseContext *pComCxt; - char *pSql; - SMsgBuf msg; -} SInsertParseBaseContext; - -typedef struct SInsertParseSyntaxCxt { - SParseContext *pComCxt; - char *pSql; - SMsgBuf msg; - SParseMetaCache *pMetaCache; -} SInsertParseSyntaxCxt; - -typedef struct SMemParam { - SRowBuilder *rb; - SSchema *schema; - int32_t toffset; - col_id_t colIdx; -} SMemParam; - -typedef struct { - uint8_t rowType; // default is 0, that is SDataRow - int32_t rowSize; -} SMemRowBuilder; - -typedef struct STableDataBlocks { - int8_t tsSource; // where does the UNIX timestamp come from, server or client - bool ordered; // if current rows are ordered or not - int32_t vgId; // virtual group id - int64_t prevTS; // previous timestamp, recorded to decide if the records array is ts ascending - int32_t numOfTables; // number of tables in current submit block - int32_t rowSize; // row size for current table - uint32_t nAllocSize; - uint32_t headerSize; // header for table info (uid, tid, submit metadata) - uint32_t size; - STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to - // avoid to be removed from cache - char *pData; - bool cloned; - int32_t createTbReqLen; - SParsedDataColInfo boundColumnInfo; - SRowBuilder rowBuilder; -} STableDataBlocks; - -int32_t insGetExtendedRowSize(STableDataBlocks *pBlock); -void insGetSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo *spd, col_id_t idx, int32_t *toffset, col_id_t *colIdx); -int32_t insSetBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks *dataBuf, int32_t numOfRows, SMsgBuf *pMsg); -int32_t insSchemaIdxCompar(const void *lhs, const void *rhs); -int32_t insBoundIdxCompar(const void *lhs, const void *rhs); -void insSetBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols); -void insDestroyBlockArrayList(SArray *pDataBlockList); -void insDestroyBlockHashmap(SHashObj *pDataBlockHash); -int32_t insInitRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo); -int32_t insGetDataBlockFromList(SHashObj *pHashList, void *id, int32_t idLen, int32_t size, int32_t startOffset, - int32_t rowSize, STableMeta *pTableMeta, STableDataBlocks **dataBlocks, - SArray *pBlockList, SVCreateTbReq *pCreateTbReq); -int32_t insMergeTableDataBlocks(SHashObj *pHashObj, SArray **pVgDataBlocks); -int32_t insBuildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq); -int32_t insAllocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize); -int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf); -int16_t insFindCol(struct SToken *pColname, int16_t start, int16_t end, SSchema *pSchema); -void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname, - SArray *tagName, uint8_t tagNum, int32_t ttl); -int32_t insMemRowAppend(SMsgBuf *pMsgBuf, const void *value, int32_t len, void *param); -int32_t insCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start); -int32_t insBuildOutput(SHashObj *pVgroupsHashObj, SArray *pVgDataBlocks, SArray **pDataBlocks); -void insDestroyDataBlock(STableDataBlocks *pDataBlock); - typedef struct SVgroupDataCxt { int32_t vgId; SSubmitReq2 *pData; } SVgroupDataCxt; +int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf); +int16_t insFindCol(struct SToken *pColname, int16_t start, int16_t end, SSchema *pSchema); +void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname, + SArray *tagName, uint8_t tagNum, int32_t ttl); int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo); void insCheckTableDataOrder(STableDataCxt *pTableCxt, TSKEY tsKey); int32_t insGetTableDataCxt(SHashObj *pHash, void *id, int32_t idLen, STableMeta *pTableMeta, SVCreateTbReq **pCreateTbReq, STableDataCxt **pTableCxt, bool colMode); -int32_t initTableColSubmitData(STableDataCxt* pTableCxt); +int32_t initTableColSubmitData(STableDataCxt *pTableCxt); int32_t insMergeTableDataCxt(SHashObj *pTableHash, SArray **pVgDataBlocks); int32_t insBuildVgDataBlocks(SHashObj *pVgroupsHashObj, SArray *pVgDataBlocks, SArray **pDataBlocks); void insDestroyTableDataCxtHashMap(SHashObj *pTableCxtHash); void insDestroyVgroupDataCxt(SVgroupDataCxt *pVgCxt); void insDestroyVgroupDataCxtList(SArray *pVgCxtList); void insDestroyVgroupDataCxtHashMap(SHashObj *pVgCxtHash); -void insDestroyTableDataCxt(STableDataCxt* pTableCxt); -void destroyBoundColInfo(SBoundColInfo* pInfo); +void insDestroyTableDataCxt(STableDataCxt *pTableCxt); +void insDestroyBoundColInfo(SBoundColInfo *pInfo); + #endif // TDENGINE_PAR_INSERT_UTIL_H diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index c3873406e3..26f9eb7f75 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -459,14 +459,16 @@ tag_item(A) ::= column_name(B) column_alias(C). tag_item(A) ::= column_name(B) AS column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); } /************************************************ create index ********************************************************/ -cmd ::= CREATE SMA INDEX not_exists_opt(D) +cmd ::= CREATE SMA INDEX not_exists_opt(D) full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } +cmd ::= CREATE INDEX not_exists_opt(D) + full_table_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); } cmd ::= DROP INDEX exists_opt(B) full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); } -index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); } -index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E) +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E) sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); } %type func_list { SNodeList* } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 68b4144ac3..9a4dfe13a7 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1604,8 +1604,11 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, } SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - const SToken* pSubDbName, bool withMeta) { + SToken* pSubDbName, bool withMeta) { CHECK_PARSER_STATUS(pCxt); + if (!checkDbName(pCxt, pSubDbName, true)) { + return NULL; + } SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index 0bb6d90fa9..b5baa54f77 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -348,7 +348,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc } end: - destroyBoundColInfo(&bindTags); + insDestroyBoundColInfo(&bindTags); taosMemoryFree(pCreateTblReq); taosArrayDestroy(tagName); return ret; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 20a9770c5f..582bb466d2 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1466,7 +1466,7 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod } static void resetEnvPreTable(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { - destroyBoundColInfo(&pCxt->tags); + insDestroyBoundColInfo(&pCxt->tags); taosMemoryFreeClear(pStmt->pTableMeta); tdDestroySVCreateTbReq(pStmt->pCreateTblReq); taosMemoryFreeClear(pStmt->pCreateTblReq); @@ -1527,7 +1527,7 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif } static int32_t setStmtInfo(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { - SParsedDataColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags)); + SBoundColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags)); if (NULL == tags) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1937,6 +1937,6 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal QUERY_EXEC_STAGE_SCHEDULE == (*pQuery)->execStage) { code = setRefreshMate(*pQuery); } - destroyBoundColInfo(&context.tags); + insDestroyBoundColInfo(&context.tags); return code; } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index cc2ca48a1f..b3018d63b4 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -22,179 +22,6 @@ #include "tRealloc.h" #include "tdatablock.h" -typedef struct SBlockKeyTuple { - TSKEY skey; - void* payloadAddr; - int16_t index; -} SBlockKeyTuple; - -typedef struct SBlockKeyInfo { - int32_t maxBytesAlloc; - SBlockKeyTuple* pKeyTuple; -} SBlockKeyInfo; - -typedef struct { - int32_t index; - SArray* rowArray; // array of merged rows(mem allocated by tRealloc/free by tFree) - STSchema* pSchema; - int64_t tbUid; // suid for child table, uid for normal table -} SBlockRowMerger; - -static FORCE_INLINE void tdResetSBlockRowMerger(SBlockRowMerger* pMerger) { - if (pMerger) { - pMerger->index = -1; - } -} - -static void tdFreeSBlockRowMerger(SBlockRowMerger* pMerger) { - if (pMerger) { - int32_t size = taosArrayGetSize(pMerger->rowArray); - for (int32_t i = 0; i < size; ++i) { - tFree(*(void**)taosArrayGet(pMerger->rowArray, i)); - } - taosArrayDestroy(pMerger->rowArray); - - taosMemoryFreeClear(pMerger->pSchema); - taosMemoryFree(pMerger); - } -} - -static int32_t rowDataCompar(const void* lhs, const void* rhs) { - TSKEY left = *(TSKEY*)lhs; - TSKEY right = *(TSKEY*)rhs; - if (left == right) { - return 0; - } else { - return left > right ? 1 : -1; - } -} - -static int32_t rowDataComparStable(const void* lhs, const void* rhs) { - TSKEY left = *(TSKEY*)lhs; - TSKEY right = *(TSKEY*)rhs; - if (left == right) { - return ((SBlockKeyTuple*)lhs)->index - ((SBlockKeyTuple*)rhs)->index; - } else { - return left > right ? 1 : -1; - } -} - -int32_t insGetExtendedRowSize(STableDataBlocks* pBlock) { - STableComInfo* pTableInfo = &pBlock->pTableMeta->tableInfo; - ASSERT(pBlock->rowSize == pTableInfo->rowSize); - return pBlock->rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + pBlock->boundColumnInfo.extendedVarLen + - (int32_t)TD_BITMAP_BYTES(pTableInfo->numOfColumns - 1); -} - -void insGetSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo* spd, col_id_t idx, int32_t* toffset, - col_id_t* colIdx) { - col_id_t schemaIdx = 0; - if (IS_DATA_COL_ORDERED(spd)) { - schemaIdx = spd->boundColumns[idx]; - if (TD_IS_TP_ROW_T(rowType)) { - *toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart - *colIdx = schemaIdx; - } else { - *toffset = idx * sizeof(SKvRowIdx); // the offset of SKvRowIdx - *colIdx = idx; - } - } else { - ASSERT(idx == (spd->colIdxInfo + idx)->boundIdx); - schemaIdx = (spd->colIdxInfo + idx)->schemaColIdx; - if (TD_IS_TP_ROW_T(rowType)) { - *toffset = (spd->cols + schemaIdx)->toffset; - *colIdx = schemaIdx; - } else { - *toffset = ((spd->colIdxInfo + idx)->finalIdx) * sizeof(SKvRowIdx); - *colIdx = (spd->colIdxInfo + idx)->finalIdx; - } - } -} - -int32_t insSetBlockInfo(SSubmitBlk* pBlocks, STableDataBlocks* dataBuf, int32_t numOfRows, SMsgBuf* pMsg) { - pBlocks->suid = (TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? 0 : dataBuf->pTableMeta->suid); - pBlocks->uid = dataBuf->pTableMeta->uid; - pBlocks->sversion = dataBuf->pTableMeta->sversion; - pBlocks->schemaLen = dataBuf->createTbReqLen; - - if (pBlocks->numOfRows + numOfRows >= INT32_MAX) { - return buildInvalidOperationMsg(pMsg, "too many rows in sql, total number of rows should be less than INT32_MAX"); - } - pBlocks->numOfRows += numOfRows; - return TSDB_CODE_SUCCESS; -} - -void insSetBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) { - pColList->numOfCols = numOfCols; - pColList->numOfBound = numOfCols; - pColList->orderStatus = ORDER_STATUS_ORDERED; // default is ORDERED for non-bound mode - pColList->boundColumns = taosMemoryCalloc(pColList->numOfCols, sizeof(col_id_t)); - pColList->cols = taosMemoryCalloc(pColList->numOfCols, sizeof(SBoundColumn)); - pColList->colIdxInfo = NULL; - pColList->flen = 0; - pColList->allNullLen = 0; - - int32_t nVar = 0; - for (int32_t i = 0; i < pColList->numOfCols; ++i) { - uint8_t type = pSchema[i].type; - if (i > 0) { - pColList->cols[i].offset = pColList->cols[i - 1].offset + pSchema[i - 1].bytes; - pColList->cols[i].toffset = pColList->flen; - pColList->flen += TYPE_BYTES[type]; - } - switch (type) { - case TSDB_DATA_TYPE_BINARY: - pColList->allNullLen += (VARSTR_HEADER_SIZE + CHAR_BYTES); - ++nVar; - break; - case TSDB_DATA_TYPE_NCHAR: - pColList->allNullLen += (VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); - ++nVar; - break; - default: - break; - } - pColList->boundColumns[i] = i; - } - pColList->allNullLen += pColList->flen; - pColList->boundNullLen = pColList->allNullLen; // default set allNullLen - pColList->extendedVarLen = (uint16_t)(nVar * sizeof(VarDataOffsetT)); -} - -int32_t insSchemaIdxCompar(const void* lhs, const void* rhs) { - uint16_t left = *(uint16_t*)lhs; - uint16_t right = *(uint16_t*)rhs; - - if (left == right) { - return 0; - } else { - return left > right ? 1 : -1; - } -} - -int32_t insBoundIdxCompar(const void* lhs, const void* rhs) { - uint16_t left = *(uint16_t*)POINTER_SHIFT(lhs, sizeof(uint16_t)); - uint16_t right = *(uint16_t*)POINTER_SHIFT(rhs, sizeof(uint16_t)); - - if (left == right) { - return 0; - } else { - return left > right ? 1 : -1; - } -} - -void destroyBoundColumnInfo(void* pBoundInfo) { - if (NULL == pBoundInfo) { - return; - } - - SParsedDataColInfo* pColList = (SParsedDataColInfo*)pBoundInfo; - - taosMemoryFreeClear(pColList->boundColumns); - taosMemoryFreeClear(pColList->cols); - taosMemoryFreeClear(pColList->colIdxInfo); -} - void qDestroyBoundColInfo(void* pInfo) { if (NULL == pInfo) { return; @@ -205,548 +32,6 @@ void qDestroyBoundColInfo(void* pInfo) { taosMemoryFreeClear(pBoundInfo->pColIndex); } -static int32_t createTableDataBlock(size_t defaultSize, int32_t rowSize, int32_t startOffset, STableMeta* pTableMeta, - STableDataBlocks** dataBlocks) { - STableDataBlocks* dataBuf = (STableDataBlocks*)taosMemoryCalloc(1, sizeof(STableDataBlocks)); - if (dataBuf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - dataBuf->nAllocSize = (uint32_t)defaultSize; - dataBuf->headerSize = startOffset; - - // the header size will always be the startOffset value, reserved for the subumit block header - if (dataBuf->nAllocSize <= dataBuf->headerSize) { - dataBuf->nAllocSize = dataBuf->headerSize * 2; - } - - dataBuf->pData = taosMemoryMalloc(dataBuf->nAllocSize); - if (dataBuf->pData == NULL) { - taosMemoryFreeClear(dataBuf); - return TSDB_CODE_OUT_OF_MEMORY; - } - memset(dataBuf->pData, 0, sizeof(SSubmitBlk)); - - dataBuf->pTableMeta = tableMetaDup(pTableMeta); - - SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo; - SSchema* pSchema = getTableColumnSchema(dataBuf->pTableMeta); - insSetBoundColumnInfo(pColInfo, pSchema, dataBuf->pTableMeta->tableInfo.numOfColumns); - - dataBuf->ordered = true; - dataBuf->prevTS = INT64_MIN; - dataBuf->rowSize = rowSize; - dataBuf->size = startOffset; - dataBuf->vgId = dataBuf->pTableMeta->vgId; - - assert(defaultSize > 0 && pTableMeta != NULL && dataBuf->pTableMeta != NULL); - - *dataBlocks = dataBuf; - return TSDB_CODE_SUCCESS; -} - -int32_t insBuildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) { - SEncoder coder = {0}; - char* pBuf; - int32_t len; - - int32_t ret = 0; - tEncodeSize(tEncodeSVCreateTbReq, pCreateTbReq, len, ret); - if (pBlocks->nAllocSize - pBlocks->size < len) { - pBlocks->nAllocSize += len + pBlocks->rowSize; - char* pTmp = taosMemoryRealloc(pBlocks->pData, pBlocks->nAllocSize); - if (pTmp != NULL) { - pBlocks->pData = pTmp; - memset(pBlocks->pData + pBlocks->size, 0, pBlocks->nAllocSize - pBlocks->size); - } else { - pBlocks->nAllocSize -= len + pBlocks->rowSize; - return TSDB_CODE_OUT_OF_MEMORY; - } - } - - pBuf = pBlocks->pData + pBlocks->size; - - tEncoderInit(&coder, pBuf, len); - int32_t code = tEncodeSVCreateTbReq(&coder, pCreateTbReq); - tEncoderClear(&coder); - pBlocks->size += len; - pBlocks->createTbReqLen = len; - - return code; -} - -void insDestroyDataBlock(STableDataBlocks* pDataBlock) { - if (pDataBlock == NULL) { - return; - } - - taosMemoryFreeClear(pDataBlock->pData); - taosMemoryFreeClear(pDataBlock->pTableMeta); - destroyBoundColumnInfo(&pDataBlock->boundColumnInfo); - taosMemoryFreeClear(pDataBlock); -} - -int32_t insGetDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset, - int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, - SArray* pBlockList, SVCreateTbReq* pCreateTbReq) { - *dataBlocks = NULL; - STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)id, idLen); - if (t1 != NULL) { - *dataBlocks = *t1; - } - - if (*dataBlocks == NULL) { - int32_t ret = createTableDataBlock((size_t)size, rowSize, startOffset, pTableMeta, dataBlocks); - if (ret != TSDB_CODE_SUCCESS) { - return ret; - } - - if (NULL != pCreateTbReq && NULL != pCreateTbReq->ctb.pTag) { - ret = insBuildCreateTbMsg(*dataBlocks, pCreateTbReq); - if (ret != TSDB_CODE_SUCCESS) { - insDestroyDataBlock(*dataBlocks); - return ret; - } - } - - // converting to 'const char*' is to handle coverity scan errors - taosHashPut(pHashList, (const char*)id, idLen, (const char*)dataBlocks, POINTER_BYTES); - if (pBlockList) { - taosArrayPush(pBlockList, dataBlocks); - } - } - - return TSDB_CODE_SUCCESS; -} - -void insDestroyBlockArrayList(SArray* pDataBlockList) { - if (pDataBlockList == NULL) { - return; - } - - size_t size = taosArrayGetSize(pDataBlockList); - for (int32_t i = 0; i < size; i++) { - void* p = taosArrayGetP(pDataBlockList, i); - insDestroyDataBlock(p); - } - - taosArrayDestroy(pDataBlockList); -} - -void insDestroyBlockHashmap(SHashObj* pDataBlockHash) { - if (pDataBlockHash == NULL) { - return; - } - - void** p1 = taosHashIterate(pDataBlockHash, NULL); - while (p1) { - SBoundColInfo* pBlocks = *p1; - destroyBoundColInfo(pBlocks); - - p1 = taosHashIterate(pDataBlockHash, p1); - } - - taosHashCleanup(pDataBlockHash); -} - -// data block is disordered, sort it in ascending order -static int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKeyInfo) { - SSubmitBlk* pBlocks = (SSubmitBlk*)dataBuf->pData; - int16_t nRows = pBlocks->numOfRows; - - // size is less than the total size, since duplicated rows may be removed yet. - - // allocate memory - size_t nAlloc = nRows * sizeof(SBlockKeyTuple); - if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) { - char* tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple*)tmp; - pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc; - } - memset(pBlkKeyInfo->pKeyTuple, 0, nAlloc); - - int32_t extendedRowSize = insGetExtendedRowSize(dataBuf); - SBlockKeyTuple* pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - char* pBlockData = pBlocks->data + pBlocks->schemaLen; - int n = 0; - while (n < nRows) { - pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData); - pBlkKeyTuple->payloadAddr = pBlockData; - pBlkKeyTuple->index = n; - - // next loop - pBlockData += extendedRowSize; - ++pBlkKeyTuple; - ++n; - } - - if (!dataBuf->ordered) { - pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - - // todo. qsort is unstable, if timestamp is same, should get the last one - taosSort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable); - - pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - int32_t i = 0; - int32_t j = 1; - while (j < nRows) { - TSKEY ti = (pBlkKeyTuple + i)->skey; - TSKEY tj = (pBlkKeyTuple + j)->skey; - - if (ti == tj) { - ++j; - continue; - } - - int32_t nextPos = (++i); - if (nextPos != j) { - memmove(pBlkKeyTuple + nextPos, pBlkKeyTuple + j, sizeof(SBlockKeyTuple)); - } - ++j; - } - - dataBuf->ordered = true; - pBlocks->numOfRows = i + 1; - } - - dataBuf->size = sizeof(SSubmitBlk) + pBlocks->numOfRows * extendedRowSize; - dataBuf->prevTS = INT64_MIN; - - return 0; -} - -static void* tdGetCurRowFromBlockMerger(SBlockRowMerger* pBlkRowMerger) { - if (pBlkRowMerger && (pBlkRowMerger->index >= 0)) { - ASSERT(pBlkRowMerger->index < taosArrayGetSize(pBlkRowMerger->rowArray)); - return *(void**)taosArrayGet(pBlkRowMerger->rowArray, pBlkRowMerger->index); - } - return NULL; -} - -static int32_t tdBlockRowMerge(STableMeta* pTableMeta, SBlockKeyTuple* pEndKeyTp, int32_t nDupRows, - SBlockRowMerger** pBlkRowMerger, int32_t rowSize) { - ASSERT(nDupRows > 1); - SBlockKeyTuple* pStartKeyTp = pEndKeyTp - (nDupRows - 1); - ASSERT(pStartKeyTp->skey == pEndKeyTp->skey); - - // TODO: optimization if end row is all normal -#if 0 - STSRow* pEndRow = (STSRow*)pEndKeyTp->payloadAddr; - if(isNormal(pEndRow)) { // set the end row if it is normal and return directly - pStartKeyTp->payloadAddr = pEndKeyTp->payloadAddr; - return TSDB_CODE_SUCCESS; - } -#endif - - if (!(*pBlkRowMerger)) { - (*pBlkRowMerger) = taosMemoryCalloc(1, sizeof(**pBlkRowMerger)); - if (!(*pBlkRowMerger)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } - (*pBlkRowMerger)->index = -1; - if (!(*pBlkRowMerger)->rowArray) { - (*pBlkRowMerger)->rowArray = taosArrayInit(1, sizeof(void*)); - if (!(*pBlkRowMerger)->rowArray) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } - } - } - - if ((*pBlkRowMerger)->pSchema) { - if ((*pBlkRowMerger)->pSchema->version != pTableMeta->sversion) { - taosMemoryFreeClear((*pBlkRowMerger)->pSchema); - } else { - if ((*pBlkRowMerger)->tbUid != (pTableMeta->suid > 0 ? pTableMeta->suid : pTableMeta->uid)) { - taosMemoryFreeClear((*pBlkRowMerger)->pSchema); - } - } - } - - if (!(*pBlkRowMerger)->pSchema) { - (*pBlkRowMerger)->pSchema = - tBuildTSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->sversion); - - if (!(*pBlkRowMerger)->pSchema) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } - (*pBlkRowMerger)->tbUid = pTableMeta->suid > 0 ? pTableMeta->suid : pTableMeta->uid; - } - - void* pDestRow = NULL; - ++((*pBlkRowMerger)->index); - if ((*pBlkRowMerger)->index < taosArrayGetSize((*pBlkRowMerger)->rowArray)) { - void** pAlloc = (void**)taosArrayGet((*pBlkRowMerger)->rowArray, (*pBlkRowMerger)->index); - if (tRealloc((uint8_t**)pAlloc, rowSize) != 0) { - return TSDB_CODE_FAILED; - } - pDestRow = *pAlloc; - } else { - if (tRealloc((uint8_t**)&pDestRow, rowSize) != 0) { - return TSDB_CODE_FAILED; - } - taosArrayPush((*pBlkRowMerger)->rowArray, &pDestRow); - } - - // merge rows to pDestRow - STSchema* pSchema = (*pBlkRowMerger)->pSchema; - SArray* pArray = taosArrayInit(pSchema->numOfCols, sizeof(SColVal)); - for (int32_t i = 0; i < pSchema->numOfCols; ++i) { - SColVal colVal = {0}; - for (int32_t j = 0; j < nDupRows; ++j) { - tTSRowGetVal((pEndKeyTp - j)->payloadAddr, pSchema, i, &colVal); - if (!COL_VAL_IS_NONE(&colVal)) { - break; - } - } - taosArrayPush(pArray, &colVal); - } - if (tdSTSRowNew(pArray, pSchema, (STSRow**)&pDestRow) < 0) { - taosArrayDestroy(pArray); - return TSDB_CODE_FAILED; - } - - taosArrayDestroy(pArray); - return TSDB_CODE_SUCCESS; -} - -// data block is disordered, sort it in ascending order, and merge dup rows if exists -static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKeyInfo, - SBlockRowMerger** ppBlkRowMerger) { - SSubmitBlk* pBlocks = (SSubmitBlk*)dataBuf->pData; - STableMeta* pTableMeta = dataBuf->pTableMeta; - int32_t nRows = pBlocks->numOfRows; - - // size is less than the total size, since duplicated rows may be removed. - - // allocate memory - size_t nAlloc = nRows * sizeof(SBlockKeyTuple); - if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) { - char* tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple*)tmp; - pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc; - } - memset(pBlkKeyInfo->pKeyTuple, 0, nAlloc); - - tdResetSBlockRowMerger(*ppBlkRowMerger); - - int32_t extendedRowSize = insGetExtendedRowSize(dataBuf); - SBlockKeyTuple* pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - char* pBlockData = pBlocks->data + pBlocks->schemaLen; - int32_t n = 0; - while (n < nRows) { - pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData); - pBlkKeyTuple->payloadAddr = pBlockData; - pBlkKeyTuple->index = n; - - // next loop - pBlockData += extendedRowSize; - ++pBlkKeyTuple; - ++n; - } - - if (!dataBuf->ordered) { - pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - - taosSort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable); - - pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; - bool hasDup = false; - int32_t nextPos = 0; - int32_t i = 0; - int32_t j = 1; - - while (j < nRows) { - TSKEY ti = (pBlkKeyTuple + i)->skey; - TSKEY tj = (pBlkKeyTuple + j)->skey; - - if (ti == tj) { - ++j; - continue; - } - - if ((j - i) > 1) { - if (tdBlockRowMerge(pTableMeta, (pBlkKeyTuple + j - 1), j - i, ppBlkRowMerger, extendedRowSize) < 0) { - return TSDB_CODE_FAILED; - } - (pBlkKeyTuple + nextPos)->payloadAddr = tdGetCurRowFromBlockMerger(*ppBlkRowMerger); - if (!hasDup) { - hasDup = true; - } - i = j; - } else { - if (hasDup) { - memmove(pBlkKeyTuple + nextPos, pBlkKeyTuple + i, sizeof(SBlockKeyTuple)); - } - ++i; - } - - ++nextPos; - ++j; - } - - if ((j - i) > 1) { - ASSERT((pBlkKeyTuple + i)->skey == (pBlkKeyTuple + j - 1)->skey); - if (tdBlockRowMerge(pTableMeta, (pBlkKeyTuple + j - 1), j - i, ppBlkRowMerger, extendedRowSize) < 0) { - return TSDB_CODE_FAILED; - } - (pBlkKeyTuple + nextPos)->payloadAddr = tdGetCurRowFromBlockMerger(*ppBlkRowMerger); - } else if (hasDup) { - memmove(pBlkKeyTuple + nextPos, pBlkKeyTuple + i, sizeof(SBlockKeyTuple)); - } - - dataBuf->ordered = true; - pBlocks->numOfRows = nextPos + 1; - } - - dataBuf->size = sizeof(SSubmitBlk) + pBlocks->numOfRows * extendedRowSize; - dataBuf->prevTS = INT64_MIN; - - return TSDB_CODE_SUCCESS; -} - -// Erase the empty space reserved for binary data -static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SBlockKeyTuple* blkKeyTuple) { - // TODO: optimize this function, handle the case while binary is not presented - int32_t nonDataLen = sizeof(SSubmitBlk) + pTableDataBlock->createTbReqLen; - SSubmitBlk* pBlock = pDataBlock; - memcpy(pDataBlock, pTableDataBlock->pData, nonDataLen); - pDataBlock = (char*)pDataBlock + nonDataLen; - - pBlock->schemaLen = pTableDataBlock->createTbReqLen; - pBlock->dataLen = 0; - - int32_t numOfRows = pBlock->numOfRows; - for (int32_t i = 0; i < numOfRows; ++i) { - void* payload = (blkKeyTuple + i)->payloadAddr; - TDRowLenT rowTLen = TD_ROW_LEN((STSRow*)payload); - memcpy(pDataBlock, payload, rowTLen); - pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); - pBlock->dataLen += rowTLen; - } - - return pBlock->dataLen + pBlock->schemaLen; -} - -int32_t insMergeTableDataBlocks(SHashObj* pHashObj, SArray** pVgDataBlocks) { - const int INSERT_HEAD_SIZE = sizeof(SSubmitReq); - int code = 0; - SHashObj* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false); - SArray* pVnodeDataBlockList = taosArrayInit(8, POINTER_BYTES); - - STableDataBlocks** p = taosHashIterate(pHashObj, NULL); - STableDataBlocks* pOneTableBlock = *p; - SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock - SBlockRowMerger* pBlkRowMerger = NULL; - - while (pOneTableBlock) { - SSubmitBlk* pBlocks = (SSubmitBlk*)pOneTableBlock->pData; - if (pBlocks->numOfRows > 0) { - STableDataBlocks* dataBuf = NULL; - pOneTableBlock->pTableMeta->vgId = pOneTableBlock->vgId; // for schemaless, restore origin vgId - int32_t ret = insGetDataBlockFromList(pVnodeDataBlockHashList, &pOneTableBlock->vgId, - sizeof(pOneTableBlock->vgId), TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0, - pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList, NULL); - if (ret != TSDB_CODE_SUCCESS) { - tdFreeSBlockRowMerger(pBlkRowMerger); - taosHashCleanup(pVnodeDataBlockHashList); - insDestroyBlockArrayList(pVnodeDataBlockList); - taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - return ret; - } - ASSERT(pOneTableBlock->pTableMeta->tableInfo.rowSize > 0); - // the maximum expanded size in byte when a row-wise data is converted to SDataRow format - int64_t destSize = dataBuf->size + pOneTableBlock->size + - sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta) + - pOneTableBlock->createTbReqLen; - - if (dataBuf->nAllocSize < destSize) { - dataBuf->nAllocSize = (uint32_t)(destSize * 1.5); - char* tmp = taosMemoryRealloc(dataBuf->pData, dataBuf->nAllocSize); - if (tmp != NULL) { - dataBuf->pData = tmp; - } else { // failed to allocate memory, free already allocated memory and return error code - tdFreeSBlockRowMerger(pBlkRowMerger); - taosHashCleanup(pVnodeDataBlockHashList); - insDestroyBlockArrayList(pVnodeDataBlockList); - taosMemoryFreeClear(dataBuf->pData); - taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - return TSDB_CODE_OUT_OF_MEMORY; - } - } - - if ((code = sortMergeDataBlockDupRows(pOneTableBlock, &blkKeyInfo, &pBlkRowMerger)) != 0) { - tdFreeSBlockRowMerger(pBlkRowMerger); - taosHashCleanup(pVnodeDataBlockHashList); - insDestroyBlockArrayList(pVnodeDataBlockList); - taosMemoryFreeClear(dataBuf->pData); - taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - return code; - } - ASSERT(blkKeyInfo.pKeyTuple != NULL && pBlocks->numOfRows > 0); - - // erase the empty space reserved for binary data - int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, blkKeyInfo.pKeyTuple); - - dataBuf->size += (finalLen + sizeof(SSubmitBlk)); - assert(dataBuf->size <= dataBuf->nAllocSize); - dataBuf->numOfTables += 1; - } - - p = taosHashIterate(pHashObj, p); - if (p == NULL) { - break; - } - - pOneTableBlock = *p; - } - - // free the table data blocks; - tdFreeSBlockRowMerger(pBlkRowMerger); - taosHashCleanup(pVnodeDataBlockHashList); - taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - *pVgDataBlocks = pVnodeDataBlockList; - return TSDB_CODE_SUCCESS; -} - -int32_t insAllocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) { - size_t remain = pDataBlock->nAllocSize - pDataBlock->size; - uint32_t nAllocSizeOld = pDataBlock->nAllocSize; - - // expand the allocated size - if (remain < allSize) { - pDataBlock->nAllocSize = (pDataBlock->size + allSize) * 1.5; - - char* tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize); - if (tmp != NULL) { - pDataBlock->pData = tmp; - memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size); - } else { - // do nothing, if allocate more memory failed - pDataBlock->nAllocSize = nAllocSizeOld; - return TSDB_CODE_OUT_OF_MEMORY; - } - } - - return TSDB_CODE_SUCCESS; -} - -int32_t insInitRowBuilder(SRowBuilder* pBuilder, int16_t schemaVer, SParsedDataColInfo* pColInfo) { - ASSERT(pColInfo->numOfCols > 0 && (pColInfo->numOfBound <= pColInfo->numOfCols)); - tdSRowInit(pBuilder, schemaVer); - tdSRowSetExtendedInfo(pBuilder, pColInfo->numOfCols, pColInfo->numOfBound, pColInfo->flen, pColInfo->allNullLen, - pColInfo->boundNullLen); - return TSDB_CODE_SUCCESS; -} - static char* tableNameGetPosition(SToken* pToken, char target) { bool inEscape = false; bool inQuote = false; @@ -875,98 +160,6 @@ void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, i return; } -int32_t insMemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) { - SMemParam* pa = (SMemParam*)param; - SRowBuilder* rb = pa->rb; - - if (value == NULL) { // it is a null data - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset, pa->colIdx); - return TSDB_CODE_SUCCESS; - } - - if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { - const char* rowEnd = tdRowEnd(rb->pBuf); - STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); - } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { - // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' - int32_t output = 0; - const char* rowEnd = tdRowEnd(rb->pBuf); - if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { - if (errno == E2BIG) { - return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pa->schema->name); - } - char buf[512] = {0}; - snprintf(buf, tListLen(buf), "%s", strerror(errno)); - return buildSyntaxErrMsg(pMsgBuf, buf, value); - } - varDataSetLen(rowEnd, output); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); - } else { - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t insCheckTimestamp(STableDataBlocks* pDataBlocks, const char* start) { - // once the data block is disordered, we do NOT keep previous timestamp any more - if (!pDataBlocks->ordered) { - return TSDB_CODE_SUCCESS; - } - - TSKEY k = *(TSKEY*)start; - if (k <= pDataBlocks->prevTS) { - pDataBlocks->ordered = false; - } - - pDataBlocks->prevTS = k; - return TSDB_CODE_SUCCESS; -} - -static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) { - SSubmitReq* submit = (SSubmitReq*)blocks->pData; - submit->header.vgId = htonl(blocks->vg.vgId); - submit->header.contLen = htonl(blocks->size); - submit->length = submit->header.contLen; - submit->numOfBlocks = htonl(blocks->numOfTables); - SSubmitBlk* blk = (SSubmitBlk*)(submit + 1); - int32_t numOfBlocks = blocks->numOfTables; - while (numOfBlocks--) { - int32_t dataLen = blk->dataLen; - int32_t schemaLen = blk->schemaLen; - blk->uid = htobe64(blk->uid); - blk->suid = htobe64(blk->suid); - blk->sversion = htonl(blk->sversion); - blk->dataLen = htonl(blk->dataLen); - blk->schemaLen = htonl(blk->schemaLen); - blk->numOfRows = htonl(blk->numOfRows); - blk = (SSubmitBlk*)(blk->data + schemaLen + dataLen); - } -} - -int32_t insBuildOutput(SHashObj* pVgroupsHashObj, SArray* pVgDataBlocks, SArray** pDataBlocks) { - size_t numOfVg = taosArrayGetSize(pVgDataBlocks); - *pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); - if (NULL == *pDataBlocks) { - return TSDB_CODE_OUT_OF_MEMORY; - } - for (size_t i = 0; i < numOfVg; ++i) { - STableDataBlocks* src = taosArrayGetP(pVgDataBlocks, i); - SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); - if (NULL == dst) { - return TSDB_CODE_OUT_OF_MEMORY; - } - taosHashGetDup(pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); - dst->numOfTables = src->numOfTables; - dst->size = src->size; - TSWAP(dst->pData, src->pData); - buildMsgHeader(src, dst); - taosArrayPush(*pDataBlocks, &dst); - } - return TSDB_CODE_SUCCESS; -} - static void initBoundCols(int32_t ncols, int16_t* pBoundCols) { for (int32_t i = 0; i < ncols; ++i) { pBoundCols[i] = i; @@ -1010,7 +203,7 @@ void insCheckTableDataOrder(STableDataCxt* pTableCxt, TSKEY tsKey) { return; } -void destroyBoundColInfo(SBoundColInfo* pInfo) { taosMemoryFreeClear(pInfo->pColIndex); } +void insDestroyBoundColInfo(SBoundColInfo* pInfo) { taosMemoryFreeClear(pInfo->pColIndex); } static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreateTbReq, STableDataCxt** pOutput, bool colMode) { @@ -1120,7 +313,7 @@ void insDestroyTableDataCxt(STableDataCxt* pTableCxt) { taosMemoryFreeClear(pTableCxt->pMeta); tDestroyTSchema(pTableCxt->pSchema); - destroyBoundColInfo(&pTableCxt->boundColsInfo); + insDestroyBoundColInfo(&pTableCxt->boundColsInfo); taosArrayDestroyEx(pTableCxt->pValues, destroyColVal); if (pTableCxt->pData) { tDestroySSubmitTbData(pTableCxt->pData, TSDB_MSG_FLG_ENCODE); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 29c3cfc428..a8966dbac5 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4569,8 +4569,89 @@ typedef struct SSampleAstInfo { SNode* pSliding; SNodeList* pPartitionByList; STableMeta* pRollupTableMeta; + bool createSmaIndex; } SSampleAstInfo; +static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { + SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); + if (NULL == pTable) { + return TSDB_CODE_OUT_OF_MEMORY; + } + snprintf(pTable->table.dbName, sizeof(pTable->table.dbName), "%s", pInfo->pDbName); + snprintf(pTable->table.tableName, sizeof(pTable->table.tableName), "%s", pInfo->pTableName); + TSWAP(pTable->pMeta, pInfo->pRollupTableMeta); + *pOutput = (SNode*)pTable; + return TSDB_CODE_SUCCESS; +} + +static int32_t addWstartToSampleProjects(SNodeList* pProjectionList) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pFunc->functionName, "_wstart"); + return nodesListPushFront(pProjectionList, (SNode*)pFunc); +} + +static int32_t addWendToSampleProjects(SNodeList* pProjectionList) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pFunc->functionName, "_wend"); + return nodesListAppend(pProjectionList, (SNode*)pFunc); +} + +static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pFunc->functionName, "_wduration"); + return nodesListAppend(pProjectionList, (SNode*)pFunc); +} + +static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList) { + SNodeList* pProjectionList = pInfo->pFuncs; + pInfo->pFuncs = NULL; + + int32_t code = addWstartToSampleProjects(pProjectionList); + if (TSDB_CODE_SUCCESS == code && pInfo->createSmaIndex) { + code = addWendToSampleProjects(pProjectionList); + if (TSDB_CODE_SUCCESS == code) { + code = addWdurationToSampleProjects(pProjectionList); + } + } + + if (TSDB_CODE_SUCCESS == code) { + SNode* pProject = NULL; + FOREACH(pProject, pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } + *pList = pProjectionList; + } else { + nodesDestroyList(pProjectionList); + } + return code; +} + +static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { + SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); + if (NULL == pInterval) { + return TSDB_CODE_OUT_OF_MEMORY; + } + TSWAP(pInterval->pInterval, pInfo->pInterval); + TSWAP(pInterval->pOffset, pInfo->pOffset); + TSWAP(pInterval->pSliding, pInfo->pSliding); + pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pInterval->pCol) { + nodesDestroyNode((SNode*)pInterval); + return TSDB_CODE_OUT_OF_MEMORY; + } + ((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + strcpy(((SColumnNode*)pInterval->pCol)->colName, ROWTS_PSEUDO_COLUMN_NAME); + *pOutput = (SNode*)pInterval; + return TSDB_CODE_SUCCESS; +} + static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, int32_t* pExprLen) { SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); @@ -4579,48 +4660,18 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch } sprintf(pSelect->stmtName, "%p", pSelect); - SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); - if (NULL == pTable) { - nodesDestroyNode((SNode*)pSelect); - return TSDB_CODE_OUT_OF_MEMORY; + int32_t code = buildTableForSampleAst(pInfo, &pSelect->pFromTable); + if (TSDB_CODE_SUCCESS == code) { + code = buildProjectsForSampleAst(pInfo, &pSelect->pProjectionList); } - snprintf(pTable->table.dbName, sizeof(pTable->table.dbName), "%s", pInfo->pDbName); - snprintf(pTable->table.tableName, sizeof(pTable->table.tableName), "%s", pInfo->pTableName); - TSWAP(pTable->pMeta, pInfo->pRollupTableMeta); - pSelect->pFromTable = (SNode*)pTable; - - TSWAP(pSelect->pProjectionList, pInfo->pFuncs); - SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); - if (NULL == pSelect->pProjectionList || NULL == pFunc) { - nodesDestroyNode((SNode*)pSelect); - return TSDB_CODE_OUT_OF_MEMORY; + if (TSDB_CODE_SUCCESS == code) { + TSWAP(pSelect->pPartitionByList, pInfo->pPartitionByList); + code = buildIntervalForSampleAst(pInfo, &pSelect->pWindow); } - strcpy(pFunc->functionName, "_wstart"); - nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); - SNode* pProject = NULL; - FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } - - TSWAP(pSelect->pPartitionByList, pInfo->pPartitionByList); - - SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); - if (NULL == pInterval) { - nodesDestroyNode((SNode*)pSelect); - return TSDB_CODE_OUT_OF_MEMORY; + if (TSDB_CODE_SUCCESS == code) { + pCxt->createStream = true; + code = translateQuery(pCxt, (SNode*)pSelect); } - pSelect->pWindow = (SNode*)pInterval; - TSWAP(pInterval->pInterval, pInfo->pInterval); - TSWAP(pInterval->pOffset, pInfo->pOffset); - TSWAP(pInterval->pSliding, pInfo->pSliding); - pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN); - if (NULL == pInterval->pCol) { - nodesDestroyNode((SNode*)pSelect); - return TSDB_CODE_OUT_OF_MEMORY; - } - ((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID; - strcpy(((SColumnNode*)pInterval->pCol)->colName, ROWTS_PSEUDO_COLUMN_NAME); - - pCxt->createStream = true; - int32_t code = translateQuery(pCxt, (SNode*)pSelect); if (TSDB_CODE_SUCCESS == code) { code = nodesNodeToString((SNode*)pSelect, false, pAst, pLen); } @@ -5162,6 +5213,7 @@ static int32_t getSmaIndexSql(STranslateContext* pCxt, char** pSql, int32_t* pLe } static int32_t buildSampleAstInfoByIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SSampleAstInfo* pInfo) { + pInfo->createSmaIndex = true; pInfo->pDbName = pStmt->dbName; pInfo->pTableName = pStmt->tableName; pInfo->pFuncs = nodesCloneList(pStmt->pOptions->pFuncs); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 123d7e8c5a..28c5c45673 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -139,6 +139,7 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 +<<<<<<< HEAD #define YYNSTATE 717 #define YYNRULE 546 #define YYNTOKEN 325 @@ -150,6 +151,19 @@ typedef union { #define YY_NO_ACTION 1612 #define YY_MIN_REDUCE 1613 #define YY_MAX_REDUCE 2158 +======= +#define YYNSTATE 722 +#define YYNRULE 546 +#define YYNTOKEN 325 +#define YY_MAX_SHIFT 721 +#define YY_MIN_SHIFTREDUCE 1069 +#define YY_MAX_SHIFTREDUCE 1614 +#define YY_ERROR_ACTION 1615 +#define YY_ACCEPT_ACTION 1616 +#define YY_NO_ACTION 1617 +#define YY_MIN_REDUCE 1618 +#define YY_MAX_REDUCE 2163 +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -218,6 +232,7 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (3190) static const YYACTIONTYPE yy_action[] = { +<<<<<<< HEAD /* 0 */ 1820, 408, 1756, 1972, 1959, 1881, 463, 356, 464, 1649, /* 10 */ 1959, 1752, 45, 43, 1539, 1955, 1818, 1754, 1879, 593, /* 20 */ 363, 1955, 1389, 38, 37, 522, 1097, 44, 42, 41, @@ -795,6 +810,573 @@ static const YYCODETYPE yy_lookahead[] = { /* 2530 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, /* 2540 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, /* 2550 */ 408, 409, 410, 461, 412, 461, 461, 461, 461, 359, +======= + /* 0 */ 35, 280, 465, 1886, 466, 1654, 474, 372, 466, 1654, + /* 10 */ 1817, 1819, 45, 43, 1544, 1964, 1884, 598, 1760, 471, + /* 20 */ 367, 412, 1394, 38, 37, 467, 1960, 44, 42, 41, + /* 30 */ 40, 39, 172, 1474, 464, 1392, 232, 469, 1660, 1801, + /* 40 */ 576, 610, 38, 37, 2134, 547, 44, 42, 41, 40, + /* 50 */ 39, 8, 610, 338, 1871, 1956, 1962, 349, 1469, 575, + /* 60 */ 178, 324, 190, 18, 2135, 577, 621, 38, 37, 1977, + /* 70 */ 1400, 44, 42, 41, 40, 39, 473, 1420, 588, 469, + /* 80 */ 1660, 38, 37, 45, 43, 44, 42, 41, 40, 39, + /* 90 */ 2139, 367, 174, 1394, 1618, 14, 139, 331, 81, 2036, + /* 100 */ 1995, 80, 60, 27, 1474, 1811, 1392, 1421, 591, 137, + /* 110 */ 162, 1581, 1630, 1946, 611, 627, 48, 718, 128, 127, + /* 120 */ 126, 125, 124, 123, 122, 121, 120, 48, 129, 1469, + /* 130 */ 103, 163, 1476, 1477, 18, 504, 1725, 448, 1503, 1976, + /* 140 */ 64, 1400, 483, 2012, 138, 1771, 106, 1978, 631, 1980, + /* 150 */ 1981, 626, 1763, 621, 1419, 2139, 1824, 149, 175, 2134, + /* 160 */ 2065, 1449, 1459, 355, 361, 2061, 14, 1475, 1478, 260, + /* 170 */ 2073, 587, 1822, 130, 586, 2138, 610, 2134, 180, 2135, + /* 180 */ 2137, 2139, 1395, 1604, 1393, 2134, 2091, 533, 718, 1271, + /* 190 */ 1272, 263, 575, 178, 1504, 194, 193, 2135, 577, 49, + /* 200 */ 531, 2138, 529, 1476, 1477, 2135, 2136, 1398, 1399, 53, + /* 210 */ 1448, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 623, + /* 220 */ 619, 1467, 1468, 1470, 1471, 1472, 1473, 2, 60, 60, + /* 230 */ 89, 60, 1449, 1459, 2080, 1419, 159, 119, 1475, 1478, + /* 240 */ 118, 117, 116, 115, 114, 113, 112, 111, 110, 571, + /* 250 */ 262, 230, 181, 1395, 2080, 1393, 1537, 38, 37, 1641, + /* 260 */ 2077, 44, 42, 41, 40, 39, 34, 365, 1498, 1499, + /* 270 */ 1500, 1501, 1502, 1506, 1507, 1508, 1509, 181, 1398, 1399, + /* 280 */ 2076, 1448, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, + /* 290 */ 623, 619, 1467, 1468, 1470, 1471, 1472, 1473, 2, 401, + /* 300 */ 11, 45, 43, 1946, 1964, 1394, 1548, 1640, 1995, 367, + /* 310 */ 413, 1394, 1419, 86, 326, 1960, 570, 537, 1392, 535, + /* 320 */ 403, 399, 1474, 414, 1392, 1228, 653, 652, 651, 1232, + /* 330 */ 650, 1234, 1235, 649, 1237, 646, 1687, 1243, 643, 1245, + /* 340 */ 1246, 640, 637, 216, 1956, 1962, 362, 1469, 160, 181, + /* 350 */ 406, 1946, 18, 1400, 1824, 621, 569, 1774, 167, 1400, + /* 360 */ 1121, 360, 1120, 665, 500, 496, 492, 488, 213, 1639, + /* 370 */ 1822, 1638, 45, 43, 1479, 215, 1324, 1325, 181, 181, + /* 380 */ 367, 181, 1394, 1824, 14, 44, 42, 41, 40, 39, + /* 390 */ 371, 1122, 552, 1474, 657, 1392, 2134, 1815, 1637, 1822, + /* 400 */ 718, 519, 518, 517, 85, 1102, 718, 211, 1619, 134, + /* 410 */ 513, 2140, 178, 1946, 512, 1946, 2135, 577, 1469, 511, + /* 420 */ 516, 1476, 1477, 1611, 1636, 510, 271, 272, 1400, 119, + /* 430 */ 1400, 270, 118, 117, 116, 115, 114, 113, 112, 111, + /* 440 */ 110, 588, 1946, 1420, 1104, 661, 1107, 1108, 1815, 1886, + /* 450 */ 1449, 1459, 611, 1450, 1824, 46, 1475, 1478, 1121, 358, + /* 460 */ 1120, 335, 1883, 598, 611, 1395, 54, 1393, 1946, 618, + /* 470 */ 1822, 1395, 137, 1393, 210, 204, 1635, 718, 183, 209, + /* 480 */ 38, 37, 479, 1771, 44, 42, 41, 40, 39, 1122, + /* 490 */ 1398, 1399, 1476, 1477, 84, 1771, 1398, 1399, 202, 1448, + /* 500 */ 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 623, 619, + /* 510 */ 1467, 1468, 1470, 1471, 1472, 1473, 2, 1767, 1610, 1421, + /* 520 */ 1946, 1449, 1459, 588, 1188, 1634, 576, 1475, 1478, 611, + /* 530 */ 2134, 590, 176, 2073, 2074, 611, 135, 2078, 1419, 519, + /* 540 */ 518, 517, 1395, 410, 1393, 575, 178, 134, 513, 411, + /* 550 */ 2135, 577, 512, 1633, 137, 1339, 1340, 511, 516, 1190, + /* 560 */ 1771, 1977, 1632, 510, 1818, 1819, 1771, 1398, 1399, 1946, + /* 570 */ 1448, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 623, + /* 580 */ 619, 1467, 1468, 1470, 1471, 1472, 1473, 2, 45, 43, + /* 590 */ 1338, 1341, 1995, 1749, 84, 359, 367, 1946, 1394, 1418, + /* 600 */ 628, 1616, 613, 160, 2037, 1946, 1946, 627, 133, 1474, + /* 610 */ 231, 1392, 1773, 1495, 177, 2073, 2074, 1766, 135, 2078, + /* 620 */ 38, 37, 1977, 2080, 44, 42, 41, 40, 39, 524, + /* 630 */ 566, 1976, 1422, 611, 1469, 2012, 656, 1571, 106, 1978, + /* 640 */ 631, 1980, 1981, 626, 534, 621, 1400, 129, 140, 2075, + /* 650 */ 146, 2036, 2065, 1995, 509, 483, 361, 2061, 229, 45, + /* 660 */ 43, 628, 262, 611, 1771, 382, 1946, 367, 627, 1394, + /* 670 */ 11, 46, 9, 527, 1629, 1371, 1372, 420, 521, 1628, + /* 680 */ 1474, 1824, 1392, 228, 1762, 60, 563, 1569, 1570, 1572, + /* 690 */ 1573, 1933, 1976, 718, 1771, 1960, 2012, 1823, 611, 164, + /* 700 */ 1978, 631, 1980, 1981, 626, 1469, 621, 552, 1476, 1477, + /* 710 */ 1867, 2134, 281, 1627, 572, 567, 561, 1400, 1946, 67, + /* 720 */ 1748, 186, 66, 1946, 1956, 1962, 2140, 178, 1626, 1771, + /* 730 */ 1484, 2135, 577, 13, 12, 621, 1419, 1449, 1459, 389, + /* 740 */ 553, 2102, 14, 1475, 1478, 611, 38, 37, 1505, 1747, + /* 750 */ 44, 42, 41, 40, 39, 31, 172, 1946, 1395, 434, + /* 760 */ 1393, 38, 37, 1867, 718, 44, 42, 41, 40, 39, + /* 770 */ 1967, 405, 1946, 404, 188, 240, 1771, 1422, 1872, 1476, + /* 780 */ 1477, 1746, 1625, 1398, 1399, 1419, 1448, 1451, 1452, 1453, + /* 790 */ 1454, 1455, 1456, 1457, 1458, 623, 619, 1467, 1468, 1470, + /* 800 */ 1471, 1472, 1473, 2, 41, 40, 39, 611, 1449, 1459, + /* 810 */ 323, 665, 1417, 11, 1475, 1478, 370, 97, 1969, 442, + /* 820 */ 32, 435, 455, 580, 160, 454, 1946, 663, 1517, 1395, + /* 830 */ 1510, 1393, 1624, 1773, 1560, 181, 373, 1422, 1771, 1764, + /* 840 */ 426, 1965, 456, 1541, 160, 428, 151, 150, 660, 659, + /* 850 */ 658, 148, 1960, 1773, 1398, 1399, 677, 1448, 1451, 1452, + /* 860 */ 1453, 1454, 1455, 1456, 1457, 1458, 623, 619, 1467, 1468, + /* 870 */ 1470, 1471, 1472, 1473, 2, 1623, 1946, 1450, 515, 514, + /* 880 */ 161, 1956, 1962, 33, 52, 300, 339, 1684, 663, 38, + /* 890 */ 37, 551, 621, 44, 42, 41, 40, 39, 416, 298, + /* 900 */ 70, 2138, 615, 69, 2037, 689, 687, 151, 150, 660, + /* 910 */ 659, 658, 148, 1867, 662, 294, 1756, 1815, 1801, 1946, + /* 920 */ 187, 198, 461, 459, 192, 678, 1450, 1741, 452, 1107, + /* 930 */ 1108, 447, 446, 445, 444, 441, 440, 439, 438, 437, + /* 940 */ 433, 432, 431, 430, 340, 423, 422, 421, 594, 418, + /* 950 */ 417, 337, 695, 694, 693, 692, 377, 60, 691, 690, + /* 960 */ 141, 685, 684, 683, 682, 681, 680, 679, 153, 675, + /* 970 */ 674, 673, 376, 375, 670, 669, 668, 667, 666, 1622, + /* 980 */ 239, 611, 663, 1621, 1758, 611, 380, 1854, 379, 508, + /* 990 */ 552, 2085, 1537, 611, 2134, 481, 105, 1613, 1614, 482, + /* 1000 */ 1977, 151, 150, 660, 659, 658, 148, 1768, 1754, 2140, + /* 1010 */ 178, 507, 1771, 71, 2135, 577, 1771, 50, 143, 3, + /* 1020 */ 131, 583, 221, 1946, 1771, 219, 235, 1946, 552, 611, + /* 1030 */ 552, 1995, 2134, 1403, 2134, 1674, 78, 77, 409, 591, + /* 1040 */ 588, 185, 611, 145, 1946, 581, 627, 2140, 178, 2140, + /* 1050 */ 178, 1631, 2135, 577, 2135, 577, 548, 520, 540, 322, + /* 1060 */ 1771, 611, 397, 79, 395, 391, 387, 384, 381, 622, + /* 1070 */ 1976, 137, 1977, 1771, 2012, 592, 62, 106, 1978, 631, + /* 1080 */ 1980, 1981, 626, 611, 621, 1540, 1402, 223, 244, 175, + /* 1090 */ 222, 2065, 1771, 1667, 655, 361, 2061, 596, 611, 611, + /* 1100 */ 552, 1665, 225, 1995, 2134, 224, 227, 181, 611, 226, + /* 1110 */ 343, 628, 597, 275, 1771, 522, 1946, 2092, 627, 2140, + /* 1120 */ 178, 238, 606, 525, 2135, 577, 1977, 611, 1568, 1771, + /* 1130 */ 1771, 179, 2073, 2074, 149, 135, 2078, 1726, 429, 1771, + /* 1140 */ 246, 608, 1976, 13, 12, 102, 2012, 47, 2105, 106, + /* 1150 */ 1978, 631, 1980, 1981, 626, 99, 621, 1995, 1771, 268, + /* 1160 */ 87, 2154, 579, 2065, 68, 628, 257, 361, 2061, 214, + /* 1170 */ 1946, 344, 627, 342, 341, 147, 506, 564, 2099, 251, + /* 1180 */ 508, 611, 1406, 611, 149, 62, 595, 1977, 47, 47, + /* 1190 */ 1661, 635, 147, 1996, 149, 374, 1976, 609, 378, 1336, + /* 1200 */ 2012, 132, 507, 106, 1978, 631, 1980, 1981, 626, 1876, + /* 1210 */ 621, 273, 1771, 1655, 1771, 2154, 603, 2065, 1995, 1150, + /* 1220 */ 147, 361, 2061, 1812, 2095, 671, 628, 277, 364, 363, + /* 1230 */ 672, 1946, 2112, 627, 589, 1405, 1221, 1511, 1408, 713, + /* 1240 */ 1460, 293, 1, 1249, 1253, 584, 1260, 1169, 259, 1474, + /* 1250 */ 1977, 1401, 1167, 1258, 1151, 256, 4, 1976, 383, 388, + /* 1260 */ 336, 2012, 1358, 288, 106, 1978, 631, 1980, 1981, 626, + /* 1270 */ 1977, 621, 152, 191, 1469, 415, 2154, 1422, 2065, 1877, + /* 1280 */ 419, 1995, 361, 2061, 450, 424, 1400, 1417, 436, 628, + /* 1290 */ 1869, 443, 449, 559, 1946, 451, 627, 457, 195, 458, + /* 1300 */ 460, 1995, 462, 1423, 463, 1425, 475, 201, 472, 628, + /* 1310 */ 1420, 476, 203, 1424, 1946, 1426, 627, 477, 478, 480, + /* 1320 */ 1976, 206, 484, 208, 2012, 82, 83, 106, 1978, 631, + /* 1330 */ 1980, 1981, 626, 617, 621, 212, 1124, 541, 501, 2154, + /* 1340 */ 1976, 2065, 503, 502, 2012, 361, 2061, 106, 1978, 631, + /* 1350 */ 1980, 1981, 626, 505, 621, 1761, 2128, 109, 325, 2154, + /* 1360 */ 218, 2065, 1923, 1922, 1757, 361, 2061, 220, 539, 154, + /* 1370 */ 721, 233, 155, 1977, 1759, 1755, 2084, 156, 157, 542, + /* 1380 */ 289, 236, 549, 543, 287, 546, 2111, 565, 2096, 556, + /* 1390 */ 601, 2110, 562, 2087, 350, 568, 2106, 574, 1409, 171, + /* 1400 */ 1404, 250, 168, 252, 1995, 711, 707, 703, 699, 285, + /* 1410 */ 242, 245, 628, 7, 557, 555, 554, 1946, 1537, 627, + /* 1420 */ 2157, 585, 2133, 1412, 1414, 351, 582, 255, 136, 1421, + /* 1430 */ 593, 253, 1977, 254, 2081, 354, 619, 1467, 1468, 1470, + /* 1440 */ 1471, 1472, 1473, 1976, 290, 104, 264, 2012, 278, 92, + /* 1450 */ 106, 1978, 631, 1980, 1981, 626, 599, 621, 600, 1894, + /* 1460 */ 1893, 1892, 2040, 1995, 2065, 291, 604, 357, 361, 2061, + /* 1470 */ 94, 628, 292, 96, 605, 1772, 1946, 258, 627, 59, + /* 1480 */ 2046, 607, 98, 1816, 633, 295, 1977, 1742, 714, 51, + /* 1490 */ 715, 327, 717, 328, 1940, 319, 284, 299, 1939, 304, + /* 1500 */ 75, 297, 1976, 1938, 1937, 76, 2012, 1934, 385, 106, + /* 1510 */ 1978, 631, 1980, 1981, 626, 266, 621, 1995, 318, 308, + /* 1520 */ 265, 2038, 386, 2065, 1386, 628, 1387, 361, 2061, 390, + /* 1530 */ 1946, 184, 627, 1932, 392, 393, 394, 1365, 1931, 234, + /* 1540 */ 396, 1930, 1929, 398, 400, 1928, 402, 1977, 1361, 1360, + /* 1550 */ 1905, 1904, 407, 408, 1903, 1902, 1976, 1315, 1862, 1861, + /* 1560 */ 2012, 1859, 142, 106, 1978, 631, 1980, 1981, 626, 1858, + /* 1570 */ 621, 1857, 1860, 1856, 1855, 614, 1853, 2065, 1995, 1852, + /* 1580 */ 1851, 361, 2061, 189, 425, 1850, 628, 427, 1849, 1848, + /* 1590 */ 1847, 1946, 1846, 627, 144, 1834, 1833, 1832, 1831, 1830, + /* 1600 */ 1829, 1828, 1827, 1317, 453, 1977, 1845, 1844, 1843, 1842, + /* 1610 */ 1841, 1840, 1839, 1838, 1837, 1836, 1835, 1976, 1826, 1825, + /* 1620 */ 1689, 2012, 1196, 196, 107, 1978, 631, 1980, 1981, 626, + /* 1630 */ 1688, 621, 1686, 197, 1650, 199, 1995, 1110, 2065, 1109, + /* 1640 */ 1649, 1918, 2064, 2061, 628, 1912, 1901, 173, 207, 1946, + /* 1650 */ 1900, 627, 1966, 1880, 1750, 1143, 73, 1685, 1683, 1977, + /* 1660 */ 1681, 1679, 1677, 485, 200, 74, 205, 1664, 468, 470, + /* 1670 */ 487, 489, 493, 497, 491, 1976, 1663, 486, 495, 2012, + /* 1680 */ 1646, 490, 107, 1978, 631, 1980, 1981, 626, 1977, 621, + /* 1690 */ 1995, 494, 498, 1752, 499, 1264, 2065, 1751, 628, 1265, + /* 1700 */ 616, 2061, 1675, 1946, 1187, 627, 1186, 1185, 61, 1184, + /* 1710 */ 686, 1179, 688, 1181, 1180, 1668, 1178, 345, 346, 1995, + /* 1720 */ 523, 1666, 347, 526, 1645, 528, 1644, 625, 1643, 629, + /* 1730 */ 532, 108, 1946, 2012, 627, 1917, 107, 1978, 631, 1980, + /* 1740 */ 1981, 626, 530, 621, 217, 1376, 1977, 1375, 1378, 55, + /* 1750 */ 2065, 536, 1367, 1911, 330, 2061, 544, 1899, 1976, 1897, + /* 1760 */ 26, 2139, 2012, 19, 16, 316, 1978, 631, 1980, 1981, + /* 1770 */ 626, 624, 621, 612, 2030, 558, 560, 1995, 1583, 28, + /* 1780 */ 241, 58, 243, 1567, 248, 628, 166, 247, 249, 29, + /* 1790 */ 1946, 1967, 627, 30, 1559, 20, 63, 17, 88, 1598, + /* 1800 */ 1977, 1603, 1604, 1597, 21, 352, 1602, 56, 1601, 353, + /* 1810 */ 1534, 545, 1533, 261, 237, 1898, 1976, 1896, 1895, 348, + /* 1820 */ 2012, 57, 550, 165, 1978, 631, 1980, 1981, 626, 5, + /* 1830 */ 621, 1995, 158, 6, 169, 1879, 91, 90, 22, 628, + /* 1840 */ 93, 267, 1565, 269, 1946, 274, 627, 65, 1878, 95, + /* 1850 */ 279, 23, 99, 12, 1977, 1410, 2015, 170, 1464, 1462, + /* 1860 */ 620, 182, 36, 1441, 15, 602, 634, 369, 276, 638, + /* 1870 */ 1976, 1461, 1433, 24, 2012, 578, 2155, 107, 1978, 631, + /* 1880 */ 1980, 1981, 626, 25, 621, 1995, 632, 1250, 1247, 636, + /* 1890 */ 639, 2065, 1244, 628, 641, 642, 2062, 644, 1946, 645, + /* 1900 */ 627, 1238, 1236, 1486, 647, 1242, 1977, 10, 648, 1241, + /* 1910 */ 1227, 100, 282, 1259, 101, 654, 1496, 1240, 1239, 1255, + /* 1920 */ 72, 1141, 1977, 664, 1976, 1175, 1174, 630, 2012, 1173, + /* 1930 */ 1172, 164, 1978, 631, 1980, 1981, 626, 1995, 621, 1171, + /* 1940 */ 1170, 1485, 1168, 1166, 1165, 628, 1164, 1194, 676, 1162, + /* 1950 */ 1946, 1161, 627, 1995, 283, 1160, 1159, 1158, 1157, 1156, + /* 1960 */ 1189, 628, 1153, 1191, 1152, 1149, 1946, 1148, 627, 1147, + /* 1970 */ 1146, 1682, 696, 2103, 697, 698, 1976, 1680, 700, 701, + /* 1980 */ 2012, 702, 1678, 310, 1978, 631, 1980, 1981, 626, 704, + /* 1990 */ 621, 706, 1976, 705, 1676, 708, 2012, 709, 710, 165, + /* 2000 */ 1978, 631, 1980, 1981, 626, 1662, 621, 712, 1099, 1642, + /* 2010 */ 286, 1977, 716, 1617, 1396, 296, 719, 720, 1617, 1617, + /* 2020 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 573, 1617, 1977, + /* 2030 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2040 */ 1617, 1617, 1995, 1617, 1617, 1617, 1617, 356, 1617, 1617, + /* 2050 */ 628, 1617, 2156, 1617, 1617, 1946, 1617, 627, 1617, 1617, + /* 2060 */ 1995, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 625, 1617, + /* 2070 */ 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, + /* 2080 */ 1617, 1976, 1617, 1977, 1617, 2012, 1617, 1617, 317, 1978, + /* 2090 */ 631, 1980, 1981, 626, 1617, 621, 1617, 1617, 1617, 1976, + /* 2100 */ 1977, 1617, 1617, 2012, 1617, 1617, 316, 1978, 631, 1980, + /* 2110 */ 1981, 626, 1617, 621, 1995, 2031, 1617, 1617, 1617, 366, + /* 2120 */ 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, + /* 2130 */ 1617, 1995, 1617, 1617, 1617, 1617, 368, 1617, 1617, 628, + /* 2140 */ 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, + /* 2150 */ 1617, 1617, 1977, 1976, 1617, 1617, 1617, 2012, 1617, 1617, + /* 2160 */ 317, 1978, 631, 1980, 1981, 626, 1617, 621, 1977, 1617, + /* 2170 */ 1976, 1617, 1617, 1617, 2012, 1617, 1617, 317, 1978, 631, + /* 2180 */ 1980, 1981, 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, + /* 2190 */ 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, 1995, + /* 2200 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, 1617, + /* 2210 */ 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, 1617, + /* 2220 */ 1977, 1617, 538, 1617, 1617, 1617, 2012, 1617, 1617, 312, + /* 2230 */ 1978, 631, 1980, 1981, 626, 1617, 621, 1617, 1976, 1617, + /* 2240 */ 1617, 1617, 2012, 1617, 1617, 301, 1978, 631, 1980, 1981, + /* 2250 */ 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, 1617, 628, + /* 2260 */ 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, + /* 2270 */ 1617, 1617, 1617, 1617, 1977, 1617, 1617, 1617, 1617, 1617, + /* 2280 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2290 */ 1976, 1617, 1617, 1617, 2012, 1977, 1617, 302, 1978, 631, + /* 2300 */ 1980, 1981, 626, 1617, 621, 1995, 1617, 1617, 1617, 1617, + /* 2310 */ 1617, 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, + /* 2320 */ 627, 1617, 1617, 1617, 1617, 1617, 1995, 1617, 1617, 1617, + /* 2330 */ 1617, 1617, 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, + /* 2340 */ 1617, 627, 1617, 1617, 1976, 1617, 1617, 1617, 2012, 1617, + /* 2350 */ 1617, 303, 1978, 631, 1980, 1981, 626, 1617, 621, 1617, + /* 2360 */ 1617, 1617, 1617, 1617, 1617, 1976, 1617, 1617, 1617, 2012, + /* 2370 */ 1617, 1977, 309, 1978, 631, 1980, 1981, 626, 1617, 621, + /* 2380 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1977, + /* 2390 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2400 */ 1617, 1617, 1995, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2410 */ 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, + /* 2420 */ 1995, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, + /* 2430 */ 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, + /* 2440 */ 1617, 1976, 1617, 1977, 1617, 2012, 1617, 1617, 313, 1978, + /* 2450 */ 631, 1980, 1981, 626, 1617, 621, 1617, 1617, 1617, 1976, + /* 2460 */ 1977, 1617, 1617, 2012, 1617, 1617, 305, 1978, 631, 1980, + /* 2470 */ 1981, 626, 1617, 621, 1995, 1617, 1617, 1617, 1617, 1617, + /* 2480 */ 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, + /* 2490 */ 1617, 1995, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, + /* 2500 */ 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, + /* 2510 */ 1617, 1617, 1977, 1976, 1617, 1617, 1617, 2012, 1617, 1617, + /* 2520 */ 314, 1978, 631, 1980, 1981, 626, 1617, 621, 1977, 1617, + /* 2530 */ 1976, 1617, 1617, 1617, 2012, 1617, 1617, 306, 1978, 631, + /* 2540 */ 1980, 1981, 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, + /* 2550 */ 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, 1995, + /* 2560 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, 1617, + /* 2570 */ 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, 1617, + /* 2580 */ 1977, 1617, 1976, 1617, 1617, 1617, 2012, 1617, 1617, 315, + /* 2590 */ 1978, 631, 1980, 1981, 626, 1617, 621, 1617, 1976, 1617, + /* 2600 */ 1617, 1617, 2012, 1977, 1617, 307, 1978, 631, 1980, 1981, + /* 2610 */ 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, 1617, 628, + /* 2620 */ 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, + /* 2630 */ 1617, 1617, 1617, 1617, 1995, 1617, 1617, 1617, 1617, 1617, + /* 2640 */ 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, + /* 2650 */ 1976, 1617, 1617, 1617, 2012, 1977, 1617, 320, 1978, 631, + /* 2660 */ 1980, 1981, 626, 1617, 621, 1617, 1617, 1617, 1617, 1617, + /* 2670 */ 1617, 1617, 1617, 1976, 1617, 1617, 1617, 2012, 1617, 1617, + /* 2680 */ 321, 1978, 631, 1980, 1981, 626, 1995, 621, 1617, 1617, + /* 2690 */ 1617, 1617, 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, + /* 2700 */ 1617, 627, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2710 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1977, 1617, + /* 2720 */ 1617, 1617, 1617, 1617, 1617, 1976, 1617, 1617, 1617, 2012, + /* 2730 */ 1617, 1617, 1989, 1978, 631, 1980, 1981, 626, 1617, 621, + /* 2740 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1995, + /* 2750 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, 1617, + /* 2760 */ 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, 1617, + /* 2770 */ 1977, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2780 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1976, 1977, + /* 2790 */ 1617, 1617, 2012, 1617, 1617, 1988, 1978, 631, 1980, 1981, + /* 2800 */ 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, 1617, 628, + /* 2810 */ 1617, 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, + /* 2820 */ 1995, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, + /* 2830 */ 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, + /* 2840 */ 1976, 1977, 1617, 1617, 2012, 1617, 1617, 1987, 1978, 631, + /* 2850 */ 1980, 1981, 626, 1617, 621, 1617, 1617, 1977, 1617, 1976, + /* 2860 */ 1617, 1617, 1617, 2012, 1617, 1617, 332, 1978, 631, 1980, + /* 2870 */ 1981, 626, 1995, 621, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2880 */ 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, 1995, 1617, + /* 2890 */ 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, 1617, 1617, + /* 2900 */ 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, 1617, 1977, + /* 2910 */ 1617, 1976, 1617, 1617, 1617, 2012, 1617, 1617, 333, 1978, + /* 2920 */ 631, 1980, 1981, 626, 1617, 621, 1617, 1976, 1617, 1617, + /* 2930 */ 1617, 2012, 1977, 1617, 329, 1978, 631, 1980, 1981, 626, + /* 2940 */ 1995, 621, 1617, 1617, 1617, 1617, 1617, 1617, 628, 1617, + /* 2950 */ 1617, 1617, 1617, 1946, 1617, 627, 1617, 1617, 1617, 1617, + /* 2960 */ 1617, 1617, 1617, 1995, 1617, 1617, 1617, 1617, 1617, 1617, + /* 2970 */ 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, 627, 1976, + /* 2980 */ 1617, 1617, 1617, 2012, 1977, 1617, 334, 1978, 631, 1980, + /* 2990 */ 1981, 626, 1617, 621, 1617, 1617, 1617, 1617, 1617, 1617, + /* 3000 */ 1617, 1617, 629, 1617, 1617, 1617, 2012, 1617, 1617, 312, + /* 3010 */ 1978, 631, 1980, 1981, 626, 1995, 621, 1617, 1617, 1617, + /* 3020 */ 1617, 1617, 1617, 628, 1617, 1617, 1617, 1617, 1946, 1617, + /* 3030 */ 627, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 3040 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, + /* 3050 */ 1617, 1617, 1617, 1617, 1976, 1617, 1617, 1617, 2012, 1617, + /* 3060 */ 1617, 311, 1978, 631, 1980, 1981, 626, 1617, 621, +}; +static const YYCODETYPE yy_lookahead[] = { + /* 0 */ 420, 421, 332, 374, 334, 335, 332, 370, 334, 335, + /* 10 */ 373, 374, 12, 13, 14, 361, 387, 388, 360, 14, + /* 20 */ 20, 336, 22, 8, 9, 20, 372, 12, 13, 14, + /* 30 */ 15, 16, 359, 33, 333, 35, 352, 336, 337, 355, + /* 40 */ 431, 20, 8, 9, 435, 393, 12, 13, 14, 15, + /* 50 */ 16, 39, 20, 380, 381, 401, 402, 403, 58, 450, + /* 60 */ 451, 376, 58, 63, 455, 456, 412, 8, 9, 328, + /* 70 */ 70, 12, 13, 14, 15, 16, 333, 20, 336, 336, + /* 80 */ 337, 8, 9, 12, 13, 12, 13, 14, 15, 16, + /* 90 */ 3, 20, 358, 22, 0, 95, 415, 63, 94, 418, + /* 100 */ 359, 97, 95, 44, 33, 371, 35, 20, 367, 367, + /* 110 */ 327, 96, 329, 372, 336, 374, 95, 117, 24, 25, + /* 120 */ 26, 27, 28, 29, 30, 31, 32, 95, 350, 58, + /* 130 */ 340, 343, 132, 133, 63, 357, 348, 79, 104, 398, + /* 140 */ 4, 70, 62, 402, 354, 367, 405, 406, 407, 408, + /* 150 */ 409, 410, 362, 412, 20, 431, 359, 44, 417, 435, + /* 160 */ 419, 161, 162, 366, 423, 424, 95, 167, 168, 427, + /* 170 */ 428, 429, 375, 431, 432, 451, 20, 435, 437, 455, + /* 180 */ 456, 431, 182, 96, 184, 435, 445, 21, 117, 132, + /* 190 */ 133, 58, 450, 451, 160, 137, 138, 455, 456, 95, + /* 200 */ 34, 451, 36, 132, 133, 455, 456, 207, 208, 96, + /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 95, 95, + /* 230 */ 97, 95, 161, 162, 404, 20, 163, 21, 167, 168, + /* 240 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 20, + /* 250 */ 163, 127, 245, 182, 404, 184, 244, 8, 9, 328, + /* 260 */ 430, 12, 13, 14, 15, 16, 232, 233, 234, 235, + /* 270 */ 236, 237, 238, 239, 240, 241, 242, 245, 207, 208, + /* 280 */ 430, 210, 211, 212, 213, 214, 215, 216, 217, 218, + /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 177, + /* 300 */ 229, 12, 13, 372, 361, 22, 14, 328, 359, 20, + /* 310 */ 22, 22, 20, 189, 190, 372, 367, 193, 35, 195, + /* 320 */ 198, 199, 33, 35, 35, 108, 109, 110, 111, 112, + /* 330 */ 113, 114, 115, 116, 117, 118, 0, 120, 121, 122, + /* 340 */ 123, 124, 125, 33, 401, 402, 403, 58, 359, 245, + /* 350 */ 389, 372, 63, 70, 359, 412, 407, 368, 48, 70, + /* 360 */ 20, 366, 22, 62, 54, 55, 56, 57, 58, 328, + /* 370 */ 375, 328, 12, 13, 14, 35, 161, 162, 245, 245, + /* 380 */ 20, 245, 22, 359, 95, 12, 13, 14, 15, 16, + /* 390 */ 366, 51, 431, 33, 369, 35, 435, 372, 328, 375, + /* 400 */ 117, 65, 66, 67, 94, 4, 117, 97, 0, 73, + /* 410 */ 74, 450, 451, 372, 78, 372, 455, 456, 58, 83, + /* 420 */ 84, 132, 133, 174, 328, 89, 126, 127, 70, 21, + /* 430 */ 70, 131, 24, 25, 26, 27, 28, 29, 30, 31, + /* 440 */ 32, 336, 372, 20, 43, 369, 45, 46, 372, 374, + /* 450 */ 161, 162, 336, 161, 359, 95, 167, 168, 20, 384, + /* 460 */ 22, 366, 387, 388, 336, 182, 350, 184, 372, 63, + /* 470 */ 375, 182, 367, 184, 164, 165, 328, 117, 350, 169, + /* 480 */ 8, 9, 172, 367, 12, 13, 14, 15, 16, 51, + /* 490 */ 207, 208, 132, 133, 342, 367, 207, 208, 188, 210, + /* 500 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + /* 510 */ 221, 222, 223, 224, 225, 226, 227, 365, 269, 20, + /* 520 */ 372, 161, 162, 336, 35, 328, 431, 167, 168, 336, + /* 530 */ 435, 426, 427, 428, 429, 336, 431, 432, 20, 65, + /* 540 */ 66, 67, 182, 350, 184, 450, 451, 73, 74, 350, + /* 550 */ 455, 456, 78, 328, 367, 132, 133, 83, 84, 70, + /* 560 */ 367, 328, 328, 89, 373, 374, 367, 207, 208, 372, + /* 570 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 580 */ 220, 221, 222, 223, 224, 225, 226, 227, 12, 13, + /* 590 */ 167, 168, 359, 0, 342, 351, 20, 372, 22, 20, + /* 600 */ 367, 325, 416, 359, 418, 372, 372, 374, 356, 33, + /* 610 */ 126, 35, 368, 207, 427, 428, 429, 365, 431, 432, + /* 620 */ 8, 9, 328, 404, 12, 13, 14, 15, 16, 4, + /* 630 */ 166, 398, 20, 336, 58, 402, 106, 207, 405, 406, + /* 640 */ 407, 408, 409, 410, 19, 412, 70, 350, 415, 430, + /* 650 */ 417, 418, 419, 359, 357, 62, 423, 424, 33, 12, + /* 660 */ 13, 367, 163, 336, 367, 389, 372, 20, 374, 22, + /* 670 */ 229, 95, 231, 48, 328, 191, 192, 350, 53, 328, + /* 680 */ 33, 359, 35, 58, 361, 95, 256, 257, 258, 259, + /* 690 */ 260, 0, 398, 117, 367, 372, 402, 375, 336, 405, + /* 700 */ 406, 407, 408, 409, 410, 58, 412, 431, 132, 133, + /* 710 */ 367, 435, 350, 328, 250, 251, 252, 70, 372, 94, + /* 720 */ 0, 378, 97, 372, 401, 402, 450, 451, 328, 367, + /* 730 */ 14, 455, 456, 1, 2, 412, 20, 161, 162, 48, + /* 740 */ 446, 447, 95, 167, 168, 336, 8, 9, 160, 0, + /* 750 */ 12, 13, 14, 15, 16, 2, 359, 372, 182, 350, + /* 760 */ 184, 8, 9, 367, 117, 12, 13, 14, 15, 16, + /* 770 */ 47, 181, 372, 183, 378, 163, 367, 20, 381, 132, + /* 780 */ 133, 0, 328, 207, 208, 20, 210, 211, 212, 213, + /* 790 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + /* 800 */ 224, 225, 226, 227, 14, 15, 16, 336, 161, 162, + /* 810 */ 18, 62, 20, 229, 167, 168, 351, 340, 95, 27, + /* 820 */ 232, 350, 30, 44, 359, 33, 372, 107, 96, 182, + /* 830 */ 242, 184, 328, 368, 96, 245, 351, 20, 367, 362, + /* 840 */ 48, 361, 50, 4, 359, 53, 126, 127, 128, 129, + /* 850 */ 130, 131, 372, 368, 207, 208, 70, 210, 211, 212, + /* 860 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + /* 870 */ 223, 224, 225, 226, 227, 328, 372, 161, 345, 346, + /* 880 */ 18, 401, 402, 2, 163, 23, 94, 0, 107, 8, + /* 890 */ 9, 170, 412, 12, 13, 14, 15, 16, 106, 37, + /* 900 */ 38, 3, 416, 41, 418, 345, 346, 126, 127, 128, + /* 910 */ 129, 130, 131, 367, 369, 352, 360, 372, 355, 372, + /* 920 */ 163, 59, 60, 61, 378, 347, 161, 349, 136, 45, + /* 930 */ 46, 139, 140, 141, 142, 143, 144, 145, 146, 147, + /* 940 */ 148, 149, 150, 151, 152, 153, 154, 155, 389, 157, + /* 950 */ 158, 159, 65, 66, 67, 68, 69, 95, 71, 72, + /* 960 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + /* 970 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 328, + /* 980 */ 163, 336, 107, 328, 360, 336, 389, 0, 389, 107, + /* 990 */ 431, 243, 244, 336, 435, 350, 134, 132, 133, 350, + /* 1000 */ 328, 126, 127, 128, 129, 130, 131, 350, 360, 450, + /* 1010 */ 451, 129, 367, 106, 455, 456, 367, 42, 42, 44, + /* 1020 */ 44, 44, 99, 372, 367, 102, 360, 372, 431, 336, + /* 1030 */ 431, 359, 435, 35, 435, 0, 174, 175, 176, 367, + /* 1040 */ 336, 179, 336, 350, 372, 266, 374, 450, 451, 450, + /* 1050 */ 451, 329, 455, 456, 455, 456, 350, 22, 389, 197, + /* 1060 */ 367, 336, 200, 156, 202, 203, 204, 205, 206, 360, + /* 1070 */ 398, 367, 328, 367, 402, 350, 44, 405, 406, 407, + /* 1080 */ 408, 409, 410, 336, 412, 246, 35, 99, 44, 417, + /* 1090 */ 102, 419, 367, 0, 360, 423, 424, 350, 336, 336, + /* 1100 */ 431, 0, 99, 359, 435, 102, 99, 245, 336, 102, + /* 1110 */ 37, 367, 350, 350, 367, 22, 372, 445, 374, 450, + /* 1120 */ 451, 58, 350, 22, 455, 456, 328, 336, 96, 367, + /* 1130 */ 367, 427, 428, 429, 44, 431, 432, 348, 151, 367, + /* 1140 */ 96, 350, 398, 1, 2, 95, 402, 44, 382, 405, + /* 1150 */ 406, 407, 408, 409, 410, 105, 412, 359, 367, 44, + /* 1160 */ 97, 417, 264, 419, 44, 367, 459, 423, 424, 338, + /* 1170 */ 372, 98, 374, 100, 101, 44, 103, 448, 434, 442, + /* 1180 */ 107, 336, 184, 336, 44, 44, 96, 328, 44, 44, + /* 1190 */ 0, 44, 44, 359, 44, 350, 398, 350, 338, 96, + /* 1200 */ 402, 44, 129, 405, 406, 407, 408, 409, 410, 382, + /* 1210 */ 412, 96, 367, 335, 367, 417, 96, 419, 359, 35, + /* 1220 */ 44, 423, 424, 371, 382, 13, 367, 96, 12, 13, + /* 1230 */ 13, 372, 434, 374, 433, 184, 96, 96, 22, 49, + /* 1240 */ 96, 96, 436, 96, 96, 268, 96, 35, 452, 33, + /* 1250 */ 328, 35, 35, 96, 70, 425, 247, 398, 400, 48, + /* 1260 */ 399, 402, 180, 391, 405, 406, 407, 408, 409, 410, + /* 1270 */ 328, 412, 96, 42, 58, 379, 417, 20, 419, 382, + /* 1280 */ 379, 359, 423, 424, 160, 377, 70, 20, 336, 367, + /* 1290 */ 336, 379, 377, 434, 372, 377, 374, 93, 336, 344, + /* 1300 */ 336, 359, 336, 20, 330, 20, 395, 342, 330, 367, + /* 1310 */ 20, 374, 342, 20, 372, 20, 374, 337, 390, 337, + /* 1320 */ 398, 342, 336, 342, 402, 342, 342, 405, 406, 407, + /* 1330 */ 408, 409, 410, 117, 412, 342, 52, 397, 339, 417, + /* 1340 */ 398, 419, 330, 339, 402, 423, 424, 405, 406, 407, + /* 1350 */ 408, 409, 410, 359, 412, 359, 434, 336, 330, 417, + /* 1360 */ 359, 419, 372, 372, 359, 423, 424, 359, 196, 359, + /* 1370 */ 19, 340, 359, 328, 359, 359, 434, 359, 359, 187, + /* 1380 */ 395, 340, 336, 394, 33, 374, 441, 255, 382, 372, + /* 1390 */ 254, 441, 372, 444, 372, 372, 382, 173, 182, 48, + /* 1400 */ 184, 443, 441, 440, 359, 54, 55, 56, 57, 58, + /* 1410 */ 385, 385, 367, 261, 263, 262, 248, 372, 244, 374, + /* 1420 */ 460, 267, 454, 207, 208, 270, 265, 400, 367, 20, + /* 1430 */ 336, 439, 328, 438, 404, 337, 220, 221, 222, 223, + /* 1440 */ 224, 225, 226, 398, 385, 94, 340, 402, 97, 340, + /* 1450 */ 405, 406, 407, 408, 409, 410, 372, 412, 372, 372, + /* 1460 */ 372, 372, 417, 359, 419, 385, 165, 372, 423, 424, + /* 1470 */ 340, 367, 355, 340, 383, 367, 372, 453, 374, 95, + /* 1480 */ 422, 130, 95, 372, 363, 336, 328, 349, 36, 392, + /* 1490 */ 331, 386, 330, 386, 0, 396, 340, 326, 0, 353, + /* 1500 */ 189, 341, 398, 0, 0, 42, 402, 0, 35, 405, + /* 1510 */ 406, 407, 408, 409, 410, 164, 412, 359, 353, 353, + /* 1520 */ 169, 417, 201, 419, 35, 367, 35, 423, 424, 201, + /* 1530 */ 372, 35, 374, 0, 35, 35, 201, 186, 0, 188, + /* 1540 */ 201, 0, 0, 35, 22, 0, 35, 328, 184, 182, + /* 1550 */ 0, 0, 178, 177, 0, 0, 398, 47, 0, 0, + /* 1560 */ 402, 0, 42, 405, 406, 407, 408, 409, 410, 0, + /* 1570 */ 412, 0, 0, 0, 0, 417, 0, 419, 359, 0, + /* 1580 */ 0, 423, 424, 151, 35, 0, 367, 151, 0, 0, + /* 1590 */ 0, 372, 0, 374, 42, 0, 0, 0, 0, 0, + /* 1600 */ 0, 0, 0, 22, 135, 328, 0, 0, 0, 0, + /* 1610 */ 0, 0, 0, 0, 0, 0, 0, 398, 0, 0, + /* 1620 */ 0, 402, 35, 58, 405, 406, 407, 408, 409, 410, + /* 1630 */ 0, 412, 0, 58, 0, 42, 359, 14, 419, 14, + /* 1640 */ 0, 0, 423, 424, 367, 0, 0, 44, 173, 372, + /* 1650 */ 0, 374, 47, 0, 0, 64, 39, 0, 0, 328, + /* 1660 */ 0, 0, 0, 35, 40, 39, 39, 0, 47, 47, + /* 1670 */ 39, 35, 35, 35, 39, 398, 0, 48, 39, 402, + /* 1680 */ 0, 48, 405, 406, 407, 408, 409, 410, 328, 412, + /* 1690 */ 359, 48, 48, 0, 39, 22, 419, 0, 367, 35, + /* 1700 */ 423, 424, 0, 372, 35, 374, 35, 35, 104, 35, + /* 1710 */ 44, 22, 44, 35, 35, 0, 35, 22, 22, 359, + /* 1720 */ 50, 0, 22, 35, 0, 35, 0, 367, 0, 398, + /* 1730 */ 22, 20, 372, 402, 374, 0, 405, 406, 407, 408, + /* 1740 */ 409, 410, 35, 412, 102, 35, 328, 35, 96, 163, + /* 1750 */ 419, 194, 35, 0, 423, 424, 22, 0, 398, 0, + /* 1760 */ 95, 3, 402, 44, 249, 405, 406, 407, 408, 409, + /* 1770 */ 410, 411, 412, 413, 414, 228, 253, 359, 96, 95, + /* 1780 */ 95, 44, 96, 96, 44, 367, 95, 95, 47, 95, + /* 1790 */ 372, 47, 374, 44, 96, 249, 3, 249, 95, 35, + /* 1800 */ 328, 96, 96, 35, 44, 35, 35, 243, 35, 35, + /* 1810 */ 96, 163, 96, 47, 165, 0, 398, 0, 0, 163, + /* 1820 */ 402, 44, 171, 405, 406, 407, 408, 409, 410, 170, + /* 1830 */ 412, 359, 185, 170, 47, 0, 39, 95, 95, 367, + /* 1840 */ 39, 96, 96, 95, 372, 95, 374, 95, 0, 95, + /* 1850 */ 47, 44, 105, 2, 328, 22, 95, 47, 96, 96, + /* 1860 */ 95, 47, 95, 22, 95, 166, 35, 35, 164, 35, + /* 1870 */ 398, 96, 96, 95, 402, 457, 458, 405, 406, 407, + /* 1880 */ 408, 409, 410, 95, 412, 359, 106, 96, 96, 95, + /* 1890 */ 95, 419, 96, 367, 35, 95, 424, 35, 372, 95, + /* 1900 */ 374, 96, 96, 228, 35, 119, 328, 230, 95, 119, + /* 1910 */ 22, 95, 44, 35, 95, 107, 207, 119, 119, 22, + /* 1920 */ 95, 64, 328, 63, 398, 35, 35, 209, 402, 35, + /* 1930 */ 35, 405, 406, 407, 408, 409, 410, 359, 412, 35, + /* 1940 */ 35, 228, 35, 35, 35, 367, 35, 70, 92, 35, + /* 1950 */ 372, 35, 374, 359, 44, 35, 22, 35, 35, 35, + /* 1960 */ 35, 367, 35, 70, 35, 35, 372, 35, 374, 22, + /* 1970 */ 35, 0, 35, 447, 48, 39, 398, 0, 35, 48, + /* 1980 */ 402, 39, 0, 405, 406, 407, 408, 409, 410, 35, + /* 1990 */ 412, 39, 398, 48, 0, 35, 402, 48, 39, 405, + /* 2000 */ 406, 407, 408, 409, 410, 0, 412, 35, 35, 0, + /* 2010 */ 22, 328, 21, 461, 22, 22, 21, 20, 461, 461, + /* 2020 */ 461, 461, 461, 461, 461, 461, 461, 449, 461, 328, + /* 2030 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2040 */ 461, 461, 359, 461, 461, 461, 461, 364, 461, 461, + /* 2050 */ 367, 461, 458, 461, 461, 372, 461, 374, 461, 461, + /* 2060 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, + /* 2070 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, + /* 2080 */ 461, 398, 461, 328, 461, 402, 461, 461, 405, 406, + /* 2090 */ 407, 408, 409, 410, 461, 412, 461, 461, 461, 398, + /* 2100 */ 328, 461, 461, 402, 461, 461, 405, 406, 407, 408, + /* 2110 */ 409, 410, 461, 412, 359, 414, 461, 461, 461, 364, + /* 2120 */ 461, 461, 367, 461, 461, 461, 461, 372, 461, 374, + /* 2130 */ 461, 359, 461, 461, 461, 461, 364, 461, 461, 367, + /* 2140 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, + /* 2150 */ 461, 461, 328, 398, 461, 461, 461, 402, 461, 461, + /* 2160 */ 405, 406, 407, 408, 409, 410, 461, 412, 328, 461, + /* 2170 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, + /* 2180 */ 408, 409, 410, 359, 412, 461, 461, 461, 461, 461, + /* 2190 */ 461, 367, 461, 461, 461, 461, 372, 461, 374, 359, + /* 2200 */ 461, 461, 461, 461, 461, 461, 461, 367, 461, 461, + /* 2210 */ 461, 461, 372, 461, 374, 461, 461, 461, 461, 461, + /* 2220 */ 328, 461, 398, 461, 461, 461, 402, 461, 461, 405, + /* 2230 */ 406, 407, 408, 409, 410, 461, 412, 461, 398, 461, + /* 2240 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, + /* 2250 */ 410, 359, 412, 461, 461, 461, 461, 461, 461, 367, + /* 2260 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, + /* 2270 */ 461, 461, 461, 461, 328, 461, 461, 461, 461, 461, + /* 2280 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2290 */ 398, 461, 461, 461, 402, 328, 461, 405, 406, 407, + /* 2300 */ 408, 409, 410, 461, 412, 359, 461, 461, 461, 461, + /* 2310 */ 461, 461, 461, 367, 461, 461, 461, 461, 372, 461, + /* 2320 */ 374, 461, 461, 461, 461, 461, 359, 461, 461, 461, + /* 2330 */ 461, 461, 461, 461, 367, 461, 461, 461, 461, 372, + /* 2340 */ 461, 374, 461, 461, 398, 461, 461, 461, 402, 461, + /* 2350 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, + /* 2360 */ 461, 461, 461, 461, 461, 398, 461, 461, 461, 402, + /* 2370 */ 461, 328, 405, 406, 407, 408, 409, 410, 461, 412, + /* 2380 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 328, + /* 2390 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2400 */ 461, 461, 359, 461, 461, 461, 461, 461, 461, 461, + /* 2410 */ 367, 461, 461, 461, 461, 372, 461, 374, 461, 461, + /* 2420 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, + /* 2430 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, + /* 2440 */ 461, 398, 461, 328, 461, 402, 461, 461, 405, 406, + /* 2450 */ 407, 408, 409, 410, 461, 412, 461, 461, 461, 398, + /* 2460 */ 328, 461, 461, 402, 461, 461, 405, 406, 407, 408, + /* 2470 */ 409, 410, 461, 412, 359, 461, 461, 461, 461, 461, + /* 2480 */ 461, 461, 367, 461, 461, 461, 461, 372, 461, 374, + /* 2490 */ 461, 359, 461, 461, 461, 461, 461, 461, 461, 367, + /* 2500 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, + /* 2510 */ 461, 461, 328, 398, 461, 461, 461, 402, 461, 461, + /* 2520 */ 405, 406, 407, 408, 409, 410, 461, 412, 328, 461, + /* 2530 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, + /* 2540 */ 408, 409, 410, 359, 412, 461, 461, 461, 461, 461, + /* 2550 */ 461, 367, 461, 461, 461, 461, 372, 461, 374, 359, +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 /* 2560 */ 461, 461, 461, 461, 461, 461, 461, 367, 461, 461, /* 2570 */ 461, 461, 372, 461, 374, 461, 461, 461, 461, 461, /* 2580 */ 461, 461, 328, 461, 461, 461, 461, 461, 461, 461, @@ -804,6 +1386,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 2620 */ 461, 367, 461, 461, 461, 461, 372, 461, 374, 461, /* 2630 */ 461, 461, 461, 461, 359, 461, 461, 461, 461, 461, /* 2640 */ 461, 461, 367, 461, 461, 461, 461, 372, 461, 374, +<<<<<<< HEAD /* 2650 */ 461, 461, 398, 461, 461, 461, 402, 328, 461, 405, /* 2660 */ 406, 407, 408, 409, 410, 461, 412, 461, 461, 461, /* 2670 */ 461, 461, 461, 398, 461, 461, 461, 402, 328, 461, @@ -1044,6 +1627,238 @@ static const YYACTIONTYPE yy_default[] = { /* 690 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, /* 700 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, /* 710 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, +======= + /* 2650 */ 398, 461, 461, 461, 402, 328, 461, 405, 406, 407, + /* 2660 */ 408, 409, 410, 461, 412, 461, 461, 461, 461, 461, + /* 2670 */ 461, 461, 461, 398, 461, 461, 461, 402, 461, 461, + /* 2680 */ 405, 406, 407, 408, 409, 410, 359, 412, 461, 461, + /* 2690 */ 461, 461, 461, 461, 367, 461, 461, 461, 461, 372, + /* 2700 */ 461, 374, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2710 */ 461, 461, 461, 461, 461, 461, 461, 461, 328, 461, + /* 2720 */ 461, 461, 461, 461, 461, 398, 461, 461, 461, 402, + /* 2730 */ 461, 461, 405, 406, 407, 408, 409, 410, 461, 412, + /* 2740 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 359, + /* 2750 */ 461, 461, 461, 461, 461, 461, 461, 367, 461, 461, + /* 2760 */ 461, 461, 372, 461, 374, 461, 461, 461, 461, 461, + /* 2770 */ 328, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2780 */ 461, 461, 461, 461, 461, 461, 461, 461, 398, 328, + /* 2790 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, + /* 2800 */ 410, 359, 412, 461, 461, 461, 461, 461, 461, 367, + /* 2810 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, + /* 2820 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, + /* 2830 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, + /* 2840 */ 398, 328, 461, 461, 402, 461, 461, 405, 406, 407, + /* 2850 */ 408, 409, 410, 461, 412, 461, 461, 328, 461, 398, + /* 2860 */ 461, 461, 461, 402, 461, 461, 405, 406, 407, 408, + /* 2870 */ 409, 410, 359, 412, 461, 461, 461, 461, 461, 461, + /* 2880 */ 367, 461, 461, 461, 461, 372, 461, 374, 359, 461, + /* 2890 */ 461, 461, 461, 461, 461, 461, 367, 461, 461, 461, + /* 2900 */ 461, 372, 461, 374, 461, 461, 461, 461, 461, 328, + /* 2910 */ 461, 398, 461, 461, 461, 402, 461, 461, 405, 406, + /* 2920 */ 407, 408, 409, 410, 461, 412, 461, 398, 461, 461, + /* 2930 */ 461, 402, 328, 461, 405, 406, 407, 408, 409, 410, + /* 2940 */ 359, 412, 461, 461, 461, 461, 461, 461, 367, 461, + /* 2950 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, + /* 2960 */ 461, 461, 461, 359, 461, 461, 461, 461, 461, 461, + /* 2970 */ 461, 367, 461, 461, 461, 461, 372, 461, 374, 398, + /* 2980 */ 461, 461, 461, 402, 328, 461, 405, 406, 407, 408, + /* 2990 */ 409, 410, 461, 412, 461, 461, 461, 461, 461, 461, + /* 3000 */ 461, 461, 398, 461, 461, 461, 402, 461, 461, 405, + /* 3010 */ 406, 407, 408, 409, 410, 359, 412, 461, 461, 461, + /* 3020 */ 461, 461, 461, 367, 461, 461, 461, 461, 372, 461, + /* 3030 */ 374, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 3040 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 3050 */ 461, 461, 461, 461, 398, 461, 461, 461, 402, 461, + /* 3060 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, +}; +#define YY_SHIFT_COUNT (721) +#define YY_SHIFT_MIN (0) +#define YY_SHIFT_MAX (2009) +static const unsigned short int yy_shift_ofst[] = { + /* 0 */ 862, 0, 71, 0, 289, 289, 289, 289, 289, 289, + /* 10 */ 289, 289, 289, 289, 289, 360, 576, 576, 647, 576, + /* 20 */ 576, 576, 576, 576, 576, 576, 576, 576, 576, 576, + /* 30 */ 576, 576, 576, 576, 576, 576, 576, 576, 576, 576, + /* 40 */ 576, 576, 576, 576, 576, 576, 576, 576, 32, 134, + /* 50 */ 21, 590, 133, 7, 104, 7, 21, 21, 1216, 1216, + /* 60 */ 7, 1216, 1216, 136, 7, 423, 156, 156, 423, 401, + /* 70 */ 401, 215, 57, 5, 5, 156, 156, 156, 156, 156, + /* 80 */ 156, 156, 156, 156, 156, 80, 156, 156, 229, 156, + /* 90 */ 518, 156, 156, 156, 156, 518, 156, 156, 518, 156, + /* 100 */ 518, 518, 518, 156, 301, 792, 34, 34, 216, 474, + /* 110 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + /* 120 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 1073, + /* 130 */ 87, 215, 57, 593, 489, 499, 499, 499, 749, 441, + /* 140 */ 441, 489, 579, 579, 579, 530, 584, 518, 358, 518, + /* 150 */ 358, 358, 530, 786, 217, 217, 217, 217, 217, 217, + /* 160 */ 217, 1351, 408, 336, 612, 249, 430, 340, 464, 292, + /* 170 */ 716, 438, 757, 884, 882, 817, 748, 12, 898, 748, + /* 180 */ 975, 839, 765, 1009, 1211, 1082, 1231, 1257, 1231, 1124, + /* 190 */ 1267, 1267, 1231, 1124, 1124, 1204, 1267, 1267, 1267, 1283, + /* 200 */ 1283, 1285, 80, 1290, 80, 1293, 1295, 80, 1293, 80, + /* 210 */ 80, 80, 1267, 80, 1284, 1284, 1283, 518, 518, 518, + /* 220 */ 518, 518, 518, 518, 518, 518, 518, 518, 1267, 1283, + /* 230 */ 358, 358, 1172, 1285, 301, 1192, 1290, 301, 1267, 1257, + /* 240 */ 1257, 358, 1132, 1136, 358, 1132, 1136, 358, 358, 518, + /* 250 */ 1152, 1224, 1132, 1151, 1153, 1168, 1009, 1155, 1154, 1161, + /* 260 */ 1174, 579, 1409, 1267, 1293, 301, 301, 1136, 358, 358, + /* 270 */ 358, 358, 358, 1136, 358, 1301, 301, 530, 301, 579, + /* 280 */ 1384, 1387, 358, 786, 1267, 301, 1452, 1283, 3069, 3069, + /* 290 */ 3069, 3069, 3069, 3069, 3069, 3069, 3069, 887, 310, 94, + /* 300 */ 625, 15, 59, 738, 720, 753, 881, 73, 781, 472, + /* 310 */ 472, 472, 472, 472, 472, 472, 472, 472, 875, 124, + /* 320 */ 373, 373, 122, 4, 58, 166, 484, 300, 300, 790, + /* 330 */ 732, 588, 790, 790, 790, 113, 691, 288, 976, 907, + /* 340 */ 987, 923, 988, 1003, 1007, 1035, 1093, 1101, 1063, 1032, + /* 350 */ 1044, 865, 779, 977, 721, 1090, 1103, 1115, 1120, 1131, + /* 360 */ 1140, 1142, 1141, 998, 1051, 406, 1144, 723, 1145, 1147, + /* 370 */ 1148, 1150, 1157, 1176, 1050, 1212, 1217, 1184, 1190, 1494, + /* 380 */ 1498, 1311, 1503, 1504, 1463, 1507, 1473, 1321, 1489, 1491, + /* 390 */ 1496, 1328, 1533, 1499, 1500, 1335, 1538, 1339, 1541, 1508, + /* 400 */ 1542, 1522, 1545, 1511, 1364, 1367, 1550, 1551, 1374, 1376, + /* 410 */ 1554, 1555, 1510, 1558, 1559, 1561, 1520, 1569, 1571, 1572, + /* 420 */ 1573, 1574, 1576, 1579, 1580, 1432, 1549, 1585, 1436, 1588, + /* 430 */ 1589, 1590, 1592, 1606, 1607, 1608, 1609, 1610, 1611, 1612, + /* 440 */ 1613, 1614, 1615, 1616, 1552, 1595, 1596, 1597, 1598, 1599, + /* 450 */ 1581, 1600, 1601, 1602, 1469, 1618, 1619, 1587, 1620, 1565, + /* 460 */ 1630, 1575, 1632, 1634, 1593, 1617, 1603, 1605, 1623, 1621, + /* 470 */ 1625, 1622, 1640, 1624, 1626, 1641, 1645, 1646, 1627, 1475, + /* 480 */ 1650, 1653, 1654, 1591, 1657, 1658, 1628, 1629, 1631, 1660, + /* 490 */ 1636, 1633, 1635, 1661, 1637, 1643, 1639, 1662, 1638, 1644, + /* 500 */ 1655, 1667, 1676, 1680, 1693, 1604, 1642, 1664, 1673, 1697, + /* 510 */ 1669, 1671, 1672, 1674, 1666, 1668, 1678, 1679, 1689, 1681, + /* 520 */ 1702, 1695, 1715, 1696, 1670, 1721, 1700, 1688, 1724, 1690, + /* 530 */ 1726, 1707, 1728, 1708, 1711, 1710, 1712, 1557, 1652, 1665, + /* 540 */ 1735, 1586, 1717, 1753, 1647, 1734, 1648, 1649, 1757, 1759, + /* 550 */ 1656, 1651, 1758, 1719, 1515, 1684, 1682, 1685, 1659, 1547, + /* 560 */ 1663, 1523, 1686, 1737, 1687, 1691, 1692, 1694, 1698, 1740, + /* 570 */ 1741, 1744, 1703, 1749, 1546, 1705, 1706, 1793, 1760, 1548, + /* 580 */ 1764, 1768, 1770, 1771, 1773, 1774, 1714, 1716, 1766, 1564, + /* 590 */ 1777, 1787, 1815, 1817, 1818, 1835, 1742, 1797, 1743, 1745, + /* 600 */ 1746, 1748, 1750, 1699, 1752, 1848, 1801, 1704, 1754, 1747, + /* 610 */ 1605, 1803, 1807, 1675, 1677, 1713, 1851, 1833, 1709, 1761, + /* 620 */ 1762, 1765, 1763, 1767, 1775, 1810, 1769, 1778, 1814, 1776, + /* 630 */ 1841, 1718, 1788, 1780, 1791, 1831, 1832, 1794, 1792, 1834, + /* 640 */ 1795, 1796, 1859, 1800, 1805, 1862, 1804, 1806, 1869, 1813, + /* 650 */ 1786, 1790, 1798, 1799, 1888, 1808, 1816, 1868, 1819, 1878, + /* 660 */ 1825, 1868, 1868, 1897, 1857, 1860, 1890, 1891, 1894, 1895, + /* 670 */ 1904, 1905, 1907, 1908, 1909, 1911, 1877, 1856, 1910, 1914, + /* 680 */ 1916, 1920, 1934, 1922, 1923, 1924, 1893, 1666, 1925, 1668, + /* 690 */ 1927, 1929, 1930, 1932, 1947, 1935, 1971, 1937, 1926, 1936, + /* 700 */ 1977, 1943, 1931, 1942, 1982, 1954, 1945, 1952, 1994, 1960, + /* 710 */ 1949, 1959, 2005, 1972, 1973, 2009, 1988, 1991, 1992, 1993, + /* 720 */ 1995, 1997, +}; +#define YY_REDUCE_COUNT (296) +#define YY_REDUCE_MIN (-420) +#define YY_REDUCE_MAX (2656) +static const short yy_reduce_ofst[] = { + /* 0 */ 276, -259, 233, 672, 744, 798, 859, 922, 942, 1045, + /* 10 */ 1104, 1158, 1219, 1277, 1331, 1360, 294, 1418, 1472, 1526, + /* 20 */ 1578, 1594, 1683, 1701, 1755, 1772, 1824, 1840, 1892, 1946, + /* 30 */ 1967, 2043, 2061, 2115, 2132, 2184, 2200, 2252, 2275, 2327, + /* 40 */ 2390, 2442, 2461, 2513, 2529, 2581, 2604, 2656, -258, 95, + /* 50 */ 105, -39, 559, 597, 599, 669, 187, 704, -346, -57, + /* 60 */ -391, 323, 480, -276, -250, 75, -222, 297, -371, -330, + /* 70 */ -326, -327, -363, -299, -257, 116, 128, 193, 199, 327, + /* 80 */ 409, 471, 645, 649, 657, 252, 693, 706, -51, 725, + /* 90 */ -203, 747, 762, 763, 772, 244, 791, 847, -5, 362, + /* 100 */ 465, 24, 485, 845, -210, -315, -420, -420, -217, -212, + /* 110 */ -69, -21, 41, 43, 70, 96, 148, 197, 225, 234, + /* 120 */ 346, 351, 385, 400, 454, 504, 547, 651, 655, -266, + /* 130 */ -170, 397, 191, 152, 533, -170, -150, 219, 477, 186, + /* 140 */ 486, 560, 343, 396, 546, -316, -319, -11, 25, 322, + /* 150 */ 76, 545, 563, 578, -342, 556, 624, 648, 666, 709, + /* 160 */ 734, -348, 722, 789, 766, 707, 729, 831, 737, 834, + /* 170 */ 834, 860, 827, 878, 852, 842, 801, 801, 796, 801, + /* 180 */ 830, 806, 834, 858, 861, 872, 896, 897, 901, 908, + /* 190 */ 952, 954, 912, 915, 918, 955, 962, 964, 966, 974, + /* 200 */ 978, 911, 965, 937, 970, 980, 928, 979, 982, 981, + /* 210 */ 983, 984, 986, 993, 999, 1004, 1012, 994, 996, 1001, + /* 220 */ 1005, 1008, 1010, 1013, 1015, 1016, 1018, 1019, 1021, 1028, + /* 230 */ 990, 991, 940, 985, 1031, 989, 1011, 1041, 1046, 1006, + /* 240 */ 1014, 1017, 945, 1025, 1020, 950, 1026, 1022, 1023, 834, + /* 250 */ 949, 958, 961, 963, 992, 995, 1027, 960, 968, 1024, + /* 260 */ 801, 1061, 1030, 1094, 1098, 1106, 1109, 1059, 1084, 1086, + /* 270 */ 1087, 1088, 1089, 1080, 1095, 1091, 1130, 1117, 1133, 1108, + /* 280 */ 1058, 1121, 1111, 1138, 1149, 1156, 1159, 1162, 1097, 1099, + /* 290 */ 1105, 1107, 1146, 1165, 1166, 1160, 1171, +}; +static const YYACTIONTYPE yy_default[] = { + /* 0 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 10 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 20 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 30 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 40 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 50 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 60 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 70 */ 1615, 1870, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 80 */ 1615, 1615, 1615, 1615, 1615, 1693, 1615, 1615, 1615, 1615, + /* 90 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 100 */ 1615, 1615, 1615, 1615, 1691, 1863, 2067, 1615, 1615, 1615, + /* 110 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 120 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 130 */ 2079, 1615, 1615, 1693, 1615, 2079, 2079, 2079, 1691, 2039, + /* 140 */ 2039, 1615, 1615, 1615, 1615, 1800, 1615, 1615, 1615, 1615, + /* 150 */ 1615, 1615, 1800, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 160 */ 1615, 1913, 1615, 1615, 2104, 2158, 1615, 1615, 2107, 1615, + /* 170 */ 1615, 1615, 1875, 1615, 1753, 2094, 2071, 2085, 2142, 2072, + /* 180 */ 2069, 2088, 1615, 2098, 1615, 1906, 1868, 1615, 1868, 1865, + /* 190 */ 1615, 1615, 1868, 1865, 1865, 1744, 1615, 1615, 1615, 1615, + /* 200 */ 1615, 1615, 1693, 1615, 1693, 1615, 1615, 1693, 1615, 1693, + /* 210 */ 1693, 1693, 1615, 1693, 1672, 1672, 1615, 1615, 1615, 1615, + /* 220 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 230 */ 1615, 1615, 1926, 1615, 1691, 1915, 1615, 1691, 1615, 1615, + /* 240 */ 1615, 1615, 2115, 2113, 1615, 2115, 2113, 1615, 1615, 1615, + /* 250 */ 2127, 2123, 2115, 2131, 2129, 2100, 2098, 2161, 2148, 2144, + /* 260 */ 2085, 1615, 1615, 1615, 1615, 1691, 1691, 2113, 1615, 1615, + /* 270 */ 1615, 1615, 1615, 2113, 1615, 1615, 1691, 1615, 1691, 1615, + /* 280 */ 1615, 1769, 1615, 1615, 1615, 1691, 1647, 1615, 1908, 1919, + /* 290 */ 1891, 1891, 1803, 1803, 1803, 1694, 1620, 1615, 1615, 1615, + /* 300 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 2126, + /* 310 */ 2125, 1994, 1615, 2043, 2042, 2041, 2032, 1993, 1765, 1615, + /* 320 */ 1992, 1991, 1615, 1615, 1615, 1615, 1615, 1882, 1881, 1985, + /* 330 */ 1615, 1615, 1986, 1984, 1983, 1615, 1615, 1615, 1615, 1615, + /* 340 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 350 */ 1615, 1615, 2145, 2149, 1615, 1615, 1615, 1615, 1615, 1615, + /* 360 */ 1615, 2068, 1615, 1615, 1615, 1615, 1615, 1968, 1615, 1615, + /* 370 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 380 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 390 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 400 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 410 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 420 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 430 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 440 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 450 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 460 */ 1615, 1615, 1615, 1615, 1615, 1615, 1652, 1973, 1615, 1615, + /* 470 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 480 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 490 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 500 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 510 */ 1615, 1615, 1615, 1615, 1732, 1731, 1615, 1615, 1615, 1615, + /* 520 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 530 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1976, 1615, + /* 540 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 550 */ 1615, 1615, 2141, 2101, 1615, 1615, 1615, 1615, 1615, 1615, + /* 560 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 570 */ 1615, 1968, 1615, 2124, 1615, 1615, 2139, 1615, 2143, 1615, + /* 580 */ 1615, 1615, 1615, 1615, 1615, 1615, 2078, 2074, 1615, 1615, + /* 590 */ 2070, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 600 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 610 */ 1967, 1615, 2029, 1615, 1615, 1615, 2063, 1615, 1615, 2014, + /* 620 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1976, + /* 630 */ 1615, 1979, 1615, 1615, 1615, 1615, 1615, 1797, 1615, 1615, + /* 640 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 650 */ 1782, 1780, 1779, 1778, 1615, 1775, 1615, 1810, 1615, 1615, + /* 660 */ 1615, 1806, 1805, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 670 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1712, 1615, + /* 680 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1704, 1615, 1703, + /* 690 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 700 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 710 */ 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, 1615, + /* 720 */ 1615, 1615, +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 }; /********** End of lemon-generated parsing tables *****************************/ @@ -2015,6 +2830,7 @@ static const char *const yyRuleName[] = { /* 69 */ "cmd ::= ALTER DATABASE db_name alter_db_options", /* 70 */ "cmd ::= FLUSH DATABASE db_name", /* 71 */ "cmd ::= TRIM DATABASE db_name speed_opt", +<<<<<<< HEAD /* 72 */ "cmd ::= COMPACT DATABASE db_name", /* 73 */ "not_exists_opt ::= IF NOT EXISTS", /* 74 */ "not_exists_opt ::=", @@ -2205,6 +3021,198 @@ static const char *const yyRuleName[] = { /* 259 */ "tag_item ::= column_name column_alias", /* 260 */ "tag_item ::= column_name AS column_alias", /* 261 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", +======= + /* 72 */ "not_exists_opt ::= IF NOT EXISTS", + /* 73 */ "not_exists_opt ::=", + /* 74 */ "exists_opt ::= IF EXISTS", + /* 75 */ "exists_opt ::=", + /* 76 */ "db_options ::=", + /* 77 */ "db_options ::= db_options BUFFER NK_INTEGER", + /* 78 */ "db_options ::= db_options CACHEMODEL NK_STRING", + /* 79 */ "db_options ::= db_options CACHESIZE NK_INTEGER", + /* 80 */ "db_options ::= db_options COMP NK_INTEGER", + /* 81 */ "db_options ::= db_options DURATION NK_INTEGER", + /* 82 */ "db_options ::= db_options DURATION NK_VARIABLE", + /* 83 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 84 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 85 */ "db_options ::= db_options KEEP integer_list", + /* 86 */ "db_options ::= db_options KEEP variable_list", + /* 87 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 88 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 89 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER", + /* 90 */ "db_options ::= db_options PRECISION NK_STRING", + /* 91 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 92 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 93 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 94 */ "db_options ::= db_options RETENTIONS retention_list", + /* 95 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 96 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", + /* 97 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", + /* 98 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", + /* 99 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 100 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", + /* 101 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 102 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", + /* 103 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", + /* 104 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", + /* 105 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER", + /* 106 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER", + /* 107 */ "alter_db_options ::= alter_db_option", + /* 108 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 109 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 110 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 111 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 112 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 113 */ "alter_db_option ::= KEEP integer_list", + /* 114 */ "alter_db_option ::= KEEP variable_list", + /* 115 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 116 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 117 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 118 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", + /* 119 */ "integer_list ::= NK_INTEGER", + /* 120 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 121 */ "variable_list ::= NK_VARIABLE", + /* 122 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 123 */ "retention_list ::= retention", + /* 124 */ "retention_list ::= retention_list NK_COMMA retention", + /* 125 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 126 */ "speed_opt ::=", + /* 127 */ "speed_opt ::= MAX_SPEED NK_INTEGER", + /* 128 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 129 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 130 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 131 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 132 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 133 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 134 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 135 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 136 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 137 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 138 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 139 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 140 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 141 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 142 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 143 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 144 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 145 */ "multi_create_clause ::= create_subtable_clause", + /* 146 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 147 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 148 */ "multi_drop_clause ::= drop_table_clause", + /* 149 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 150 */ "drop_table_clause ::= exists_opt full_table_name", + /* 151 */ "specific_cols_opt ::=", + /* 152 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 153 */ "full_table_name ::= table_name", + /* 154 */ "full_table_name ::= db_name NK_DOT table_name", + /* 155 */ "column_def_list ::= column_def", + /* 156 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 157 */ "column_def ::= column_name type_name", + /* 158 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 159 */ "type_name ::= BOOL", + /* 160 */ "type_name ::= TINYINT", + /* 161 */ "type_name ::= SMALLINT", + /* 162 */ "type_name ::= INT", + /* 163 */ "type_name ::= INTEGER", + /* 164 */ "type_name ::= BIGINT", + /* 165 */ "type_name ::= FLOAT", + /* 166 */ "type_name ::= DOUBLE", + /* 167 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 168 */ "type_name ::= TIMESTAMP", + /* 169 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 170 */ "type_name ::= TINYINT UNSIGNED", + /* 171 */ "type_name ::= SMALLINT UNSIGNED", + /* 172 */ "type_name ::= INT UNSIGNED", + /* 173 */ "type_name ::= BIGINT UNSIGNED", + /* 174 */ "type_name ::= JSON", + /* 175 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 176 */ "type_name ::= MEDIUMBLOB", + /* 177 */ "type_name ::= BLOB", + /* 178 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 179 */ "type_name ::= DECIMAL", + /* 180 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 181 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 182 */ "tags_def_opt ::=", + /* 183 */ "tags_def_opt ::= tags_def", + /* 184 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 185 */ "table_options ::=", + /* 186 */ "table_options ::= table_options COMMENT NK_STRING", + /* 187 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 188 */ "table_options ::= table_options WATERMARK duration_list", + /* 189 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 190 */ "table_options ::= table_options TTL NK_INTEGER", + /* 191 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 192 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 193 */ "alter_table_options ::= alter_table_option", + /* 194 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 195 */ "alter_table_option ::= COMMENT NK_STRING", + /* 196 */ "alter_table_option ::= TTL NK_INTEGER", + /* 197 */ "duration_list ::= duration_literal", + /* 198 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 199 */ "rollup_func_list ::= rollup_func_name", + /* 200 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 201 */ "rollup_func_name ::= function_name", + /* 202 */ "rollup_func_name ::= FIRST", + /* 203 */ "rollup_func_name ::= LAST", + /* 204 */ "col_name_list ::= col_name", + /* 205 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 206 */ "col_name ::= column_name", + /* 207 */ "cmd ::= SHOW DNODES", + /* 208 */ "cmd ::= SHOW USERS", + /* 209 */ "cmd ::= SHOW USER PRIVILEGES", + /* 210 */ "cmd ::= SHOW DATABASES", + /* 211 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 212 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 213 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 214 */ "cmd ::= SHOW MNODES", + /* 215 */ "cmd ::= SHOW QNODES", + /* 216 */ "cmd ::= SHOW FUNCTIONS", + /* 217 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 218 */ "cmd ::= SHOW STREAMS", + /* 219 */ "cmd ::= SHOW ACCOUNTS", + /* 220 */ "cmd ::= SHOW APPS", + /* 221 */ "cmd ::= SHOW CONNECTIONS", + /* 222 */ "cmd ::= SHOW LICENCES", + /* 223 */ "cmd ::= SHOW GRANTS", + /* 224 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 225 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 226 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 227 */ "cmd ::= SHOW QUERIES", + /* 228 */ "cmd ::= SHOW SCORES", + /* 229 */ "cmd ::= SHOW TOPICS", + /* 230 */ "cmd ::= SHOW VARIABLES", + /* 231 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 232 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 233 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 234 */ "cmd ::= SHOW BNODES", + /* 235 */ "cmd ::= SHOW SNODES", + /* 236 */ "cmd ::= SHOW CLUSTER", + /* 237 */ "cmd ::= SHOW TRANSACTIONS", + /* 238 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 239 */ "cmd ::= SHOW CONSUMERS", + /* 240 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 241 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 242 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 243 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 244 */ "cmd ::= SHOW VNODES NK_STRING", + /* 245 */ "db_name_cond_opt ::=", + /* 246 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 247 */ "like_pattern_opt ::=", + /* 248 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 249 */ "table_name_cond ::= table_name", + /* 250 */ "from_db_opt ::=", + /* 251 */ "from_db_opt ::= FROM db_name", + /* 252 */ "tag_list_opt ::=", + /* 253 */ "tag_list_opt ::= tag_item", + /* 254 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 255 */ "tag_item ::= TBNAME", + /* 256 */ "tag_item ::= QTAGS", + /* 257 */ "tag_item ::= column_name", + /* 258 */ "tag_item ::= column_name column_alias", + /* 259 */ "tag_item ::= column_name AS column_alias", + /* 260 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", + /* 261 */ "cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP", +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 /* 262 */ "cmd ::= DROP INDEX exists_opt full_table_name", /* 263 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", /* 264 */ "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", @@ -3173,6 +4181,7 @@ static const struct { { 325, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ { 325, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ { 325, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ +<<<<<<< HEAD { 325, -3 }, /* (72) cmd ::= COMPACT DATABASE db_name */ { 340, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */ { 340, 0 }, /* (74) not_exists_opt ::= */ @@ -3363,6 +4372,198 @@ static const struct { { 381, -2 }, /* (259) tag_item ::= column_name column_alias */ { 381, -3 }, /* (260) tag_item ::= column_name AS column_alias */ { 325, -8 }, /* (261) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ +======= + { 340, -3 }, /* (72) not_exists_opt ::= IF NOT EXISTS */ + { 340, 0 }, /* (73) not_exists_opt ::= */ + { 342, -2 }, /* (74) exists_opt ::= IF EXISTS */ + { 342, 0 }, /* (75) exists_opt ::= */ + { 341, 0 }, /* (76) db_options ::= */ + { 341, -3 }, /* (77) db_options ::= db_options BUFFER NK_INTEGER */ + { 341, -3 }, /* (78) db_options ::= db_options CACHEMODEL NK_STRING */ + { 341, -3 }, /* (79) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 341, -3 }, /* (80) db_options ::= db_options COMP NK_INTEGER */ + { 341, -3 }, /* (81) db_options ::= db_options DURATION NK_INTEGER */ + { 341, -3 }, /* (82) db_options ::= db_options DURATION NK_VARIABLE */ + { 341, -3 }, /* (83) db_options ::= db_options MAXROWS NK_INTEGER */ + { 341, -3 }, /* (84) db_options ::= db_options MINROWS NK_INTEGER */ + { 341, -3 }, /* (85) db_options ::= db_options KEEP integer_list */ + { 341, -3 }, /* (86) db_options ::= db_options KEEP variable_list */ + { 341, -3 }, /* (87) db_options ::= db_options PAGES NK_INTEGER */ + { 341, -3 }, /* (88) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 341, -3 }, /* (89) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 341, -3 }, /* (90) db_options ::= db_options PRECISION NK_STRING */ + { 341, -3 }, /* (91) db_options ::= db_options REPLICA NK_INTEGER */ + { 341, -3 }, /* (92) db_options ::= db_options VGROUPS NK_INTEGER */ + { 341, -3 }, /* (93) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 341, -3 }, /* (94) db_options ::= db_options RETENTIONS retention_list */ + { 341, -3 }, /* (95) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 341, -3 }, /* (96) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 341, -3 }, /* (97) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 341, -3 }, /* (98) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 341, -4 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 341, -3 }, /* (100) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 341, -4 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 341, -3 }, /* (102) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 341, -3 }, /* (103) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 341, -3 }, /* (104) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 341, -3 }, /* (105) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 341, -3 }, /* (106) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 343, -1 }, /* (107) alter_db_options ::= alter_db_option */ + { 343, -2 }, /* (108) alter_db_options ::= alter_db_options alter_db_option */ + { 348, -2 }, /* (109) alter_db_option ::= BUFFER NK_INTEGER */ + { 348, -2 }, /* (110) alter_db_option ::= CACHEMODEL NK_STRING */ + { 348, -2 }, /* (111) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 348, -2 }, /* (112) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 348, -2 }, /* (113) alter_db_option ::= KEEP integer_list */ + { 348, -2 }, /* (114) alter_db_option ::= KEEP variable_list */ + { 348, -2 }, /* (115) alter_db_option ::= PAGES NK_INTEGER */ + { 348, -2 }, /* (116) alter_db_option ::= REPLICA NK_INTEGER */ + { 348, -2 }, /* (117) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 348, -2 }, /* (118) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 345, -1 }, /* (119) integer_list ::= NK_INTEGER */ + { 345, -3 }, /* (120) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 346, -1 }, /* (121) variable_list ::= NK_VARIABLE */ + { 346, -3 }, /* (122) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 347, -1 }, /* (123) retention_list ::= retention */ + { 347, -3 }, /* (124) retention_list ::= retention_list NK_COMMA retention */ + { 349, -3 }, /* (125) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 344, 0 }, /* (126) speed_opt ::= */ + { 344, -2 }, /* (127) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 325, -9 }, /* (128) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 325, -3 }, /* (129) cmd ::= CREATE TABLE multi_create_clause */ + { 325, -9 }, /* (130) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 325, -3 }, /* (131) cmd ::= DROP TABLE multi_drop_clause */ + { 325, -4 }, /* (132) cmd ::= DROP STABLE exists_opt full_table_name */ + { 325, -3 }, /* (133) cmd ::= ALTER TABLE alter_table_clause */ + { 325, -3 }, /* (134) cmd ::= ALTER STABLE alter_table_clause */ + { 357, -2 }, /* (135) alter_table_clause ::= full_table_name alter_table_options */ + { 357, -5 }, /* (136) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 357, -4 }, /* (137) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 357, -5 }, /* (138) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 357, -5 }, /* (139) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 357, -5 }, /* (140) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 357, -4 }, /* (141) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 357, -5 }, /* (142) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 357, -5 }, /* (143) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 357, -6 }, /* (144) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 354, -1 }, /* (145) multi_create_clause ::= create_subtable_clause */ + { 354, -2 }, /* (146) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 362, -10 }, /* (147) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 356, -1 }, /* (148) multi_drop_clause ::= drop_table_clause */ + { 356, -2 }, /* (149) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 365, -2 }, /* (150) drop_table_clause ::= exists_opt full_table_name */ + { 363, 0 }, /* (151) specific_cols_opt ::= */ + { 363, -3 }, /* (152) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 350, -1 }, /* (153) full_table_name ::= table_name */ + { 350, -3 }, /* (154) full_table_name ::= db_name NK_DOT table_name */ + { 351, -1 }, /* (155) column_def_list ::= column_def */ + { 351, -3 }, /* (156) column_def_list ::= column_def_list NK_COMMA column_def */ + { 368, -2 }, /* (157) column_def ::= column_name type_name */ + { 368, -4 }, /* (158) column_def ::= column_name type_name COMMENT NK_STRING */ + { 360, -1 }, /* (159) type_name ::= BOOL */ + { 360, -1 }, /* (160) type_name ::= TINYINT */ + { 360, -1 }, /* (161) type_name ::= SMALLINT */ + { 360, -1 }, /* (162) type_name ::= INT */ + { 360, -1 }, /* (163) type_name ::= INTEGER */ + { 360, -1 }, /* (164) type_name ::= BIGINT */ + { 360, -1 }, /* (165) type_name ::= FLOAT */ + { 360, -1 }, /* (166) type_name ::= DOUBLE */ + { 360, -4 }, /* (167) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 360, -1 }, /* (168) type_name ::= TIMESTAMP */ + { 360, -4 }, /* (169) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 360, -2 }, /* (170) type_name ::= TINYINT UNSIGNED */ + { 360, -2 }, /* (171) type_name ::= SMALLINT UNSIGNED */ + { 360, -2 }, /* (172) type_name ::= INT UNSIGNED */ + { 360, -2 }, /* (173) type_name ::= BIGINT UNSIGNED */ + { 360, -1 }, /* (174) type_name ::= JSON */ + { 360, -4 }, /* (175) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 360, -1 }, /* (176) type_name ::= MEDIUMBLOB */ + { 360, -1 }, /* (177) type_name ::= BLOB */ + { 360, -4 }, /* (178) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 360, -1 }, /* (179) type_name ::= DECIMAL */ + { 360, -4 }, /* (180) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 360, -6 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 352, 0 }, /* (182) tags_def_opt ::= */ + { 352, -1 }, /* (183) tags_def_opt ::= tags_def */ + { 355, -4 }, /* (184) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 353, 0 }, /* (185) table_options ::= */ + { 353, -3 }, /* (186) table_options ::= table_options COMMENT NK_STRING */ + { 353, -3 }, /* (187) table_options ::= table_options MAX_DELAY duration_list */ + { 353, -3 }, /* (188) table_options ::= table_options WATERMARK duration_list */ + { 353, -5 }, /* (189) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 353, -3 }, /* (190) table_options ::= table_options TTL NK_INTEGER */ + { 353, -5 }, /* (191) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 353, -3 }, /* (192) table_options ::= table_options DELETE_MARK duration_list */ + { 358, -1 }, /* (193) alter_table_options ::= alter_table_option */ + { 358, -2 }, /* (194) alter_table_options ::= alter_table_options alter_table_option */ + { 371, -2 }, /* (195) alter_table_option ::= COMMENT NK_STRING */ + { 371, -2 }, /* (196) alter_table_option ::= TTL NK_INTEGER */ + { 369, -1 }, /* (197) duration_list ::= duration_literal */ + { 369, -3 }, /* (198) duration_list ::= duration_list NK_COMMA duration_literal */ + { 370, -1 }, /* (199) rollup_func_list ::= rollup_func_name */ + { 370, -3 }, /* (200) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 373, -1 }, /* (201) rollup_func_name ::= function_name */ + { 373, -1 }, /* (202) rollup_func_name ::= FIRST */ + { 373, -1 }, /* (203) rollup_func_name ::= LAST */ + { 366, -1 }, /* (204) col_name_list ::= col_name */ + { 366, -3 }, /* (205) col_name_list ::= col_name_list NK_COMMA col_name */ + { 375, -1 }, /* (206) col_name ::= column_name */ + { 325, -2 }, /* (207) cmd ::= SHOW DNODES */ + { 325, -2 }, /* (208) cmd ::= SHOW USERS */ + { 325, -3 }, /* (209) cmd ::= SHOW USER PRIVILEGES */ + { 325, -2 }, /* (210) cmd ::= SHOW DATABASES */ + { 325, -4 }, /* (211) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 325, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 325, -3 }, /* (213) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 325, -2 }, /* (214) cmd ::= SHOW MNODES */ + { 325, -2 }, /* (215) cmd ::= SHOW QNODES */ + { 325, -2 }, /* (216) cmd ::= SHOW FUNCTIONS */ + { 325, -5 }, /* (217) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 325, -2 }, /* (218) cmd ::= SHOW STREAMS */ + { 325, -2 }, /* (219) cmd ::= SHOW ACCOUNTS */ + { 325, -2 }, /* (220) cmd ::= SHOW APPS */ + { 325, -2 }, /* (221) cmd ::= SHOW CONNECTIONS */ + { 325, -2 }, /* (222) cmd ::= SHOW LICENCES */ + { 325, -2 }, /* (223) cmd ::= SHOW GRANTS */ + { 325, -4 }, /* (224) cmd ::= SHOW CREATE DATABASE db_name */ + { 325, -4 }, /* (225) cmd ::= SHOW CREATE TABLE full_table_name */ + { 325, -4 }, /* (226) cmd ::= SHOW CREATE STABLE full_table_name */ + { 325, -2 }, /* (227) cmd ::= SHOW QUERIES */ + { 325, -2 }, /* (228) cmd ::= SHOW SCORES */ + { 325, -2 }, /* (229) cmd ::= SHOW TOPICS */ + { 325, -2 }, /* (230) cmd ::= SHOW VARIABLES */ + { 325, -3 }, /* (231) cmd ::= SHOW CLUSTER VARIABLES */ + { 325, -3 }, /* (232) cmd ::= SHOW LOCAL VARIABLES */ + { 325, -5 }, /* (233) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 325, -2 }, /* (234) cmd ::= SHOW BNODES */ + { 325, -2 }, /* (235) cmd ::= SHOW SNODES */ + { 325, -2 }, /* (236) cmd ::= SHOW CLUSTER */ + { 325, -2 }, /* (237) cmd ::= SHOW TRANSACTIONS */ + { 325, -4 }, /* (238) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 325, -2 }, /* (239) cmd ::= SHOW CONSUMERS */ + { 325, -2 }, /* (240) cmd ::= SHOW SUBSCRIPTIONS */ + { 325, -5 }, /* (241) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 325, -7 }, /* (242) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 325, -3 }, /* (243) cmd ::= SHOW VNODES NK_INTEGER */ + { 325, -3 }, /* (244) cmd ::= SHOW VNODES NK_STRING */ + { 376, 0 }, /* (245) db_name_cond_opt ::= */ + { 376, -2 }, /* (246) db_name_cond_opt ::= db_name NK_DOT */ + { 377, 0 }, /* (247) like_pattern_opt ::= */ + { 377, -2 }, /* (248) like_pattern_opt ::= LIKE NK_STRING */ + { 378, -1 }, /* (249) table_name_cond ::= table_name */ + { 379, 0 }, /* (250) from_db_opt ::= */ + { 379, -2 }, /* (251) from_db_opt ::= FROM db_name */ + { 380, 0 }, /* (252) tag_list_opt ::= */ + { 380, -1 }, /* (253) tag_list_opt ::= tag_item */ + { 380, -3 }, /* (254) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 381, -1 }, /* (255) tag_item ::= TBNAME */ + { 381, -1 }, /* (256) tag_item ::= QTAGS */ + { 381, -1 }, /* (257) tag_item ::= column_name */ + { 381, -2 }, /* (258) tag_item ::= column_name column_alias */ + { 381, -3 }, /* (259) tag_item ::= column_name AS column_alias */ + { 325, -8 }, /* (260) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 325, -9 }, /* (261) cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 { 325, -4 }, /* (262) cmd ::= DROP INDEX exists_opt full_table_name */ { 383, -10 }, /* (263) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { 383, -12 }, /* (264) 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 */ @@ -3902,8 +5103,13 @@ static YYACTIONTYPE yy_reduce( yymsp[0].minor.yy77 = yylhsminor.yy77; break; case 54: /* force_opt ::= */ +<<<<<<< HEAD case 74: /* not_exists_opt ::= */ yytestcase(yyruleno==74); case 76: /* exists_opt ::= */ yytestcase(yyruleno==76); +======= + case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73); + case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 288: /* analyze_opt ::= */ yytestcase(yyruleno==288); case 295: /* agg_func_opt ::= */ yytestcase(yyruleno==295); case 470: /* set_quantifier_opt ::= */ yytestcase(yyruleno==470); @@ -4137,7 +5343,11 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; +<<<<<<< HEAD case 121: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ +======= + case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 318: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==318); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy601 = yylhsminor.yy601; @@ -4150,6 +5360,7 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy601 = yylhsminor.yy601; break; +<<<<<<< HEAD case 124: /* retention_list ::= retention */ case 146: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==146); case 149: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==149); @@ -4157,6 +5368,15 @@ static YYACTIONTYPE yy_reduce( case 200: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==200); case 205: /* col_name_list ::= col_name */ yytestcase(yyruleno==205); case 254: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==254); +======= + case 123: /* retention_list ::= retention */ + case 145: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==145); + case 148: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==148); + case 155: /* column_def_list ::= column_def */ yytestcase(yyruleno==155); + case 199: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==199); + case 204: /* col_name_list ::= col_name */ yytestcase(yyruleno==204); + case 253: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==253); +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 265: /* func_list ::= func */ yytestcase(yyruleno==265); case 346: /* literal_list ::= signed_literal */ yytestcase(yyruleno==346); case 412: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==412); @@ -4167,11 +5387,19 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy601 = createNodeList(pCxt, yymsp[0].minor.yy600); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; +<<<<<<< HEAD case 125: /* retention_list ::= retention_list NK_COMMA retention */ case 157: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==157); case 201: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==201); case 206: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==206); case 255: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==255); +======= + case 124: /* retention_list ::= retention_list NK_COMMA retention */ + case 156: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==156); + case 200: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==200); + case 205: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==205); + case 254: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==254); +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 266: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==266); case 347: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==347); case 413: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==413); @@ -4185,11 +5413,19 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy600 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; +<<<<<<< HEAD case 127: /* speed_opt ::= */ case 297: /* bufsize_opt ::= */ yytestcase(yyruleno==297); { yymsp[1].minor.yy248 = 0; } break; case 128: /* speed_opt ::= MAX_SPEED NK_INTEGER */ +======= + case 126: /* speed_opt ::= */ + case 297: /* bufsize_opt ::= */ yytestcase(yyruleno==297); +{ yymsp[1].minor.yy248 = 0; } + break; + case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 298: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==298); { yymsp[-1].minor.yy248 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; @@ -4206,7 +5442,11 @@ static YYACTIONTYPE yy_reduce( case 133: /* cmd ::= DROP STABLE exists_opt full_table_name */ { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } break; +<<<<<<< HEAD case 134: /* cmd ::= ALTER TABLE alter_table_clause */ +======= + case 133: /* cmd ::= ALTER TABLE alter_table_clause */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 320: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==320); { pCxt->pRootNode = yymsp[0].minor.yy600; } break; @@ -4253,8 +5493,13 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy600 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy600, &yymsp[-2].minor.yy77, yymsp[0].minor.yy600); } yymsp[-5].minor.yy600 = yylhsminor.yy600; break; +<<<<<<< HEAD case 147: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 150: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==150); +======= + case 146: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 149: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==149); +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 419: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==419); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } yymsp[-1].minor.yy601 = yylhsminor.yy601; @@ -4267,9 +5512,15 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy600 = createDropTableClause(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; +<<<<<<< HEAD case 152: /* specific_cols_opt ::= */ case 183: /* tags_def_opt ::= */ yytestcase(yyruleno==183); case 253: /* tag_list_opt ::= */ yytestcase(yyruleno==253); +======= + case 151: /* specific_cols_opt ::= */ + case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); + case 252: /* tag_list_opt ::= */ yytestcase(yyruleno==252); +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 482: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==482); case 505: /* group_by_clause_opt ::= */ yytestcase(yyruleno==505); case 524: /* order_by_clause_opt ::= */ yytestcase(yyruleno==524); @@ -4361,7 +5612,11 @@ static YYACTIONTYPE yy_reduce( case 182: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ { yymsp[-5].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; +<<<<<<< HEAD case 184: /* tags_def_opt ::= tags_def */ +======= + case 183: /* tags_def_opt ::= tags_def */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 411: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==411); { yylhsminor.yy601 = yymsp[0].minor.yy601; } yymsp[0].minor.yy601 = yylhsminor.yy601; @@ -4414,12 +5669,20 @@ static YYACTIONTYPE yy_reduce( case 197: /* alter_table_option ::= TTL NK_INTEGER */ { yymsp[-1].minor.yy661.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; +<<<<<<< HEAD case 198: /* duration_list ::= duration_literal */ +======= + case 197: /* duration_list ::= duration_literal */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 375: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==375); { yylhsminor.yy601 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; +<<<<<<< HEAD case 199: /* duration_list ::= duration_list NK_COMMA duration_literal */ +======= + case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 376: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==376); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } yymsp[-2].minor.yy601 = yylhsminor.yy601; @@ -4557,7 +5820,11 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy600 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy77); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; +<<<<<<< HEAD case 248: /* like_pattern_opt ::= */ +======= + case 247: /* like_pattern_opt ::= */ +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 308: /* subtable_opt ::= */ yytestcase(yyruleno==308); case 421: /* case_when_else_opt ::= */ yytestcase(yyruleno==421); case 451: /* from_clause_opt ::= */ yytestcase(yyruleno==451); @@ -4597,6 +5864,12 @@ static YYACTIONTYPE yy_reduce( case 261: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy841, yymsp[-3].minor.yy600, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } break; +<<<<<<< HEAD +======= + case 261: /* cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy841, yymsp[-5].minor.yy600, yymsp[-3].minor.yy600, yymsp[-1].minor.yy601, NULL); } + break; +>>>>>>> bd38f600c09ca3873b76d5561caa800200dc3187 case 262: /* cmd ::= DROP INDEX exists_opt full_table_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } break; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index e1687fc3a5..83341d200a 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1284,18 +1284,14 @@ static int32_t smaIndexOptFindSmaFunc(SNode* pQueryFunc, SNodeList* pSmaFuncs) { return -1; } -static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeList* pSmaFuncs, SNodeList** pOutput, - int32_t* pWStrartIndex) { +static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeList* pSmaFuncs, + SNodeList** pOutput) { SNodeList* pCols = NULL; SNode* pFunc = NULL; int32_t code = TSDB_CODE_SUCCESS; int32_t index = 0; int32_t smaFuncIndex = -1; - *pWStrartIndex = -1; FOREACH(pFunc, pFuncs) { - if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) { - *pWStrartIndex = index; - } smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs); if (smaFuncIndex < 0) { break; @@ -1317,8 +1313,7 @@ static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNo return code; } -static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList** pCols, - int32_t* pWStrartIndex) { +static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList** pCols) { SWindowLogicNode* pWindow = (SWindowLogicNode*)pScan->node.pParent; if (!smaIndexOptEqualInterval(pScan, pWindow, pIndex)) { return TSDB_CODE_SUCCESS; @@ -1326,14 +1321,14 @@ static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo SNodeList* pSmaFuncs = NULL; int32_t code = nodesStringToList(pIndex->expr, &pSmaFuncs); if (TSDB_CODE_SUCCESS == code) { - code = smaIndexOptCreateSmaCols(pWindow->pFuncs, pIndex->dstTbUid, pSmaFuncs, pCols, pWStrartIndex); + code = smaIndexOptCreateSmaCols(pWindow->pFuncs, pIndex->dstTbUid, pSmaFuncs, pCols); } nodesDestroyList(pSmaFuncs); return code; } static int32_t smaIndexOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex, - SNodeList* pSmaCols, int32_t wstrartIndex) { + SNodeList* pSmaCols) { SLogicNode* pSmaScan = NULL; int32_t code = smaIndexOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan); if (TSDB_CODE_SUCCESS == code) { @@ -1350,10 +1345,9 @@ static int32_t smaIndexOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogi for (int32_t i = 0; i < nindexes; ++i) { STableIndexInfo* pIndex = taosArrayGet(pScan->pSmaIndexes, i); SNodeList* pSmaCols = NULL; - int32_t wstrartIndex = -1; - code = smaIndexOptCouldApplyIndex(pScan, pIndex, &pSmaCols, &wstrartIndex); + code = smaIndexOptCouldApplyIndex(pScan, pIndex, &pSmaCols); if (TSDB_CODE_SUCCESS == code && NULL != pSmaCols) { - code = smaIndexOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols, wstrartIndex); + code = smaIndexOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols); taosArrayDestroyEx(pScan->pSmaIndexes, smaIndexOptDestroySmaIndex); pScan->pSmaIndexes = NULL; pCxt->optimized = true; diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 48df7e36a3..e8216fcd7c 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -375,7 +375,7 @@ extern SSchedulerMgmt schMgmt; #define SCH_JOB_NEED_WAIT(_job) (!SCH_IS_QUERY_JOB(_job)) #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) +#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) \ diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index d422f0e88f..6a8f81f8c7 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -668,6 +668,7 @@ void schFreeJobImpl(void *job) { taosMemoryFreeClear(pJob->userRes.execRes); taosMemoryFreeClear(pJob->fetchRes); taosMemoryFreeClear(pJob->sql); + tsem_destroy(&pJob->rspSem); taosMemoryFree(pJob); int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1); @@ -748,7 +749,10 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - tsem_init(&pJob->rspSem, 0, 0); + if (tsem_init(&pJob->rspSem, 0, 0)) { + SCH_JOB_ELOG("tsem_init failed, errno:%d", errno); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } pJob->refId = taosAddRef(schMgmt.jobRef, pJob); if (pJob->refId < 0) { diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 903b1a9354..62ba74bd23 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -49,6 +49,10 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray* // exec while (1) { + if (pTask->taskStatus == TASK_STATUS__DROPPING) { + return 0; + } + SSDataBlock* output = NULL; uint64_t ts = 0; if ((code = qExecTask(exec, &output, &ts)) < 0) { diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index cf388da92c..e26c8a5c5b 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -663,8 +663,7 @@ int32_t streamStateSessionClear(SStreamState* pState) { void* buf = NULL; int32_t size = 0; int32_t code = streamStateSessionGetKVByCur(pCur, &delKey, &buf, &size); - if (code == 0) { - ASSERT(size > 0); + if (code == 0 && size > 0) { memset(buf, 0, size); streamStateSessionPut(pState, &delKey, buf, size); } else { diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 6af60af43d..b5227152df 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -238,7 +238,7 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode); int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms); int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode); int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms); -int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode); +void syncNodeResetElectTimer(SSyncNode* pSyncNode); int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode); int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode); int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode); diff --git a/source/libs/sync/inc/syncPipeline.h b/source/libs/sync/inc/syncPipeline.h index 8c7edf85ff..a0a0691694 100644 --- a/source/libs/sync/inc/syncPipeline.h +++ b/source/libs/sync/inc/syncPipeline.h @@ -61,7 +61,7 @@ typedef struct SSyncLogBuffer { // SSyncLogRepMgr SSyncLogReplMgr* syncLogReplMgrCreate(); void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr); -int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr); +void syncLogReplMgrReset(SSyncLogReplMgr* pMgr); int32_t syncNodeLogReplMgrInit(SSyncNode* pNode); void syncNodeLogReplMgrDestroy(SSyncNode* pNode); @@ -109,6 +109,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); #ifdef __cplusplus } #endif diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 2b6e14a457..974a8f968e 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -56,7 +56,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI void snapshotSenderDestroy(SSyncSnapshotSender *pSender); bool snapshotSenderIsStart(SSyncSnapshotSender *pSender); int32_t snapshotSenderStart(SSyncSnapshotSender *pSender); -int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); @@ -79,8 +79,8 @@ typedef struct SSyncSnapshotReceiver { SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId fromId); void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver); -int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg); -int32_t snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); +void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg); +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index f1aa9312c6..1a481a7e14 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -200,12 +200,15 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) { code = syncNodeOnLocalCmd(pSyncNode, pMsg); break; default: - sError("vgId:%d, failed to process msg:%p since invalid type:%s", pSyncNode->vgId, pMsg, - TMSG_INFO(pMsg->msgType)); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; code = -1; } syncNodeRelease(pSyncNode); + if (code != 0) { + sDebug("vgId:%d, failed to process sync msg:%p type:%s since 0x%x", pSyncNode->vgId, pMsg, TMSG_INFO(pMsg->msgType), + terrno); + } return code; } @@ -228,8 +231,7 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { syncNodeRelease(pNode); if (ret == 1) { - sInfo("send timeout response, seq:%" PRId64 " handle:%p ahandle:%p", seq, rpcMsg.info.handle, - rpcMsg.info.ahandle); + sInfo("send timeout response, seq:%" PRId64 " handle:%p ahandle:%p", seq, rpcMsg.info.handle, rpcMsg.info.ahandle); rpcSendResponse(&rpcMsg); return 0; } else { @@ -1084,13 +1086,17 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // snapshot senders for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i); - // ASSERT(pSender != NULL); - (pSyncNode->senders)[i] = pSender; - sSDebug(pSender, "snapshot sender create new while open, data:%p", pSender); + if (pSender == NULL) return NULL; + + pSyncNode->senders[i] = pSender; + sSDebug(pSender, "snapshot sender create while open sync node, data:%p", pSender); } // snapshot receivers pSyncNode->pNewNodeReceiver = snapshotReceiverCreate(pSyncNode, EMPTY_RAFT_ID); + if (pSyncNode->pNewNodeReceiver == NULL) return NULL; + sRDebug(pSyncNode->pNewNodeReceiver, "snapshot receiver create while open sync node, data:%p", + pSyncNode->pNewNodeReceiver); // is config changing pSyncNode->changing = false; @@ -1131,10 +1137,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->hbrSlowNum = 0; pSyncNode->tmrRoutineNum = 0; - sNInfo(pSyncNode, "sync open, node:%p", pSyncNode); - sTrace("vgId:%d, tsElectInterval:%d, tsHeartbeatInterval:%d, tsHeartbeatTimeout:%d", pSyncNode->vgId, tsElectInterval, - tsHeartbeatInterval, tsHeartbeatTimeout); - + sNInfo(pSyncNode, "sync open, node:%p electInterval:%d heartbeatInterval:%d heartbeatTimeout:%d", pSyncNode, + tsElectInterval, tsHeartbeatInterval, tsHeartbeatTimeout); return pSyncNode; _error: @@ -1251,6 +1255,8 @@ void syncNodePreClose(SSyncNode* pSyncNode) { snapshotReceiverForceStop(pSyncNode->pNewNodeReceiver); } + sDebug("vgId:%d, snapshot receiver destroy while preclose sync node, data:%p", pSyncNode->vgId, + pSyncNode->pNewNodeReceiver); snapshotReceiverDestroy(pSyncNode->pNewNodeReceiver); pSyncNode->pNewNodeReceiver = NULL; } @@ -1295,15 +1301,15 @@ void syncNodeClose(SSyncNode* pSyncNode) { syncNodeStopHeartbeatTimer(pSyncNode); for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { - if ((pSyncNode->senders)[i] != NULL) { - sSTrace((pSyncNode->senders)[i], "snapshot sender destroy while close, data:%p", (pSyncNode->senders)[i]); + if (pSyncNode->senders[i] != NULL) { + sDebug("vgId:%d, snapshot sender destroy while close, data:%p", pSyncNode->vgId, pSyncNode->senders[i]); - if (snapshotSenderIsStart((pSyncNode->senders)[i])) { - snapshotSenderStop((pSyncNode->senders)[i], false); + if (snapshotSenderIsStart(pSyncNode->senders[i])) { + snapshotSenderStop(pSyncNode->senders[i], false); } - snapshotSenderDestroy((pSyncNode->senders)[i]); - (pSyncNode->senders)[i] = NULL; + snapshotSenderDestroy(pSyncNode->senders[i]); + pSyncNode->senders[i] = NULL; } } @@ -1312,6 +1318,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { snapshotReceiverForceStop(pSyncNode->pNewNodeReceiver); } + sDebug("vgId:%d, snapshot receiver destroy while close, data:%p", pSyncNode->vgId, pSyncNode->pNewNodeReceiver); snapshotReceiverDestroy(pSyncNode->pNewNodeReceiver); pSyncNode->pNewNodeReceiver = NULL; } @@ -1382,8 +1389,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) { return ret; } -int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; +void syncNodeResetElectTimer(SSyncNode* pSyncNode) { int32_t electMS; if (pSyncNode->pRaftCfg->isStandBy) { @@ -1391,11 +1397,11 @@ int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) { } else { electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine); } - ret = syncNodeRestartElectTimer(pSyncNode, electMS); + + (void)syncNodeRestartElectTimer(pSyncNode, electMS); sNTrace(pSyncNode, "reset elect timer, min:%d, max:%d, ms:%d", pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine, electMS); - return ret; } static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) { @@ -1455,23 +1461,20 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { return 0; } -// utils -------------- int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg) { SEpSet epSet; syncUtilRaftId2EpSet(destRaftId, &epSet); - if (pSyncNode->syncSendMSg != NULL) { - // htonl - syncUtilMsgHtoN(pMsg->pCont); + if (pSyncNode->syncSendMSg != NULL) { + syncUtilMsgHtoN(pMsg->pCont); pMsg->info.noResp = 1; - pSyncNode->syncSendMSg(&epSet, pMsg); + return pSyncNode->syncSendMSg(&epSet, pMsg); } else { sError("vgId:%d, sync send msg by id error, fp-send-msg is null", pSyncNode->vgId); rpcFreeCont(pMsg->pCont); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; } - - return 0; } int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg) { @@ -1586,7 +1589,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde memcpy(oldReplicasId, pSyncNode->replicasId, sizeof(oldReplicasId)); SSyncSnapshotSender* oldSenders[TSDB_MAX_REPLICA]; for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { - oldSenders[i] = (pSyncNode->senders)[i]; + oldSenders[i] = pSyncNode->senders[i]; sSTrace(oldSenders[i], "snapshot sender save old"); } @@ -1625,7 +1628,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde // clear new for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { - (pSyncNode->senders)[i] = NULL; + pSyncNode->senders[i] = NULL; } // reset new @@ -1640,16 +1643,16 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde sNTrace(pSyncNode, "snapshot sender reset for: %" PRId64 ", newIndex:%d, %s:%d, %p", (pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]); - (pSyncNode->senders)[i] = oldSenders[j]; + pSyncNode->senders[i] = oldSenders[j]; oldSenders[j] = NULL; reset = true; // reset replicaIndex - int32_t oldreplicaIndex = (pSyncNode->senders)[i]->replicaIndex; - (pSyncNode->senders)[i]->replicaIndex = i; + int32_t oldreplicaIndex = pSyncNode->senders[i]->replicaIndex; + pSyncNode->senders[i]->replicaIndex = i; sNTrace(pSyncNode, "snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d", oldreplicaIndex, - i, host, port, (pSyncNode->senders)[i], reset); + i, host, port, pSyncNode->senders[i], reset); break; } @@ -1658,18 +1661,23 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde // create new for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { - if ((pSyncNode->senders)[i] == NULL) { - (pSyncNode->senders)[i] = snapshotSenderCreate(pSyncNode, i); - sSTrace((pSyncNode->senders)[i], "snapshot sender create new while reconfig, data:%p", (pSyncNode->senders)[i]); + if (pSyncNode->senders[i] == NULL) { + pSyncNode->senders[i] = snapshotSenderCreate(pSyncNode, i); + if (pSyncNode->senders[i] == NULL) { + // will be created later while send snapshot + sSError(pSyncNode->senders[i], "snapshot sender create failed while reconfig"); + } else { + sSDebug(pSyncNode->senders[i], "snapshot sender create while reconfig, data:%p", pSyncNode->senders[i]); + } } else { - sSTrace((pSyncNode->senders)[i], "snapshot sender already exist, data:%p", (pSyncNode->senders)[i]); + sSDebug(pSyncNode->senders[i], "snapshot sender already exist, data:%p", pSyncNode->senders[i]); } } // free old for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { if (oldSenders[i] != NULL) { - sNTrace(pSyncNode, "snapshot sender destroy old, data:%p replica-index:%d", oldSenders[i], i); + sSDebug(oldSenders[i], "snapshot sender destroy old, data:%p replica-index:%d", oldSenders[i], i); snapshotSenderDestroy(oldSenders[i]); oldSenders[i] = NULL; } @@ -1844,8 +1852,8 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId)); if (pMySender != NULL) { for (int32_t i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) { - if ((pSyncNode->senders)[i]->privateTerm > pMySender->privateTerm) { - pMySender->privateTerm = (pSyncNode->senders)[i]->privateTerm; + if (pSyncNode->senders[i]->privateTerm > pMySender->privateTerm) { + pMySender->privateTerm = pSyncNode->senders[i]->privateTerm; } } (pMySender->privateTerm) += 100; @@ -2376,9 +2384,20 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand } int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { + if (pEntry->dataLen < sizeof(SMsgHead)) { + sError("vgId:%d, cannot append an invalid client request with no msg head. type:%s, dataLen:%d", ths->vgId, + TMSG_INFO(pEntry->originalRpcType), pEntry->dataLen); + syncEntryDestroy(pEntry); + return -1; + } + // append to log buffer if (syncLogBufferAppend(ths->pLogBuf, ths, pEntry) < 0) { - sError("vgId:%d, failed to enqueue sync log buffer. index:%" PRId64 "", ths->vgId, pEntry->index); + sError("vgId:%d, failed to enqueue sync log buffer, index:%" PRId64, ths->vgId, pEntry->index); + terrno = TSDB_CODE_SYN_BUFFER_FULL; + (void)syncLogFsmExecute(ths, ths->pFsm, ths->state, ths->pRaftStore->currentTerm, pEntry, + TSDB_CODE_SYN_BUFFER_FULL); + syncEntryDestroy(pEntry); return -1; } @@ -2671,16 +2690,24 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn pEntry = syncEntryBuildFromRpcMsg(pMsg, term, index); } + if (pEntry == NULL) { + sError("vgId:%d, failed to process client request since %s.", ths->vgId, terrstr()); + return -1; + } + if (ths->state == TAOS_SYNC_STATE_LEADER) { if (pRetIndex) { (*pRetIndex) = index; } int32_t code = syncNodeAppend(ths, pEntry); - if (code < 0 && ths->vgId != 1 && vnodeIsMsgBlock(pEntry->originalRpcType)) { - ASSERTS(false, "failed to append blocking msg"); + if (code < 0) { + sNError(ths, "failed to append blocking msg"); } return code; + } else { + syncEntryDestroy(pEntry); + pEntry = NULL; } return -1; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index f438856ace..ee649c268c 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -26,6 +26,11 @@ #include "syncSnapshot.h" #include "syncUtil.h" +static bool syncIsMsgBlock(tmsg_t type) { + return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || + (type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_CONFIRM); +} + int64_t syncLogBufferGetEndIndex(SSyncLogBuffer* pBuf) { taosThreadMutexLock(&pBuf->mutex); int64_t index = pBuf->endIndex; @@ -40,7 +45,7 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt if (index - pBuf->startIndex >= pBuf->size) { sError("vgId:%d, failed to append due to sync log buffer full. index:%" PRId64 "", pNode->vgId, index); - goto _out; + goto _err; } ASSERT(index == pBuf->endIndex); @@ -61,9 +66,8 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt taosThreadMutexUnlock(&pBuf->mutex); return 0; -_out: +_err: syncLogBufferValidate(pBuf); - syncEntryDestroy(pEntry); taosThreadMutexUnlock(&pBuf->mutex); return -1; } @@ -112,7 +116,7 @@ SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, S return prevLogTerm; } - sError("vgId:%d, failed to get log term since %s. index: %" PRId64 "", pNode->vgId, terrstr(), prevIndex); + sInfo("vgId:%d, failed to get log term since %s. index:%" PRId64, pNode->vgId, terrstr(), prevIndex); terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; return -1; } @@ -441,26 +445,25 @@ _out: return matchIndex; } -int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry) { - ASSERTS(pFsm->FpCommitCb != NULL, "No commit cb registered for the FSM"); - +int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, + int32_t applyCode) { if ((pNode->replicaNum == 1) && pNode->restoreFinish && pNode->vgId != 1) { return 0; } - if (pNode->vgId != 1 && vnodeIsMsgBlock(pEntry->originalRpcType)) { - sTrace("vgId:%d, blocking msg ready to execute. index:%" PRId64 ", term: %" PRId64 ", type: %s", pNode->vgId, - pEntry->index, pEntry->term, TMSG_INFO(pEntry->originalRpcType)); + if (pNode->vgId != 1 && syncIsMsgBlock(pEntry->originalRpcType)) { + sTrace("vgId:%d, blocking msg ready to execute, index:%" PRId64 ", term:%" PRId64 ", type:%s code:0x%x", + pNode->vgId, pEntry->index, pEntry->term, TMSG_INFO(pEntry->originalRpcType), applyCode); } - SRpcMsg rpcMsg = {0}; + SRpcMsg rpcMsg = {.code = applyCode}; syncEntry2OriginalRpc(pEntry, &rpcMsg); SFsmCbMeta cbMeta = {0}; cbMeta.index = pEntry->index; cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(pNode, pEntry->index); cbMeta.isWeak = pEntry->isWeak; - cbMeta.code = 0; + cbMeta.code = applyCode; cbMeta.state = role; cbMeta.seqNum = pEntry->seqNum; cbMeta.term = pEntry->term; @@ -469,7 +472,6 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn (void)syncRespMgrGetAndDel(pNode->pSyncRespMgr, cbMeta.seqNum, &rpcMsg.info); int32_t code = pFsm->FpCommitCb(pFsm, &rpcMsg, &cbMeta); - ASSERT(rpcMsg.pCont == NULL); return code; } @@ -520,7 +522,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm pEntry->term, TMSG_INFO(pEntry->originalRpcType)); } - if (syncLogFsmExecute(pNode, pFsm, role, term, pEntry) != 0) { + if (syncLogFsmExecute(pNode, pFsm, role, term, 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, term); @@ -566,7 +568,9 @@ _out: return ret; } -int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { +void syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { + if (pMgr == NULL) return; + ASSERT(pMgr->startIndex >= 0); for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) { memset(&pMgr->states[index % pMgr->size], 0, sizeof(pMgr->states[0])); @@ -576,7 +580,6 @@ int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { pMgr->endIndex = 0; pMgr->restored = false; pMgr->retryBackoff = 0; - return 0; } int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 018ac5bb7d..3f9f397ef5 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -115,8 +115,8 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI const char* sysErrStr = strerror(errno); sNError(pData->pSyncNode, - "wal restore from snapshot error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", - snapshotIndex, err, err, errStr, sysErr, sysErrStr); + "wal restore from snapshot error, index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", snapshotIndex, + err, errStr, sysErr, sysErrStr); return -1; } @@ -212,8 +212,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sNError(pData->pSyncNode, "wal write error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", - pEntry->index, err, err, errStr, sysErr, sysErrStr); + sNError(pData->pSyncNode, "wal write error, index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", + pEntry->index, err, errStr, sysErr, sysErrStr); return -1; } @@ -257,11 +257,11 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR const char* sysErrStr = strerror(errno); if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { - sNTrace(pData->pSyncNode, "wal read not exist, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, - err, err, errStr, sysErr, sysErrStr); + sNTrace(pData->pSyncNode, "wal read not exist, index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", index, + err, errStr, sysErr, sysErrStr); } else { - sNTrace(pData->pSyncNode, "wal read error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, - err, err, errStr, sysErr, sysErrStr); + sNTrace(pData->pSyncNode, "wal read error, index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", index, err, + errStr, sysErr, sysErrStr); } /* @@ -341,8 +341,8 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn const char* errStr = tstrerror(err); int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sError("vgId:%d, wal truncate error, from-index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", - pData->pSyncNode->vgId, fromIndex, err, err, errStr, sysErr, sysErrStr); + sError("vgId:%d, wal truncate error, from-index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", + pData->pSyncNode->vgId, fromIndex, err, errStr, sysErr, sysErrStr); } // event log @@ -392,8 +392,8 @@ int32_t raftLogUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) { const char* errStr = tstrerror(err); int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sError("vgId:%d, wal update commit index error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", - pData->pSyncNode->vgId, index, err, err, errStr, sysErr, sysErrStr); + sError("vgId:%d, wal update commit index error, index:%" PRId64 ", err:0x%x, msg:%s, syserr:%d, sysmsg:%s", + pData->pSyncNode->vgId, index, err, errStr, sysErr, sysErrStr); return -1; } return 0; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 30324c1113..f2da2fb2ce 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -49,13 +49,11 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; - sDebug("vgId:%d, snapshot sender create", pSender->pSyncNode->vgId); return pSender; } void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender == NULL) return; - sDebug("vgId:%d, snapshot sender destroy", pSender->pSyncNode->vgId); // free current block if (pSender->pCurrentBlock != NULL) { @@ -76,12 +74,6 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; } int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { - if (snapshotSenderIsStart(pSender)) { - sSError(pSender, "vgId:%d, snapshot sender is already start"); - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - return -1; - } - pSender->start = true; pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; @@ -96,7 +88,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { pSender->snapshot.lastApplyTerm = SYNC_TERM_INVALID; pSender->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; - memset(&(pSender->lastConfig), 0, sizeof(pSender->lastConfig)); + memset(&pSender->lastConfig, 0, sizeof(pSender->lastConfig)); pSender->sendingMS = 0; pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; pSender->startTime = taosGetTimestampMs(); @@ -112,7 +104,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { SyncSnapshotSend *pMsg = rpcMsg.pCont; pMsg->srcId = pSender->pSyncNode->myRaftId; - pMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; + pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->beginIndex = pSender->snapshotParam.start; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; @@ -123,7 +115,6 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { pMsg->seq = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT; // event log - sSDebug(pSender, "snapshot sender start"); syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender start"); // send msg @@ -135,7 +126,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { return 0; } -int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { sSDebug(pSender, "snapshot sender stop, finish:%d reader:%p", finish, pSender->pReader); // update flag @@ -155,8 +146,6 @@ int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { pSender->pCurrentBlock = NULL; pSender->blockLen = 0; } - - return 0; } // when sender receive ack, call this function to send msg from seq @@ -178,8 +167,8 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { } if (pSender->blockLen > 0) { - sSDebug(pSender, "snapshot sender continue to read, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); // has read data + sSDebug(pSender, "snapshot sender continue to read, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); } else { // read finish, update seq to end pSender->seq = SYNC_SNAPSHOT_SEQ_END; @@ -195,7 +184,7 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { SyncSnapshotSend *pMsg = rpcMsg.pCont; pMsg->srcId = pSender->pSyncNode->myRaftId; - pMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; + pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->beginIndex = pSender->snapshotParam.start; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; @@ -203,7 +192,6 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; pMsg->lastConfig = pSender->lastConfig; pMsg->seq = pSender->seq; - // pMsg->privateTerm = pSender->privateTerm; if (pSender->pCurrentBlock != NULL) { memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); @@ -211,10 +199,8 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { // event log if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { - sSDebug(pSender, "snapshot sender finish, seq:%d", pSender->seq); syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender finish"); } else { - sSDebug(pSender, "snapshot sender sending, seq:%d", pSender->seq); syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender sending"); } @@ -239,7 +225,7 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { SyncSnapshotSend *pMsg = rpcMsg.pCont; pMsg->srcId = pSender->pSyncNode->myRaftId; - pMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; + pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; pMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pMsg->beginIndex = pSender->snapshotParam.start; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; @@ -249,12 +235,10 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { pMsg->seq = pSender->seq; if (pSender->pCurrentBlock != NULL && pSender->blockLen > 0) { - // pMsg->privateTerm = pSender->privateTerm; memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); } // event log - sSDebug(pSender, "snapshot sender resend, seq:%d", pSender->seq); syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender resend"); // send msg @@ -294,19 +278,16 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) { } if (snapshotSenderIsStart(pSender)) { - sSError(pSender, "snapshot sender already start, ignore"); + sSInfo(pSender, "snapshot sender already start, ignore"); return 0; } if (pSender->finish && taosGetTimestampMs() - pSender->endTime < SNAPSHOT_WAIT_MS) { sSInfo(pSender, "snapshot sender start too frequently, ignore"); - return 1; + return 0; } - char host[64]; - uint16_t port; - syncUtilU642Addr(pDestId->addr, host, sizeof(host), &port); - sSInfo(pSender, "snapshot sender start for peer:%s:%u", host, port); + sSInfo(pSender, "snapshot sender start"); int32_t code = snapshotSenderStart(pSender); if (code != 0) { @@ -339,13 +320,11 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->snapshot.lastApplyTerm = 0; pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; - sDebug("vgId:%d, snapshot receiver create", pSyncNode->vgId); return pReceiver; } void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { if (pReceiver == NULL) return; - sDebug("vgId:%d, snapshot receiver destroy", pReceiver->pSyncNode->vgId); // close writer if (pReceiver->pWriter != NULL) { @@ -369,7 +348,6 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { // force close, abandon incomplete data if (pReceiver->pWriter != NULL) { - // event log int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false, &pReceiver->snapshot); if (ret != 0) { @@ -381,13 +359,7 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { pReceiver->start = false; } -int32_t snapshotReceiverStartWriter(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) { - if (!snapshotReceiverIsStart(pReceiver)) { - sRError(pReceiver, "snapshot receiver is not start"); - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - return -1; - } - +static int32_t snapshotReceiverStartWriter(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) { if (pReceiver->pWriter != NULL) { sRError(pReceiver, "vgId:%d, snapshot receiver writer is not null"); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; @@ -417,10 +389,10 @@ int32_t snapshotReceiverStartWriter(SSyncSnapshotReceiver *pReceiver, SyncSnapsh return 0; } -int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pPreMsg) { +void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pPreMsg) { if (snapshotReceiverIsStart(pReceiver)) { sRInfo(pReceiver, "snapshot receiver has started"); - return 0; + return; } pReceiver->start = true; @@ -431,12 +403,11 @@ int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend // event log sRInfo(pReceiver, "snapshot receiver is start"); - return 0; } // just set start = false // FpSnapshotStopWrite should not be called, assert writer == NULL -int32_t snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { sRInfo(pReceiver, "snapshot receiver stop, not apply, writer:%p", pReceiver->pWriter); if (pReceiver->pWriter != NULL) { @@ -451,17 +422,10 @@ int32_t snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { } pReceiver->start = false; - return 0; } // when recv last snapshot block, apply data into snapshot static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { - if (pMsg->seq != SYNC_SNAPSHOT_SEQ_END) { - sRError(pReceiver, "snapshot receiver seq:%d is invalid", pMsg->seq); - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - return -1; - } - int32_t code = 0; if (pReceiver->pWriter != NULL) { // write data @@ -523,7 +487,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap static int32_t snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { if (pMsg->seq != pReceiver->ack + 1) { sRError(pReceiver, "snapshot receiver invalid seq, ack:%d seq:%d", pReceiver->ack, pMsg->seq); - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + terrno = TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG; return -1; } @@ -583,6 +547,7 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) { static int32_t syncNodeOnSnapshotPre(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; int64_t timeNow = taosGetTimestampMs(); + int32_t code = 0; if (snapshotReceiverIsStart(pReceiver)) { // already start @@ -594,14 +559,14 @@ static int32_t syncNodeOnSnapshotPre(SSyncNode *pSyncNode, SyncSnapshotSend *pMs sRInfo(pReceiver, "snapshot receiver startTime:%" PRId64 " == msg startTime:%" PRId64 " send reply", pReceiver->startTime, pMsg->startTime); goto _SEND_REPLY; - } else { // ignore - sRInfo(pReceiver, "snapshot receiver startTime:%" PRId64 " < msg startTime:%" PRId64 " ignore", - pReceiver->startTime, pMsg->startTime); - return 0; + sRError(pReceiver, "snapshot receiver startTime:%" PRId64 " < msg startTime:%" PRId64 " ignore", + pReceiver->startTime, pMsg->startTime); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + code = terrno; + goto _SEND_REPLY; } - } else { // start new sRInfo(pReceiver, "snapshot receiver not start yet so start new one"); @@ -612,7 +577,8 @@ _START_RECEIVER: if (timeNow - pMsg->startTime > SNAPSHOT_MAX_CLOCK_SKEW_MS) { sRError(pReceiver, "snapshot receiver time skew too much, now:%" PRId64 " msg startTime:%" PRId64, timeNow, pMsg->startTime); - return -1; + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + code = terrno; } else { // waiting for clock match while (timeNow < pMsg->startTime) { @@ -648,7 +614,7 @@ _SEND_REPLY: pRspMsg->lastTerm = pMsg->lastTerm; pRspMsg->startTime = pReceiver->startTime; pRspMsg->ack = pMsg->seq; // receiver maybe already closed - pRspMsg->code = 0; + pRspMsg->code = code; pRspMsg->snapBeginIndex = syncNodeGetSnapBeginIndex(pSyncNode); // send msg @@ -658,26 +624,36 @@ _SEND_REPLY: return -1; } - return 0; + return code; } static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // condition 1 SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; + int32_t code = TSDB_CODE_SYN_INTERNAL_ERROR; if (!snapshotReceiverIsStart(pReceiver)) { - sRError(pReceiver, "snapshot receiver not start"); - return -1; + sRError(pReceiver, "snapshot receiver begin failed since not start"); + goto _SEND_REPLY; } if (pReceiver->startTime != pMsg->startTime) { - sRError(pReceiver, "snapshot receiver startTime:%" PRId64 " not equal to msg startTime:%" PRId64, + sRError(pReceiver, "snapshot receiver begin failed since startTime:%" PRId64 " not equal to msg startTime:%" PRId64, pReceiver->startTime, pMsg->startTime); - return -1; + goto _SEND_REPLY; } // start writer - snapshotReceiverStartWriter(pReceiver, pMsg); + if (snapshotReceiverStartWriter(pReceiver, pMsg) != 0) { + sRError(pReceiver, "snapshot receiver begin failed since start writer failed"); + goto _SEND_REPLY; + } + + code = 0; +_SEND_REPLY: + if (code != 0 && terrno != 0) { + code = terrno; + } // build msg SRpcMsg rpcMsg = {0}; @@ -694,7 +670,7 @@ static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *p pRspMsg->lastTerm = pMsg->lastTerm; pRspMsg->startTime = pReceiver->startTime; pRspMsg->ack = pReceiver->ack; // receiver maybe already closed - pRspMsg->code = 0; + pRspMsg->code = code; pRspMsg->snapBeginIndex = pReceiver->snapshotParam.start; // send msg @@ -704,10 +680,10 @@ static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *p return -1; } - return 0; + return code; } -static int32_t syncNodeOnSnapshotTransfering(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { +static int32_t syncNodeOnSnapshotReceive(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // condition 4 // transfering SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; @@ -721,8 +697,12 @@ static int32_t syncNodeOnSnapshotTransfering(SSyncNode *pSyncNode, SyncSnapshotS timeNow = taosGetTimestampMs(); } + int32_t code = 0; if (snapshotReceiverGotData(pReceiver, pMsg) != 0) { - return -1; + code = terrno; + if (code >= SYNC_SNAPSHOT_SEQ_INVALID) { + code = TSDB_CODE_SYN_INTERNAL_ERROR; + } } // build msg @@ -740,17 +720,17 @@ static int32_t syncNodeOnSnapshotTransfering(SSyncNode *pSyncNode, SyncSnapshotS pRspMsg->lastTerm = pMsg->lastTerm; pRspMsg->startTime = pReceiver->startTime; pRspMsg->ack = pReceiver->ack; // receiver maybe already closed - pRspMsg->code = 0; + pRspMsg->code = code; pRspMsg->snapBeginIndex = pReceiver->snapshotParam.start; // send msg - syncLogSendSyncSnapshotRsp(pSyncNode, pRspMsg, "snapshot receiver receiving"); + syncLogSendSyncSnapshotRsp(pSyncNode, pRspMsg, "snapshot receiver received"); if (syncNodeSendMsgById(&pRspMsg->destId, pSyncNode, &rpcMsg) != 0) { sRError(pReceiver, "snapshot receiver send resp failed since %s", terrstr()); return -1; } - return 0; + return code; } static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { @@ -787,7 +767,7 @@ static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMs pRspMsg->lastTerm = pMsg->lastTerm; pRspMsg->startTime = pReceiver->startTime; pRspMsg->ack = pReceiver->ack; // receiver maybe already closed - pRspMsg->code = 0; + pRspMsg->code = code; pRspMsg->snapBeginIndex = pReceiver->snapshotParam.start; // send msg @@ -797,7 +777,7 @@ static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMs return -1; } - return 0; + return code; } // receiver on message @@ -827,12 +807,14 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { // if already drop replica, do not process if (!syncNodeInRaftGroup(pSyncNode, &pMsg->srcId)) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "not in my config"); - return 0; + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + return -1; } if (pMsg->term < pSyncNode->pRaftStore->currentTerm) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "reject since small term"); - return 0; + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + return -1; } if (pMsg->term > pSyncNode->pRaftStore->currentTerm) { @@ -841,56 +823,49 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { syncNodeResetElectTimer(pSyncNode); // state, term, seq/ack + int32_t code = 0; if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq pre-snapshot"); - syncNodeOnSnapshotPre(pSyncNode, pMsg); + code = syncNodeOnSnapshotPre(pSyncNode, pMsg); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq begin"); - syncNodeOnSnapshotBegin(pSyncNode, pMsg); + code = syncNodeOnSnapshotBegin(pSyncNode, pMsg); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq end"); - syncNodeOnSnapshotEnd(pSyncNode, pMsg); + code = syncNodeOnSnapshotEnd(pSyncNode, pMsg); if (syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode) != 0) { sRError(pReceiver, "failed to reinit log buffer since %s", terrstr()); - return -1; + code = -1; } } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { // force close, no response syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process force stop"); snapshotReceiverForceStop(pReceiver); } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { - syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq"); - syncNodeOnSnapshotTransfering(pSyncNode, pMsg); + syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq data"); + code = syncNodeOnSnapshotReceive(pSyncNode, pMsg); } else { // error log sRError(pReceiver, "snapshot receiver recv error seq:%d, my ack:%d", pMsg->seq, pReceiver->ack); - return -1; + code = -1; } } else { // error log sRError(pReceiver, "snapshot receiver term not equal"); - return -1; + code = -1; } } else { // error log sRError(pReceiver, "snapshot receiver not follower"); - return -1; + code = -1; } - return 0; + return code; } -int32_t syncNodeOnSnapshotReplyPre(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { - // get sender - SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, &(pMsg->srcId)); - if (pSender == NULL) { - sNError(pSyncNode, "prepare snapshot error since sender is null"); - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - return -1; - } - +static int32_t syncNodeOnSnapshotPreRsp(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { SSnapshot snapshot = {0}; pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); @@ -912,7 +887,7 @@ int32_t syncNodeOnSnapshotReplyPre(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) pSender->snapshot = snapshot; // start reader - int32_t code = pSyncNode->pFsm->FpSnapshotStartRead(pSyncNode->pFsm, &(pSender->snapshotParam), &(pSender->pReader)); + int32_t code = pSyncNode->pFsm->FpSnapshotStartRead(pSyncNode->pFsm, &pSender->snapshotParam, &pSender->pReader); if (code != 0) { sSError(pSender, "prepare snapshot failed since %s", terrstr()); return -1; @@ -933,7 +908,7 @@ int32_t syncNodeOnSnapshotReplyPre(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) SyncSnapshotSend *pSendMsg = rpcMsg.pCont; pSendMsg->srcId = pSender->pSyncNode->myRaftId; - pSendMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; + pSendMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; pSendMsg->term = pSender->pSyncNode->pRaftStore->currentTerm; pSendMsg->beginIndex = pSender->snapshotParam.start; pSendMsg->lastIndex = pSender->snapshot.lastApplyIndex; @@ -963,8 +938,9 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { SyncSnapshotRsp *pMsg = pRpcMsg->pCont; // if already drop replica, do not process - if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId))) { + if (!syncNodeInRaftGroup(pSyncNode, &pMsg->srcId)) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "maybe replica already dropped"); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; } @@ -976,76 +952,96 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { return -1; } - if (pMsg->startTime != pSender->startTime) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "sender:% " PRId64 " receiver:%" PRId64 " time not match"); - return -1; + // state, term, seq/ack + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender not leader"); + sSError(pSender, "snapshot sender not leader"); + terrno = TSDB_CODE_SYN_NOT_LEADER; + goto _ERROR; } - // state, term, seq/ack - if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { - // prepare , send begin msg - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq pre-snapshot"); - syncNodeOnSnapshotReplyPre(pSyncNode, pMsg); - return 0; - } + if (pMsg->startTime != pSender->startTime) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender and receiver time not match"); + sSError(pSender, "sender:%" PRId64 " receiver:%" PRId64 " time not match, code:0x%x", pMsg->startTime, + pSender->startTime, pMsg->code); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + goto _ERROR; + } - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq begin"); - if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { - return -1; - } + if (pMsg->term != pSyncNode->pRaftStore->currentTerm) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender and receiver term not match"); + sSError(pSender, "snapshot sender term not equal, msg term:%" PRId64 " currentTerm:%" PRId64, pMsg->term, + pSyncNode->pRaftStore->currentTerm); + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + goto _ERROR; + } - if (snapshotSend(pSender) != 0) { - return -1; - } - return 0; - } + if (pMsg->code != 0) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error code"); + sSError(pSender, "snapshot sender receive error code:0x%x and stop sender", pMsg->code); + terrno = pMsg->code; + goto _ERROR; + } - // receive ack is finish, close sender - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq end"); - snapshotSenderStop(pSender, true); - SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); - if (pMgr) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "reset repl mgr"); - syncLogReplMgrReset(pMgr); - } - return 0; - } + // prepare , send begin msg + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq pre-snapshot"); + return syncNodeOnSnapshotPreRsp(pSyncNode, pSender, pMsg); + } - // send next msg - if (pMsg->ack == pSender->seq) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq"); - // update sender ack - if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { - return -1; - } - if (snapshotSend(pSender) != 0) { - return -1; - } + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq begin"); + if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { + return -1; + } - } else if (pMsg->ack == pSender->seq - 1) { - // maybe resend - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq and resend"); - snapshotReSend(pSender); + if (snapshotSend(pSender) != 0) { + return -1; + } + return 0; + } - } else { - // error log - sSError(pSender, "snapshot sender recv error ack:%d, my seq:%d", pMsg->ack, pSender->seq); - return -1; - } - } else { - // error log - sSError(pSender, "snapshot sender term not equal"); + // receive ack is finish, close sender + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq end"); + snapshotSenderStop(pSender, true); + SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); + syncLogReplMgrReset(pMgr); + return 0; + } + + // send next msg + if (pMsg->ack == pSender->seq) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq data"); + // update sender ack + if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { + return -1; + } + if (snapshotSend(pSender) != 0) { + return -1; + } + } else if (pMsg->ack == pSender->seq - 1) { + // maybe resend + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq and resend"); + if (snapshotReSend(pSender) != 0) { return -1; } } else { // error log - sSError(pSender, "snapshot sender not leader"); + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error ack"); + sSError(pSender, "snapshot sender receive error ack:%d, my seq:%d", pMsg->ack, pSender->seq); + snapshotSenderStop(pSender, true); + SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); + syncLogReplMgrReset(pMgr); return -1; } return 0; + +_ERROR: + snapshotSenderStop(pSender, true); + SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); + syncLogReplMgrReset(pMgr); + + return -1; } diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 8d9933b160..62d82edeb1 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -869,11 +869,19 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) { return -1; } + if (tdbOsLSeek(jfd, 0L, SEEK_SET) < 0) { + tdbError("failed to lseek jfd due to %s. file:%s, offset:0", strerror(errno), pPager->dbFileName); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + pageBuf = tdbOsCalloc(1, pPager->pageSize); if (pageBuf == NULL) { return -1; } + tdbDebug("pager/restore: %p, %d/%d, txnId:%s", pPager, pPager->dbOrigSize, pPager->dbFileSize, jFileName); + for (int pgIndex = 0; pgIndex < journalSize; ++pgIndex) { // read pgno & the page from journal SPgno pgno; @@ -884,6 +892,8 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) { return -1; } + tdbTrace("pager/restore: restore pgno:%d,", pgno); + ret = tdbOsRead(jfd, pageBuf, pPager->pageSize); if (ret < 0) { tdbOsFree(pageBuf); @@ -923,7 +933,7 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) { return -1; } - if (tdbOsRemove(pPager->jFileName) < 0 && errno != ENOENT) { + if (tdbOsRemove(jFileName) < 0 && errno != ENOENT) { tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), pPager->jFileName); terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -943,7 +953,12 @@ int tdbPagerRestoreJournals(SPager *pPager) { while ((pDirEntry = tdbReadDir(pDir)) != NULL) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { - if (tdbPagerRestore(pPager, name) < 0) { + char jname[TD_PATH_MAX] = {0}; + int dirLen = strlen(pPager->pEnv->dbName); + memcpy(jname, pPager->pEnv->dbName, dirLen); + jname[dirLen] = '/'; + memcpy(jname + dirLen + 1, name, strlen(name)); + if (tdbPagerRestore(pPager, jname) < 0) { tdbCloseDir(&pDir); tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), name); @@ -969,7 +984,12 @@ int tdbPagerRollback(SPager *pPager) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { - if (tdbOsRemove(name) < 0 && errno != ENOENT) { + char jname[TD_PATH_MAX] = {0}; + int dirLen = strlen(pPager->pEnv->dbName); + memcpy(jname, pPager->pEnv->dbName, dirLen); + jname[dirLen] = '/'; + memcpy(jname + dirLen + 1, name, strlen(name)); + if (tdbOsRemove(jname) < 0 && errno != ENOENT) { tdbCloseDir(&pDir); tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 2950169979..972e2f29e5 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -108,13 +108,13 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF ASSERT(pPager != NULL); if (rollback) { - tdbPagerRollback(pPager); - } else { ret = tdbPagerRestoreJournals(pPager); if (ret < 0) { tdbOsFree(pTb); return -1; } + } else { + tdbPagerRollback(pPager); } // pTb->pBt diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index d144a76eb0..1dc79e0cfb 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1665,11 +1665,20 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { if (pCtx->retryCode != TSDB_CODE_SUCCESS) { int32_t code = pResp->code; // return internal code app - if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK) { + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) { pResp->code = pCtx->retryCode; } } + // check whole vnodes is offline on this vgroup + if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps || pCtx->retryStep > 0) { + if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + pResp->code = TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED; + } else if (pResp->code == TSDB_CODE_RPC_BROKEN_LINK) { + pResp->code = TSDB_CODE_RPC_SOMENODE_BROKEN_LINK; + } + } + STraceId* trace = &pResp->info.traceId; bool hasEpSet = cliTryExtractEpSet(pResp, &pCtx->epSet); if (hasEpSet) { diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 2b1f68d5f6..7384877313 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -1001,6 +1001,13 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, uv_loop_init(srv->loop); char pipeName[PATH_MAX]; + + if (false == taosValidIpAndPort(srv->ip, srv->port)) { + terrno = TAOS_SYSTEM_ERROR(errno); + tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr()); + goto End; + } + #if defined(WINDOWS) || defined(DARWIN) int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0); if (ret != 0) { @@ -1087,12 +1094,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, } #endif - if (false == taosValidIpAndPort(srv->ip, srv->port)) { - terrno = TAOS_SYSTEM_ERROR(errno); - tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr()); - goto End; - } - if (false == addHandleToAcceptloop(srv)) { goto End; } @@ -1185,8 +1186,8 @@ void transCloseServer(void* arg) { // impl later SServerObj* srv = arg; - tDebug("send quit msg to accept thread"); if (srv->inited) { + tDebug("send quit msg to accept thread"); uv_async_send(srv->pAcceptAsync); taosThreadJoin(srv->thread, NULL); SRV_RELEASE_UV(srv->loop); diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index b7cb20896b..0d85a8bec4 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -44,6 +44,10 @@ if(TD_WINDOWS) os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump ) elseif(TD_DARWIN_64) + find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) + target_link_libraries(os PUBLIC ${CORE_FOUNDATION_FRAMEWORK}) + find_library(SYSTEM_CONFIGURATION_FRAMEWORK SystemConfiguration) + target_link_libraries(os PUBLIC ${SYSTEM_CONFIGURATION_FRAMEWORK}) target_link_libraries( os PUBLIC dl m iconv ) diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index db2a9937b5..6611a937f2 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -988,7 +988,7 @@ int32_t taosGetFqdn(char *fqdn) { #endif char hostname[1024]; hostname[1023] = '\0'; - if (gethostname(hostname, 1023) == -1) { + if (taosGetlocalhostname(hostname, 1023) == -1) { #ifdef WINDOWS printf("failed to get hostname, reason:%s\n", strerror(WSAGetLastError())); #else @@ -998,30 +998,28 @@ int32_t taosGetFqdn(char *fqdn) { return -1; } - struct addrinfo hints = {0}; - struct addrinfo *result = NULL; #ifdef __APPLE__ // on macosx, hostname -f has the form of xxx.local // which will block getaddrinfo for a few seconds if AI_CANONNAME is set // thus, we choose AF_INET (ipv4 for the moment) to make getaddrinfo return // immediately - hints.ai_family = AF_INET; + // hints.ai_family = AF_INET; + strcpy(fqdn, hostname); + strcpy(fqdn+strlen(hostname), ".local"); #else // __APPLE__ + struct addrinfo hints = {0}; + struct addrinfo *result = NULL; hints.ai_flags = AI_CANONNAME; -#endif // __APPLE__ + int32_t ret = getaddrinfo(hostname, NULL, &hints, &result); if (!result) { fprintf(stderr, "failed to get fqdn, code:%d, reason:%s\n", ret, gai_strerror(ret)); return -1; } - -#ifdef __APPLE__ - // refer to comments above - strcpy(fqdn, hostname); -#else // __APPLE__ strcpy(fqdn, result->ai_canonname); -#endif // __APPLE__ freeaddrinfo(result); +#endif // __APPLE__ + return 0; } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index e1abe84841..6c9bf40e4d 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -98,6 +98,9 @@ LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception); #include #include #include +#include +#include +#include #else @@ -1007,6 +1010,11 @@ SysNameInfo taosGetSysNameInfo() { tstrncpy(info.machine, uts.machine, sizeof(info.machine)); } + char localHostName[512]; + taosGetlocalhostname(localHostName, 512); + TdCmdPtr pCmd = taosOpenCmd("scutil --get LocalHostName"); + tstrncpy(info.nodename, localHostName, sizeof(info.nodename)); + return info; #else SysNameInfo info = {0}; @@ -1042,3 +1050,46 @@ bool taosCheckCurrentInDll() { return false; #endif } + +#ifdef _TD_DARWIN_64 +int taosGetMaclocalhostnameByCommand(char *hostname, size_t maxLen) { + TdCmdPtr pCmd = taosOpenCmd("scutil --get LocalHostName"); + if (pCmd != NULL) { + if (taosGetsCmd(pCmd, maxLen - 1, hostname) > 0) { + int len = strlen(hostname); + if (hostname[len - 1] == '\n') { + hostname[len - 1] = '\0'; + } + return 0; + } + taosCloseCmd(&pCmd); + } + return -1; +} + +int getMacLocalHostNameBySCD(char *hostname, size_t maxLen) { + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR(""), NULL, NULL); + CFStringRef hostname_cfstr = SCDynamicStoreCopyLocalHostName(store); + if (hostname_cfstr != NULL) { + CFStringGetCString(hostname_cfstr, hostname, maxLen - 1, kCFStringEncodingMacRoman); + CFRelease(hostname_cfstr); + } else { + return -1; + } + CFRelease(store); + return 0; +} +#endif + +int taosGetlocalhostname(char *hostname, size_t maxLen) { +#ifdef _TD_DARWIN_64 + int res = getMacLocalHostNameBySCD(hostname, maxLen); + if (res != 0) { + return taosGetMaclocalhostnameByCommand(hostname, maxLen); + } else { + return 0; + } +#else + return gethostname(hostname, maxLen); +#endif +} diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 4c922a9132..7bf63abc5f 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -51,6 +51,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQD TAOS_DEFINE_ERROR(TSDB_CODE_RPC_PORT_EADDRINUSE, "Port already in use") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_BROKEN_LINK, "Conn is broken") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TIMEOUT, "Conn read timeout") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED, "some vnode/qnode/mnode(s) out of service") //common & util TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized") @@ -406,6 +407,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_PROPOSE_NOT_READY, "Sync not ready for pr TAOS_DEFINE_ERROR(TSDB_CODE_SYN_STANDBY_NOT_READY, "Sync not ready for standby") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BATCH_ERROR, "Sync batch error") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_RESTORING, "Sync is restoring") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG, "Sync invalid snapshot msg") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BUFFER_FULL, "Sync buffer is full") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error") //tq @@ -645,13 +648,10 @@ const char* tstrerror(int32_t err) { // this is a system errno if ((err & 0x00ff0000) == 0x00ff0000) { int32_t code = err & 0x0000ffff; - if (code >= 0 && code < 36) { - return strerror(code); - } else { - return "unknown err"; - } + // strerror can handle any invalid code + // invalid code return Unknown error + return strerror(code); } - int32_t s = 0; int32_t e = sizeof(errors) / sizeof(errors[0]); diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 37c4035fb0..ac207003b5 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -681,8 +681,8 @@ ,,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 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb2.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb3.py diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 662c4a1a6c..217bd66ef6 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -134,6 +134,7 @@ echo "mDebugFlag 143" >> $TAOS_CFG echo "wDebugFlag 143" >> $TAOS_CFG echo "sDebugFlag 143" >> $TAOS_CFG echo "tsdbDebugFlag 143" >> $TAOS_CFG +echo "tdbDebugFlag 143" >> $TAOS_CFG echo "tqDebugFlag 143" >> $TAOS_CFG echo "fsDebugFlag 143" >> $TAOS_CFG echo "idxDebugFlag 143" >> $TAOS_CFG diff --git a/tests/script/test.sh b/tests/script/test.sh index a7a5d34fbe..19180382fd 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -10,13 +10,11 @@ set +e #set -x FILE_NAME= -RELEASE=0 -ASYNC=0 VALGRIND=0 -UNIQUE=0 +TEST=0 UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` -while getopts "f:agvum" arg +while getopts "f:tgv" arg do case $arg in f) @@ -25,8 +23,8 @@ do v) VALGRIND=1 ;; - u) - UNIQUE=1 + t) + TEST=1 ;; g) VALGRIND=2 @@ -140,6 +138,11 @@ if [ -n "$FILE_NAME" ]; then result=$? echo "Execute result:" $result + if [ $TEST -eq 1 ]; then + echo "Exit without check asan errors" + exit 1 + fi + if [ $result -eq 0 ]; then $CODE_DIR/sh/sigint_stop_dnodes.sh $CODE_DIR/sh/checkAsan.sh diff --git a/tests/script/tsim/stream/basic3.sim b/tests/script/tsim/stream/basic3.sim index 48fb860a72..41e19b19af 100644 --- a/tests/script/tsim/stream/basic3.sim +++ b/tests/script/tsim/stream/basic3.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c debugflag -v 131 -system sh/exec.sh -n dnode1 -s start -v +system sh/cfg.sh -n dnode1 -c debugflag 131 +system sh/exec.sh -n dnode1 -s start sleep 5000 diff --git a/tests/script/tsim/stream/sliding.sim b/tests/script/tsim/stream/sliding.sim index c9a1ddd922..8287274cd2 100644 --- a/tests/script/tsim/stream/sliding.sim +++ b/tests/script/tsim/stream/sliding.sim @@ -672,6 +672,123 @@ if $data61 != 1 then goto loop5 endi +print step 8 + +sql drop stream IF EXISTS streams4; +sql drop database IF EXISTS test4; + +sql create database test4 vgroups 6; +sql use test4; +sql create stable st(ts timestamp, a int, b int, c int, d double) 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 streams4 trigger at_once into streamt4 as select _wstart as ts, count(*),min(a) c1 from st interval(10s) sliding(5s); + +sql insert into t1 values(1648791213000,1,1,1,1.0); +sql insert into t1 values(1648791243000,2,1,1,1.0); + +sql insert into t2 values(1648791273000,3,1,1,1.0); +sql insert into t2 values(1648791313000,4,1,1,1.0); + +$loop_count = 0 + +loop6: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt4 order by 1; + +# row 0 +if $rows != 8 then + print ====loop6=rows=$rows + goto loop6 +endi + +if $data01 != 1 then + print ====loop6=data01=$data01 + goto loop6 +endi + +if $data02 != 1 then + print ====loop6=data02=$data02 + return -1 +endi + +if $data11 != 1 then + print ====loop6=data11=$data11 + goto loop6 +endi + +if $data12 != 1 then + print ====loop6=data12=$data12 + return -1 +endi + +if $data21 != 1 then + print ====loop6=data21=$data21 + goto loop6 +endi + +if $data22 != 2 then + print ====loop6=data22=$data22 + return -1 +endi + +if $data31 != 1 then + print ====loop6=data31=$data31 + goto loop6 +endi + +if $data32 != 2 then + print ====loop6=data32=$data32 + return -1 +endi + +if $data41 != 1 then + print ====loop6=data41=$data41 + goto loop6 +endi + +if $data42 != 3 then + print ====loop6=data42=$data42 + return -1 +endi + +if $data51 != 1 then + print ====loop6=data51=$data51 + goto loop6 +endi + +if $data52 != 3 then + print ====loop6=data52=$data52 + return -1 +endi + +if $data61 != 1 then + print ====loop6=data61=$data61 + return -1 +endi + +if $data62 != 4 then + print ====loop6=data62=$data62 + return -1 +endi + +if $data71 != 1 then + print ====loop6=data71=$data71 + return -1 +endi + +if $data72 != 4 then + print ====loop6=data72=$data72 + return -1 +endi + $loop_all = $loop_all + 1 print ============loop_all=$loop_all diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index fd06eedefd..0fa9bcfbd4 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -61,7 +61,7 @@ class TDTestCase: def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName - sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) + sql += "(now + %ds, %d, '%s', '%s', %d, %d, %d)"%(consumerId, consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) tdSql.query(sql) @@ -174,12 +174,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -271,12 +272,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -337,6 +339,7 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath @@ -406,12 +409,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/subscribeDb0.py b/tests/system-test/7-tmq/subscribeDb0.py index d4c5e2f87f..50ef52cb15 100644 --- a/tests/system-test/7-tmq/subscribeDb0.py +++ b/tests/system-test/7-tmq/subscribeDb0.py @@ -174,12 +174,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -191,6 +192,7 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath @@ -254,12 +256,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 141d013270..4cda062401 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -60,7 +60,7 @@ class TMQCom: def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName - sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) + sql += "(now + %ds, %d, '%s', '%s', %d, %d, %d)"%(consumerId, consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) tdSql.query(sql)