diff --git a/cmake/cmake.define b/cmake/cmake.define index 55412fd26f8749eabdd0451ed15d030932754edd..1d34896f9aa1636f493f1d844f2e4d34daff8077 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -71,8 +71,8 @@ ELSE () ENDIF () IF (${SANITIZER} MATCHES "true") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") MESSAGE(STATUS "Will compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") diff --git a/docs-examples/go/insert/sql/main.go b/docs-examples/go/insert/sql/main.go new file mode 100644 index 0000000000000000000000000000000000000000..91386855334c1930af721e0b4f43395c6a6d8e82 --- /dev/null +++ b/docs-examples/go/insert/sql/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "database/sql" + "fmt" + + _ "github.com/taosdata/driver-go/v2/taosRestful" +) + +func createStable(taos *sql.DB) { + _, err := taos.Exec("CREATE DATABASE power") + if err != nil { + fmt.Println("failed to create database, err:", err) + } + _, err = taos.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") + if err != nil { + fmt.Println("failed to create stable, err:", err) + } +} + +func insertData(taos *sql.DB) { + sql := `INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)` + result, err := taos.Exec(sql) + if err != nil { + fmt.Println("failed to insert, err:", err) + return + } + rowsAffected, err := result.RowsAffected() + if err != nil { + fmt.Println("failed to get affected rows, err:", err) + return + } + fmt.Println("RowsAffected", rowsAffected) +} + +func main() { + var taosDSN = "root:taosdata@http(localhost:6041)/" + taos, err := sql.Open("taosRestful", taosDSN) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } + defer taos.Close() + createStable(taos) + insertData(taos) +} diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index cea40f4785be8e32a07fadf165a7407d56fddf8e..db8644ecfed50f354e61ff20b424f93dc559f8d7 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -190,7 +190,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource, uint32_t numOfRow2); int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows); -int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock); +int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex); int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows); void colDataTrim(SColumnInfoData* pColumnInfoData); diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 9104e8a4234a48692f73d9d4c3225e9cd0668ee0..bd3ca6ae8d6239efc70b6379e9a18c69fb69d788 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1352,7 +1352,7 @@ typedef struct { typedef struct { int32_t code; - char tbFName[TSDB_TABLE_FNAME_LEN]; + char tbFName[TSDB_TABLE_FNAME_LEN]; int32_t sversion; int32_t tversion; } SResReadyRsp; @@ -2524,7 +2524,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum); buf = taosDecodeFixedI32(buf, &pRsp->blockNum); pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void*)); - pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(void*)); + pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t)); pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void*)); pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void*)); if (pRsp->blockNum != 0) { diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index bb57946082202e60b60a2f9625cbebabdc684add..68a1e08f518f5c5e230076cd56344ea1161804cb 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -230,23 +230,23 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t taosPrintLog("QRY ", DEBUG_INFO, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ } \ } while (0) -#define qDebug(...) \ - do { \ - if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ - } \ +#define qDebug(...) \ + do { \ + if (qDebugFlag & DEBUG_DEBUG) { \ + taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + } \ } while (0) -#define qTrace(...) \ - do { \ - if (qDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \ - } \ +#define qTrace(...) \ + do { \ + if (qDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + } \ } while (0) -#define qDebugL(...) \ - do { \ - if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ - } \ +#define qDebugL(...) \ + do { \ + if (qDebugFlag & DEBUG_DEBUG) { \ + taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + } \ } while (0) #define QRY_ERR_RET(c) \ diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 66287099cdc81783c1a7b1ba6e42c8265945cf63..e28618d940c53ad0f592ca14cd44e42f01ce0db9 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -39,64 +39,50 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SUCCESS 0 #define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error -// rpc -#define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) -#define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002) -#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003) -#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004) -#define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005) -#define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006) -#define TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x0007) -#define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008) -#define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009) -#define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A) -#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B) -#define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C) -#define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D) -#define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E) -#define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F) -#define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010) -#define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011) -#define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012) -#define TSDB_CODE_RPC_INVALID_TIME_STAMP TAOS_DEF_ERROR_CODE(0, 0x0013) -#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) -#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015) -#define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016) -#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) - //common & util -#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0100) -#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0101) -#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0102) -#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0103) -#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0104) -#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0105) -#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0106) -#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0107) -#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0108) -#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0109) -#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x010A) -#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x010B) -#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x010C) -#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x010D) -#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x010E) -#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x010F) -#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110) -#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0111) -#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0112) -#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0113) -#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0114) -#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0115) -#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0116) -#define TSDB_CODE_NEED_RETRY TAOS_DEF_ERROR_CODE(0, 0x0117) -#define TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE TAOS_DEF_ERROR_CODE(0, 0x0118) - -#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0140) -#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0141) -#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0152) -#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0153) -#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0154) -#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0155) +#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) +#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0002) +#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0003) +#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0010) +#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011) +#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012) +#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0013) +#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0014) +#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0015) +#define TSDB_CODE_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0016) +#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0017) +#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0018) +#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0019) +#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x001A) +#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x001B) +#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x001C) +#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x001D) +#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x001E) +#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x001F) +#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0020) +#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0021) +#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0022) +#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0023) +#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0024) +#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0025) +#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0026) +#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0027) +#define TSDB_CODE_NEED_RETRY TAOS_DEF_ERROR_CODE(0, 0x0028) +#define TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE TAOS_DEF_ERROR_CODE(0, 0x0029) + +#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0040) +#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0041) +#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0042) +#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0043) +#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0044) +#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0045) + +// rpc +#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0100) +#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0101) +#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102) +#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103) +#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104) //client #define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) @@ -296,8 +282,8 @@ int32_t* taosGetErrno(); // dnode #define TSDB_CODE_NODE_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0400) #define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401) -#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403) -#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0404) +#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0402) +#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403) // vnode #define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 736cb9854958d3ae8cc0e34321347ef8cb8d0d9d..6e1a9c5726b65291390007515e2cc7b8c1d86dd1 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -341,7 +341,7 @@ size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) { size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; } -int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock) { +int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) { if (pDataBlock == NULL || pDataBlock->info.rows <= 0) { return 0; } @@ -350,7 +350,8 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock) { return -1; } - SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, 0); + int32_t index = (tsColumnIndex == -1)? 0:tsColumnIndex; + SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, index); if (pColInfoData->info.type != TSDB_DATA_TYPE_TIMESTAMP) { return 0; } diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index 5818b5880190f5db86e4e72557989544db012245..2b3ac7ae73196d36578976d8049212c8f86dc764 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -134,10 +134,10 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType); int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); - -void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); -void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); -void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg); +void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); +void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); +void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg); +void dmProcessFetchRsp(SRpcMsg *pMsg); // dmNodes.c int32_t dmOpenNode(SMgmtWrapper *pWrapper); diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 96285bbe1ca58bc1e3c900cb787aae0e3387e234..c83550c7b1e6b198e6c1647784bd70afa72d15b5 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" #include "dmNodes.h" +#include "qworker.h" static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) { SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); @@ -279,38 +280,42 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus) void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { dDebug("msg:%p, net test req will be processed", pMsg); - SRpcMsg rsp = {.code = 0, .info = pMsg->info}; + + SRpcMsg rsp = {.info = pMsg->info}; rsp.pCont = rpcMallocCont(pMsg->contLen); if (rsp.pCont == NULL) { rsp.code = TSDB_CODE_OUT_OF_MEMORY; } else { rsp.contLen = pMsg->contLen; } + rpcSendResponse(&rsp); + rpcFreeCont(pMsg->pCont); } void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { dDebug("msg:%p, server startup status req will be processed", pMsg); + SServerStatusRsp statusRsp = {0}; dmGetServerStartupStatus(pDnode, &statusRsp); - SRpcMsg rspMsg = {.info = pMsg->info}; - int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp); - if (rspLen < 0) { - rspMsg.code = TSDB_CODE_OUT_OF_MEMORY; - goto _OVER; - } - - void *pRsp = rpcMallocCont(rspLen); - if (pRsp == NULL) { - rspMsg.code = TSDB_CODE_OUT_OF_MEMORY; - goto _OVER; + SRpcMsg rsp = {.info = pMsg->info}; + int32_t contLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp); + if (contLen < 0) { + rsp.code = TSDB_CODE_OUT_OF_MEMORY; + } else { + rsp.pCont = rpcMallocCont(contLen); + if (rsp.pCont != NULL) { + tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp); + rsp.contLen = contLen; + } } - tSerializeSServerStatusRsp(pRsp, rspLen, &statusRsp); - rspMsg.pCont = pRsp; - rspMsg.contLen = rspLen; - -_OVER: - rpcSendResponse(&rspMsg); + rpcSendResponse(&rsp); + rpcFreeCont(pMsg->pCont); } + +void dmProcessFetchRsp(SRpcMsg *pMsg) { + qWorkerProcessFetchRsp(NULL, NULL, pMsg); + // rpcFreeCont(pMsg->pCont); +} \ No newline at end of file diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index d044ad3b2e5558c4c0660c12c4826068dceccbf1..72878d0d853e2067bdd73d42bb4b001ccfdb5295 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -142,13 +142,14 @@ static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg queue->tail = headLen + bodyLen; } else if (remain < 8 + headLen) { memcpy(queue->pBuffer + queue->tail + 8, pHead, remain - 8); - memcpy(queue->pBuffer, (char*)pHead + remain - 8, rawHeadLen - (remain - 8)); + memcpy(queue->pBuffer, (char *)pHead + remain - 8, rawHeadLen - (remain - 8)); if (rawBodyLen > 0) memcpy(queue->pBuffer + headLen - (remain - 8), pBody, rawBodyLen); queue->tail = headLen - (remain - 8) + bodyLen; } else if (remain < 8 + headLen + bodyLen) { memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen); if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, remain - 8 - headLen); - if (rawBodyLen > 0) memcpy(queue->pBuffer, (char*)pBody + remain - 8 - headLen, rawBodyLen - (remain - 8 - headLen)); + if (rawBodyLen > 0) + memcpy(queue->pBuffer, (char *)pBody + remain - 8 - headLen, rawBodyLen - (remain - 8 - headLen)); queue->tail = bodyLen - (remain - 8 - headLen); } else { memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen); @@ -312,12 +313,7 @@ static void *dmConsumChildQueue(void *param) { code = dmProcessNodeMsg(pWrapper, pMsg); if (code != 0) { dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pMsg, terrstr()); - SRpcMsg rsp = { - .code = (terrno != 0 ? terrno : code), - .pCont = pMsg->info.rsp, - .contLen = pMsg->info.rspLen, - .info = pMsg->info, - }; + SRpcMsg rsp = {.code = (terrno != 0 ? terrno : code), .info = pMsg->info}; dmPutToProcPQueue(proc, &rsp, DND_FUNC_RSP); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); @@ -469,8 +465,18 @@ void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) { taosMsleep(retry); } } + + rpcFreeCont(pMsg->pCont); + pMsg->pCont = NULL; + pMsg->contLen = 0; } int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) { - return dmPushToProcQueue(proc, proc->cqueue, pMsg, ftype); + int32_t code = dmPushToProcQueue(proc, proc->cqueue, pMsg, ftype); + if (code == 0) { + dTrace("msg:%p, is freed after push to cqueue", pMsg); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + return code; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index fe9a81bef1aefc698551b6aff54298b3e39826ff..8dfcb798ac966e25fc430b3bcddf7e69fd6534a2 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -15,11 +15,10 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" -#include "qworker.h" -#define INTERNAL_USER "_dnd" -#define INTERNAL_CKEY "_key" -#define INTERNAL_SECRET "_pwd" +static void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet); +static void dmSendRsp(SRpcMsg *pMsg); +static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg); static inline int32_t dmBuildNodeMsg(SRpcMsg *pMsg, SRpcMsg *pRpc) { SRpcConnInfo connInfo = {0}; @@ -49,49 +48,42 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { } static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { - SDnodeTrans * pTrans = &pDnode->trans; + SDnodeTrans *pTrans = &pDnode->trans; int32_t code = -1; - SRpcMsg * pMsg = NULL; - bool needRelease = false; - SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)]; + SRpcMsg *pMsg = NULL; SMgmtWrapper *pWrapper = NULL; + SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)]; dTrace("msg:%s is received, handle:%p len:%d code:0x%x app:%p refId:%" PRId64, TMSG_INFO(pRpc->msgType), pRpc->info.handle, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId); - pRpc->info.noResp = 0; - pRpc->info.persistHandle = 0; - pRpc->info.wrapper = NULL; - pRpc->info.node = NULL; - pRpc->info.rsp = NULL; - pRpc->info.rspLen = 0; if (pRpc->msgType == TDMT_DND_NET_TEST) { dmProcessNetTestReq(pDnode, pRpc); - goto _OVER_JUST_FREE; + return; } else if (pRpc->msgType == TDMT_MND_SYSTABLE_RETRIEVE_RSP || pRpc->msgType == TDMT_VND_FETCH_RSP) { - qWorkerProcessFetchRsp(NULL, NULL, pRpc); - goto _OVER_JUST_FREE; + dmProcessFetchRsp(pRpc); + return; } else { } if (pDnode->status != DND_STAT_RUNNING) { if (pRpc->msgType == TDMT_DND_SERVER_STATUS) { dmProcessServerStartupStatus(pDnode, pRpc); - goto _OVER_JUST_FREE; + return; } else { terrno = TSDB_CODE_APP_NOT_READY; - goto _OVER_RSP_FREE; + goto _OVER; } } if (IsReq(pRpc) && pRpc->pCont == NULL) { terrno = TSDB_CODE_INVALID_MSG_LEN; - goto _OVER_RSP_FREE; + goto _OVER; } if (pHandle->defaultNtype == NODE_END) { terrno = TSDB_CODE_MSG_NOT_PROCESSED; - goto _OVER_RSP_FREE; + goto _OVER; } else { pWrapper = &pDnode->wrappers[pHandle->defaultNtype]; if (pHandle->needCheckVgId) { @@ -106,15 +98,15 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { } } else { terrno = TSDB_CODE_INVALID_MSG_LEN; - goto _OVER_RSP_FREE; + goto _OVER; } } } if (dmMarkWrapper(pWrapper) != 0) { - goto _OVER_RSP_FREE; + pWrapper = NULL; + goto _OVER; } else { - needRelease = true; pRpc->info.wrapper = pWrapper; } @@ -134,24 +126,23 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { } _OVER: - if (code == 0) { - if (pWrapper != NULL && InParentProc(pWrapper)) { - dTrace("msg:%p, is freed after push to cqueue", pMsg); - taosFreeQitem(pMsg); - rpcFreeCont(pRpc->pCont); - } - } else { + if (code != 0) { dError("msg:%p, failed to process since %s", pMsg, terrstr()); if (terrno != 0) code = terrno; if (IsReq(pRpc)) { - if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) { - if (pRpc->msgType > TDMT_MND_MSG && pRpc->msgType < TDMT_VND_MSG) { - code = TSDB_CODE_NODE_REDIRECT; - } + SRpcMsg rsp = {.code = code, .info = pRpc->info}; + + if ((code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) && pRpc->msgType > TDMT_MND_MSG && + pRpc->msgType < TDMT_VND_MSG) { + dmBuildMnodeRedirectRsp(pDnode, &rsp); + } + + if (pWrapper != NULL) { + dmSendRsp(&rsp); + } else { + rpcSendResponse(&rsp); } - SRpcMsg rspMsg = {.code = code, .info = pRpc->info}; - tmsgSendRsp(&rspMsg); } dTrace("msg:%p, is freed", pMsg); @@ -159,19 +150,7 @@ _OVER: rpcFreeCont(pRpc->pCont); } - if (needRelease) { - dmReleaseWrapper(pWrapper); - } - return; - -_OVER_JUST_FREE: - rpcFreeCont(pRpc->pCont); - return; - -_OVER_RSP_FREE: - rpcFreeCont(pRpc->pCont); - SRpcMsg simpleRsp = {.code = terrno, .info = pRpc->info}; - rpcSendResponse(&simpleRsp); + dmReleaseWrapper(pWrapper); } int32_t dmInitMsgHandle(SDnode *pDnode) { @@ -179,11 +158,11 @@ int32_t dmInitMsgHandle(SDnode *pDnode) { for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - SArray * pArray = (*pWrapper->func.getHandlesFp)(); + SArray *pArray = (*pWrapper->func.getHandlesFp)(); if (pArray == NULL) return -1; for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { - SMgmtHandle * pMgmt = taosArrayGet(pArray, i); + SMgmtHandle *pMgmt = taosArrayGet(pArray, i); SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)]; if (pMgmt->needCheckVgId) { pHandle->needCheckVgId = pMgmt->needCheckVgId; @@ -218,13 +197,25 @@ static inline void dmSendRsp(SRpcMsg *pMsg) { SMgmtWrapper *pWrapper = pMsg->info.wrapper; if (InChildProc(pWrapper)) { dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP); - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; } else { rpcSendResponse(pMsg); } } +static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { + SMEpSet msg = {0}; + dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &msg.epSet); + + int32_t contLen = tSerializeSMEpSet(NULL, 0, &msg); + pMsg->pCont = rpcMallocCont(contLen); + if (pMsg->pCont == NULL) { + pMsg->code = TSDB_CODE_OUT_OF_MEMORY; + } else { + tSerializeSMEpSet(pMsg->pCont, contLen, &msg); + pMsg->contLen = contLen; + } +} + static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) { SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; SMEpSet msg = {.epSet = *pNewEpSet}; @@ -246,8 +237,6 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { SMgmtWrapper *pWrapper = pMsg->info.wrapper; if (InChildProc(pWrapper)) { dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_REGIST); - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; } else { rpcRegisterBrokenLinkArg(pMsg); } @@ -275,7 +264,6 @@ int32_t dmInitClient(SDnode *pDnode) { rpcInit.sessions = 1024; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.user = INTERNAL_USER; rpcInit.parent = pDnode; rpcInit.rfp = rpcRfp; @@ -343,34 +331,3 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) { }; return msgCb; } - -static void dmSendMnodeRedirectRsp(SRpcMsg *pMsg) { - SDnode *pDnode = dmInstance(); - SEpSet epSet = {0}; - dmGetMnodeEpSet(&pDnode->data, &epSet); - - dDebug("msg:%p, is redirected, num:%d use:%d", pMsg, epSet.numOfEps, epSet.inUse); - for (int32_t i = 0; i < epSet.numOfEps; ++i) { - dDebug("mnode index:%d %s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); - if (strcmp(epSet.eps[i].fqdn, tsLocalFqdn) == 0 && epSet.eps[i].port == tsServerPort) { - epSet.inUse = (i + 1) % epSet.numOfEps; - } - - epSet.eps[i].port = htons(epSet.eps[i].port); - } - - SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; - SMEpSet msg = {.epSet = epSet}; - int32_t contLen = tSerializeSMEpSet(NULL, 0, &msg); - rsp.pCont = rpcMallocCont(contLen); - if (rsp.pCont == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - } else { - tSerializeSMEpSet(rsp.pCont, contLen, &msg); - rsp.contLen = contLen; - } - - dmSendRsp(&rsp); - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; -} diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index e7256a3a87526d8c4b2b1e67189f8aa45935acf5..4946669678cd0fd17a22b935aa9e2613e58d73db 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -173,6 +173,7 @@ int32_t dmReadEps(SDnodeData *pData); int32_t dmWriteEps(SDnodeData *pData); void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps); void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); +void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet); void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); #ifdef __cplusplus diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 94fa5695578ccfbcdfc6b7a7c1d4ee834c1f99f9..e0af20e41bfef194d90d30316c16042522e7f87d 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -314,6 +314,17 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { taosThreadRwlockUnlock(&pData->lock); } +void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet) { + dmGetMnodeEpSet(pData, pEpSet); + dDebug("msg:%p, is redirected, num:%d use:%d", pMsg, pEpSet->numOfEps, pEpSet->inUse); + for (int32_t i = 0; i < pEpSet->numOfEps; ++i) { + dDebug("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); + if (strcmp(pEpSet->eps[i].fqdn, tsLocalFqdn) == 0 && pEpSet->eps[i].port == tsServerPort) { + pEpSet->inUse = (i + 1) % pEpSet->numOfEps; + } + } +} + void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { taosThreadRwlockWrlock(&pData->lock); pData->mnodeEps = *pEpSet; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 35ecaa748ecdbdce486814f063b7678004f68909..6210fe3fcfd66f1395a3f5c9e20fa1bee9558611 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -994,9 +994,6 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr pAction->msgSent = 0; pAction->msgReceived = 0; pAction->errCode = terrno; - if (terrno == TSDB_CODE_INVALID_PTR || terrno == TSDB_CODE_NODE_OFFLINE) { - rpcFreeCont(rpcMsg.pCont); - } mError("trans:%d, action:%d not send since %s", pTrans->id, action, terrstr()); return -1; } diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 2bcfd01904dbe32357e8f6afe1e81294ec9de50e..ee4dfc65312a78037d6f3e1b4d7f65a467a8ad30 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -483,12 +483,12 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS; goto _err; } - if (!IS_VAR_DATA_TYPE(pColumn->type) || pColumn->bytes <= pAlterTbReq->bytes) { + if (!IS_VAR_DATA_TYPE(pColumn->type) || pColumn->bytes > pAlterTbReq->colModBytes) { terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION; goto _err; } pSchema->sver++; - pColumn->bytes = pAlterTbReq->bytes; + pColumn->bytes = pAlterTbReq->colModBytes; break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: if (pColumn == NULL) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index f0aa4d2ac64fb1d5931fb768b7def18ec9f58292..d3b1f56a711f53d6e8248e4c4d3f7fed6793fd90 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2775,7 +2775,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int win->ekey = key; if (rv != TD_ROW_SVER(row)) { - pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 1); + pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, TD_ROW_SVER(row)); rv = TD_ROW_SVER(row); } numOfRows += mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, &curRows, row, NULL, numOfCols, pCheckInfo->tableId, diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index f0af677641c3e08cd4d848ec4c98b28fce4662ee..a90bb7afcb6847ba0cb803d7a7e58720159bf10f 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -77,7 +77,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { pVnode->path = (char *)&pVnode[1]; strcpy(pVnode->path, path); pVnode->config = info.config; - pVnode->state = info.state; + pVnode->state.committed = info.state.committed; + pVnode->state.applied = info.state.committed; pVnode->pTfs = pTfs; pVnode->msgCb = msgCb; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 85d9b14c60759ed25ddfb1f376184d61b4bc87c1..2d4355191ef73d801cc7718f45ea8191b1aa7232 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -13,11 +13,11 @@ * along with this program. If not, see . */ -#include "trpc.h" -#include "query.h" -#include "tname.h" #include "catalogInt.h" +#include "query.h" #include "systable.h" +#include "tname.h" +#include "trpc.h" int32_t ctgActUpdateVg(SCtgMetaAction *action); int32_t ctgActUpdateTbl(SCtgMetaAction *action); @@ -27,38 +27,11 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action); int32_t ctgActUpdateUser(SCtgMetaAction *action); extern SCtgDebug gCTGDebug; -SCatalogMgmt gCtgMgmt = {0}; -SCtgAction gCtgAction[CTG_ACT_MAX] = {{ - CTG_ACT_UPDATE_VG, - "update vgInfo", - ctgActUpdateVg - }, - { - CTG_ACT_UPDATE_TBL, - "update tbMeta", - ctgActUpdateTbl - }, - { - CTG_ACT_REMOVE_DB, - "remove DB", - ctgActRemoveDB - }, - { - CTG_ACT_REMOVE_STB, - "remove stbMeta", - ctgActRemoveStb - }, - { - CTG_ACT_REMOVE_TBL, - "remove tbMeta", - ctgActRemoveTbl - }, - { - CTG_ACT_UPDATE_USER, - "update user", - ctgActUpdateUser - } -}; +SCatalogMgmt gCtgMgmt = {0}; +SCtgAction gCtgAction[CTG_ACT_MAX] = { + {CTG_ACT_UPDATE_VG, "update vgInfo", ctgActUpdateVg}, {CTG_ACT_UPDATE_TBL, "update tbMeta", ctgActUpdateTbl}, + {CTG_ACT_REMOVE_DB, "remove DB", ctgActRemoveDB}, {CTG_ACT_REMOVE_STB, "remove stbMeta", ctgActRemoveStb}, + {CTG_ACT_REMOVE_TBL, "remove tbMeta", ctgActRemoveTbl}, {CTG_ACT_UPDATE_USER, "update user", ctgActUpdateUser}}; void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { if (NULL == mgmt->slots) { @@ -76,11 +49,10 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { taosMemoryFreeClear(mgmt->slots); } - void ctgFreeTableMetaCache(SCtgTbMetaCache *cache) { CTG_LOCK(CTG_WRITE, &cache->stbLock); if (cache->stbCache) { - int32_t stblNum = taosHashGetSize(cache->stbCache); + int32_t stblNum = taosHashGetSize(cache->stbCache); taosHashCleanup(cache->stbCache); cache->stbCache = NULL; CTG_CACHE_STAT_SUB(stblNum, stblNum); @@ -106,7 +78,7 @@ void ctgFreeVgInfo(SDBVgInfo *vgInfo) { taosHashCleanup(vgInfo->vgHash); vgInfo->vgHash = NULL; } - + taosMemoryFreeClear(vgInfo); } @@ -116,7 +88,7 @@ void ctgFreeDbCache(SCtgDBCache *dbCache) { } CTG_LOCK(CTG_WRITE, &dbCache->vgLock); - ctgFreeVgInfo (dbCache->vgInfo); + ctgFreeVgInfo(dbCache->vgInfo); CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock); ctgFreeTableMetaCache(&dbCache->tbCache); @@ -128,13 +100,13 @@ void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) { taosHashCleanup(userCache->writeDbs); } -void ctgFreeHandle(SCatalog* pCtg) { +void ctgFreeHandle(SCatalog *pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); - + if (pCtg->dbCache) { int32_t dbNum = taosHashGetSize(pCtg->dbCache); - + void *pIter = taosHashIterate(pCtg->dbCache, NULL); while (pIter) { SCtgDBCache *dbCache = pIter; @@ -142,42 +114,40 @@ void ctgFreeHandle(SCatalog* pCtg) { atomic_store_8(&dbCache->deleted, 1); ctgFreeDbCache(dbCache); - + pIter = taosHashIterate(pCtg->dbCache, pIter); - } + } taosHashCleanup(pCtg->dbCache); - + CTG_CACHE_STAT_SUB(dbNum, dbNum); } if (pCtg->userCache) { int32_t userNum = taosHashGetSize(pCtg->userCache); - + void *pIter = taosHashIterate(pCtg->userCache, NULL); while (pIter) { SCtgUserAuth *userCache = pIter; ctgFreeSCtgUserAuth(userCache); - + pIter = taosHashIterate(pCtg->userCache, pIter); - } + } taosHashCleanup(pCtg->userCache); - + CTG_CACHE_STAT_SUB(userNum, userNum); } - + taosMemoryFree(pCtg); } - - void ctgWaitAction(SCtgMetaAction *action) { while (true) { tsem_wait(&gCtgMgmt.queue.rspSem); - - if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { + + if (atomic_load_8((int8_t *)&gCtgMgmt.exit)) { tsem_post(&gCtgMgmt.queue.rspSem); break; } @@ -193,19 +163,18 @@ void ctgWaitAction(SCtgMetaAction *action) { void ctgPopAction(SCtgMetaAction **action) { SCtgQNode *orig = gCtgMgmt.queue.head; - + SCtgQNode *node = gCtgMgmt.queue.head->next; gCtgMgmt.queue.head = gCtgMgmt.queue.head->next; CTG_QUEUE_SUB(); - + taosMemoryFreeClear(orig); *action = &node->action; } - -int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) { +int32_t ctgPushAction(SCatalog *pCtg, SCtgMetaAction *action) { SCtgQNode *node = taosMemoryCalloc(1, sizeof(SCtgQNode)); if (NULL == node) { qError("calloc %d failed", (int32_t)sizeof(SCtgQNode)); @@ -213,7 +182,7 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) { } action->seqId = atomic_add_fetch_64(&gCtgMgmt.queue.seqId, 1); - + node->action = *action; CTG_LOCK(CTG_WRITE, &gCtgMgmt.queue.qlock); @@ -235,10 +204,9 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) { return TSDB_CODE_SUCCESS; } - -int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_REMOVE_DB}; +int32_t ctgPushRmDBMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_REMOVE_DB}; SCtgRemoveDBMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveDBMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveDBMsg)); @@ -266,10 +234,10 @@ _return: CTG_RET(code); } - -int32_t ctgPushRmStbMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_REMOVE_STB, .syncReq = syncReq}; +int32_t ctgPushRmStbMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, + bool syncReq) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_REMOVE_STB, .syncReq = syncReq}; SCtgRemoveStbMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveStbMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveStbMsg)); @@ -294,11 +262,9 @@ _return: CTG_RET(code); } - - -int32_t ctgPushRmTblMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_REMOVE_TBL, .syncReq = syncReq}; +int32_t ctgPushRmTblMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_REMOVE_TBL, .syncReq = syncReq}; SCtgRemoveTblMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveTblMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveTblMsg)); @@ -322,9 +288,9 @@ _return: CTG_RET(code); } -int32_t ctgPushUpdateVgMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_UPDATE_VG, .syncReq = syncReq}; +int32_t ctgPushUpdateVgMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, SDBVgInfo *dbInfo, bool syncReq) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_UPDATE_VG, .syncReq = syncReq}; SCtgUpdateVgMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateVgMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateVgMsg)); @@ -355,9 +321,9 @@ _return: CTG_RET(code); } -int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_UPDATE_TBL, .syncReq = syncReq}; +int32_t ctgPushUpdateTblMsgInQueue(SCatalog *pCtg, STableMetaOutput *output, bool syncReq) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_UPDATE_TBL, .syncReq = syncReq}; SCtgUpdateTblMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateTblMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateTblMsg)); @@ -377,17 +343,17 @@ int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, boo CTG_ERR_JRET(ctgPushAction(pCtg, &action)); return TSDB_CODE_SUCCESS; - + _return: taosMemoryFreeClear(msg); - + CTG_RET(code); } -int32_t ctgPushUpdateUserMsgInQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq) { - int32_t code = 0; - SCtgMetaAction action= {.act = CTG_ACT_UPDATE_USER, .syncReq = syncReq}; +int32_t ctgPushUpdateUserMsgInQueue(SCatalog *pCtg, SGetUserAuthRsp *pAuth, bool syncReq) { + int32_t code = 0; + SCtgMetaAction action = {.act = CTG_ACT_UPDATE_USER, .syncReq = syncReq}; SCtgUpdateUserMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateUserMsg)); if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateUserMsg)); @@ -402,38 +368,37 @@ int32_t ctgPushUpdateUserMsgInQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool CTG_ERR_JRET(ctgPushAction(pCtg, &action)); return TSDB_CODE_SUCCESS; - + _return: tFreeSGetUserAuthRsp(pAuth); taosMemoryFreeClear(msg); - + CTG_RET(code); } int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) { CTG_LOCK(CTG_READ, &dbCache->vgLock); - + if (dbCache->deleted) { CTG_UNLOCK(CTG_READ, &dbCache->vgLock); - ctgDebug("db is dropping, dbId:%"PRIx64, dbCache->dbId); - + ctgDebug("db is dropping, dbId:%" PRIx64, dbCache->dbId); + *inCache = false; return TSDB_CODE_SUCCESS; } - if (NULL == dbCache->vgInfo) { CTG_UNLOCK(CTG_READ, &dbCache->vgLock); *inCache = false; - ctgDebug("db vgInfo is empty, dbId:%"PRIx64, dbCache->dbId); + ctgDebug("db vgInfo is empty, dbId:%" PRIx64, dbCache->dbId); return TSDB_CODE_SUCCESS; } *inCache = true; - + return TSDB_CODE_SUCCESS; } @@ -441,7 +406,7 @@ int32_t ctgWAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache) { CTG_LOCK(CTG_WRITE, &dbCache->vgLock); if (dbCache->deleted) { - ctgDebug("db is dropping, dbId:%"PRIx64, dbCache->dbId); + ctgDebug("db is dropping, dbId:%" PRIx64, dbCache->dbId); CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock); CTG_ERR_RET(TSDB_CODE_CTG_DB_DROPPED); } @@ -449,20 +414,13 @@ int32_t ctgWAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache) { return TSDB_CODE_SUCCESS; } -void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) { - taosHashRelease(pCtg->dbCache, dbCache); -} - -void ctgReleaseVgInfo(SCtgDBCache *dbCache) { - CTG_UNLOCK(CTG_READ, &dbCache->vgLock); -} +void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) { taosHashRelease(pCtg->dbCache, dbCache); } -void ctgWReleaseVgInfo(SCtgDBCache *dbCache) { - CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock); -} +void ctgReleaseVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_READ, &dbCache->vgLock); } +void ctgWReleaseVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock); } -int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { +int32_t ctgAcquireDBCacheImpl(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { char *p = strchr(dbFName, '.'); if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; @@ -474,7 +432,7 @@ int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache * } else { dbCache = (SCtgDBCache *)taosHashGet(pCtg->dbCache, dbFName, strlen(dbFName)); } - + if (NULL == dbCache) { *pCache = NULL; ctgDebug("db not in cache, dbFName:%s", dbFName); @@ -484,28 +442,27 @@ int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache * if (dbCache->deleted) { if (acquire) { ctgReleaseDBCache(pCtg, dbCache); - } - + } + *pCache = NULL; ctgDebug("db is removing from cache, dbFName:%s", dbFName); return TSDB_CODE_SUCCESS; } *pCache = dbCache; - + return TSDB_CODE_SUCCESS; } -int32_t ctgAcquireDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache) { +int32_t ctgAcquireDBCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache) { CTG_RET(ctgAcquireDBCacheImpl(pCtg, dbFName, pCache, true)); } -int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache) { +int32_t ctgGetDBCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache) { CTG_RET(ctgAcquireDBCacheImpl(pCtg, dbFName, pCache, false)); } - -int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool *inCache) { +int32_t ctgAcquireVgInfoFromCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache, bool *inCache) { SCtgDBCache *dbCache = NULL; if (NULL == pCtg->dbCache) { @@ -514,11 +471,11 @@ int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCac } ctgAcquireDBCache(pCtg, dbFName, &dbCache); - if (NULL == dbCache) { + if (NULL == dbCache) { ctgDebug("db %s not in cache", dbFName); goto _return; } - + ctgAcquireVgInfo(pCtg, dbCache, inCache); if (!(*inCache)) { ctgDebug("vgInfo of db %s not in cache", dbFName); @@ -531,7 +488,7 @@ int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCac CTG_CACHE_STAT_ADD(vgHitNum, 1); ctgDebug("Got db vgInfo from cache, dbFName:%s", dbFName); - + return TSDB_CODE_SUCCESS; _return: @@ -544,12 +501,12 @@ _return: *inCache = false; CTG_CACHE_STAT_ADD(vgMissNum, 1); - + return TSDB_CODE_SUCCESS; } -int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, SArray *out) { - char *msg = NULL; +int32_t ctgGetQnodeListFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, SArray *out) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pMgmtEps->inUse); @@ -559,16 +516,16 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt ctgError("Build qnode list msg failed, error:%s", tstrerror(code)); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_QNODE_LIST, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { ctgError("error rsp for qnode list, error:%s", tstrerror(rpcRsp.code)); CTG_ERR_RET(rpcRsp.code); @@ -585,9 +542,9 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt return TSDB_CODE_SUCCESS; } - -int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, SBuildUseDBInput *input, SUseDbOutput *out) { - char *msg = NULL; +int32_t ctgGetDBVgInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, SBuildUseDBInput *input, + SUseDbOutput *out) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db); @@ -597,16 +554,16 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtE ctgError("Build use db msg failed, code:%x, db:%s", code, input->db); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_USE_DB, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { ctgError("error rsp for use db, error:%s, db:%s", tstrerror(rpcRsp.code), input->db); CTG_ERR_RET(rpcRsp.code); @@ -623,8 +580,8 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtE return TSDB_CODE_SUCCESS; } -int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *dbFName, SDbCfgInfo *out) { - char *msg = NULL; +int32_t ctgGetDBCfgFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName, SDbCfgInfo *out) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName); @@ -634,16 +591,16 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, ctgError("Build get db cfg msg failed, code:%x, db:%s", code, dbFName); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_GET_DB_CFG, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { ctgError("error rsp for get db cfg, error:%s, db:%s", tstrerror(rpcRsp.code), dbFName); CTG_ERR_RET(rpcRsp.code); @@ -660,8 +617,9 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, return TSDB_CODE_SUCCESS; } -int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *indexName, SIndexInfo *out) { - char *msg = NULL; +int32_t ctgGetIndexInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *indexName, + SIndexInfo *out) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get index from mnode, indexName:%s", indexName); @@ -671,16 +629,16 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt ctgError("Build get index msg failed, code:%x, db:%s", code, indexName); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_GET_INDEX, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { ctgError("error rsp for get index, error:%s, indexName:%s", tstrerror(rpcRsp.code), indexName); CTG_ERR_RET(rpcRsp.code); @@ -697,8 +655,9 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt return TSDB_CODE_SUCCESS; } -int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *funcName, SFuncInfo **out) { - char *msg = NULL; +int32_t ctgGetUdfInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *funcName, + SFuncInfo **out) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get udf info from mnode, funcName:%s", funcName); @@ -708,23 +667,23 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEp ctgError("Build get udf msg failed, code:%x, db:%s", code, funcName); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_RETRIEVE_FUNC, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { if (TSDB_CODE_MND_FUNC_NOT_EXIST == rpcRsp.code) { ctgDebug("funcName %s not exist in mnode", funcName); taosMemoryFreeClear(*out); CTG_RET(TSDB_CODE_SUCCESS); } - + ctgError("error rsp for get udf, error:%s, funcName:%s", tstrerror(rpcRsp.code), funcName); CTG_ERR_RET(rpcRsp.code); } @@ -740,8 +699,9 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEp return TSDB_CODE_SUCCESS; } -int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *user, SGetUserAuthRsp *authRsp) { - char *msg = NULL; +int32_t ctgGetUserDbAuthFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *user, + SGetUserAuthRsp *authRsp) { + char *msg = NULL; int32_t msgLen = 0; ctgDebug("try to get user auth from mnode, user:%s", user); @@ -751,16 +711,16 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm ctgError("Build get user auth msg failed, code:%x, db:%s", code, user); CTG_ERR_RET(code); } - + SRpcMsg rpcMsg = { .msgType = TDMT_MND_GET_USER_AUTH, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); + rpcSendRecv(pRpc, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); if (TSDB_CODE_SUCCESS != rpcRsp.code) { ctgError("error rsp for get user auth, error:%s, user:%s", tstrerror(rpcRsp.code), user); CTG_ERR_RET(rpcRsp.code); @@ -777,8 +737,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm return TSDB_CODE_SUCCESS; } - -int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist) { +int32_t ctgIsTableMetaExistInCache(SCatalog *pCtg, char *dbFName, char *tbName, int32_t *exist) { if (NULL == pCtg->dbCache) { *exist = 0; ctgWarn("empty db cache, dbFName:%s, tbName:%s", dbFName, tbName); @@ -793,13 +752,13 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, } size_t sz = 0; - CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); + CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); STableMeta *tbMeta = taosHashGet(dbCache->tbCache.metaCache, tbName, strlen(tbName)); CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); - + if (NULL == tbMeta) { ctgReleaseDBCache(pCtg, dbCache); - + *exist = 0; ctgDebug("tbmeta not in cache, dbFName:%s, tbName:%s", dbFName, tbName); return TSDB_CODE_SUCCESS; @@ -808,14 +767,14 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, *exist = 1; ctgReleaseDBCache(pCtg, dbCache); - + ctgDebug("tbmeta is in cache, dbFName:%s, tbName:%s", dbFName, tbName); - + return TSDB_CODE_SUCCESS; } - -int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, bool *inCache, int32_t flag, uint64_t *dbId) { +int32_t ctgGetTableMetaFromCache(SCatalog *pCtg, const SName *pTableName, STableMeta **pTableMeta, bool *inCache, + int32_t flag, uint64_t *dbId) { if (NULL == pCtg->dbCache) { ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname); goto _return; @@ -836,10 +795,11 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ctgDebug("db %s not in cache", pTableName->tname); goto _return; } - + int32_t sz = 0; CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); - int32_t code = taosHashGetDup_m(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname), (void **)pTableMeta, &sz); + int32_t code = taosHashGetDup_m(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname), + (void **)pTableMeta, &sz); CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); if (NULL == *pTableMeta) { @@ -852,7 +812,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable *dbId = dbCache->dbId; } - STableMeta* tbMeta = *pTableMeta; + STableMeta *tbMeta = *pTableMeta; if (tbMeta->tableType != TSDB_CHILD_TABLE) { ctgReleaseDBCache(pCtg, dbCache); @@ -860,34 +820,36 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable *inCache = true; CTG_CACHE_STAT_ADD(tblHitNum, 1); - + return TSDB_CODE_SUCCESS; } - ctgDebug("Got subtable meta from cache, type:%d, dbFName:%s, tbName:%s, suid:%" PRIx64, tbMeta->tableType, dbFName, pTableName->tname, tbMeta->suid); - + ctgDebug("Got subtable meta from cache, type:%d, dbFName:%s, tbName:%s, suid:%" PRIx64, tbMeta->tableType, dbFName, + pTableName->tname, tbMeta->suid); + CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock); - + STableMeta **stbMeta = taosHashGet(dbCache->tbCache.stbCache, &tbMeta->suid, sizeof(tbMeta->suid)); if (NULL == stbMeta || NULL == *stbMeta) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock); ctgReleaseDBCache(pCtg, dbCache); - ctgError("stb not in stbCache, suid:%"PRIx64, tbMeta->suid); + ctgError("stb not in stbCache, suid:%" PRIx64, tbMeta->suid); taosMemoryFreeClear(*pTableMeta); goto _return; } - if ((*stbMeta)->suid != tbMeta->suid) { + if ((*stbMeta)->suid != tbMeta->suid) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock); ctgReleaseDBCache(pCtg, dbCache); taosMemoryFreeClear(*pTableMeta); - ctgError("stable suid in stbCache mis-match, expected suid:%"PRIx64 ",actual suid:%"PRIx64, tbMeta->suid, (*stbMeta)->suid); + ctgError("stable suid in stbCache mis-match, expected suid:%" PRIx64 ",actual suid:%" PRIx64, tbMeta->suid, + (*stbMeta)->suid); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } int32_t metaSize = CTG_META_SIZE(*stbMeta); *pTableMeta = taosMemoryRealloc(*pTableMeta, metaSize); - if (NULL == *pTableMeta) { + if (NULL == *pTableMeta) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock); ctgReleaseDBCache(pCtg, dbCache); ctgError("realloc size[%d] failed", metaSize); @@ -904,23 +866,23 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable CTG_CACHE_STAT_ADD(tblHitNum, 1); ctgDebug("Got tbmeta from cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname); - + return TSDB_CODE_SUCCESS; _return: *inCache = false; CTG_CACHE_STAT_ADD(tblMissNum, 1); - + return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const char* dbFName, const char *tableName, int32_t *tbType) { +int32_t ctgGetTableTypeFromCache(SCatalog *pCtg, const char *dbFName, const char *tableName, int32_t *tbType) { if (NULL == pCtg->dbCache) { - ctgWarn("empty db cache, dbFName:%s, tbName:%s", dbFName, tableName); + ctgWarn("empty db cache, dbFName:%s, tbName:%s", dbFName, tableName); return TSDB_CODE_SUCCESS; } - + SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { @@ -932,9 +894,9 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const char* dbFName, const char if (NULL == pTableMeta) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); - ctgWarn("tbl not in cache, dbFName:%s, tbName:%s", dbFName, tableName); + ctgWarn("tbl not in cache, dbFName:%s, tbName:%s", dbFName, tableName); ctgReleaseDBCache(pCtg, dbCache); - + return TSDB_CODE_SUCCESS; } @@ -946,17 +908,18 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const char* dbFName, const char ctgReleaseDBCache(pCtg, dbCache); - ctgDebug("Got tbtype from cache, dbFName:%s, tbName:%s, type:%d", dbFName, tableName, *tbType); - + ctgDebug("Got tbtype from cache, dbFName:%s, tbName:%s, type:%d", dbFName, tableName, *tbType); + return TSDB_CODE_SUCCESS; } -int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass) { +int32_t ctgChkAuthFromCache(SCatalog *pCtg, const char *user, const char *dbFName, AUTH_TYPE type, bool *inCache, + bool *pass) { if (NULL == pCtg->userCache) { ctgDebug("empty user auth cache, user:%s", user); goto _return; } - + SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, user, strlen(user)); if (NULL == pUser) { ctgDebug("user not in cache, user:%s", user); @@ -967,7 +930,7 @@ int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFNam ctgDebug("Got user from cache, user:%s", user); CTG_CACHE_STAT_ADD(userHitNum, 1); - + if (pUser->superUser) { *pass = true; return TSDB_CODE_SUCCESS; @@ -979,32 +942,33 @@ int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFNam CTG_UNLOCK(CTG_READ, &pUser->lock); return TSDB_CODE_SUCCESS; } - + if (pUser->readDbs && taosHashGet(pUser->readDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_READ) { *pass = true; } - + if (pUser->writeDbs && taosHashGet(pUser->writeDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_WRITE) { *pass = true; } CTG_UNLOCK(CTG_READ, &pUser->lock); - + return TSDB_CODE_SUCCESS; _return: *inCache = false; CTG_CACHE_STAT_ADD(userMissNum, 1); - + return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableMetaFromMnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, char *dbFName, char* tbName, STableMetaOutput* output) { +int32_t ctgGetTableMetaFromMnodeImpl(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, char *dbFName, char *tbName, + STableMetaOutput *output) { SBuildTableMetaInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName}; - char *msg = NULL; - SEpSet *pVnodeEpSet = NULL; - int32_t msgLen = 0; + char *msg = NULL; + SEpSet *pVnodeEpSet = NULL; + int32_t msgLen = 0; ctgDebug("try to get table meta from mnode, dbFName:%s, tbName:%s", dbFName, tbName); @@ -1016,22 +980,23 @@ int32_t ctgGetTableMetaFromMnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* SRpcMsg rpcMsg = { .msgType = TDMT_MND_TABLE_META, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; - rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp); - + rpcSendRecv(pTrans, (SEpSet *)pMgmtEps, &rpcMsg, &rpcRsp); + if (TSDB_CODE_SUCCESS != rpcRsp.code) { if (CTG_TABLE_NOT_EXIST(rpcRsp.code)) { SET_META_TYPE_NULL(output->metaType); ctgDebug("stablemeta not exist in mnode, dbFName:%s, tbName:%s", dbFName, tbName); return TSDB_CODE_SUCCESS; } - - ctgError("error rsp for stablemeta from mnode, code:%s, dbFName:%s, tbName:%s", tstrerror(rpcRsp.code), dbFName, tbName); + + ctgError("error rsp for stablemeta from mnode, code:%s, dbFName:%s, tbName:%s", tstrerror(rpcRsp.code), dbFName, + tbName); CTG_ERR_RET(rpcRsp.code); } @@ -1046,15 +1011,18 @@ int32_t ctgGetTableMetaFromMnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableMetaFromMnode(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMetaOutput* output) { +int32_t ctgGetTableMetaFromMnode(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + STableMetaOutput *output) { char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); return ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, dbFName, (char *)pTableName->tname, output); } -int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* output) { - if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName || NULL == vgroupInfo || NULL == output) { +int32_t ctgGetTableMetaFromVnodeImpl(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + SVgroupInfo *vgroupInfo, STableMetaOutput *output) { + if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName || NULL == vgroupInfo || + NULL == output) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } @@ -1063,39 +1031,43 @@ int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* ctgDebug("try to get table meta from vnode, dbFName:%s, tbName:%s", dbFName, tNameGetTableName(pTableName)); - SBuildTableMetaInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)}; - char *msg = NULL; + SBuildTableMetaInput bInput = { + .vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)}; + char *msg = NULL; int32_t msgLen = 0; int32_t code = queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)](&bInput, &msg, 0, &msgLen); if (code) { - ctgError("Build vnode tablemeta msg failed, code:%x, dbFName:%s, tbName:%s", code, dbFName, tNameGetTableName(pTableName)); + ctgError("Build vnode tablemeta msg failed, code:%x, dbFName:%s, tbName:%s", code, dbFName, + tNameGetTableName(pTableName)); CTG_ERR_RET(code); } SRpcMsg rpcMsg = { .msgType = TDMT_VND_TABLE_META, - .pCont = msg, + .pCont = msg, .contLen = msgLen, }; SRpcMsg rpcRsp = {0}; rpcSendRecv(pTrans, &vgroupInfo->epSet, &rpcMsg, &rpcRsp); - + if (TSDB_CODE_SUCCESS != rpcRsp.code) { if (CTG_TABLE_NOT_EXIST(rpcRsp.code)) { SET_META_TYPE_NULL(output->metaType); ctgDebug("tablemeta not exist in vnode, dbFName:%s, tbName:%s", dbFName, tNameGetTableName(pTableName)); return TSDB_CODE_SUCCESS; } - - ctgError("error rsp for table meta from vnode, code:%s, dbFName:%s, tbName:%s", tstrerror(rpcRsp.code), dbFName, tNameGetTableName(pTableName)); + + ctgError("error rsp for table meta from vnode, code:%s, dbFName:%s, tbName:%s", tstrerror(rpcRsp.code), dbFName, + tNameGetTableName(pTableName)); CTG_ERR_RET(rpcRsp.code); } code = queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)](output, rpcRsp.pCont, rpcRsp.contLen); if (code) { - ctgError("Process vnode tablemeta rsp failed, code:%s, dbFName:%s, tbName:%s", tstrerror(code), dbFName, tNameGetTableName(pTableName)); + ctgError("Process vnode tablemeta rsp failed, code:%s, dbFName:%s, tbName:%s", tstrerror(code), dbFName, + tNameGetTableName(pTableName)); CTG_ERR_RET(code); } @@ -1103,17 +1075,18 @@ int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet* return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableMetaFromVnode(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* output) { +int32_t ctgGetTableMetaFromVnode(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + SVgroupInfo *vgroupInfo, STableMetaOutput *output) { int32_t code = 0; int32_t retryNum = 0; - + while (retryNum < CTG_DEFAULT_MAX_RETRY_TIMES) { code = ctgGetTableMetaFromVnodeImpl(pCtg, pTrans, pMgmtEps, pTableName, vgroupInfo, output); if (code) { if (TSDB_CODE_VND_HASH_MISMATCH == code) { char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); - + code = catalogRefreshDBVgInfo(pCtg, pTrans, pMgmtEps, dbFName); if (code != TSDB_CODE_SUCCESS) { break; @@ -1140,17 +1113,17 @@ int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) { return TSDB_CODE_SUCCESS; } -int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList) { - SHashObj *vgroupHash = NULL; +int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray **pList) { + SHashObj *vgroupHash = NULL; SVgroupInfo *vgInfo = NULL; - SArray *vgList = NULL; - int32_t code = 0; - int32_t vgNum = taosHashGetSize(vgHash); + SArray *vgList = NULL; + int32_t code = 0; + int32_t vgNum = taosHashGetSize(vgHash); vgList = taosArrayInit(vgNum, sizeof(SVgroupInfo)); if (NULL == vgList) { ctgError("taosArrayInit failed, num:%d", vgNum); - CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); + CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } void *pIter = taosHashIterate(vgHash, NULL); @@ -1159,10 +1132,10 @@ int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList) { if (NULL == taosArrayPush(vgList, vgInfo)) { ctgError("taosArrayPush failed, vgId:%d", vgInfo->vgId); - taosHashCancelIterate(vgHash, pIter); + taosHashCancelIterate(vgHash, pIter); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } - + pIter = taosHashIterate(vgHash, pIter); vgInfo = NULL; } @@ -1184,9 +1157,9 @@ _return: int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup) { int32_t code = 0; - + int32_t vgNum = taosHashGetSize(dbInfo->vgHash); - char db[TSDB_DB_FNAME_LEN] = {0}; + char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); if (vgNum <= 0) { @@ -1195,7 +1168,7 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName } tableNameHashFp fp = NULL; - SVgroupInfo *vgInfo = NULL; + SVgroupInfo *vgInfo = NULL; CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp)); @@ -1211,13 +1184,14 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName taosHashCancelIterate(dbInfo->vgHash, pIter); break; } - + pIter = taosHashIterate(dbInfo->vgHash, pIter); vgInfo = NULL; } if (NULL == vgInfo) { - ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, taosHashGetSize(dbInfo->vgHash)); + ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, + taosHashGetSize(dbInfo->vgHash)); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } @@ -1226,54 +1200,53 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName CTG_RET(code); } -int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) { - if (*(uint64_t *)key1 < ((SSTableMetaVersion*)key2)->suid) { +int32_t ctgStbVersionSearchCompare(const void *key1, const void *key2) { + if (*(uint64_t *)key1 < ((SSTableMetaVersion *)key2)->suid) { return -1; - } else if (*(uint64_t *)key1 > ((SSTableMetaVersion*)key2)->suid) { + } else if (*(uint64_t *)key1 > ((SSTableMetaVersion *)key2)->suid) { return 1; } else { return 0; } } -int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) { - if (*(int64_t *)key1 < ((SDbVgVersion*)key2)->dbId) { +int32_t ctgDbVgVersionSearchCompare(const void *key1, const void *key2) { + if (*(int64_t *)key1 < ((SDbVgVersion *)key2)->dbId) { return -1; - } else if (*(int64_t *)key1 > ((SDbVgVersion*)key2)->dbId) { + } else if (*(int64_t *)key1 > ((SDbVgVersion *)key2)->dbId) { return 1; } else { return 0; } } -int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) { - if (((SSTableMetaVersion*)key1)->suid < ((SSTableMetaVersion*)key2)->suid) { +int32_t ctgStbVersionSortCompare(const void *key1, const void *key2) { + if (((SSTableMetaVersion *)key1)->suid < ((SSTableMetaVersion *)key2)->suid) { return -1; - } else if (((SSTableMetaVersion*)key1)->suid > ((SSTableMetaVersion*)key2)->suid) { + } else if (((SSTableMetaVersion *)key1)->suid > ((SSTableMetaVersion *)key2)->suid) { return 1; } else { return 0; } } -int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) { - if (((SDbVgVersion*)key1)->dbId < ((SDbVgVersion*)key2)->dbId) { +int32_t ctgDbVgVersionSortCompare(const void *key1, const void *key2) { + if (((SDbVgVersion *)key1)->dbId < ((SDbVgVersion *)key2)->dbId) { return -1; - } else if (((SDbVgVersion*)key1)->dbId > ((SDbVgVersion*)key2)->dbId) { + } else if (((SDbVgVersion *)key1)->dbId > ((SDbVgVersion *)key2)->dbId) { return 1; } else { return 0; } } - int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) { mgmt->slotRIdx = 0; mgmt->slotNum = rentSec / CTG_RENT_SLOT_SECOND; mgmt->type = type; size_t msgSize = sizeof(SCtgRentSlot) * mgmt->slotNum; - + mgmt->slots = taosMemoryCalloc(1, msgSize); if (NULL == mgmt->slots) { qError("calloc %d failed", (int32_t)msgSize); @@ -1281,34 +1254,34 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) { } qDebug("meta rent initialized, type:%d, slotNum:%d", type, mgmt->slotNum); - + return TSDB_CODE_SUCCESS; } - int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; - + int32_t code = 0; + CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { slot->meta = taosArrayInit(CTG_DEFAULT_RENT_SLOT_SIZE, size); if (NULL == slot->meta) { - qError("taosArrayInit %d failed, id:%"PRIx64", slot idx:%d, type:%d", CTG_DEFAULT_RENT_SLOT_SIZE, id, widx, mgmt->type); + qError("taosArrayInit %d failed, id:%" PRIx64 ", slot idx:%d, type:%d", CTG_DEFAULT_RENT_SLOT_SIZE, id, widx, + mgmt->type); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } } if (NULL == taosArrayPush(slot->meta, meta)) { - qError("taosArrayPush meta to rent failed, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qError("taosArrayPush meta to rent failed, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } slot->needSort = true; - qDebug("add meta to rent, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qDebug("add meta to rent, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); _return: @@ -1316,20 +1289,22 @@ _return: CTG_RET(code); } -int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { +int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, + __compar_fn_t searchCompare) { int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; + int32_t code = 0; CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { - qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qError("empty meta slot, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } if (slot->needSort) { - qDebug("meta slot before sorte, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta)); + qDebug("meta slot before sorte, slot idx:%d, type:%d, size:%d", widx, mgmt->type, + (int32_t)taosArrayGetSize(slot->meta)); taosArraySort(slot->meta, sortCompare); slot->needSort = false; qDebug("meta slot sorted, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta)); @@ -1337,20 +1312,22 @@ int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t si void *orig = taosArraySearch(slot->meta, &id, searchCompare, TD_EQ); if (NULL == orig) { - qError("meta not found in slot, id:%"PRIx64", slot idx:%d, type:%d, size:%d", id, widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta)); + qError("meta not found in slot, id:%" PRIx64 ", slot idx:%d, type:%d, size:%d", id, widx, mgmt->type, + (int32_t)taosArrayGetSize(slot->meta)); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } memcpy(orig, meta, size); - qDebug("meta in rent updated, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qDebug("meta in rent updated, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); _return: CTG_UNLOCK(CTG_WRITE, &slot->lock); if (code) { - qWarn("meta in rent update failed, will try to add it, code:%x, id:%"PRIx64", slot idx:%d, type:%d", code, id, widx, mgmt->type); + qWarn("meta in rent update failed, will try to add it, code:%x, id:%" PRIx64 ", slot idx:%d, type:%d", code, id, + widx, mgmt->type); CTG_RET(ctgMetaRentAdd(mgmt, meta, id, size)); } @@ -1361,11 +1338,11 @@ int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortComp int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; - + int32_t code = 0; + CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { - qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qError("empty meta slot, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } @@ -1377,13 +1354,13 @@ int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortComp int32_t idx = taosArraySearchIdx(slot->meta, &id, searchCompare, TD_EQ); if (idx < 0) { - qError("meta not found in slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qError("meta not found in slot, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } taosArrayRemove(slot->meta, idx); - qDebug("meta in rent removed, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); + qDebug("meta in rent removed, id:%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); _return: @@ -1392,7 +1369,6 @@ _return: CTG_RET(code); } - int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) { int16_t ridx = atomic_add_fetch_16(&mgmt->slotRIdx, 1); if (ridx >= mgmt->slotNum) { @@ -1401,8 +1377,8 @@ int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_ } SCtgRentSlot *slot = &mgmt->slots[ridx]; - int32_t code = 0; - + int32_t code = 0; + CTG_LOCK(CTG_READ, &slot->lock); if (NULL == slot->meta) { qDebug("empty meta in slot:%d, type:%d", ridx, mgmt->type); @@ -1468,13 +1444,15 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { SCtgDBCache newDBCache = {0}; newDBCache.dbId = dbId; - newDBCache.tbCache.metaCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + newDBCache.tbCache.metaCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (NULL == newDBCache.tbCache.metaCache) { ctgError("taosHashInit %d metaCache failed", gCtgMgmt.cfg.maxTblCacheNum); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - newDBCache.tbCache.stbCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_ENTRY_LOCK); + newDBCache.tbCache.stbCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_ENTRY_LOCK); if (NULL == newDBCache.tbCache.stbCache) { ctgError("taosHashInit %d stbCache failed", gCtgMgmt.cfg.maxTblCacheNum); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); @@ -1486,21 +1464,21 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { ctgDebug("db already in cache, dbFName:%s", dbFName); goto _return; } - + ctgError("taosHashPut db to cache failed, dbFName:%s", dbFName); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } CTG_CACHE_STAT_ADD(dbNum, 1); - + SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1}; strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName)); - ctgDebug("db added to cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbId); + ctgDebug("db added to cache, dbFName:%s, dbId:%" PRIx64, dbFName, dbId); CTG_ERR_RET(ctgMetaRentAdd(&pCtg->dbRent, &vgVersion, dbId, sizeof(SDbVgVersion))); - ctgDebug("db added to rent, dbFName:%s, vgVersion:%d, dbId:%"PRIx64, dbFName, vgVersion.vgVersion, dbId); + ctgDebug("db added to rent, dbFName:%s, vgVersion:%d, dbId:%" PRIx64, dbFName, vgVersion.vgVersion, dbId); return TSDB_CODE_SUCCESS; @@ -1511,8 +1489,7 @@ _return: CTG_RET(code); } - -void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) { +void ctgRemoveStbRent(SCatalog *pCtg, SCtgTbMetaCache *cache) { CTG_LOCK(CTG_WRITE, &cache->stbLock); if (cache->stbCache) { void *pIter = taosHashIterate(cache->stbCache, NULL); @@ -1520,21 +1497,21 @@ void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) { uint64_t *suid = NULL; suid = taosHashGetKey(pIter, NULL); - if (TSDB_CODE_SUCCESS == ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) { - ctgDebug("stb removed from rent, suid:%"PRIx64, *suid); + if (TSDB_CODE_SUCCESS == + ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) { + ctgDebug("stb removed from rent, suid:%" PRIx64, *suid); } - + pIter = taosHashIterate(cache->stbCache, pIter); } } CTG_UNLOCK(CTG_WRITE, &cache->stbLock); } - -int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) { +int32_t ctgRemoveDB(SCatalog *pCtg, SCtgDBCache *dbCache, const char *dbFName) { uint64_t dbId = dbCache->dbId; - - ctgInfo("start to remove db from cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbCache->dbId); + + ctgInfo("start to remove db from cache, dbFName:%s, dbId:%" PRIx64, dbFName, dbCache->dbId); atomic_store_8(&dbCache->deleted, 1); @@ -1543,8 +1520,8 @@ int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) { ctgFreeDbCache(dbCache); CTG_ERR_RET(ctgMetaRentRemove(&pCtg->dbRent, dbCache->dbId, ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare)); - - ctgDebug("db removed from rent, dbFName:%s, dbId:%"PRIx64, dbFName, dbCache->dbId); + + ctgDebug("db removed from rent, dbFName:%s, dbId:%" PRIx64, dbFName, dbCache->dbId); if (taosHashRemove(pCtg->dbCache, dbFName, strlen(dbFName))) { ctgInfo("taosHashRemove from dbCache failed, may be removed, dbFName:%s", dbFName); @@ -1553,19 +1530,18 @@ int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) { CTG_CACHE_STAT_SUB(dbNum, 1); - ctgInfo("db removed from cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbId); - + ctgInfo("db removed from cache, dbFName:%s, dbId:%" PRIx64, dbFName, dbId); + return TSDB_CODE_SUCCESS; } - -int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCtgDBCache **pCache) { - int32_t code = 0; +int32_t ctgGetAddDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SCtgDBCache **pCache) { + int32_t code = 0; SCtgDBCache *dbCache = NULL; ctgGetDBCache(pCtg, dbFName, &dbCache); - + if (dbCache) { - // TODO OPEN IT + // TODO OPEN IT #if 0 if (dbCache->dbId == dbId) { *pCache = dbCache; @@ -1582,7 +1558,7 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt *pCache = dbCache; return TSDB_CODE_SUCCESS; } - + if (dbCache->dbId == dbId) { *pCache = dbCache; return TSDB_CODE_SUCCESS; @@ -1590,7 +1566,7 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt #endif CTG_ERR_RET(ctgRemoveDB(pCtg, dbCache, dbFName)); } - + CTG_ERR_RET(ctgAddNewDBCache(pCtg, dbFName, dbId)); ctgGetDBCache(pCtg, dbFName, &dbCache); @@ -1600,46 +1576,47 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt return TSDB_CODE_SUCCESS; } - -int32_t ctgUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SDBVgInfo** pDbInfo) { - int32_t code = 0; - SDBVgInfo* dbInfo = *pDbInfo; +int32_t ctgUpdateDBVgInfo(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SDBVgInfo **pDbInfo) { + int32_t code = 0; + SDBVgInfo *dbInfo = *pDbInfo; if (NULL == dbInfo->vgHash) { return TSDB_CODE_SUCCESS; } - + if (dbInfo->vgVersion < 0 || taosHashGetSize(dbInfo->vgHash) <= 0) { - ctgError("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d", - dbFName, dbInfo->vgHash, dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash)); + ctgError("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d", dbFName, dbInfo->vgHash, + dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash)); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - bool newAdded = false; + bool newAdded = false; SDbVgVersion vgVersion = {.dbId = dbId, .vgVersion = dbInfo->vgVersion, .numOfTable = dbInfo->numOfTable}; SCtgDBCache *dbCache = NULL; CTG_ERR_RET(ctgGetAddDBCache(pCtg, dbFName, dbId, &dbCache)); if (NULL == dbCache) { - ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:%"PRIx64, dbFName, dbId); + ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:%" PRIx64, dbFName, dbId); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } SDBVgInfo *vgInfo = NULL; CTG_ERR_RET(ctgWAcquireVgInfo(pCtg, dbCache)); - + if (dbCache->vgInfo) { if (dbInfo->vgVersion < dbCache->vgInfo->vgVersion) { - ctgDebug("db vgVersion is old, dbFName:%s, vgVersion:%d, currentVersion:%d", dbFName, dbInfo->vgVersion, dbCache->vgInfo->vgVersion); + ctgDebug("db vgVersion is old, dbFName:%s, vgVersion:%d, currentVersion:%d", dbFName, dbInfo->vgVersion, + dbCache->vgInfo->vgVersion); ctgWReleaseVgInfo(dbCache); - + return TSDB_CODE_SUCCESS; } if (dbInfo->vgVersion == dbCache->vgInfo->vgVersion && dbInfo->numOfTable == dbCache->vgInfo->numOfTable) { - ctgDebug("no new db vgVersion or numOfTable, dbFName:%s, vgVersion:%d, numOfTable:%d", dbFName, dbInfo->vgVersion, dbInfo->numOfTable); + ctgDebug("no new db vgVersion or numOfTable, dbFName:%s, vgVersion:%d, numOfTable:%d", dbFName, dbInfo->vgVersion, + dbInfo->numOfTable); ctgWReleaseVgInfo(dbCache); - + return TSDB_CODE_SUCCESS; } @@ -1650,53 +1627,55 @@ int32_t ctgUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SD *pDbInfo = NULL; - ctgDebug("db vgInfo updated, dbFName:%s, vgVersion:%d, dbId:%"PRIx64, dbFName, vgVersion.vgVersion, vgVersion.dbId); + ctgDebug("db vgInfo updated, dbFName:%s, vgVersion:%d, dbId:%" PRIx64, dbFName, vgVersion.vgVersion, vgVersion.dbId); ctgWReleaseVgInfo(dbCache); dbCache = NULL; strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName)); - CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion), ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare)); - + CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion), + ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare)); + CTG_RET(code); } - -int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, uint64_t dbId, char *tbName, STableMeta *meta, int32_t metaSize) { +int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, uint64_t dbId, char *tbName, + STableMeta *meta, int32_t metaSize) { SCtgTbMetaCache *tbCache = &dbCache->tbCache; CTG_LOCK(CTG_READ, &tbCache->metaLock); if (dbCache->deleted || NULL == tbCache->metaCache || NULL == tbCache->stbCache) { - CTG_UNLOCK(CTG_READ, &tbCache->metaLock); - ctgError("db is dropping, dbId:%"PRIx64, dbCache->dbId); + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + ctgError("db is dropping, dbId:%" PRIx64, dbCache->dbId); CTG_ERR_RET(TSDB_CODE_CTG_DB_DROPPED); } - int8_t origType = 0; - uint64_t origSuid = 0; - bool isStb = meta->tableType == TSDB_SUPER_TABLE; + int8_t origType = 0; + uint64_t origSuid = 0; + bool isStb = meta->tableType == TSDB_SUPER_TABLE; STableMeta *orig = taosHashGet(tbCache->metaCache, tbName, strlen(tbName)); if (orig) { origType = orig->tableType; - if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) { - CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && + orig->tversion >= meta->tversion) { + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); return TSDB_CODE_SUCCESS; } - + if (origType == TSDB_SUPER_TABLE) { if ((!isStb) || orig->suid != meta->suid) { CTG_LOCK(CTG_WRITE, &tbCache->stbLock); if (taosHashRemove(tbCache->stbCache, &orig->suid, sizeof(orig->suid))) { - ctgError("stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"PRIx64, dbFName, tbName, orig->suid); + ctgError("stb not exist in stbCache, dbFName:%s, stb:%s, suid:%" PRIx64, dbFName, tbName, orig->suid); } else { CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); - ctgDebug("stb removed from stbCache, dbFName:%s, stb:%s, suid:%"PRIx64, dbFName, tbName, orig->suid); - + ctgDebug("stb removed from stbCache, dbFName:%s, stb:%s, suid:%" PRIx64, dbFName, tbName, orig->suid); + ctgMetaRentRemove(&pCtg->stbRent, orig->suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare); } @@ -1707,13 +1686,13 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui if (isStb) { CTG_LOCK(CTG_WRITE, &tbCache->stbLock); } - + if (taosHashPut(tbCache->metaCache, tbName, strlen(tbName), meta, metaSize) != 0) { if (isStb) { CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); } - - CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); ctgError("taosHashPut tbmeta to cache failed, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } @@ -1722,35 +1701,38 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui CTG_CACHE_STAT_ADD(tblNum, 1); } - ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64, dbFName, tbName, meta->tableType, meta->suid); + ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64, dbFName, tbName, meta->tableType, + meta->suid); ctgdShowTableMeta(pCtg, tbName, meta); if (!isStb) { - CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); return TSDB_CODE_SUCCESS; } STableMeta *tbMeta = taosHashGet(tbCache->metaCache, tbName, strlen(tbName)); if (taosHashPut(tbCache->stbCache, &meta->suid, sizeof(meta->suid), &tbMeta, POINTER_BYTES) != 0) { CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); - CTG_UNLOCK(CTG_READ, &tbCache->metaLock); - ctgError("taosHashPut stable to stable cache failed, suid:%"PRIx64, meta->suid); + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + ctgError("taosHashPut stable to stable cache failed, suid:%" PRIx64, meta->suid); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } CTG_CACHE_STAT_ADD(stblNum, 1); - + CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); CTG_UNLOCK(CTG_READ, &tbCache->metaLock); - ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64 ",ma:%p", dbFName, tbName, meta->tableType, meta->suid, tbMeta); + ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64 ",ma:%p", dbFName, tbName, + meta->tableType, meta->suid, tbMeta); - SSTableMetaVersion metaRent = {.dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion}; + SSTableMetaVersion metaRent = { + .dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion}; strcpy(metaRent.dbFName, dbFName); strcpy(metaRent.stbName, tbName); CTG_ERR_RET(ctgMetaRentAdd(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableMetaVersion))); - + return TSDB_CODE_SUCCESS; } @@ -1772,7 +1754,7 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) { } int32_t *vgId = NULL; - void *pIter = taosHashIterate(src->vgHash, NULL); + void *pIter = taosHashIterate(src->vgHash, NULL); while (pIter) { vgId = taosHashGetKey(pIter, NULL); @@ -1783,18 +1765,16 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) { taosMemoryFreeClear(*dst); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - + pIter = taosHashIterate(src->vgHash, pIter); } - return TSDB_CODE_SUCCESS; } - - -int32_t ctgGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SCtgDBCache** dbCache, SDBVgInfo **pInfo) { - bool inCache = false; +int32_t ctgGetDBVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName, SCtgDBCache **dbCache, + SDBVgInfo **pInfo) { + bool inCache = false; int32_t code = 0; CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, dbCache, &inCache)); @@ -1803,7 +1783,7 @@ int32_t ctgGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const return TSDB_CODE_SUCCESS; } - SUseDbOutput DbOut = {0}; + SUseDbOutput DbOut = {0}; SBuildUseDBInput input = {0}; tstrncpy(input.db, dbFName, tListLen(input.db)); @@ -1829,18 +1809,18 @@ _return: taosMemoryFreeClear(*pInfo); *pInfo = DbOut.dbVgroup; - + CTG_RET(code); } -int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName) { - bool inCache = false; - int32_t code = 0; - SCtgDBCache* dbCache = NULL; +int32_t ctgRefreshDBVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName) { + bool inCache = false; + int32_t code = 0; + SCtgDBCache *dbCache = NULL; CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache, &inCache)); - SUseDbOutput DbOut = {0}; + SUseDbOutput DbOut = {0}; SBuildUseDBInput input = {0}; tstrncpy(input.db, dbFName, tListLen(input.db)); @@ -1850,7 +1830,7 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, c ctgReleaseVgInfo(dbCache); ctgReleaseDBCache(pCtg, dbCache); } - + input.vgVersion = CTG_DEFAULT_INVALID_VERSION; input.numOfTable = 0; @@ -1869,8 +1849,6 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, c return TSDB_CODE_SUCCESS; } - - int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) { *pOutput = taosMemoryMalloc(sizeof(STableMetaOutput)); if (NULL == *pOutput) { @@ -1895,15 +1873,14 @@ int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) return TSDB_CODE_SUCCESS; } - - -int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, int32_t flag, STableMetaOutput **pOutput, bool syncReq) { +int32_t ctgRefreshTblMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, int32_t flag, + STableMetaOutput **pOutput, bool syncReq) { if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } SVgroupInfo vgroupInfo = {0}; - int32_t code = 0; + int32_t code = 0; if (!CTG_FLAG_IS_SYS_DB(flag)) { CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pTrans, pMgmtEps, pTableName, &vgroupInfo)); @@ -1919,7 +1896,8 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, if (CTG_FLAG_IS_SYS_DB(flag)) { ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName)); - CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, (char *)pTableName->tname, output)); + CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, + (char *)pTableName->tname, output)); } else if (CTG_FLAG_IS_STB(flag)) { ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(pTableName)); @@ -1939,7 +1917,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pTableName)); taosMemoryFreeClear(output->tbMeta); - + CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, output->dbFName, output->tbName, output)); } else if (CTG_IS_META_BOTH(output->metaType)) { int32_t exist = 0; @@ -1953,14 +1931,14 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, if (CTG_IS_META_NULL(moutput.metaType)) { SET_META_TYPE_NULL(output->metaType); } - + taosMemoryFreeClear(output->tbMeta); output->tbMeta = moutput.tbMeta; moutput.tbMeta = NULL; } else { taosMemoryFreeClear(output->tbMeta); - - SET_META_TYPE_CTABLE(output->metaType); + + SET_META_TYPE_CTABLE(output->metaType); } } } @@ -1972,9 +1950,11 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, } if (CTG_IS_META_TABLE(output->metaType)) { - ctgDebug("tbmeta got, dbFName:%s, tbName:%s, tbType:%d", output->dbFName, output->tbName, output->tbMeta->tableType); + ctgDebug("tbmeta got, dbFName:%s, tbName:%s, tbType:%d", output->dbFName, output->tbName, + output->tbMeta->tableType); } else { - ctgDebug("tbmeta got, dbFName:%s, tbName:%s, tbType:%d, stbMetaGot:%d", output->dbFName, output->ctbName, output->ctbMeta.tableType, CTG_IS_META_BOTH(output->metaType)); + ctgDebug("tbmeta got, dbFName:%s, tbName:%s, tbType:%d, stbMetaGot:%d", output->dbFName, output->ctbName, + output->ctbMeta.tableType, CTG_IS_META_BOTH(output->metaType)); } if (pOutput) { @@ -1989,19 +1969,20 @@ _return: taosMemoryFreeClear(output->tbMeta); taosMemoryFreeClear(output); - + CTG_RET(code); } -int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta, int32_t flag) { +int32_t ctgGetTableMeta(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const SName *pTableName, + STableMeta **pTableMeta, int32_t flag) { if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pTableMeta) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - bool inCache = false; - int32_t code = 0; - uint64_t dbId = 0; - uint64_t suid = 0; + bool inCache = false; + int32_t code = 0; + uint64_t dbId = 0; + uint64_t suid = 0; STableMetaOutput *output = NULL; if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { @@ -2013,7 +1994,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons int32_t tbType = 0; if (inCache) { - if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) { + if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && + ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) { goto _return; } @@ -2027,7 +2009,6 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_FLAG_SET_STB(flag, tbType); } - while (true) { CTG_ERR_JRET(ctgRefreshTblMeta(pCtg, pRpc, pMgmtEps, pTableName, flag, &output, false)); @@ -2038,7 +2019,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons if (CTG_IS_META_BOTH(output->metaType)) { memcpy(output->tbMeta, &output->ctbMeta, sizeof(output->ctbMeta)); - + *pTableMeta = output->tbMeta; goto _return; } @@ -2055,11 +2036,11 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons strcpy(stbName.tname, output->tbName); taosMemoryFreeClear(output->tbMeta); - + CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &inCache, flag, NULL)); if (!inCache) { ctgDebug("stb no longer exist, dbFName:%s, tbName:%s", output->dbFName, pTableName->tname); - + continue; } @@ -2095,12 +2076,13 @@ _return: CTG_RET(code); } -int32_t ctgChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass) { - bool inCache = false; +int32_t ctgChkAuth(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *user, const char *dbFName, + AUTH_TYPE type, bool *pass) { + bool inCache = false; int32_t code = 0; - + *pass = false; - + CTG_ERR_RET(ctgChkAuthFromCache(pCtg, user, dbFName, type, &inCache, pass)); if (inCache) { @@ -2109,7 +2091,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const cha SGetUserAuthRsp authRsp = {0}; CTG_ERR_RET(ctgGetUserDbAuthFromMnode(pCtg, pRpc, pMgmtEps, user, &authRsp)); - + if (authRsp.superAuth) { *pass = true; goto _return; @@ -2135,53 +2117,52 @@ _return: return TSDB_CODE_SUCCESS; } - int32_t ctgActUpdateVg(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgUpdateVgMsg *msg = action->data; - + CTG_ERR_JRET(ctgUpdateDBVgInfo(msg->pCtg, msg->dbFName, msg->dbId, &msg->dbInfo)); _return: ctgFreeVgInfo(msg->dbInfo); taosMemoryFreeClear(msg); - + CTG_RET(code); } int32_t ctgActRemoveDB(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgRemoveDBMsg *msg = action->data; - SCatalog* pCtg = msg->pCtg; + SCatalog *pCtg = msg->pCtg; SCtgDBCache *dbCache = NULL; ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache); if (NULL == dbCache) { goto _return; } - + if (dbCache->dbId != msg->dbId) { - ctgInfo("dbId already updated, dbFName:%s, dbId:%"PRIx64 ", targetId:%"PRIx64, msg->dbFName, dbCache->dbId, msg->dbId); + ctgInfo("dbId already updated, dbFName:%s, dbId:%" PRIx64 ", targetId:%" PRIx64, msg->dbFName, dbCache->dbId, + msg->dbId); goto _return; } - + CTG_ERR_JRET(ctgRemoveDB(pCtg, dbCache, msg->dbFName)); _return: taosMemoryFreeClear(msg); - + CTG_RET(code); } - int32_t ctgActUpdateTbl(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgUpdateTblMsg *msg = action->data; - SCatalog* pCtg = msg->pCtg; - STableMetaOutput* output = msg->output; - SCtgDBCache *dbCache = NULL; + SCatalog *pCtg = msg->pCtg; + STableMetaOutput *output = msg->output; + SCtgDBCache *dbCache = NULL; if ((!CTG_IS_META_CTABLE(output->metaType)) && NULL == output->tbMeta) { ctgError("no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s", output->dbFName, output->tbName); @@ -2191,22 +2172,24 @@ int32_t ctgActUpdateTbl(SCtgMetaAction *action) { if (CTG_IS_META_BOTH(output->metaType) && TSDB_SUPER_TABLE != output->tbMeta->tableType) { ctgError("table type error, expected:%d, actual:%d", TSDB_SUPER_TABLE, output->tbMeta->tableType); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - + } + CTG_ERR_JRET(ctgGetAddDBCache(pCtg, output->dbFName, output->dbId, &dbCache)); if (NULL == dbCache) { - ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:%"PRIx64, output->dbFName, output->dbId); + ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:%" PRIx64, output->dbFName, output->dbId); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } if (CTG_IS_META_TABLE(output->metaType) || CTG_IS_META_BOTH(output->metaType)) { int32_t metaSize = CTG_META_SIZE(output->tbMeta); - - CTG_ERR_JRET(ctgUpdateTblMeta(pCtg, dbCache, output->dbFName, output->dbId, output->tbName, output->tbMeta, metaSize)); + + CTG_ERR_JRET( + ctgUpdateTblMeta(pCtg, dbCache, output->dbFName, output->dbId, output->tbName, output->tbMeta, metaSize)); } if (CTG_IS_META_CTABLE(output->metaType) || CTG_IS_META_BOTH(output->metaType)) { - CTG_ERR_JRET(ctgUpdateTblMeta(pCtg, dbCache, output->dbFName, output->dbId, output->ctbName, (STableMeta *)&output->ctbMeta, sizeof(output->ctbMeta))); + CTG_ERR_JRET(ctgUpdateTblMeta(pCtg, dbCache, output->dbFName, output->dbId, output->ctbName, + (STableMeta *)&output->ctbMeta, sizeof(output->ctbMeta))); } _return: @@ -2215,17 +2198,16 @@ _return: taosMemoryFreeClear(output->tbMeta); taosMemoryFreeClear(output); } - + taosMemoryFreeClear(msg); - + CTG_RET(code); } - int32_t ctgActRemoveStb(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgRemoveStbMsg *msg = action->data; - SCatalog* pCtg = msg->pCtg; + SCatalog *pCtg = msg->pCtg; SCtgDBCache *dbCache = NULL; ctgGetDBCache(pCtg, msg->dbFName, &dbCache); @@ -2234,44 +2216,46 @@ int32_t ctgActRemoveStb(SCtgMetaAction *action) { } if (msg->dbId && (dbCache->dbId != msg->dbId)) { - ctgDebug("dbId already modified, dbFName:%s, current:%"PRIx64", dbId:%"PRIx64", stb:%s, suid:%"PRIx64, msg->dbFName, dbCache->dbId, msg->dbId, msg->stbName, msg->suid); + ctgDebug("dbId already modified, dbFName:%s, current:%" PRIx64 ", dbId:%" PRIx64 ", stb:%s, suid:%" PRIx64, + msg->dbFName, dbCache->dbId, msg->dbId, msg->stbName, msg->suid); return TSDB_CODE_SUCCESS; } - + CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock); if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) { - ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); + ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%" PRIx64, msg->dbFName, msg->stbName, + msg->suid); } else { CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); - if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) { - ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); + if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) { + ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%" PRIx64, msg->dbFName, msg->stbName, msg->suid); } else { CTG_CACHE_STAT_SUB(tblNum, 1); } CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); - + CTG_UNLOCK(CTG_WRITE, &dbCache->tbCache.stbLock); - - ctgInfo("stb removed from cache, dbFName:%s, stbName:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); + + ctgInfo("stb removed from cache, dbFName:%s, stbName:%s, suid:%" PRIx64, msg->dbFName, msg->stbName, msg->suid); CTG_ERR_JRET(ctgMetaRentRemove(&msg->pCtg->stbRent, msg->suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)); - - ctgDebug("stb removed from rent, dbFName:%s, stbName:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); - + + ctgDebug("stb removed from rent, dbFName:%s, stbName:%s, suid:%" PRIx64, msg->dbFName, msg->stbName, msg->suid); + _return: taosMemoryFreeClear(msg); - + CTG_RET(code); } int32_t ctgActRemoveTbl(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgRemoveTblMsg *msg = action->data; - SCatalog* pCtg = msg->pCtg; + SCatalog *pCtg = msg->pCtg; SCtgDBCache *dbCache = NULL; ctgGetDBCache(pCtg, msg->dbFName, &dbCache); @@ -2280,7 +2264,8 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) { } if (dbCache->dbId != msg->dbId) { - ctgDebug("dbId already modified, dbFName:%s, current:%"PRIx64", dbId:%"PRIx64", tbName:%s", msg->dbFName, dbCache->dbId, msg->dbId, msg->tbName); + ctgDebug("dbId already modified, dbFName:%s, current:%" PRIx64 ", dbId:%" PRIx64 ", tbName:%s", msg->dbFName, + dbCache->dbId, msg->dbId, msg->tbName); return TSDB_CODE_SUCCESS; } @@ -2304,18 +2289,19 @@ _return: } int32_t ctgActUpdateUser(SCtgMetaAction *action) { - int32_t code = 0; + int32_t code = 0; SCtgUpdateUserMsg *msg = action->data; - SCatalog* pCtg = msg->pCtg; + SCatalog *pCtg = msg->pCtg; if (NULL == pCtg->userCache) { - pCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + pCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), + false, HASH_ENTRY_LOCK); if (NULL == pCtg->userCache) { ctgError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } } - + SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, msg->userAuth.user, strlen(msg->userAuth.user)); if (NULL == pUser) { SCtgUserAuth userAuth = {0}; @@ -2326,7 +2312,7 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) { userAuth.readDbs = msg->userAuth.readDbs; userAuth.writeDbs = msg->userAuth.writeDbs; - if (taosHashPut(pCtg->userCache, msg->userAuth.user, strlen(msg->userAuth.user), &userAuth, sizeof(userAuth))) { + if (taosHashPut(pCtg->userCache, msg->userAuth.user, sizeof(msg->userAuth.user), &userAuth, sizeof(userAuth))) { ctgError("taosHashPut user %s to cache failed", msg->userAuth.user); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } @@ -2356,30 +2342,28 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) { _return: - taosHashCleanup(msg->userAuth.createdDbs); taosHashCleanup(msg->userAuth.readDbs); taosHashCleanup(msg->userAuth.writeDbs); - + taosMemoryFreeClear(msg); - + CTG_RET(code); } - -void* ctgUpdateThreadFunc(void* param) { +void *ctgUpdateThreadFunc(void *param) { setThreadName("catalog"); qInfo("catalog update thread started"); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); - + while (true) { if (tsem_wait(&gCtgMgmt.queue.reqSem)) { qError("ctg tsem_wait failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); } - - if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { + + if (atomic_load_8((int8_t *)&gCtgMgmt.exit)) { tsem_post(&gCtgMgmt.queue.rspSem); break; } @@ -2389,7 +2373,7 @@ void* ctgUpdateThreadFunc(void* param) { SCatalog *pCtg = ((SCtgUpdateMsgHeader *)action->data)->pCtg; ctgDebug("process [%s] action", gCtgAction[action->act].name); - + (*gCtgAction[action->act].func)(action); gCtgMgmt.queue.seqDone = action->seqId; @@ -2398,7 +2382,7 @@ void* ctgUpdateThreadFunc(void* param) { tsem_post(&gCtgMgmt.queue.rspSem); } - CTG_RUNTIME_STAT_ADD(qDoneNum, 1); + CTG_RUNTIME_STAT_ADD(qDoneNum, 1); ctgdShowClusterCache(pCtg); } @@ -2406,11 +2390,10 @@ void* ctgUpdateThreadFunc(void* param) { CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); qInfo("catalog update thread stopped"); - + return NULL; } - int32_t ctgStartUpdateThread() { TdThreadAttr thAttr; taosThreadAttrInit(&thAttr); @@ -2420,27 +2403,28 @@ int32_t ctgStartUpdateThread() { terrno = TAOS_SYSTEM_ERROR(errno); CTG_ERR_RET(terrno); } - + taosThreadAttrDestroy(&thAttr); return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) { - STableMeta *tbMeta = NULL; - int32_t code = 0; - SVgroupInfo vgroupInfo = {0}; - SCtgDBCache* dbCache = NULL; - SArray *vgList = NULL; - SDBVgInfo *vgInfo = NULL; +int32_t ctgGetTableDistVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const SName *pTableName, + SArray **pVgList) { + STableMeta *tbMeta = NULL; + int32_t code = 0; + SVgroupInfo vgroupInfo = {0}; + SCtgDBCache *dbCache = NULL; + SArray *vgList = NULL; + SDBVgInfo *vgInfo = NULL; *pVgList = NULL; - + CTG_ERR_JRET(ctgGetTableMeta(pCtg, pRpc, pMgmtEps, pTableName, &tbMeta, CTG_FLAG_UNKNOWN_STB)); char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); - SHashObj *vgHash = NULL; + SHashObj *vgHash = NULL; CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pRpc, pMgmtEps, db, &dbCache, &vgInfo)); if (dbCache) { @@ -2455,7 +2439,7 @@ int32_t ctgGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps // USE HASH METHOD INSTEAD OF VGID IN TBMETA ctgError("invalid method to get none stb vgInfo, tbType:%d", tbMeta->tableType); CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT); - + #if 0 int32_t vgId = tbMeta->vgId; if (taosHashGetDup(vgHash, &vgId, sizeof(vgId), &vgroupInfo) != 0) { @@ -2476,7 +2460,7 @@ int32_t ctgGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps *pVgList = vgList; vgList = NULL; -#endif +#endif } _return: @@ -2507,7 +2491,7 @@ int32_t catalogInit(SCatalogCfg *cfg) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - atomic_store_8((int8_t*)&gCtgMgmt.exit, false); + atomic_store_8((int8_t *)&gCtgMgmt.exit, false); if (cfg) { memcpy(&gCtgMgmt.cfg, cfg, sizeof(*cfg)); @@ -2534,7 +2518,8 @@ int32_t catalogInit(SCatalogCfg *cfg) { gCtgMgmt.cfg.stbRentSec = CTG_DEFAULT_RENT_SECOND; } - gCtgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); + gCtgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), + false, HASH_ENTRY_LOCK); if (NULL == gCtgMgmt.pCluster) { qError("taosHashInit %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); @@ -2544,7 +2529,7 @@ int32_t catalogInit(SCatalogCfg *cfg) { qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); } - + if (tsem_init(&gCtgMgmt.queue.rspSem, 0, 0)) { qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); @@ -2559,30 +2544,31 @@ int32_t catalogInit(SCatalogCfg *cfg) { CTG_ERR_RET(ctgStartUpdateThread()); - qDebug("catalog initialized, maxDb:%u, maxTbl:%u, dbRentSec:%u, stbRentSec:%u", gCtgMgmt.cfg.maxDBCacheNum, gCtgMgmt.cfg.maxTblCacheNum, gCtgMgmt.cfg.dbRentSec, gCtgMgmt.cfg.stbRentSec); + qDebug("catalog initialized, maxDb:%u, maxTbl:%u, dbRentSec:%u, stbRentSec:%u", gCtgMgmt.cfg.maxDBCacheNum, + gCtgMgmt.cfg.maxTblCacheNum, gCtgMgmt.cfg.dbRentSec, gCtgMgmt.cfg.stbRentSec); return TSDB_CODE_SUCCESS; } -int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { +int32_t catalogGetHandle(uint64_t clusterId, SCatalog **catalogHandle) { if (NULL == catalogHandle) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } if (NULL == gCtgMgmt.pCluster) { - qError("catalog cluster cache are not ready, clusterId:%"PRIx64, clusterId); + qError("catalog cluster cache are not ready, clusterId:%" PRIx64, clusterId); CTG_ERR_RET(TSDB_CODE_CTG_NOT_READY); } - int32_t code = 0; + int32_t code = 0; SCatalog *clusterCtg = NULL; while (true) { - SCatalog **ctg = (SCatalog **)taosHashGet(gCtgMgmt.pCluster, (char*)&clusterId, sizeof(clusterId)); + SCatalog **ctg = (SCatalog **)taosHashGet(gCtgMgmt.pCluster, (char *)&clusterId, sizeof(clusterId)); if (ctg && (*ctg)) { *catalogHandle = *ctg; - qDebug("got catalog handle from cache, clusterId:%"PRIx64", CTG:%p", clusterId, *ctg); + qDebug("got catalog handle from cache, clusterId:%" PRIx64 ", CTG:%p", clusterId, *ctg); return TSDB_CODE_SUCCESS; } @@ -2597,7 +2583,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB)); CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE)); - clusterCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + clusterCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), + false, HASH_ENTRY_LOCK); if (NULL == clusterCtg->dbCache) { qError("taosHashInit %d dbCache failed", CTG_DEFAULT_CACHE_DB_NUMBER); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); @@ -2609,12 +2596,12 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { ctgFreeHandle(clusterCtg); continue; } - - qError("taosHashPut CTG to cache failed, clusterId:%"PRIx64, clusterId); + + qError("taosHashPut CTG to cache failed, clusterId:%" PRIx64, clusterId); CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); } - qDebug("add CTG to cache, clusterId:%"PRIx64", CTG:%p", clusterId, clusterCtg); + qDebug("add CTG to cache, clusterId:%" PRIx64 ", CTG:%p", clusterId, clusterCtg); break; } @@ -2622,36 +2609,36 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { *catalogHandle = clusterCtg; CTG_CACHE_STAT_ADD(clusterNum, 1); - + return TSDB_CODE_SUCCESS; _return: ctgFreeHandle(clusterCtg); - + CTG_RET(code); } -void catalogFreeHandle(SCatalog* pCtg) { +void catalogFreeHandle(SCatalog *pCtg) { if (NULL == pCtg) { return; } if (taosHashRemove(gCtgMgmt.pCluster, &pCtg->clusterId, sizeof(pCtg->clusterId))) { - ctgWarn("taosHashRemove from cluster failed, may already be freed, clusterId:%"PRIx64, pCtg->clusterId); + ctgWarn("taosHashRemove from cluster failed, may already be freed, clusterId:%" PRIx64, pCtg->clusterId); return; } CTG_CACHE_STAT_SUB(clusterNum, 1); uint64_t clusterId = pCtg->clusterId; - + ctgFreeHandle(pCtg); - - ctgInfo("handle freed, culsterId:%"PRIx64, clusterId); + + ctgInfo("handle freed, culsterId:%" PRIx64, clusterId); } -int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t *tableNum) { +int32_t catalogGetDBVgVersion(SCatalog *pCtg, const char *dbFName, int32_t *version, int64_t *dbId, int32_t *tableNum) { CTG_API_ENTER(); if (NULL == pCtg || NULL == dbFName || NULL == version || NULL == dbId) { @@ -2659,8 +2646,8 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers } SCtgDBCache *dbCache = NULL; - bool inCache = false; - int32_t code = 0; + bool inCache = false; + int32_t code = 0; CTG_ERR_JRET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache, &inCache)); if (!inCache) { @@ -2684,18 +2671,19 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SArray** vgroupList) { +int32_t catalogGetDBVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName, + SArray **vgroupList) { CTG_API_ENTER(); if (NULL == pCtg || NULL == dbFName || NULL == pRpc || NULL == pMgmtEps || NULL == vgroupList) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - SCtgDBCache* dbCache = NULL; - int32_t code = 0; - SArray *vgList = NULL; - SHashObj *vgHash = NULL; - SDBVgInfo *vgInfo = NULL; + SCtgDBCache *dbCache = NULL; + int32_t code = 0; + SArray *vgList = NULL; + SHashObj *vgHash = NULL; + SDBVgInfo *vgInfo = NULL; CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pRpc, pMgmtEps, dbFName, &dbCache, &vgInfo)); if (dbCache) { vgHash = dbCache->vgInfo->vgHash; @@ -2720,15 +2708,14 @@ _return: taosMemoryFreeClear(vgInfo); } - CTG_API_LEAVE(code); + CTG_API_LEAVE(code); } - -int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SDBVgInfo* dbInfo) { +int32_t catalogUpdateDBVgInfo(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SDBVgInfo *dbInfo) { CTG_API_ENTER(); int32_t code = 0; - + if (NULL == pCtg || NULL == dbFName || NULL == dbInfo) { ctgFreeVgInfo(dbInfo); CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT); @@ -2741,12 +2728,11 @@ _return: CTG_API_LEAVE(code); } - -int32_t catalogRemoveDB(SCatalog* pCtg, const char* dbFName, uint64_t dbId) { +int32_t catalogRemoveDB(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { CTG_API_ENTER(); int32_t code = 0; - + if (NULL == pCtg || NULL == dbFName) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2758,21 +2744,19 @@ int32_t catalogRemoveDB(SCatalog* pCtg, const char* dbFName, uint64_t dbId) { CTG_ERR_JRET(ctgPushRmDBMsgInQueue(pCtg, dbFName, dbId)); CTG_API_LEAVE(TSDB_CODE_SUCCESS); - + _return: CTG_API_LEAVE(code); } -int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet) { - return 0; -} +int32_t catalogUpdateVgEpSet(SCatalog *pCtg, const char *dbFName, int32_t vgId, SEpSet *epSet) { return 0; } -int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { +int32_t catalogRemoveTableMeta(SCatalog *pCtg, const SName *pTableName) { CTG_API_ENTER(); int32_t code = 0; - + if (NULL == pCtg || NULL == pTableName) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2782,8 +2766,8 @@ int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { } STableMeta *tblMeta = NULL; - bool inCache = false; - uint64_t dbId = 0; + bool inCache = false; + uint64_t dbId = 0; CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &inCache, 0, &dbId)); if (!inCache) { @@ -2793,7 +2777,7 @@ int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); - + if (TSDB_SUPER_TABLE == tblMeta->tableType) { CTG_ERR_JRET(ctgPushRmStbMsgInQueue(pCtg, dbFName, dbId, pTableName->tname, tblMeta->suid, true)); } else { @@ -2809,12 +2793,11 @@ _return: CTG_API_LEAVE(code); } - -int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid) { +int32_t catalogRemoveStbMeta(SCatalog *pCtg, const char *dbFName, uint64_t dbId, const char *stbName, uint64_t suid) { CTG_API_ENTER(); int32_t code = 0; - + if (NULL == pCtg || NULL == dbFName || NULL == stbName) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2826,29 +2809,32 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, CTG_ERR_JRET(ctgPushRmStbMsgInQueue(pCtg, dbFName, dbId, stbName, suid, true)); CTG_API_LEAVE(TSDB_CODE_SUCCESS); - + _return: CTG_API_LEAVE(code); } -int32_t catalogGetIndexMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, const char *pIndexName, SIndexMeta** pIndexMeta) { +int32_t catalogGetIndexMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + const char *pIndexName, SIndexMeta **pIndexMeta) { return 0; } -int32_t catalogGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { +int32_t catalogGetTableMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + STableMeta **pTableMeta) { CTG_API_ENTER(); CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_UNKNOWN_STB)); } -int32_t catalogGetSTableMeta(SCatalog* pCtg, void * pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { +int32_t catalogGetSTableMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + STableMeta **pTableMeta) { CTG_API_ENTER(); CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_STB)); } -int32_t catalogUpdateSTableMeta(SCatalog* pCtg, STableMetaRsp *rspMsg) { +int32_t catalogUpdateSTableMeta(SCatalog *pCtg, STableMetaRsp *rspMsg) { CTG_API_ENTER(); if (NULL == pCtg || NULL == rspMsg) { @@ -2860,42 +2846,41 @@ int32_t catalogUpdateSTableMeta(SCatalog* pCtg, STableMetaRsp *rspMsg) { ctgError("malloc %d failed", (int32_t)sizeof(STableMetaOutput)); CTG_API_LEAVE(TSDB_CODE_CTG_MEM_ERROR); } - + int32_t code = 0; strcpy(output->dbFName, rspMsg->dbFName); strcpy(output->tbName, rspMsg->tbName); output->dbId = rspMsg->dbId; - + SET_META_TYPE_TABLE(output->metaType); - + CTG_ERR_JRET(queryCreateTableMetaFromMsg(rspMsg, true, &output->tbMeta)); CTG_ERR_JRET(ctgPushUpdateTblMsgInQueue(pCtg, output, false)); CTG_API_LEAVE(code); - + _return: taosMemoryFreeClear(output->tbMeta); taosMemoryFreeClear(output); - + CTG_API_LEAVE(code); } - - -int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t* sver, int32_t *tbType, uint64_t *suid, char* stbName) { +int32_t ctgGetTbSverFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *sver, int32_t *tbType, uint64_t *suid, + char *stbName) { *sver = -1; - + if (NULL == pCtg->dbCache) { ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname); return TSDB_CODE_SUCCESS; } SCtgDBCache *dbCache = NULL; - char dbFName[TSDB_DB_FNAME_LEN] = {0}; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, dbFName); ctgAcquireDBCache(pCtg, dbFName, &dbCache); @@ -2903,9 +2888,9 @@ int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t* ctgDebug("db %s not in cache", pTableName->tname); return TSDB_CODE_SUCCESS; } - + CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); - STableMeta* tbMeta = taosHashGet(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname)); + STableMeta *tbMeta = taosHashGet(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname)); if (tbMeta) { *tbType = tbMeta->tableType; *suid = tbMeta->suid; @@ -2923,32 +2908,33 @@ int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t* if (*tbType != TSDB_CHILD_TABLE) { ctgReleaseDBCache(pCtg, dbCache); ctgDebug("Got sver %d from cache, type:%d, dbFName:%s, tbName:%s", *sver, *tbType, dbFName, pTableName->tname); - + return TSDB_CODE_SUCCESS; } ctgDebug("Got subtable meta from cache, dbFName:%s, tbName:%s, suid:%" PRIx64, dbFName, pTableName->tname, *suid); - + CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock); - + STableMeta **stbMeta = taosHashGet(dbCache->tbCache.stbCache, suid, sizeof(*suid)); if (NULL == stbMeta || NULL == *stbMeta) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock); ctgReleaseDBCache(pCtg, dbCache); - ctgDebug("stb not in stbCache, suid:%"PRIx64, *suid); + ctgDebug("stb not in stbCache, suid:%" PRIx64, *suid); return TSDB_CODE_SUCCESS; } if ((*stbMeta)->suid != *suid) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock); ctgReleaseDBCache(pCtg, dbCache); - ctgError("stable suid in stbCache mis-match, expected suid:%"PRIx64 ",actual suid:%"PRIx64, *suid, (*stbMeta)->suid); + ctgError("stable suid in stbCache mis-match, expected suid:%" PRIx64 ",actual suid:%" PRIx64, *suid, + (*stbMeta)->suid); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } size_t nameLen = 0; - char* name = taosHashGetKey(*stbMeta, &nameLen); - + char *name = taosHashGetKey(*stbMeta, &nameLen); + strncpy(stbName, name, nameLen); stbName[nameLen] = 0; @@ -2959,18 +2945,18 @@ int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t* ctgReleaseDBCache(pCtg, dbCache); ctgDebug("Got sver %d from cache, type:%d, dbFName:%s, tbName:%s", *sver, *tbType, dbFName, pTableName->tname); - + return TSDB_CODE_SUCCESS; } -int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SArray* pTables) { +int32_t catalogChkTbMetaVersion(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, SArray *pTables) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTables) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - SName name; + SName name; int32_t sver = 0; int32_t tbNum = taosArrayGetSize(pTables); for (int32_t i = 0; i < tbNum; ++i) { @@ -2980,21 +2966,21 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm } tNameFromString(&name, pTb->tbFName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - + if (CTG_IS_SYS_DBNAME(name.dbname)) { continue; } - int32_t tbType = 0; + int32_t tbType = 0; uint64_t suid = 0; - char stbName[TSDB_TABLE_FNAME_LEN]; + char stbName[TSDB_TABLE_FNAME_LEN]; ctgGetTbSverFromCache(pCtg, &name, &sver, &tbType, &suid, stbName); if (sver >= 0 && sver < pTb->sver) { switch (tbType) { case TSDB_CHILD_TABLE: { SName stb = name; strcpy(stb.tname, stbName); - catalogRemoveTableMeta(pCtg, &stb); + catalogRemoveTableMeta(pCtg, &stb); break; } case TSDB_SUPER_TABLE: @@ -3011,8 +2997,7 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm CTG_API_LEAVE(TSDB_CODE_SUCCESS); } - -int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const char* dbFName) { +int32_t catalogRefreshDBVgInfo(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const char *dbFName) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == dbFName) { @@ -3022,23 +3007,28 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmt CTG_API_LEAVE(ctgRefreshDBVgInfo(pCtg, pTrans, pMgmtEps, dbFName)); } -int32_t catalogRefreshTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, int32_t isSTable) { +int32_t catalogRefreshTableMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + int32_t isSTable) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - CTG_API_LEAVE(ctgRefreshTblMeta(pCtg, pTrans, pMgmtEps, pTableName, CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable), NULL, true)); + CTG_API_LEAVE(ctgRefreshTblMeta(pCtg, pTrans, pMgmtEps, pTableName, + CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable), NULL, true)); } -int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable) { +int32_t catalogRefreshGetTableMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + STableMeta **pTableMeta, int32_t isSTable) { CTG_API_ENTER(); - CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable))); + CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, + CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable))); } -int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) { +int32_t catalogGetTableDistVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const SName *pTableName, + SArray **pVgList) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pVgList) { @@ -3056,12 +3046,13 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm code = ctgGetTableDistVgInfo(pCtg, pRpc, pMgmtEps, pTableName, pVgList); if (code) { if (TSDB_CODE_CTG_VG_META_MISMATCH == code) { - CTG_ERR_JRET(ctgRefreshTblMeta(pCtg, pRpc, pMgmtEps, pTableName, CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(CTG_FLAG_UNKNOWN_STB), NULL, true)); + CTG_ERR_JRET(ctgRefreshTblMeta(pCtg, pRpc, pMgmtEps, pTableName, + CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(CTG_FLAG_UNKNOWN_STB), NULL, true)); char dbFName[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(pTableName, dbFName); + tNameGetFullDbName(pTableName, dbFName); CTG_ERR_JRET(ctgRefreshDBVgInfo(pCtg, pRpc, pMgmtEps, dbFName)); - + continue; } } @@ -3074,8 +3065,8 @@ _return: CTG_API_LEAVE(code); } - -int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) { +int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, + SVgroupInfo *pVgroup) { CTG_API_ENTER(); if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { @@ -3083,9 +3074,9 @@ int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pM CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - SCtgDBCache* dbCache = NULL; - int32_t code = 0; - char db[TSDB_DB_FNAME_LEN] = {0}; + SCtgDBCache *dbCache = NULL; + int32_t code = 0; + char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); SDBVgInfo *vgInfo = NULL; @@ -3108,8 +3099,8 @@ _return: CTG_API_LEAVE(code); } - -int32_t catalogGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SCatalogReq* pReq, SMetaData* pRsp) { +int32_t catalogGetAllMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SCatalogReq *pReq, + SMetaData *pRsp) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pReq || NULL == pRsp) { @@ -3131,11 +3122,11 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, ctgError("taosArrayInit %d failed", tbNum); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } - + for (int32_t i = 0; i < tbNum; ++i) { - SName *name = taosArrayGet(pReq->pTableName, i); + SName *name = taosArrayGet(pReq->pTableName, i); STableMeta *pTableMeta = NULL; - + CTG_ERR_JRET(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, name, &pTableMeta, CTG_FLAG_UNKNOWN_STB)); if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) { @@ -3153,7 +3144,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, CTG_API_LEAVE(TSDB_CODE_SUCCESS); -_return: +_return: if (pRsp->pTableMeta) { int32_t aSize = taosArrayGetSize(pRsp->pTableMeta); @@ -3161,19 +3152,19 @@ _return: STableMeta *pMeta = taosArrayGetP(pRsp->pTableMeta, i); taosMemoryFreeClear(pMeta); } - + taosArrayDestroy(pRsp->pTableMeta); pRsp->pTableMeta = NULL; } - + CTG_API_LEAVE(code); } -int32_t catalogGetQnodeList(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, SArray* pQnodeList) { +int32_t catalogGetQnodeList(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, SArray *pQnodeList) { CTG_API_ENTER(); - + int32_t code = 0; - if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pQnodeList) { + if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pQnodeList) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3184,7 +3175,7 @@ _return: CTG_API_LEAVE(TSDB_CODE_SUCCESS); } -int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableMetaVersion **stables, uint32_t *num) { +int32_t catalogGetExpiredSTables(SCatalog *pCtg, SSTableMetaVersion **stables, uint32_t *num) { CTG_API_ENTER(); if (NULL == pCtg || NULL == stables || NULL == num) { @@ -3194,9 +3185,9 @@ int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableMetaVersion **stables, u CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void **)stables, num, sizeof(SSTableMetaVersion))); } -int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion **dbs, uint32_t *num) { +int32_t catalogGetExpiredDBs(SCatalog *pCtg, SDbVgVersion **dbs, uint32_t *num) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == dbs || NULL == num) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3204,9 +3195,9 @@ int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion **dbs, uint32_t *num) CTG_API_LEAVE(ctgMetaRentGet(&pCtg->dbRent, (void **)dbs, num, sizeof(SDbVgVersion))); } -int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion **users, uint32_t *num) { +int32_t catalogGetExpiredUsers(SCatalog *pCtg, SUserAuthVersion **users, uint32_t *num) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == users || NULL == num) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3220,7 +3211,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion **users, uint32_ } } - uint32_t i = 0; + uint32_t i = 0; SCtgUserAuth *pAuth = taosHashIterate(pCtg->userCache, NULL); while (pAuth != NULL) { void *key = taosHashGetKey(pAuth, NULL); @@ -3232,10 +3223,9 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion **users, uint32_ CTG_API_LEAVE(TSDB_CODE_SUCCESS); } - -int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SDbCfgInfo* pDbCfg) { +int32_t catalogGetDBCfg(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName, SDbCfgInfo *pDbCfg) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == dbFName || NULL == pDbCfg) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3243,9 +3233,10 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_API_LEAVE(ctgGetDBCfgFromMnode(pCtg, pRpc, pMgmtEps, dbFName, pDbCfg)); } -int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* indexName, SIndexInfo* pInfo) { +int32_t catalogGetIndexInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *indexName, + SIndexInfo *pInfo) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == indexName || NULL == pInfo) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3253,9 +3244,9 @@ int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, CTG_API_LEAVE(ctgGetIndexInfoFromMnode(pCtg, pRpc, pMgmtEps, indexName, pInfo)); } -int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* funcName, SFuncInfo** pInfo) { +int32_t catalogGetUdfInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *funcName, SFuncInfo **pInfo) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == funcName || NULL == pInfo) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -3267,32 +3258,33 @@ int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, co } CTG_ERR_JRET(ctgGetUdfInfoFromMnode(pCtg, pRpc, pMgmtEps, funcName, pInfo)); - + _return: if (code) { - taosMemoryFreeClear(*pInfo); + taosMemoryFreeClear(*pInfo); } - + CTG_API_LEAVE(code); } -int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass) { +int32_t catalogChkAuth(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *user, const char *dbFName, + AUTH_TYPE type, bool *pass) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == user || NULL == dbFName || NULL == pass) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } int32_t code = 0; CTG_ERR_JRET(ctgChkAuth(pCtg, pRpc, pMgmtEps, user, dbFName, type, pass)); - + _return: CTG_API_LEAVE(code); } -int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) { +int32_t catalogUpdateUserAuthInfo(SCatalog *pCtg, SGetUserAuthRsp *pAuth) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pAuth) { @@ -3302,20 +3294,19 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) { CTG_API_LEAVE(ctgPushUpdateUserMsgInQueue(pCtg, pAuth, false)); } - void catalogDestroy(void) { qInfo("start to destroy catalog"); - - if (NULL == gCtgMgmt.pCluster || atomic_load_8((int8_t*)&gCtgMgmt.exit)) { + + if (NULL == gCtgMgmt.pCluster || atomic_load_8((int8_t *)&gCtgMgmt.exit)) { return; } - atomic_store_8((int8_t*)&gCtgMgmt.exit, true); + atomic_store_8((int8_t *)&gCtgMgmt.exit, true); if (tsem_post(&gCtgMgmt.queue.reqSem)) { qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); } - + if (tsem_post(&gCtgMgmt.queue.rspSem)) { qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); } @@ -3323,21 +3314,21 @@ void catalogDestroy(void) { while (CTG_IS_LOCKED(&gCtgMgmt.lock)) { taosUsleep(1); } - + CTG_LOCK(CTG_WRITE, &gCtgMgmt.lock); SCatalog *pCtg = NULL; - void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); + void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); while (pIter) { pCtg = *(SCatalog **)pIter; if (pCtg) { catalogFreeHandle(pCtg); } - + pIter = taosHashIterate(gCtgMgmt.pCluster, pIter); } - + taosHashCleanup(gCtgMgmt.pCluster); gCtgMgmt.pCluster = NULL; @@ -3346,5 +3337,3 @@ void catalogDestroy(void) { qInfo("catalog destroyed"); } - - diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 599664ae6d0ac3a9b351c7459a46b3702500e23a..4475cb9e62c1c60800425c95224b399c9051059c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1903,7 +1903,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SArray* pColMatchIn filterFreeInfo(filter); extractQualifiedTupleByFilterResult(pBlock, rowRes, keep); - blockDataUpdateTsWindow(pBlock); + blockDataUpdateTsWindow(pBlock, 0); } void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) { @@ -2072,7 +2072,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI } qDebug("%s result generated, rows:%d, groupId:%"PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, pBlock->info.groupId); - blockDataUpdateTsWindow(pBlock); + blockDataUpdateTsWindow(pBlock, 0); return 0; } @@ -2797,7 +2797,9 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI } pRes->info.rows = numOfRows; - blockDataUpdateTsWindow(pRes); + + // todo move this to time window aggregator, since the primary timestamp may not be known by exchange operator. + blockDataUpdateTsWindow(pRes, 0); int64_t el = taosGetTimestampUs() - startTs; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 16dcf30f3945d246f8549f170038cd2d63a73dd9..7606374cdbc1572fbf15112c41d24ca0ac7e2532 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -553,7 +553,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { pInfo->pageIndex += 1; - blockDataUpdateTsWindow(pInfo->binfo.pRes); + blockDataUpdateTsWindow(pInfo->binfo.pRes, 0); pInfo->binfo.pRes->info.groupId = pGroupInfo->groupId; return pInfo->binfo.pRes; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 8b6ab96b6df3471f88f91d8d277eb1c127112a29..d4225caa71d0885e8aba3f4148dec9917d20dbd1 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -689,7 +689,7 @@ static SSDataBlock* getUpdateDataBlock(SStreamBlockScanInfo* pInfo, bool inverti } pDataBlock->info.rows = size; pDataBlock->info.type = STREAM_REPROCESS; - blockDataUpdateTsWindow(pDataBlock); + blockDataUpdateTsWindow(pDataBlock, 0); taosArrayClear(pInfo->tsArray); return pDataBlock; } @@ -899,7 +899,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { } rows = pBlockInfo->rows; doFilter(pInfo->pCondition, pInfo->pRes, NULL); - blockDataUpdateTsWindow(pInfo->pRes); + blockDataUpdateTsWindow(pInfo->pRes, 0); break; } @@ -972,9 +972,10 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR } pInfo->primaryTsIndex = 0; // TODO(liuyao) get it from physical plan - pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, 10000); // TODO(liuyao) get watermark from physical plan - if (pInfo->pUpdateInfo == NULL) { - goto _error; + if (pSTInfo->interval.interval > 0) { + pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, 10000); // TODO(liuyao) get watermark from physical plan + } else { + pInfo->pUpdateInfo = NULL; } pInfo->readHandle = *pHandle; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index c3a447c802ce8065e79d302bc0ae29385afdec98..588c3e90e7757feb1ca7dcd1950c14f84b38c577 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -621,7 +621,7 @@ static void saveDataBlockLastRow(char** pRow, SArray* pDataBlock, int32_t rowInd } } -static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, +static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, uint64_t tableGroupId) { SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info; @@ -639,13 +639,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe // int32_t prevIndex = pResultRowInfo->curPos; TSKEY* tsCols = NULL; - if (pSDataBlock->pDataBlock != NULL) { - SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + if (pBlock->pDataBlock != NULL) { + SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex); tsCols = (int64_t*)pColDataInfo->pData; + + if (tsCols != NULL) { + blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex); + } } int32_t startPos = 0; - TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascScan); + TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols, pBlock->info.rows, ascScan); STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); @@ -670,7 +674,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe int32_t forwardStep = 0; TSKEY ekey = ascScan? win.ekey:win.skey; forwardStep = - getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); ASSERT(forwardStep > 0); // prev time window not interpolation yet. @@ -686,7 +690,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe } STimeWindow w = pRes->win; - ret = setTimeWindowOutputBuf(pResultRowInfo, pSDataBlock->info.uid, &w, masterScan, &pResult, tableGroupId, + ret = setTimeWindowOutputBuf(pResultRowInfo, pBlock->info.uid, &w, masterScan, &pResult, tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { @@ -694,17 +698,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe } assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP)); - doTimeWindowInterpolation(pOperatorInfo, &pInfo->binfo, pSDataBlock->pDataBlock, *(TSKEY*)pInfo->pRow[0], -1, + doTimeWindowInterpolation(pOperatorInfo, &pInfo->binfo, pBlock->pDataBlock, *(TSKEY*)pInfo->pRow[0], -1, tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP); setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); setNotInterpoWindowKey(pInfo->binfo.pCtx, pOperatorInfo->numOfExprs, RESULT_ROW_START_INTERP); - doApplyFunctions(pInfo->binfo.pCtx, &w, &pInfo->timeWindowData, startPos, 0, tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); + doApplyFunctions(pInfo->binfo.pCtx, &w, &pInfo->timeWindowData, startPos, 0, tsCols, pBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); } // restore current time window - ret = setTimeWindowOutputBuf(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, tableGroupId, + ret = setTimeWindowOutputBuf(pResultRowInfo, pBlock->info.uid, &win, masterScan, &pResult, tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { @@ -714,17 +718,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe #endif // window start key interpolation - doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, forwardStep, + doWindowBorderInterpolation(pOperatorInfo, pBlock, pInfo->binfo.pCtx, pResult, &win, startPos, forwardStep, pInfo->order, false); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardStep, tsCols, - pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); + pBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); STimeWindow nextWin = win; while (1) { int32_t prevEndPos = (forwardStep - 1) * step + startPos; - startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo->order); + startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, pInfo->order); if (startPos < 0) { break; } @@ -748,20 +752,20 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe ekey = ascScan? nextWin.ekey:nextWin.skey; forwardStep = - getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); // window start(end) key interpolation - doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos, forwardStep, + doWindowBorderInterpolation(pOperatorInfo, pBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos, forwardStep, pInfo->order, false); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardStep, tsCols, - pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); + pBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); } if (pInfo->timeWindowInterpo) { - int32_t rowIndex = ascScan ? (pSDataBlock->info.rows - 1) : 0; - saveDataBlockLastRow(pInfo->pRow, pSDataBlock->pDataBlock, rowIndex, pSDataBlock->info.numOfCols); + int32_t rowIndex = ascScan ? (pBlock->info.rows - 1) : 0; + saveDataBlockLastRow(pInfo->pRow, pBlock->pDataBlock, rowIndex, pBlock->info.numOfCols); } return pUpdated; @@ -938,8 +942,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { return pBInfo->pRes; } - int32_t order = TSDB_ORDER_ASC; - STimeWindow win = pTaskInfo->window; + int32_t order = TSDB_ORDER_ASC; SOperatorInfo* downstream = pOperator->pDownstream[0]; while (1) { @@ -952,6 +955,8 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { } setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true); + blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId); + doStateWindowAggImpl(pOperator, pInfo, pBlock); } @@ -1429,6 +1434,8 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true); + blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId); + doSessionWindowAggImpl(pOperator, pInfo, pBlock); } diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index c7ec0eece209a6d584ce846802abede47a9b8e81..880ac6c78eb8e04c08de7b612cdc58b50025e2c9 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -189,7 +189,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) { pInfo->current += 1; - blockDataUpdateTsWindow(pBlock); + blockDataUpdateTsWindow(pBlock, 0); return pBlock; } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 10bb47d3ffd9ed59b72aab3d528b19d909bf4e8c..2cba1eb043e0e4063b4a7519a3c116820412c69d 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -241,7 +241,7 @@ alter_table_clause(A) ::= alter_table_clause(A) ::= full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); } alter_table_clause(A) ::= - full_table_name(B) SET TAG column_name(C) NK_EQ literal(D). { A = createAlterTableSetTag(pCxt, B, &C, releaseRawExprNode(pCxt, D)); } + full_table_name(B) SET TAG column_name(C) NK_EQ signed_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } %type multi_create_clause { SNodeList* } %destructor multi_create_clause { nodesDestroyList($$); } @@ -448,7 +448,7 @@ agg_func_opt(A) ::= AGGREGATE. %type bufsize_opt { int32_t } %destructor bufsize_opt { } bufsize_opt(A) ::= . { A = 0; } -bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). { A = strtol(B.z, NULL, 10); } +bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); } /************************************************ create/drop stream **************************************************/ cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index bc16bd89e66e581e334e515e6f61a637b8d9c37a..8e18c267d68f0db99306062f5e0d9a9444ae5bc0 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -694,66 +694,110 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { return translateValueImpl(pCxt, pVal, pVal->node.resType); } -static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { - if (nodesIsUnaryOp(pOp)) { - if (OP_TYPE_MINUS == pOp->opType) { - if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); - } - pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - } else { - pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; +static bool isMultiResFunc(SNode* pNode) { + if (NULL == pNode) { + return false; + } + if (QUERY_NODE_FUNCTION != nodeType(pNode) || !fmIsMultiResFunc(((SFunctionNode*)pNode)->funcId)) { + return false; + } + SNodeList* pParameterList = ((SFunctionNode*)pNode)->pParameterList; + if (LIST_LENGTH(pParameterList) > 1) { + return true; + } + SNode* pParam = nodesListGetNode(pParameterList, 0); + return (QUERY_NODE_COLUMN == nodeType(pParam) ? 0 == strcmp(((SColumnNode*)pParam)->colName, "*") : false); +} + +static EDealRes translateUnaryOperator(STranslateContext* pCxt, SOperatorNode* pOp) { + if (OP_TYPE_MINUS == pOp->opType) { + if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); } - return DEAL_RES_CONTINUE; + pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + } else { + pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; } + return DEAL_RES_CONTINUE; +} + +static EDealRes translateArithmeticOperator(STranslateContext* pCxt, SOperatorNode* pOp) { SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; - if (nodesIsArithmeticOp(pOp)) { - if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || - TSDB_DATA_TYPE_BLOB == rdt.type) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || + TSDB_DATA_TYPE_BLOB == rdt.type) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) || + (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) || + (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + + if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) || + (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) || + (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) || + (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) { + pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + } else { + pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + } + return DEAL_RES_CONTINUE; +} + +static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNode* pOp) { + SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; + SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; + if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { + ((SExprNode*)pOp->pRight)->resType = ((SExprNode*)pOp->pLeft)->resType; + } + if (nodesIsRegularOp(pOp)) { + if (!IS_STR_DATA_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); } - if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) || - (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) || - (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) { + if (QUERY_NODE_VALUE != nodeType(pOp->pRight) || !IS_STR_DATA_TYPE(((SExprNode*)(pOp->pRight))->resType.type)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } + } + pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + return DEAL_RES_CONTINUE; +} - if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) || - (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) || - (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) || - (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) { - pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; - } else { - pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - } +static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pOp) { + SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; + SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; + if (TSDB_DATA_TYPE_JSON != ldt.type || TSDB_DATA_TYPE_BINARY != rdt.type) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + pOp->node.resType.type = TSDB_DATA_TYPE_JSON; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_JSON].bytes; + return DEAL_RES_CONTINUE; +} + +static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { + if (isMultiResFunc(pOp->pLeft)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); + } + if (isMultiResFunc(pOp->pRight)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + + if (nodesIsUnaryOp(pOp)) { + return translateUnaryOperator(pCxt, pOp); + } else if (nodesIsArithmeticOp(pOp)) { + return translateArithmeticOperator(pCxt, pOp); } else if (nodesIsComparisonOp(pOp)) { - if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); - } - if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { - ((SExprNode*)pOp->pRight)->resType = ((SExprNode*)pOp->pLeft)->resType; - } - if (nodesIsRegularOp(pOp)) { - if (!IS_STR_DATA_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); - } - if (QUERY_NODE_VALUE != nodeType(pOp->pRight) || !IS_STR_DATA_TYPE(((SExprNode*)(pOp->pRight))->resType.type)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); - } - } - pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + return translateComparisonOperator(pCxt, pOp); } else if (nodesIsJsonOp(pOp)) { - if (TSDB_DATA_TYPE_JSON != ldt.type || TSDB_DATA_TYPE_BINARY != rdt.type) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); - } - pOp->node.resType.type = TSDB_DATA_TYPE_JSON; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_JSON].bytes; + return translateJsonOperator(pCxt, pOp); } return DEAL_RES_CONTINUE; } @@ -808,6 +852,13 @@ static bool hasInvalidFuncNesting(SNodeList* pParameterList) { } static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { + SNode* pParam = NULL; + FOREACH(pParam, pFunc->pParameterList) { + if (isMultiResFunc(pParam)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pParam)->aliasName); + } + } + SFmGetFuncInfoParam param = {.pCtg = pCxt->pParseCxt->pCatalog, .pRpc = pCxt->pParseCxt->pTransporter, .pMgmtEps = &pCxt->pParseCxt->mgmtEpSet, @@ -926,9 +977,10 @@ typedef struct SCheckExprForGroupByCxt { STranslateContext* pTranslateCxt; int32_t selectFuncNum; bool hasSelectValFunc; + bool hasOtherAggFunc; } SCheckExprForGroupByCxt; -static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, bool* pHasSelectValFunc, SNode** pNode) { +static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; @@ -942,9 +994,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, bool* pHasSel } if (TSDB_CODE_SUCCESS == pCxt->errCode) { *pNode = (SNode*)pFunc; - if (NULL != pHasSelectValFunc) { - *pHasSelectValFunc = true; - } } else { nodesDestroyNode(pFunc); } @@ -956,8 +1005,12 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) { return DEAL_RES_CONTINUE; } - pCxt->selectFuncNum += isSelectFunc(*pNode) ? 1 : 0; - if (pCxt->selectFuncNum > 1 && pCxt->hasSelectValFunc) { + if (isSelectFunc(*pNode)) { + ++(pCxt->selectFuncNum); + } else if (isAggFunc(*pNode)) { + pCxt->hasOtherAggFunc = true; + } + if ((pCxt->selectFuncNum > 1 && pCxt->hasSelectValFunc) || (pCxt->hasOtherAggFunc && pCxt->hasSelectValFunc)) { return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt)); } if (isAggFunc(*pNode) && !isDistinctOrderBy(pCxt->pTranslateCxt)) { @@ -970,10 +1023,11 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { } } if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { - if (pCxt->selectFuncNum > 1) { + if (pCxt->selectFuncNum > 1 || pCxt->hasOtherAggFunc) { return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt)); } else { - return rewriteColToSelectValFunc(pCxt->pTranslateCxt, &pCxt->hasSelectValFunc, pNode); + pCxt->hasSelectValFunc = true; + return rewriteColToSelectValFunc(pCxt->pTranslateCxt, pNode); } } if (isAggFunc(*pNode) && isDistinctOrderBy(pCxt->pTranslateCxt)) { @@ -983,7 +1037,8 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { } static int32_t checkExprForGroupBy(STranslateContext* pCxt, SNode** pNode) { - SCheckExprForGroupByCxt cxt = {.pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false}; + SCheckExprForGroupByCxt cxt = { + .pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false, .hasOtherAggFunc = false}; nodesRewriteExpr(pNode, doCheckExprForGroupBy, &cxt); if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) { return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt)); @@ -995,7 +1050,8 @@ static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList if (NULL == getGroupByList(pCxt)) { return TSDB_CODE_SUCCESS; } - SCheckExprForGroupByCxt cxt = {.pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false}; + SCheckExprForGroupByCxt cxt = { + .pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false, .hasOtherAggFunc = false}; nodesRewriteExprs(pList, doCheckExprForGroupBy, &cxt); if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) { return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt)); @@ -1008,7 +1064,7 @@ static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) { return DEAL_RES_IGNORE_CHILD; } if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { - return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode); + return rewriteColToSelectValFunc((STranslateContext*)pContext, pNode); } return DEAL_RES_CONTINUE; } @@ -1027,11 +1083,16 @@ typedef struct CheckAggColCoexistCxt { bool existCol; bool existNonstdFunc; int32_t selectFuncNum; + bool existOtherAggFunc; } CheckAggColCoexistCxt; static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) { CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext; - pCxt->selectFuncNum += isSelectFunc(pNode) ? 1 : 0; + if (isSelectFunc(pNode)) { + ++(pCxt->selectFuncNum); + } else if (isAggFunc(pNode)) { + pCxt->existOtherAggFunc = true; + } if (isAggFunc(pNode)) { pCxt->existAggFunc = true; return DEAL_RES_IGNORE_CHILD; @@ -1050,13 +1111,17 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) if (NULL != pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; } - CheckAggColCoexistCxt cxt = { - .pTranslateCxt = pCxt, .existAggFunc = false, .existCol = false, .existNonstdFunc = false}; + CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt, + .existAggFunc = false, + .existCol = false, + .existNonstdFunc = false, + .selectFuncNum = 0, + .existOtherAggFunc = false}; nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt); if (!pSelect->isDistinct) { nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); } - if (1 == cxt.selectFuncNum) { + if (1 == cxt.selectFuncNum && !cxt.existOtherAggFunc) { return rewriteColsToSelectValFunc(pCxt, pSelect); } if ((cxt.selectFuncNum > 1 || cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) { @@ -1230,18 +1295,6 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { return TSDB_CODE_SUCCESS; } -static bool isMultiResFunc(SNode* pNode) { - if (QUERY_NODE_FUNCTION != nodeType(pNode) || !fmIsMultiResFunc(((SFunctionNode*)pNode)->funcId)) { - return false; - } - SNodeList* pParameterList = ((SFunctionNode*)pNode)->pParameterList; - if (LIST_LENGTH(pParameterList) > 1) { - return true; - } - SNode* pParam = nodesListGetNode(pParameterList, 0); - return (QUERY_NODE_COLUMN == nodeType(pParam) ? 0 == strcmp(((SColumnNode*)pParam)->colName, "*") : false); -} - static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { @@ -1872,7 +1925,7 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { } static bool dataTypeEqual(const SDataType* l, const SDataType* r) { - return (l->type == r->type && l->bytes == l->bytes && l->precision == r->precision && l->scale == l->scale); + return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale); } static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { @@ -2726,9 +2779,11 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm SName tableName; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name); - collectUseTable(&tableName, pCxt->pTables); - - return buildRollupAst(pCxt, pStmt, pReq); + int32_t code = collectUseTable(&tableName, pCxt->pTables); + if (TSDB_CODE_SUCCESS == code) { + code = buildRollupAst(pCxt, pStmt, pReq); + } + return code; } static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { @@ -4033,13 +4088,18 @@ static int32_t createValueFromFunction(STranslateContext* pCxt, SFunctionNode* p return scalarCalculateConstants((SNode*)pFunc, (SNode**)pVal); } +static int32_t colDataBytesToValueDataBytes(uint8_t type, int32_t bytes) { + if (TSDB_DATA_TYPE_VARCHAR == type || TSDB_DATA_TYPE_BINARY == type || TSDB_DATA_TYPE_VARBINARY == type) { + return bytes - VARSTR_HEADER_SIZE; + } else if (TSDB_DATA_TYPE_NCHAR == type) { + return (bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE; + } + return bytes; +} + static SDataType schemaToDataType(SSchema* pSchema) { SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes, .precision = 0, .scale = 0}; - if (TSDB_DATA_TYPE_VARCHAR == dt.type || TSDB_DATA_TYPE_BINARY == dt.type || TSDB_DATA_TYPE_VARBINARY == dt.type) { - dt.bytes -= VARSTR_HEADER_SIZE; - } else if (TSDB_DATA_TYPE_NCHAR == dt.type) { - dt.bytes = (dt.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE; - } + dt.bytes = colDataBytesToValueDataBytes(pSchema->type, pSchema->bytes); return dt; } @@ -4441,7 +4501,8 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); - } else if (!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->bytes >= pReq->colModBytes) { + } else if (!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type || + pSchema->bytes >= pReq->colModBytes) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_MODIFY_COL); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 2d844e18429fbaaed9e6a61cf3234c7dc5da26a3..0854bb83e471151e83efd066192ee576561b28ee 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -211,540 +211,538 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2167) +#define YY_ACTTAB_COUNT (2154) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 383, 76, 384, 1380, 391, 519, 384, 1380, 1631, 28, - /* 10 */ 223, 1467, 35, 33, 113, 1463, 343, 347, 1646, 1777, - /* 20 */ 301, 1470, 1159, 1627, 1635, 1633, 36, 34, 32, 31, - /* 30 */ 30, 1729, 1776, 1478, 94, 522, 1774, 93, 92, 91, - /* 40 */ 90, 89, 88, 87, 86, 85, 1662, 1157, 1523, 292, - /* 50 */ 32, 31, 30, 503, 291, 1726, 1777, 479, 14, 1521, - /* 60 */ 35, 33, 1285, 502, 1165, 518, 1631, 1617, 301, 145, - /* 70 */ 1159, 349, 274, 1774, 398, 36, 34, 32, 31, 30, - /* 80 */ 1, 1627, 1634, 1633, 1675, 112, 24, 132, 1647, 505, - /* 90 */ 1649, 1650, 501, 522, 522, 1157, 36, 34, 32, 31, - /* 100 */ 30, 61, 601, 1247, 271, 483, 14, 519, 35, 33, - /* 110 */ 597, 596, 1165, 1158, 108, 518, 301, 305, 1159, 104, - /* 120 */ 1181, 274, 1473, 110, 939, 128, 419, 130, 2, 1360, - /* 130 */ 54, 484, 1791, 1480, 1777, 1478, 519, 69, 212, 1722, - /* 140 */ 478, 1348, 477, 1157, 1196, 1777, 1777, 146, 104, 417, - /* 150 */ 601, 1774, 1247, 1248, 14, 424, 1160, 1471, 147, 1775, - /* 160 */ 1165, 1158, 1774, 1774, 1478, 103, 102, 101, 100, 99, - /* 170 */ 98, 97, 96, 95, 1253, 38, 2, 554, 1163, 1164, - /* 180 */ 54, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 190 */ 1224, 1225, 1226, 1227, 1228, 1229, 553, 552, 601, 551, - /* 200 */ 550, 549, 1248, 495, 1160, 342, 1309, 341, 148, 1158, - /* 210 */ 27, 299, 1242, 1243, 1244, 1245, 1246, 1250, 1251, 1252, - /* 220 */ 131, 1183, 506, 1253, 1435, 304, 1163, 1164, 1568, 1209, + /* 0 */ 1467, 1777, 1777, 1646, 383, 1634, 384, 1380, 292, 11, + /* 10 */ 10, 343, 35, 33, 1776, 146, 24, 923, 1774, 1774, + /* 20 */ 301, 391, 1159, 384, 1380, 1631, 36, 34, 32, 31, + /* 30 */ 30, 1662, 26, 36, 34, 32, 31, 30, 518, 503, + /* 40 */ 1627, 1633, 36, 34, 32, 31, 30, 1157, 1346, 502, + /* 50 */ 1777, 522, 130, 1617, 1360, 927, 928, 518, 14, 483, + /* 60 */ 35, 33, 1285, 145, 1165, 28, 223, 1774, 301, 1675, + /* 70 */ 1159, 349, 80, 1647, 505, 1649, 1650, 501, 77, 522, + /* 80 */ 1, 62, 1715, 1777, 1181, 519, 273, 1711, 518, 1261, + /* 90 */ 1634, 113, 398, 309, 108, 1157, 1775, 104, 1777, 1470, + /* 100 */ 1774, 1646, 601, 1473, 419, 271, 14, 317, 35, 33, + /* 110 */ 1631, 147, 1165, 1158, 1478, 1774, 301, 38, 1159, 36, + /* 120 */ 34, 32, 31, 30, 388, 1627, 1633, 56, 2, 1662, + /* 130 */ 1181, 36, 34, 32, 31, 30, 522, 503, 36, 34, + /* 140 */ 32, 31, 30, 1157, 55, 1523, 1777, 502, 39, 131, + /* 150 */ 601, 1617, 291, 1435, 14, 1371, 1160, 1521, 1662, 145, + /* 160 */ 1165, 1158, 559, 1774, 1450, 274, 472, 1675, 140, 1341, + /* 170 */ 132, 1647, 505, 1649, 1650, 501, 2, 522, 1163, 1164, + /* 180 */ 1517, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, + /* 190 */ 1224, 1225, 1226, 1227, 1228, 1229, 1247, 1410, 601, 519, + /* 200 */ 1299, 471, 1183, 55, 1160, 1617, 1456, 1196, 148, 1158, + /* 210 */ 473, 347, 447, 94, 484, 1791, 93, 92, 91, 90, + /* 220 */ 89, 88, 87, 86, 85, 1729, 1163, 1164, 1478, 1209, /* 230 */ 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, - /* 240 */ 1226, 1227, 1228, 1229, 1407, 465, 1307, 1308, 1310, 1311, - /* 250 */ 55, 54, 1160, 36, 34, 32, 31, 30, 148, 27, - /* 260 */ 299, 1242, 1243, 1244, 1245, 1246, 1250, 1251, 1252, 63, - /* 270 */ 289, 479, 1284, 188, 1163, 1164, 1346, 1209, 1210, 1212, + /* 240 */ 1226, 1227, 1228, 1229, 1454, 148, 1248, 479, 1523, 1726, + /* 250 */ 1340, 1777, 1160, 597, 596, 306, 1309, 433, 432, 55, + /* 260 */ 1521, 1523, 431, 398, 145, 109, 428, 1253, 1774, 427, + /* 270 */ 426, 425, 148, 1522, 1163, 1164, 112, 1209, 1210, 1212, /* 280 */ 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, 1226, 1227, - /* 290 */ 1228, 1229, 35, 33, 36, 34, 32, 31, 30, 112, - /* 300 */ 301, 1456, 1159, 148, 577, 576, 575, 316, 148, 574, - /* 310 */ 573, 572, 114, 567, 566, 565, 564, 563, 562, 561, - /* 320 */ 560, 121, 1299, 1239, 1523, 313, 54, 1157, 991, 1662, - /* 330 */ 306, 1646, 1559, 1561, 317, 1521, 472, 110, 140, 311, - /* 340 */ 35, 33, 1230, 473, 1165, 993, 923, 128, 301, 1517, - /* 350 */ 1159, 481, 142, 1722, 1723, 1480, 1727, 26, 398, 1662, - /* 360 */ 8, 36, 34, 32, 31, 30, 503, 36, 34, 32, - /* 370 */ 31, 30, 471, 468, 1777, 1157, 502, 1410, 314, 148, - /* 380 */ 1617, 556, 601, 462, 927, 928, 128, 145, 35, 33, - /* 390 */ 334, 1774, 1165, 1158, 1480, 518, 301, 1675, 1159, 53, - /* 400 */ 268, 1647, 505, 1649, 1650, 501, 382, 522, 9, 386, - /* 410 */ 336, 332, 1029, 545, 544, 543, 1033, 542, 1035, 1036, - /* 420 */ 541, 1038, 538, 1157, 1044, 535, 1046, 1047, 532, 529, - /* 430 */ 601, 36, 34, 32, 31, 30, 1160, 433, 432, 548, - /* 440 */ 1165, 1158, 431, 474, 469, 109, 428, 1454, 519, 427, - /* 450 */ 426, 425, 1185, 1469, 148, 39, 9, 1729, 1163, 1164, - /* 460 */ 348, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 470 */ 1224, 1225, 1226, 1227, 1228, 1229, 1478, 1283, 601, 1292, - /* 480 */ 1235, 1725, 433, 432, 1160, 1183, 1183, 431, 148, 1158, - /* 490 */ 109, 428, 1523, 447, 427, 426, 425, 1341, 312, 1637, - /* 500 */ 1196, 1159, 1617, 1521, 556, 455, 1163, 1164, 309, 1209, + /* 290 */ 1228, 1229, 35, 33, 1349, 465, 1307, 1308, 1310, 1311, + /* 300 */ 301, 556, 1159, 27, 299, 1242, 1243, 1244, 1245, 1246, + /* 310 */ 1250, 1251, 1252, 110, 939, 94, 62, 1469, 93, 92, + /* 320 */ 91, 90, 89, 88, 87, 86, 85, 1157, 143, 1722, + /* 330 */ 1723, 148, 1727, 519, 1184, 519, 479, 1631, 1474, 417, + /* 340 */ 35, 33, 1230, 506, 1165, 348, 304, 104, 301, 1568, + /* 350 */ 1159, 55, 1627, 1633, 424, 36, 34, 32, 31, 30, + /* 360 */ 8, 479, 1478, 522, 1478, 112, 36, 34, 32, 31, + /* 370 */ 30, 1556, 433, 432, 1635, 1157, 154, 431, 156, 1646, + /* 380 */ 109, 428, 601, 519, 427, 426, 425, 148, 35, 33, + /* 390 */ 112, 556, 1165, 1158, 1631, 358, 301, 305, 1159, 1523, + /* 400 */ 60, 274, 110, 59, 1182, 128, 312, 1662, 9, 1627, + /* 410 */ 1633, 1521, 1478, 1185, 1480, 503, 481, 142, 1722, 1723, + /* 420 */ 522, 1727, 468, 1157, 1196, 502, 342, 110, 341, 1617, + /* 430 */ 601, 313, 1247, 64, 289, 1397, 1160, 188, 1559, 1561, + /* 440 */ 1165, 1158, 144, 1722, 1723, 1675, 1727, 548, 263, 1647, + /* 450 */ 505, 1649, 1650, 501, 1370, 522, 9, 434, 1163, 1164, + /* 460 */ 334, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, + /* 470 */ 1224, 1225, 1226, 1227, 1228, 1229, 283, 311, 601, 148, + /* 480 */ 336, 332, 1248, 1120, 1160, 128, 475, 455, 148, 1158, + /* 490 */ 373, 1122, 474, 469, 1480, 1463, 519, 36, 34, 32, + /* 500 */ 31, 30, 1369, 1253, 1617, 1465, 1163, 1164, 359, 1209, /* 510 */ 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, - /* 520 */ 1226, 1227, 1228, 1229, 154, 1631, 1157, 36, 34, 32, - /* 530 */ 31, 30, 1160, 1777, 390, 1639, 1523, 386, 388, 1371, - /* 540 */ 1627, 1634, 1633, 1165, 1181, 373, 145, 1522, 59, 1370, - /* 550 */ 1774, 58, 522, 456, 1163, 1164, 1646, 1209, 1210, 1212, + /* 520 */ 1226, 1227, 1228, 1229, 284, 1478, 282, 281, 1368, 421, + /* 530 */ 558, 1292, 1160, 423, 158, 157, 456, 1183, 214, 27, + /* 540 */ 299, 1242, 1243, 1244, 1245, 1246, 1250, 1251, 1252, 1646, + /* 550 */ 382, 1121, 1617, 386, 1163, 1164, 422, 1209, 1210, 1212, /* 560 */ 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, 1226, 1227, - /* 570 */ 1228, 1229, 35, 33, 270, 519, 1181, 214, 1340, 61, - /* 580 */ 301, 601, 1159, 366, 1662, 519, 378, 358, 1617, 158, - /* 590 */ 157, 503, 1158, 1777, 128, 1369, 174, 516, 1617, 1729, - /* 600 */ 1474, 502, 1481, 1478, 379, 1617, 145, 1157, 139, 519, - /* 610 */ 1774, 483, 1368, 1478, 415, 411, 407, 403, 173, 283, - /* 620 */ 485, 359, 1675, 1724, 1165, 259, 1647, 505, 1649, 1650, - /* 630 */ 501, 519, 522, 1120, 940, 1160, 939, 1478, 479, 445, - /* 640 */ 2, 1122, 62, 397, 1617, 171, 1367, 1211, 1211, 11, - /* 650 */ 10, 1777, 443, 1366, 430, 429, 7, 1163, 1164, 1478, - /* 660 */ 127, 1617, 601, 941, 147, 1365, 112, 284, 1774, 282, - /* 670 */ 281, 1184, 421, 1158, 377, 1364, 423, 372, 371, 370, + /* 570 */ 1228, 1229, 35, 33, 270, 1777, 1181, 1662, 1617, 519, + /* 580 */ 301, 314, 1159, 366, 1249, 482, 378, 1461, 145, 128, + /* 590 */ 554, 397, 1774, 390, 423, 502, 386, 1235, 1480, 1617, + /* 600 */ 940, 54, 939, 1183, 379, 1254, 70, 1157, 1478, 553, + /* 610 */ 552, 1367, 551, 550, 549, 1675, 1366, 422, 81, 1647, + /* 620 */ 505, 1649, 1650, 501, 1165, 522, 1365, 1471, 1715, 941, + /* 630 */ 127, 1186, 294, 1711, 141, 1407, 32, 31, 30, 191, + /* 640 */ 2, 25, 1029, 545, 544, 543, 1033, 542, 1035, 1036, + /* 650 */ 541, 1038, 538, 1743, 1044, 535, 1046, 1047, 532, 529, + /* 660 */ 497, 1617, 601, 1364, 1363, 1362, 1617, 1359, 1358, 1357, + /* 670 */ 1356, 1355, 1354, 1158, 377, 1353, 1617, 372, 371, 370, /* 680 */ 369, 368, 365, 364, 363, 362, 361, 357, 356, 355, - /* 690 */ 354, 353, 352, 351, 350, 1617, 1183, 519, 519, 422, - /* 700 */ 519, 1121, 1617, 170, 110, 165, 1455, 167, 479, 1475, - /* 710 */ 1597, 1186, 517, 1249, 1617, 1363, 1160, 1362, 1359, 143, - /* 720 */ 1722, 1723, 487, 1727, 1617, 1478, 1478, 163, 1478, 1261, - /* 730 */ 1646, 1358, 1357, 1356, 1254, 490, 112, 1355, 1163, 1164, - /* 740 */ 1182, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 750 */ 1224, 1225, 1226, 1227, 1228, 1229, 519, 246, 1662, 519, - /* 760 */ 1508, 1354, 1353, 1352, 1617, 503, 1617, 1617, 236, 1556, - /* 770 */ 25, 315, 571, 569, 110, 502, 156, 927, 928, 1617, - /* 780 */ 1617, 1617, 1617, 1351, 1478, 483, 1617, 1478, 506, 144, - /* 790 */ 1722, 1723, 1606, 1727, 1569, 559, 1675, 1450, 554, 79, - /* 800 */ 1647, 505, 1649, 1650, 501, 1646, 522, 423, 570, 1715, - /* 810 */ 1617, 1617, 1617, 273, 1711, 1560, 1561, 553, 552, 1397, - /* 820 */ 551, 550, 549, 1734, 1280, 1777, 1280, 558, 179, 1392, - /* 830 */ 422, 177, 1617, 1662, 1144, 1145, 199, 324, 147, 1465, - /* 840 */ 503, 434, 1774, 181, 129, 1390, 180, 1461, 337, 252, - /* 850 */ 502, 436, 183, 185, 1617, 182, 184, 118, 1211, 45, - /* 860 */ 483, 250, 52, 46, 272, 51, 1646, 439, 202, 11, - /* 870 */ 10, 1675, 1343, 1344, 79, 1647, 505, 1649, 1650, 501, - /* 880 */ 438, 522, 159, 37, 1715, 37, 191, 37, 273, 1711, - /* 890 */ 225, 497, 75, 116, 1662, 446, 547, 457, 454, 1306, - /* 900 */ 1777, 482, 71, 1361, 117, 1168, 54, 488, 204, 187, - /* 910 */ 1436, 502, 118, 145, 1167, 1617, 1453, 1774, 218, 1646, - /* 920 */ 45, 441, 491, 1255, 209, 1217, 435, 1115, 466, 1663, - /* 930 */ 227, 186, 1675, 511, 448, 80, 1647, 505, 1649, 1650, - /* 940 */ 501, 527, 522, 78, 233, 1715, 117, 1662, 1381, 294, - /* 950 */ 1711, 141, 1022, 416, 503, 50, 1518, 480, 49, 1745, - /* 960 */ 245, 217, 220, 215, 502, 118, 3, 1181, 1617, 461, - /* 970 */ 1742, 1171, 1646, 119, 57, 56, 346, 222, 117, 153, - /* 980 */ 1170, 1050, 319, 323, 340, 1675, 1054, 964, 263, 1647, - /* 990 */ 505, 1649, 1650, 501, 279, 522, 269, 991, 280, 330, - /* 1000 */ 1662, 326, 322, 150, 965, 1061, 241, 482, 554, 1128, - /* 1010 */ 360, 155, 1558, 1059, 367, 374, 375, 502, 120, 376, - /* 1020 */ 380, 1617, 1187, 381, 389, 1190, 475, 553, 552, 392, - /* 1030 */ 551, 550, 549, 393, 148, 162, 164, 1189, 1675, 1349, - /* 1040 */ 394, 80, 1647, 505, 1649, 1650, 501, 1646, 522, 166, - /* 1050 */ 395, 1715, 1188, 396, 169, 294, 1711, 141, 60, 399, - /* 1060 */ 94, 172, 420, 93, 92, 91, 90, 89, 88, 87, - /* 1070 */ 86, 85, 1468, 418, 288, 1662, 1743, 1165, 176, 1464, - /* 1080 */ 1646, 84, 503, 178, 122, 1601, 123, 242, 189, 1466, - /* 1090 */ 1462, 124, 502, 125, 449, 1186, 1617, 450, 192, 453, - /* 1100 */ 1746, 243, 194, 467, 458, 197, 1756, 509, 1662, 6, - /* 1110 */ 459, 1755, 476, 1675, 1736, 503, 80, 1647, 505, 1649, - /* 1120 */ 1650, 501, 464, 522, 293, 502, 1715, 200, 470, 1617, - /* 1130 */ 294, 1711, 1790, 463, 203, 5, 208, 1280, 135, 210, - /* 1140 */ 111, 1749, 1646, 1185, 40, 492, 1675, 295, 1730, 80, - /* 1150 */ 1647, 505, 1649, 1650, 501, 216, 522, 1567, 489, 1715, - /* 1160 */ 18, 1566, 211, 294, 1711, 1790, 512, 229, 507, 244, - /* 1170 */ 1662, 508, 303, 513, 1772, 514, 70, 503, 231, 1696, - /* 1180 */ 68, 525, 1793, 1479, 247, 1451, 238, 502, 600, 1611, - /* 1190 */ 290, 1617, 47, 1773, 249, 134, 1646, 253, 251, 1610, - /* 1200 */ 486, 219, 260, 318, 221, 1646, 254, 1607, 1675, 493, - /* 1210 */ 320, 80, 1647, 505, 1649, 1650, 501, 321, 522, 1153, - /* 1220 */ 1154, 1715, 151, 325, 1662, 294, 1711, 1790, 1605, 327, - /* 1230 */ 328, 503, 1604, 1662, 329, 331, 1733, 1603, 333, 1602, - /* 1240 */ 503, 502, 335, 1587, 152, 1617, 338, 339, 1131, 1130, - /* 1250 */ 502, 1581, 1580, 344, 1617, 1579, 345, 1578, 1098, 1646, - /* 1260 */ 483, 1551, 1675, 1550, 1549, 132, 1647, 505, 1649, 1650, - /* 1270 */ 501, 1675, 522, 1548, 259, 1647, 505, 1649, 1650, 501, - /* 1280 */ 1547, 522, 1546, 1545, 1544, 1543, 1542, 1662, 1541, 1540, - /* 1290 */ 1539, 1538, 1537, 1536, 503, 1535, 1534, 1533, 115, 1646, - /* 1300 */ 1777, 1532, 1531, 1530, 502, 1529, 1528, 1527, 1617, 1100, - /* 1310 */ 1792, 1526, 1525, 145, 1524, 1409, 1377, 1774, 1646, 160, - /* 1320 */ 1376, 385, 138, 401, 930, 1675, 1595, 1662, 81, 1647, - /* 1330 */ 505, 1649, 1650, 501, 503, 522, 106, 929, 1715, 405, - /* 1340 */ 1402, 107, 1714, 1711, 502, 1589, 1662, 1573, 1617, 1564, - /* 1350 */ 1457, 161, 387, 500, 168, 1408, 1406, 958, 402, 1404, - /* 1360 */ 1400, 406, 410, 502, 414, 1675, 400, 1617, 81, 1647, - /* 1370 */ 505, 1649, 1650, 501, 1646, 522, 404, 408, 1715, 409, - /* 1380 */ 412, 413, 494, 1711, 1675, 1389, 1388, 267, 1647, 505, - /* 1390 */ 1649, 1650, 501, 499, 522, 496, 1687, 1375, 1459, 1065, - /* 1400 */ 1064, 1458, 1662, 604, 990, 989, 568, 83, 988, 503, - /* 1410 */ 987, 570, 1398, 984, 983, 175, 285, 240, 982, 502, - /* 1420 */ 437, 286, 1391, 1617, 1393, 287, 440, 1374, 442, 105, - /* 1430 */ 1373, 444, 1594, 1646, 82, 593, 589, 585, 581, 239, - /* 1440 */ 1675, 1588, 1138, 81, 1647, 505, 1649, 1650, 501, 1572, - /* 1450 */ 522, 451, 1571, 1715, 1563, 64, 196, 4, 1712, 37, - /* 1460 */ 15, 1662, 201, 77, 43, 207, 234, 48, 503, 1305, - /* 1470 */ 133, 205, 22, 41, 1298, 206, 452, 193, 502, 1637, - /* 1480 */ 65, 198, 1617, 23, 16, 298, 1277, 1646, 1276, 213, - /* 1490 */ 136, 308, 307, 126, 42, 1329, 1334, 17, 1323, 1675, - /* 1500 */ 515, 1173, 268, 1647, 505, 1649, 1650, 501, 1328, 522, - /* 1510 */ 296, 1333, 13, 1332, 297, 1662, 10, 1646, 19, 1219, - /* 1520 */ 1240, 1218, 500, 29, 137, 460, 1166, 12, 195, 149, - /* 1530 */ 20, 1204, 502, 504, 1562, 21, 1617, 230, 224, 1303, - /* 1540 */ 226, 71, 228, 1165, 1175, 1662, 1136, 510, 190, 66, - /* 1550 */ 1646, 232, 503, 1675, 67, 1636, 267, 1647, 505, 1649, - /* 1560 */ 1650, 501, 502, 522, 235, 1688, 1617, 1678, 521, 300, - /* 1570 */ 1221, 44, 524, 1051, 526, 310, 528, 530, 1662, 1048, - /* 1580 */ 1646, 523, 531, 1675, 1045, 503, 268, 1647, 505, 1649, - /* 1590 */ 1650, 501, 1169, 522, 533, 502, 1039, 534, 536, 1617, - /* 1600 */ 1037, 537, 302, 539, 540, 1028, 1060, 1058, 1662, 1043, - /* 1610 */ 1646, 1042, 479, 72, 1041, 503, 1675, 1040, 546, 268, - /* 1620 */ 1647, 505, 1649, 1650, 501, 502, 522, 1057, 73, 1617, - /* 1630 */ 74, 1056, 956, 555, 997, 1174, 557, 237, 1662, 978, - /* 1640 */ 112, 977, 976, 973, 975, 503, 1675, 974, 972, 255, - /* 1650 */ 1647, 505, 1649, 1650, 501, 502, 522, 1177, 971, 1617, - /* 1660 */ 483, 1646, 994, 992, 968, 967, 966, 963, 520, 1224, - /* 1670 */ 1225, 962, 961, 1405, 578, 579, 1675, 1646, 110, 262, - /* 1680 */ 1647, 505, 1649, 1650, 501, 580, 522, 1403, 582, 1662, - /* 1690 */ 583, 584, 1401, 212, 1722, 478, 503, 477, 586, 588, - /* 1700 */ 1777, 1399, 587, 591, 592, 1662, 502, 590, 1387, 595, - /* 1710 */ 1617, 594, 503, 145, 1386, 1372, 598, 1774, 599, 1347, - /* 1720 */ 1161, 248, 502, 602, 1646, 603, 1617, 1675, 1347, 1347, - /* 1730 */ 264, 1647, 505, 1649, 1650, 501, 1347, 522, 1347, 1347, - /* 1740 */ 1347, 1347, 1646, 1675, 1347, 1347, 256, 1647, 505, 1649, - /* 1750 */ 1650, 501, 1662, 522, 1347, 1347, 1347, 1646, 1347, 503, - /* 1760 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 502, - /* 1770 */ 1662, 1347, 1347, 1617, 1347, 1347, 1347, 503, 1347, 1347, - /* 1780 */ 1347, 1347, 1347, 1347, 1347, 1662, 1347, 502, 1347, 1347, - /* 1790 */ 1675, 1617, 503, 265, 1647, 505, 1649, 1650, 501, 1347, - /* 1800 */ 522, 1347, 502, 1347, 1646, 1347, 1617, 1347, 1675, 1347, - /* 1810 */ 1347, 257, 1647, 505, 1649, 1650, 501, 1347, 522, 1347, - /* 1820 */ 1646, 1347, 1347, 1675, 1347, 1347, 266, 1647, 505, 1649, - /* 1830 */ 1650, 501, 1662, 522, 1347, 1347, 1347, 1347, 1347, 503, - /* 1840 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1662, 502, - /* 1850 */ 1347, 1347, 1347, 1617, 1347, 503, 1347, 1347, 1347, 1347, - /* 1860 */ 1347, 1347, 1347, 1347, 1347, 502, 1347, 1646, 1347, 1617, - /* 1870 */ 1675, 1347, 1347, 258, 1647, 505, 1649, 1650, 501, 1347, - /* 1880 */ 522, 1347, 1347, 1347, 1347, 1347, 1675, 1347, 1347, 1658, - /* 1890 */ 1647, 505, 1649, 1650, 501, 1662, 522, 1646, 1347, 1347, - /* 1900 */ 1347, 1347, 503, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1910 */ 1347, 1347, 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, - /* 1920 */ 1347, 1347, 1347, 1347, 1347, 1662, 1347, 1347, 1347, 1347, - /* 1930 */ 1347, 1347, 503, 1675, 1347, 1347, 1657, 1647, 505, 1649, - /* 1940 */ 1650, 501, 502, 522, 1347, 1347, 1617, 1646, 1347, 1347, - /* 1950 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1960 */ 1347, 1347, 1347, 1675, 1347, 1347, 1656, 1647, 505, 1649, - /* 1970 */ 1650, 501, 1347, 522, 1347, 1662, 1347, 1646, 1347, 1347, - /* 1980 */ 1347, 1347, 503, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1990 */ 1347, 1347, 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, - /* 2000 */ 1347, 1347, 1347, 1347, 1347, 1662, 1347, 1347, 1347, 1347, - /* 2010 */ 1347, 1347, 503, 1675, 1347, 1347, 277, 1647, 505, 1649, - /* 2020 */ 1650, 501, 502, 522, 1347, 1347, 1617, 1646, 1347, 1347, - /* 2030 */ 1347, 1347, 1347, 1347, 1347, 1347, 1646, 1347, 1347, 1347, - /* 2040 */ 1347, 1347, 1347, 1675, 1347, 1347, 276, 1647, 505, 1649, - /* 2050 */ 1650, 501, 1347, 522, 1347, 1662, 1347, 1347, 1347, 1347, - /* 2060 */ 1347, 1347, 503, 1347, 1662, 1347, 1347, 1347, 1347, 1347, - /* 2070 */ 1347, 503, 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, - /* 2080 */ 1347, 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, 1347, - /* 2090 */ 1646, 1347, 1347, 1675, 1347, 1347, 278, 1647, 505, 1649, - /* 2100 */ 1650, 501, 1675, 522, 1347, 275, 1647, 505, 1649, 1650, - /* 2110 */ 501, 1347, 522, 1347, 1347, 1347, 1347, 1347, 1662, 1347, - /* 2120 */ 1347, 1347, 1347, 1347, 1347, 503, 1347, 1347, 1347, 1347, - /* 2130 */ 1347, 1347, 1347, 1347, 1347, 502, 1347, 1347, 1347, 1617, - /* 2140 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 2150 */ 1347, 1347, 1347, 1347, 1347, 1347, 1675, 1347, 1347, 261, - /* 2160 */ 1647, 505, 1649, 1650, 501, 1347, 522, + /* 690 */ 354, 353, 352, 351, 350, 577, 576, 575, 316, 1211, + /* 700 */ 574, 573, 572, 114, 567, 566, 565, 564, 563, 562, + /* 710 */ 561, 560, 121, 1617, 1617, 1617, 1160, 1617, 1617, 1617, + /* 720 */ 1617, 1617, 1617, 1352, 7, 1617, 128, 1351, 430, 429, + /* 730 */ 1646, 571, 569, 1560, 1561, 1481, 927, 928, 1163, 1164, + /* 740 */ 1729, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, + /* 750 */ 1224, 1225, 1226, 1227, 1228, 1229, 199, 129, 1662, 519, + /* 760 */ 1284, 1646, 252, 1729, 1725, 1211, 503, 991, 1159, 519, + /* 770 */ 1183, 1475, 1606, 1617, 250, 53, 502, 1617, 52, 506, + /* 780 */ 1617, 1597, 1734, 1280, 993, 1569, 483, 1724, 1478, 1662, + /* 790 */ 1144, 1145, 487, 1157, 479, 159, 1675, 482, 1478, 80, + /* 800 */ 1647, 505, 1649, 1650, 501, 246, 522, 502, 1508, 1715, + /* 810 */ 1165, 1617, 519, 273, 1711, 570, 454, 324, 179, 55, + /* 820 */ 1168, 177, 485, 112, 516, 1777, 181, 1675, 490, 180, + /* 830 */ 81, 1647, 505, 1649, 1650, 501, 1637, 522, 145, 519, + /* 840 */ 1715, 1478, 1774, 483, 294, 1711, 141, 183, 601, 185, + /* 850 */ 182, 517, 184, 445, 495, 337, 79, 1646, 215, 1158, + /* 860 */ 110, 519, 519, 547, 461, 1742, 443, 964, 1478, 47, + /* 870 */ 272, 118, 1639, 236, 315, 212, 1722, 478, 1392, 477, + /* 880 */ 11, 10, 1777, 1390, 965, 1662, 1171, 58, 57, 346, + /* 890 */ 1478, 1478, 153, 503, 1280, 147, 1361, 340, 46, 1774, + /* 900 */ 436, 1167, 1160, 502, 202, 439, 37, 1617, 1436, 269, + /* 910 */ 37, 457, 330, 37, 326, 322, 150, 225, 1343, 1344, + /* 920 */ 1646, 1455, 116, 1675, 1163, 1164, 81, 1647, 505, 1649, + /* 930 */ 1650, 501, 1211, 522, 218, 117, 1715, 466, 1306, 76, + /* 940 */ 294, 1711, 1790, 448, 204, 118, 1255, 148, 1662, 72, + /* 950 */ 1217, 1749, 1663, 1115, 1381, 46, 503, 227, 527, 209, + /* 960 */ 416, 174, 511, 480, 1518, 1283, 502, 1170, 1745, 217, + /* 970 */ 1617, 117, 1646, 139, 1239, 233, 220, 488, 222, 415, + /* 980 */ 411, 407, 403, 173, 118, 1022, 1675, 119, 117, 81, + /* 990 */ 1647, 505, 1649, 1650, 501, 245, 522, 1453, 1050, 1715, + /* 1000 */ 1662, 3, 1181, 294, 1711, 1790, 319, 63, 503, 323, + /* 1010 */ 171, 1054, 991, 554, 1772, 491, 280, 279, 502, 241, + /* 1020 */ 1128, 155, 1617, 360, 1061, 1558, 367, 1059, 120, 375, + /* 1030 */ 374, 1646, 553, 552, 380, 551, 550, 549, 1675, 1187, + /* 1040 */ 376, 81, 1647, 505, 1649, 1650, 501, 438, 522, 381, + /* 1050 */ 389, 1715, 1190, 162, 392, 294, 1711, 1790, 393, 1662, + /* 1060 */ 1189, 164, 446, 394, 166, 395, 1733, 503, 170, 1188, + /* 1070 */ 165, 396, 167, 399, 169, 61, 187, 502, 418, 172, + /* 1080 */ 1165, 1617, 1646, 420, 1468, 176, 1464, 483, 441, 554, + /* 1090 */ 84, 242, 163, 435, 288, 1601, 178, 1675, 186, 1646, + /* 1100 */ 259, 1647, 505, 1649, 1650, 501, 122, 522, 553, 552, + /* 1110 */ 1662, 551, 550, 549, 123, 1466, 1462, 124, 503, 125, + /* 1120 */ 449, 189, 51, 453, 450, 50, 1777, 1662, 502, 243, + /* 1130 */ 458, 192, 1617, 194, 1186, 503, 197, 459, 483, 147, + /* 1140 */ 1746, 467, 509, 1774, 1756, 502, 6, 200, 1675, 1617, + /* 1150 */ 463, 259, 1647, 505, 1649, 1650, 501, 1646, 522, 464, + /* 1160 */ 476, 5, 1736, 203, 1755, 1675, 293, 210, 82, 1647, + /* 1170 */ 505, 1649, 1650, 501, 1280, 522, 111, 1777, 1715, 470, + /* 1180 */ 208, 1185, 1714, 1711, 1348, 1662, 40, 211, 492, 1646, + /* 1190 */ 145, 1773, 135, 503, 1774, 1730, 295, 489, 18, 1567, + /* 1200 */ 1793, 507, 508, 502, 1566, 512, 303, 1617, 103, 102, + /* 1210 */ 101, 100, 99, 98, 97, 96, 95, 1662, 216, 479, + /* 1220 */ 1696, 513, 229, 1675, 219, 500, 82, 1647, 505, 1649, + /* 1230 */ 1650, 501, 514, 522, 231, 502, 1715, 69, 486, 1617, + /* 1240 */ 494, 1711, 1646, 493, 221, 244, 1479, 71, 112, 525, + /* 1250 */ 1451, 247, 600, 238, 48, 1675, 134, 253, 267, 1647, + /* 1260 */ 505, 1649, 1650, 501, 499, 522, 496, 1687, 483, 290, + /* 1270 */ 1662, 260, 249, 254, 251, 1611, 1610, 318, 503, 1607, + /* 1280 */ 320, 321, 1153, 1154, 151, 110, 325, 1605, 502, 327, + /* 1290 */ 328, 329, 1617, 1604, 331, 1603, 333, 1602, 335, 1646, + /* 1300 */ 212, 1722, 478, 1587, 477, 152, 339, 1777, 1675, 338, + /* 1310 */ 1131, 82, 1647, 505, 1649, 1650, 501, 1581, 522, 1130, + /* 1320 */ 145, 1715, 1580, 344, 1774, 345, 1712, 1662, 604, 1579, + /* 1330 */ 1578, 1551, 1098, 1550, 1549, 503, 1548, 1547, 1546, 1545, + /* 1340 */ 1544, 1543, 240, 1100, 115, 502, 1646, 1542, 1541, 1617, + /* 1350 */ 1540, 1539, 462, 1538, 105, 1537, 1536, 1535, 1534, 1533, + /* 1360 */ 593, 589, 585, 581, 239, 1675, 1532, 1531, 268, 1647, + /* 1370 */ 505, 1649, 1650, 501, 1662, 522, 1530, 1529, 1528, 1527, + /* 1380 */ 1526, 1525, 503, 1524, 1409, 1646, 1377, 138, 78, 160, + /* 1390 */ 1376, 234, 502, 1595, 1589, 1573, 1617, 106, 385, 930, + /* 1400 */ 161, 929, 107, 1564, 1457, 387, 168, 1408, 1406, 401, + /* 1410 */ 400, 958, 1675, 1662, 1404, 132, 1647, 505, 1649, 1650, + /* 1420 */ 501, 503, 522, 1402, 1400, 515, 402, 1389, 406, 404, + /* 1430 */ 1388, 502, 175, 405, 410, 1617, 1646, 414, 298, 408, + /* 1440 */ 1375, 409, 1459, 1458, 413, 412, 1398, 1064, 1065, 990, + /* 1450 */ 460, 1675, 989, 195, 268, 1647, 505, 1649, 1650, 501, + /* 1460 */ 1792, 522, 45, 988, 1662, 1646, 987, 568, 1393, 570, + /* 1470 */ 285, 1136, 500, 190, 286, 1391, 984, 287, 983, 1374, + /* 1480 */ 982, 440, 502, 437, 442, 1373, 1617, 444, 1594, 83, + /* 1490 */ 1588, 1138, 451, 1662, 1572, 1571, 126, 1646, 1563, 4, + /* 1500 */ 65, 503, 1675, 196, 37, 267, 1647, 505, 1649, 1650, + /* 1510 */ 501, 502, 522, 49, 1688, 1617, 452, 193, 300, 15, + /* 1520 */ 201, 43, 1305, 206, 41, 1662, 1298, 133, 207, 205, + /* 1530 */ 22, 1675, 23, 503, 268, 1647, 505, 1649, 1650, 501, + /* 1540 */ 1637, 522, 1277, 502, 66, 213, 198, 1617, 1276, 42, + /* 1550 */ 302, 136, 1334, 1646, 16, 17, 13, 1323, 1329, 10, + /* 1560 */ 1328, 19, 296, 1675, 1333, 1332, 268, 1647, 505, 1649, + /* 1570 */ 1650, 501, 297, 522, 1219, 137, 149, 29, 1204, 510, + /* 1580 */ 1218, 1662, 12, 20, 1646, 21, 226, 1240, 1562, 503, + /* 1590 */ 504, 224, 230, 232, 72, 1636, 235, 1303, 1175, 502, + /* 1600 */ 1221, 228, 67, 1617, 68, 526, 1678, 521, 44, 310, + /* 1610 */ 1051, 1048, 1662, 1646, 524, 528, 530, 531, 533, 1675, + /* 1620 */ 503, 1045, 255, 1647, 505, 1649, 1650, 501, 534, 522, + /* 1630 */ 502, 1039, 536, 537, 1617, 1037, 539, 1043, 1042, 540, + /* 1640 */ 1041, 1662, 1040, 1028, 73, 74, 1060, 75, 1057, 503, + /* 1650 */ 1675, 1056, 546, 262, 1647, 505, 1649, 1650, 501, 502, + /* 1660 */ 522, 956, 1646, 1617, 555, 557, 237, 997, 308, 307, + /* 1670 */ 978, 977, 973, 1646, 1058, 976, 994, 975, 1173, 1675, + /* 1680 */ 974, 972, 264, 1647, 505, 1649, 1650, 501, 971, 522, + /* 1690 */ 1662, 992, 968, 967, 966, 963, 962, 1405, 503, 961, + /* 1700 */ 578, 1662, 579, 1166, 580, 1403, 582, 583, 502, 503, + /* 1710 */ 584, 1401, 1617, 586, 587, 588, 1399, 590, 592, 502, + /* 1720 */ 1165, 591, 1387, 1617, 1646, 1386, 594, 1372, 1675, 595, + /* 1730 */ 598, 256, 1647, 505, 1649, 1650, 501, 1161, 522, 1675, + /* 1740 */ 599, 603, 265, 1647, 505, 1649, 1650, 501, 248, 522, + /* 1750 */ 602, 1347, 1662, 1646, 1347, 1347, 1347, 1347, 523, 1347, + /* 1760 */ 503, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1169, + /* 1770 */ 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, + /* 1780 */ 1347, 1662, 1347, 1347, 1347, 1646, 1347, 1347, 1347, 503, + /* 1790 */ 1675, 1347, 1347, 257, 1647, 505, 1649, 1650, 501, 502, + /* 1800 */ 522, 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, + /* 1810 */ 1347, 1347, 1174, 1662, 1347, 1347, 1347, 1347, 1347, 1675, + /* 1820 */ 1347, 503, 266, 1647, 505, 1649, 1650, 501, 1347, 522, + /* 1830 */ 1347, 502, 1347, 1347, 1177, 1617, 1347, 1347, 1347, 1347, + /* 1840 */ 1347, 1646, 1347, 1347, 1347, 520, 1224, 1225, 1347, 1347, + /* 1850 */ 1347, 1675, 1347, 1347, 258, 1647, 505, 1649, 1650, 501, + /* 1860 */ 1347, 522, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1662, + /* 1870 */ 1347, 1347, 1646, 1347, 1347, 1347, 1347, 503, 1347, 1347, + /* 1880 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 502, 1347, 1347, + /* 1890 */ 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, + /* 1900 */ 1662, 1646, 1347, 1347, 1347, 1347, 1347, 1675, 503, 1347, + /* 1910 */ 1658, 1647, 505, 1649, 1650, 501, 1347, 522, 502, 1347, + /* 1920 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1662, + /* 1930 */ 1347, 1347, 1646, 1347, 1347, 1347, 1347, 503, 1675, 1347, + /* 1940 */ 1347, 1657, 1647, 505, 1649, 1650, 501, 502, 522, 1347, + /* 1950 */ 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, + /* 1960 */ 1662, 1646, 1347, 1347, 1347, 1347, 1347, 1675, 503, 1347, + /* 1970 */ 1656, 1647, 505, 1649, 1650, 501, 1347, 522, 502, 1347, + /* 1980 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1662, + /* 1990 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 503, 1675, 1347, + /* 2000 */ 1347, 277, 1647, 505, 1649, 1650, 501, 502, 522, 1347, + /* 2010 */ 1347, 1617, 1646, 1347, 1347, 1347, 1347, 1347, 1347, 1347, + /* 2020 */ 1347, 1347, 1347, 1646, 1347, 1347, 1347, 1675, 1347, 1347, + /* 2030 */ 276, 1647, 505, 1649, 1650, 501, 1347, 522, 1347, 1347, + /* 2040 */ 1662, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 503, 1347, + /* 2050 */ 1347, 1662, 1347, 1347, 1347, 1347, 1347, 1347, 502, 503, + /* 2060 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 502, + /* 2070 */ 1347, 1347, 1347, 1617, 1347, 1347, 1347, 1646, 1675, 1347, + /* 2080 */ 1347, 278, 1647, 505, 1649, 1650, 501, 1347, 522, 1675, + /* 2090 */ 1347, 1347, 275, 1647, 505, 1649, 1650, 501, 1347, 522, + /* 2100 */ 1347, 1347, 1347, 1347, 1347, 1662, 1347, 1347, 1347, 1347, + /* 2110 */ 1347, 1347, 1347, 503, 1347, 1347, 1347, 1347, 1347, 1347, + /* 2120 */ 1347, 1347, 1347, 502, 1347, 1347, 1347, 1617, 1347, 1347, + /* 2130 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, + /* 2140 */ 1347, 1347, 1347, 1675, 1347, 1347, 261, 1647, 505, 1649, + /* 2150 */ 1650, 501, 1347, 522, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 244, 251, 246, 247, 244, 248, 246, 247, 290, 321, - /* 10 */ 322, 270, 12, 13, 264, 270, 296, 260, 241, 336, - /* 20 */ 20, 271, 22, 305, 306, 307, 12, 13, 14, 15, - /* 30 */ 16, 308, 349, 276, 21, 317, 353, 24, 25, 26, - /* 40 */ 27, 28, 29, 30, 31, 32, 269, 47, 269, 273, - /* 50 */ 14, 15, 16, 276, 275, 332, 336, 248, 58, 280, - /* 60 */ 12, 13, 14, 286, 64, 20, 290, 290, 20, 349, - /* 70 */ 22, 248, 58, 353, 57, 12, 13, 14, 15, 16, - /* 80 */ 80, 305, 306, 307, 307, 276, 2, 310, 311, 312, - /* 90 */ 313, 314, 315, 317, 317, 47, 12, 13, 14, 15, - /* 100 */ 16, 253, 102, 89, 281, 296, 58, 248, 12, 13, - /* 110 */ 249, 250, 64, 113, 266, 20, 20, 261, 22, 260, - /* 120 */ 20, 58, 274, 314, 22, 269, 267, 240, 80, 242, - /* 130 */ 80, 354, 355, 277, 336, 276, 248, 251, 329, 330, - /* 140 */ 331, 0, 333, 47, 81, 336, 336, 349, 260, 47, - /* 150 */ 102, 353, 89, 139, 58, 267, 156, 271, 349, 349, - /* 160 */ 64, 113, 353, 353, 276, 24, 25, 26, 27, 28, - /* 170 */ 29, 30, 31, 32, 160, 80, 80, 92, 178, 179, - /* 180 */ 80, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 190 */ 190, 191, 192, 193, 194, 195, 111, 112, 102, 114, - /* 200 */ 115, 116, 139, 58, 156, 155, 178, 157, 208, 113, - /* 210 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 220 */ 254, 20, 286, 160, 258, 289, 178, 179, 292, 181, + /* 0 */ 270, 336, 336, 241, 244, 271, 246, 247, 274, 1, + /* 10 */ 2, 297, 12, 13, 349, 349, 2, 4, 353, 353, + /* 20 */ 20, 244, 22, 246, 247, 291, 12, 13, 14, 15, + /* 30 */ 16, 269, 2, 12, 13, 14, 15, 16, 20, 277, + /* 40 */ 306, 307, 12, 13, 14, 15, 16, 47, 238, 287, + /* 50 */ 336, 317, 240, 291, 242, 42, 43, 20, 58, 297, + /* 60 */ 12, 13, 14, 349, 64, 321, 322, 353, 20, 307, + /* 70 */ 22, 248, 310, 311, 312, 313, 314, 315, 251, 317, + /* 80 */ 80, 253, 320, 336, 20, 248, 324, 325, 20, 81, + /* 90 */ 271, 264, 57, 274, 266, 47, 349, 260, 336, 272, + /* 100 */ 353, 241, 102, 275, 267, 282, 58, 297, 12, 13, + /* 110 */ 291, 349, 64, 113, 277, 353, 20, 80, 22, 12, + /* 120 */ 13, 14, 15, 16, 14, 306, 307, 4, 80, 269, + /* 130 */ 20, 12, 13, 14, 15, 16, 317, 277, 12, 13, + /* 140 */ 14, 15, 16, 47, 80, 269, 336, 287, 80, 254, + /* 150 */ 102, 291, 276, 258, 58, 241, 156, 281, 269, 349, + /* 160 */ 64, 113, 257, 353, 259, 58, 277, 307, 268, 148, + /* 170 */ 310, 311, 312, 313, 314, 315, 80, 317, 178, 179, + /* 180 */ 280, 181, 182, 183, 184, 185, 186, 187, 188, 189, + /* 190 */ 190, 191, 192, 193, 194, 195, 89, 0, 102, 248, + /* 200 */ 81, 312, 20, 80, 156, 291, 0, 81, 208, 113, + /* 210 */ 20, 260, 297, 21, 354, 355, 24, 25, 26, 27, + /* 220 */ 28, 29, 30, 31, 32, 308, 178, 179, 277, 181, /* 230 */ 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 240 */ 192, 193, 194, 195, 0, 217, 218, 219, 220, 221, - /* 250 */ 4, 80, 156, 12, 13, 14, 15, 16, 208, 196, - /* 260 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 165, - /* 270 */ 166, 248, 4, 169, 178, 179, 238, 181, 182, 183, + /* 240 */ 192, 193, 194, 195, 0, 208, 139, 248, 269, 332, + /* 250 */ 229, 336, 156, 249, 250, 276, 178, 60, 61, 80, + /* 260 */ 281, 269, 65, 57, 349, 68, 69, 160, 353, 72, + /* 270 */ 73, 74, 208, 281, 178, 179, 277, 181, 182, 183, /* 280 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 290 */ 194, 195, 12, 13, 12, 13, 14, 15, 16, 276, - /* 300 */ 20, 0, 22, 208, 60, 61, 62, 63, 208, 65, - /* 310 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - /* 320 */ 76, 77, 81, 178, 269, 278, 80, 47, 47, 269, - /* 330 */ 275, 241, 285, 286, 296, 280, 276, 314, 268, 261, - /* 340 */ 12, 13, 14, 20, 64, 64, 4, 269, 20, 279, - /* 350 */ 22, 328, 329, 330, 331, 277, 333, 2, 57, 269, - /* 360 */ 80, 12, 13, 14, 15, 16, 276, 12, 13, 14, - /* 370 */ 15, 16, 312, 143, 336, 47, 286, 0, 261, 208, - /* 380 */ 290, 57, 102, 293, 42, 43, 269, 349, 12, 13, - /* 390 */ 151, 353, 64, 113, 277, 20, 20, 307, 22, 3, - /* 400 */ 310, 311, 312, 313, 314, 315, 245, 317, 80, 248, - /* 410 */ 171, 172, 93, 94, 95, 96, 97, 98, 99, 100, - /* 420 */ 101, 102, 103, 47, 105, 106, 107, 108, 109, 110, - /* 430 */ 102, 12, 13, 14, 15, 16, 156, 60, 61, 91, - /* 440 */ 64, 113, 65, 213, 214, 68, 69, 0, 248, 72, - /* 450 */ 73, 74, 20, 241, 208, 80, 80, 308, 178, 179, - /* 460 */ 260, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 470 */ 190, 191, 192, 193, 194, 195, 276, 209, 102, 14, - /* 480 */ 14, 332, 60, 61, 156, 20, 20, 65, 208, 113, - /* 490 */ 68, 69, 269, 296, 72, 73, 74, 148, 275, 44, - /* 500 */ 81, 22, 290, 280, 57, 248, 178, 179, 273, 181, + /* 290 */ 194, 195, 12, 13, 0, 217, 218, 219, 220, 221, + /* 300 */ 20, 57, 22, 196, 197, 198, 199, 200, 201, 202, + /* 310 */ 203, 204, 205, 314, 22, 21, 253, 271, 24, 25, + /* 320 */ 26, 27, 28, 29, 30, 31, 32, 47, 329, 330, + /* 330 */ 331, 208, 333, 248, 20, 248, 248, 291, 275, 47, + /* 340 */ 12, 13, 14, 287, 64, 260, 290, 260, 20, 293, + /* 350 */ 22, 80, 306, 307, 267, 12, 13, 14, 15, 16, + /* 360 */ 80, 248, 277, 317, 277, 277, 12, 13, 14, 15, + /* 370 */ 16, 277, 60, 61, 271, 47, 55, 65, 284, 241, + /* 380 */ 68, 69, 102, 248, 72, 73, 74, 208, 12, 13, + /* 390 */ 277, 57, 64, 113, 291, 260, 20, 261, 22, 269, + /* 400 */ 79, 58, 314, 82, 20, 269, 276, 269, 80, 306, + /* 410 */ 307, 281, 277, 20, 278, 277, 328, 329, 330, 331, + /* 420 */ 317, 333, 143, 47, 81, 287, 155, 314, 157, 291, + /* 430 */ 102, 279, 89, 165, 166, 0, 156, 169, 286, 287, + /* 440 */ 64, 113, 329, 330, 331, 307, 333, 91, 310, 311, + /* 450 */ 312, 313, 314, 315, 241, 317, 80, 22, 178, 179, + /* 460 */ 151, 181, 182, 183, 184, 185, 186, 187, 188, 189, + /* 470 */ 190, 191, 192, 193, 194, 195, 35, 261, 102, 208, + /* 480 */ 171, 172, 139, 79, 156, 269, 348, 248, 208, 113, + /* 490 */ 75, 87, 213, 214, 278, 270, 248, 12, 13, 14, + /* 500 */ 15, 16, 241, 160, 291, 270, 178, 179, 260, 181, /* 510 */ 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 520 */ 192, 193, 194, 195, 55, 290, 47, 12, 13, 14, - /* 530 */ 15, 16, 156, 336, 245, 80, 269, 248, 14, 241, - /* 540 */ 305, 306, 307, 64, 20, 75, 349, 280, 79, 241, - /* 550 */ 353, 82, 317, 296, 178, 179, 241, 181, 182, 183, + /* 520 */ 192, 193, 194, 195, 83, 277, 85, 86, 241, 88, + /* 530 */ 64, 14, 156, 92, 119, 120, 297, 20, 145, 196, + /* 540 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 241, + /* 550 */ 245, 147, 291, 248, 178, 179, 115, 181, 182, 183, /* 560 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 570 */ 194, 195, 12, 13, 18, 248, 20, 145, 229, 253, - /* 580 */ 20, 102, 22, 27, 269, 248, 30, 260, 290, 119, - /* 590 */ 120, 276, 113, 336, 269, 241, 33, 260, 290, 308, - /* 600 */ 274, 286, 277, 276, 48, 290, 349, 47, 45, 248, - /* 610 */ 353, 296, 241, 276, 51, 52, 53, 54, 55, 35, - /* 620 */ 224, 260, 307, 332, 64, 310, 311, 312, 313, 314, - /* 630 */ 315, 248, 317, 79, 20, 156, 22, 276, 248, 21, - /* 640 */ 80, 87, 79, 260, 290, 82, 241, 182, 182, 1, - /* 650 */ 2, 336, 34, 241, 255, 256, 37, 178, 179, 276, - /* 660 */ 145, 290, 102, 49, 349, 241, 276, 83, 353, 85, - /* 670 */ 86, 20, 88, 113, 118, 241, 92, 121, 122, 123, + /* 570 */ 194, 195, 12, 13, 18, 336, 20, 269, 291, 248, + /* 580 */ 20, 261, 22, 27, 139, 277, 30, 270, 349, 269, + /* 590 */ 92, 260, 353, 245, 92, 287, 248, 14, 278, 291, + /* 600 */ 20, 3, 22, 20, 48, 160, 251, 47, 277, 111, + /* 610 */ 112, 241, 114, 115, 116, 307, 241, 115, 310, 311, + /* 620 */ 312, 313, 314, 315, 64, 317, 241, 272, 320, 49, + /* 630 */ 145, 20, 324, 325, 326, 0, 14, 15, 16, 270, + /* 640 */ 80, 196, 93, 94, 95, 96, 97, 98, 99, 100, + /* 650 */ 101, 102, 103, 345, 105, 106, 107, 108, 109, 110, + /* 660 */ 270, 291, 102, 241, 241, 241, 291, 241, 241, 241, + /* 670 */ 241, 241, 241, 113, 118, 241, 291, 121, 122, 123, /* 680 */ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - /* 690 */ 134, 135, 136, 137, 138, 290, 20, 248, 248, 115, - /* 700 */ 248, 147, 290, 140, 314, 142, 0, 144, 248, 260, - /* 710 */ 260, 20, 260, 139, 290, 241, 156, 241, 241, 329, - /* 720 */ 330, 331, 41, 333, 290, 276, 276, 164, 276, 81, - /* 730 */ 241, 241, 241, 241, 160, 41, 276, 241, 178, 179, - /* 740 */ 20, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 750 */ 190, 191, 192, 193, 194, 195, 248, 262, 269, 248, - /* 760 */ 265, 241, 241, 241, 290, 276, 290, 290, 260, 276, - /* 770 */ 196, 260, 255, 256, 314, 286, 283, 42, 43, 290, - /* 780 */ 290, 290, 290, 241, 276, 296, 290, 276, 286, 329, - /* 790 */ 330, 331, 0, 333, 292, 257, 307, 259, 92, 310, - /* 800 */ 311, 312, 313, 314, 315, 241, 317, 92, 41, 320, - /* 810 */ 290, 290, 290, 324, 325, 285, 286, 111, 112, 0, - /* 820 */ 114, 115, 116, 206, 207, 336, 207, 64, 84, 0, - /* 830 */ 115, 87, 290, 269, 167, 168, 145, 45, 349, 270, - /* 840 */ 276, 22, 353, 84, 18, 0, 87, 270, 81, 23, - /* 850 */ 286, 22, 84, 84, 290, 87, 87, 41, 182, 41, - /* 860 */ 296, 35, 36, 145, 146, 39, 241, 22, 41, 1, - /* 870 */ 2, 307, 193, 194, 310, 311, 312, 313, 314, 315, - /* 880 */ 4, 317, 56, 41, 320, 41, 270, 41, 324, 325, - /* 890 */ 41, 270, 80, 41, 269, 19, 270, 81, 299, 81, - /* 900 */ 336, 276, 90, 242, 41, 47, 80, 226, 81, 33, - /* 910 */ 258, 286, 41, 349, 47, 290, 0, 353, 356, 241, - /* 920 */ 41, 45, 228, 81, 341, 81, 50, 81, 347, 269, - /* 930 */ 81, 55, 307, 81, 303, 310, 311, 312, 313, 314, - /* 940 */ 315, 41, 317, 117, 81, 320, 41, 269, 247, 324, - /* 950 */ 325, 326, 81, 249, 276, 79, 279, 334, 82, 309, - /* 960 */ 81, 350, 350, 338, 286, 41, 337, 20, 290, 344, - /* 970 */ 345, 113, 241, 41, 148, 149, 150, 350, 41, 153, - /* 980 */ 113, 81, 248, 45, 158, 307, 81, 47, 310, 311, - /* 990 */ 312, 313, 314, 315, 304, 317, 170, 47, 255, 173, - /* 1000 */ 269, 175, 176, 177, 64, 81, 297, 276, 92, 154, - /* 1010 */ 248, 40, 248, 81, 284, 282, 139, 286, 81, 282, - /* 1020 */ 248, 290, 20, 243, 243, 20, 348, 111, 112, 301, - /* 1030 */ 114, 115, 116, 286, 208, 253, 253, 20, 307, 0, - /* 1040 */ 294, 310, 311, 312, 313, 314, 315, 241, 317, 253, - /* 1050 */ 276, 320, 20, 287, 253, 324, 325, 326, 253, 248, - /* 1060 */ 21, 253, 269, 24, 25, 26, 27, 28, 29, 30, - /* 1070 */ 31, 32, 269, 243, 243, 269, 345, 64, 269, 269, - /* 1080 */ 241, 248, 276, 269, 269, 290, 269, 301, 251, 269, - /* 1090 */ 269, 269, 286, 269, 163, 20, 290, 300, 251, 286, - /* 1100 */ 309, 294, 251, 216, 276, 251, 346, 215, 269, 223, - /* 1110 */ 287, 346, 222, 307, 343, 276, 310, 311, 312, 313, - /* 1120 */ 314, 315, 290, 317, 290, 286, 320, 291, 290, 290, - /* 1130 */ 324, 325, 326, 211, 291, 210, 342, 207, 340, 339, - /* 1140 */ 276, 335, 241, 20, 40, 227, 307, 230, 308, 310, - /* 1150 */ 311, 312, 313, 314, 315, 351, 317, 291, 225, 320, - /* 1160 */ 80, 291, 327, 324, 325, 326, 142, 276, 290, 265, - /* 1170 */ 269, 290, 290, 288, 335, 287, 80, 276, 251, 323, - /* 1180 */ 251, 272, 357, 276, 248, 259, 251, 286, 243, 0, - /* 1190 */ 295, 290, 298, 352, 252, 302, 241, 263, 239, 0, - /* 1200 */ 352, 351, 263, 72, 351, 241, 263, 0, 307, 352, - /* 1210 */ 47, 310, 311, 312, 313, 314, 315, 174, 317, 47, - /* 1220 */ 47, 320, 47, 174, 269, 324, 325, 326, 0, 47, - /* 1230 */ 47, 276, 0, 269, 174, 47, 335, 0, 47, 0, - /* 1240 */ 276, 286, 47, 0, 80, 290, 160, 159, 113, 156, - /* 1250 */ 286, 0, 0, 152, 290, 0, 151, 0, 44, 241, - /* 1260 */ 296, 0, 307, 0, 0, 310, 311, 312, 313, 314, - /* 1270 */ 315, 307, 317, 0, 310, 311, 312, 313, 314, 315, - /* 1280 */ 0, 317, 0, 0, 0, 0, 0, 269, 0, 0, - /* 1290 */ 0, 0, 0, 0, 276, 0, 0, 0, 40, 241, - /* 1300 */ 336, 0, 0, 0, 286, 0, 0, 0, 290, 22, - /* 1310 */ 355, 0, 0, 349, 0, 0, 0, 353, 241, 40, - /* 1320 */ 0, 44, 41, 45, 14, 307, 0, 269, 310, 311, - /* 1330 */ 312, 313, 314, 315, 276, 317, 37, 14, 320, 45, - /* 1340 */ 0, 37, 324, 325, 286, 0, 269, 0, 290, 0, - /* 1350 */ 0, 38, 44, 276, 37, 0, 0, 59, 37, 0, - /* 1360 */ 0, 37, 37, 286, 37, 307, 47, 290, 310, 311, - /* 1370 */ 312, 313, 314, 315, 241, 317, 47, 47, 320, 45, - /* 1380 */ 47, 45, 324, 325, 307, 0, 0, 310, 311, 312, - /* 1390 */ 313, 314, 315, 316, 317, 318, 319, 0, 0, 47, - /* 1400 */ 22, 0, 269, 19, 47, 47, 41, 89, 47, 276, - /* 1410 */ 47, 41, 0, 47, 47, 87, 22, 33, 47, 286, - /* 1420 */ 48, 22, 0, 290, 0, 22, 47, 0, 22, 45, - /* 1430 */ 0, 22, 0, 241, 20, 51, 52, 53, 54, 55, - /* 1440 */ 307, 0, 47, 310, 311, 312, 313, 314, 315, 0, - /* 1450 */ 317, 22, 0, 320, 0, 80, 37, 41, 325, 41, - /* 1460 */ 212, 269, 81, 79, 41, 44, 82, 145, 276, 81, - /* 1470 */ 80, 80, 80, 206, 81, 41, 145, 142, 286, 44, - /* 1480 */ 80, 140, 290, 41, 212, 293, 81, 241, 81, 44, - /* 1490 */ 44, 12, 13, 161, 41, 47, 81, 41, 81, 307, - /* 1500 */ 116, 22, 310, 311, 312, 313, 314, 315, 47, 317, - /* 1510 */ 47, 47, 212, 47, 47, 269, 2, 241, 41, 81, - /* 1520 */ 178, 81, 276, 80, 44, 141, 47, 80, 144, 44, - /* 1530 */ 80, 22, 286, 180, 0, 80, 290, 37, 81, 81, - /* 1540 */ 80, 90, 80, 64, 22, 269, 162, 143, 164, 80, - /* 1550 */ 241, 140, 276, 307, 80, 44, 310, 311, 312, 313, - /* 1560 */ 314, 315, 286, 317, 44, 319, 290, 80, 80, 293, - /* 1570 */ 81, 80, 91, 81, 47, 47, 80, 47, 269, 81, - /* 1580 */ 241, 102, 80, 307, 81, 276, 310, 311, 312, 313, - /* 1590 */ 314, 315, 113, 317, 47, 286, 81, 80, 47, 290, - /* 1600 */ 81, 80, 293, 47, 80, 22, 47, 113, 269, 104, - /* 1610 */ 241, 104, 248, 80, 104, 276, 307, 104, 92, 310, - /* 1620 */ 311, 312, 313, 314, 315, 286, 317, 47, 80, 290, - /* 1630 */ 80, 22, 59, 58, 64, 156, 78, 41, 269, 47, - /* 1640 */ 276, 47, 47, 22, 47, 276, 307, 47, 47, 310, - /* 1650 */ 311, 312, 313, 314, 315, 286, 317, 178, 47, 290, - /* 1660 */ 296, 241, 64, 47, 47, 47, 47, 47, 189, 190, - /* 1670 */ 191, 47, 47, 0, 47, 45, 307, 241, 314, 310, - /* 1680 */ 311, 312, 313, 314, 315, 37, 317, 0, 47, 269, - /* 1690 */ 45, 37, 0, 329, 330, 331, 276, 333, 47, 37, - /* 1700 */ 336, 0, 45, 45, 37, 269, 286, 47, 0, 46, - /* 1710 */ 290, 47, 276, 349, 0, 0, 22, 353, 21, 358, - /* 1720 */ 22, 22, 286, 21, 241, 20, 290, 307, 358, 358, - /* 1730 */ 310, 311, 312, 313, 314, 315, 358, 317, 358, 358, - /* 1740 */ 358, 358, 241, 307, 358, 358, 310, 311, 312, 313, - /* 1750 */ 314, 315, 269, 317, 358, 358, 358, 241, 358, 276, - /* 1760 */ 358, 358, 358, 358, 358, 358, 358, 358, 358, 286, - /* 1770 */ 269, 358, 358, 290, 358, 358, 358, 276, 358, 358, - /* 1780 */ 358, 358, 358, 358, 358, 269, 358, 286, 358, 358, - /* 1790 */ 307, 290, 276, 310, 311, 312, 313, 314, 315, 358, - /* 1800 */ 317, 358, 286, 358, 241, 358, 290, 358, 307, 358, - /* 1810 */ 358, 310, 311, 312, 313, 314, 315, 358, 317, 358, - /* 1820 */ 241, 358, 358, 307, 358, 358, 310, 311, 312, 313, - /* 1830 */ 314, 315, 269, 317, 358, 358, 358, 358, 358, 276, - /* 1840 */ 358, 358, 358, 358, 358, 358, 358, 358, 269, 286, - /* 1850 */ 358, 358, 358, 290, 358, 276, 358, 358, 358, 358, - /* 1860 */ 358, 358, 358, 358, 358, 286, 358, 241, 358, 290, - /* 1870 */ 307, 358, 358, 310, 311, 312, 313, 314, 315, 358, - /* 1880 */ 317, 358, 358, 358, 358, 358, 307, 358, 358, 310, - /* 1890 */ 311, 312, 313, 314, 315, 269, 317, 241, 358, 358, - /* 1900 */ 358, 358, 276, 358, 358, 358, 358, 358, 358, 358, - /* 1910 */ 358, 358, 286, 358, 358, 358, 290, 358, 358, 358, - /* 1920 */ 358, 358, 358, 358, 358, 269, 358, 358, 358, 358, - /* 1930 */ 358, 358, 276, 307, 358, 358, 310, 311, 312, 313, - /* 1940 */ 314, 315, 286, 317, 358, 358, 290, 241, 358, 358, - /* 1950 */ 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - /* 1960 */ 358, 358, 358, 307, 358, 358, 310, 311, 312, 313, - /* 1970 */ 314, 315, 358, 317, 358, 269, 358, 241, 358, 358, - /* 1980 */ 358, 358, 276, 358, 358, 358, 358, 358, 358, 358, - /* 1990 */ 358, 358, 286, 358, 358, 358, 290, 358, 358, 358, - /* 2000 */ 358, 358, 358, 358, 358, 269, 358, 358, 358, 358, - /* 2010 */ 358, 358, 276, 307, 358, 358, 310, 311, 312, 313, - /* 2020 */ 314, 315, 286, 317, 358, 358, 290, 241, 358, 358, - /* 2030 */ 358, 358, 358, 358, 358, 358, 241, 358, 358, 358, - /* 2040 */ 358, 358, 358, 307, 358, 358, 310, 311, 312, 313, - /* 2050 */ 314, 315, 358, 317, 358, 269, 358, 358, 358, 358, - /* 2060 */ 358, 358, 276, 358, 269, 358, 358, 358, 358, 358, - /* 2070 */ 358, 276, 286, 358, 358, 358, 290, 358, 358, 358, - /* 2080 */ 358, 286, 358, 358, 358, 290, 358, 358, 358, 358, - /* 2090 */ 241, 358, 358, 307, 358, 358, 310, 311, 312, 313, - /* 2100 */ 314, 315, 307, 317, 358, 310, 311, 312, 313, 314, - /* 2110 */ 315, 358, 317, 358, 358, 358, 358, 358, 269, 358, - /* 2120 */ 358, 358, 358, 358, 358, 276, 358, 358, 358, 358, - /* 2130 */ 358, 358, 358, 358, 358, 286, 358, 358, 358, 290, - /* 2140 */ 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - /* 2150 */ 358, 358, 358, 358, 358, 358, 307, 358, 358, 310, - /* 2160 */ 311, 312, 313, 314, 315, 358, 317, + /* 690 */ 134, 135, 136, 137, 138, 60, 61, 62, 63, 182, + /* 700 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + /* 710 */ 75, 76, 77, 291, 291, 291, 156, 291, 291, 291, + /* 720 */ 291, 291, 291, 241, 37, 291, 269, 241, 255, 256, + /* 730 */ 241, 255, 256, 286, 287, 278, 42, 43, 178, 179, + /* 740 */ 308, 181, 182, 183, 184, 185, 186, 187, 188, 189, + /* 750 */ 190, 191, 192, 193, 194, 195, 145, 18, 269, 248, + /* 760 */ 4, 241, 23, 308, 332, 182, 277, 47, 22, 248, + /* 770 */ 20, 260, 0, 291, 35, 36, 287, 291, 39, 287, + /* 780 */ 291, 260, 206, 207, 64, 293, 297, 332, 277, 269, + /* 790 */ 167, 168, 41, 47, 248, 56, 307, 277, 277, 310, + /* 800 */ 311, 312, 313, 314, 315, 262, 317, 287, 265, 320, + /* 810 */ 64, 291, 248, 324, 325, 41, 300, 45, 84, 80, + /* 820 */ 47, 87, 224, 277, 260, 336, 84, 307, 41, 87, + /* 830 */ 310, 311, 312, 313, 314, 315, 44, 317, 349, 248, + /* 840 */ 320, 277, 353, 297, 324, 325, 326, 84, 102, 84, + /* 850 */ 87, 260, 87, 21, 58, 81, 117, 241, 338, 113, + /* 860 */ 314, 248, 248, 270, 344, 345, 34, 47, 277, 145, + /* 870 */ 146, 41, 80, 260, 260, 329, 330, 331, 0, 333, + /* 880 */ 1, 2, 336, 0, 64, 269, 113, 148, 149, 150, + /* 890 */ 277, 277, 153, 277, 207, 349, 242, 158, 41, 353, + /* 900 */ 22, 47, 156, 287, 41, 22, 41, 291, 258, 170, + /* 910 */ 41, 81, 173, 41, 175, 176, 177, 41, 193, 194, + /* 920 */ 241, 0, 41, 307, 178, 179, 310, 311, 312, 313, + /* 930 */ 314, 315, 182, 317, 356, 41, 320, 347, 81, 80, + /* 940 */ 324, 325, 326, 304, 81, 41, 81, 208, 269, 90, + /* 950 */ 81, 335, 269, 81, 247, 41, 277, 81, 41, 341, + /* 960 */ 249, 33, 81, 334, 280, 209, 287, 113, 309, 350, + /* 970 */ 291, 41, 241, 45, 178, 81, 350, 226, 350, 51, + /* 980 */ 52, 53, 54, 55, 41, 81, 307, 41, 41, 310, + /* 990 */ 311, 312, 313, 314, 315, 81, 317, 0, 81, 320, + /* 1000 */ 269, 337, 20, 324, 325, 326, 248, 79, 277, 45, + /* 1010 */ 82, 81, 47, 92, 335, 228, 255, 305, 287, 298, + /* 1020 */ 154, 40, 291, 248, 81, 248, 285, 81, 81, 139, + /* 1030 */ 283, 241, 111, 112, 248, 114, 115, 116, 307, 20, + /* 1040 */ 283, 310, 311, 312, 313, 314, 315, 4, 317, 243, + /* 1050 */ 243, 320, 20, 253, 302, 324, 325, 326, 287, 269, + /* 1060 */ 20, 253, 19, 295, 253, 277, 335, 277, 140, 20, + /* 1070 */ 142, 288, 144, 248, 253, 253, 33, 287, 243, 253, + /* 1080 */ 64, 291, 241, 269, 269, 269, 269, 297, 45, 92, + /* 1090 */ 248, 302, 164, 50, 243, 291, 269, 307, 55, 241, + /* 1100 */ 310, 311, 312, 313, 314, 315, 269, 317, 111, 112, + /* 1110 */ 269, 114, 115, 116, 269, 269, 269, 269, 277, 269, + /* 1120 */ 163, 251, 79, 287, 301, 82, 336, 269, 287, 295, + /* 1130 */ 277, 251, 291, 251, 20, 277, 251, 288, 297, 349, + /* 1140 */ 309, 216, 215, 353, 346, 287, 223, 292, 307, 291, + /* 1150 */ 211, 310, 311, 312, 313, 314, 315, 241, 317, 291, + /* 1160 */ 222, 210, 343, 292, 346, 307, 291, 339, 310, 311, + /* 1170 */ 312, 313, 314, 315, 207, 317, 277, 336, 320, 291, + /* 1180 */ 342, 20, 324, 325, 0, 269, 40, 327, 227, 241, + /* 1190 */ 349, 352, 340, 277, 353, 308, 230, 225, 80, 292, + /* 1200 */ 357, 291, 291, 287, 292, 142, 291, 291, 24, 25, + /* 1210 */ 26, 27, 28, 29, 30, 31, 32, 269, 351, 248, + /* 1220 */ 323, 289, 277, 307, 351, 277, 310, 311, 312, 313, + /* 1230 */ 314, 315, 288, 317, 251, 287, 320, 251, 352, 291, + /* 1240 */ 324, 325, 241, 352, 351, 265, 277, 80, 277, 273, + /* 1250 */ 259, 248, 243, 251, 299, 307, 303, 263, 310, 311, + /* 1260 */ 312, 313, 314, 315, 316, 317, 318, 319, 297, 296, + /* 1270 */ 269, 263, 252, 263, 239, 0, 0, 72, 277, 0, + /* 1280 */ 47, 174, 47, 47, 47, 314, 174, 0, 287, 47, + /* 1290 */ 47, 174, 291, 0, 47, 0, 47, 0, 47, 241, + /* 1300 */ 329, 330, 331, 0, 333, 80, 159, 336, 307, 160, + /* 1310 */ 113, 310, 311, 312, 313, 314, 315, 0, 317, 156, + /* 1320 */ 349, 320, 0, 152, 353, 151, 325, 269, 19, 0, + /* 1330 */ 0, 0, 44, 0, 0, 277, 0, 0, 0, 0, + /* 1340 */ 0, 0, 33, 22, 40, 287, 241, 0, 0, 291, + /* 1350 */ 0, 0, 294, 0, 45, 0, 0, 0, 0, 0, + /* 1360 */ 51, 52, 53, 54, 55, 307, 0, 0, 310, 311, + /* 1370 */ 312, 313, 314, 315, 269, 317, 0, 0, 0, 0, + /* 1380 */ 0, 0, 277, 0, 0, 241, 0, 41, 79, 40, + /* 1390 */ 0, 82, 287, 0, 0, 0, 291, 37, 44, 14, + /* 1400 */ 38, 14, 37, 0, 0, 44, 37, 0, 0, 45, + /* 1410 */ 47, 59, 307, 269, 0, 310, 311, 312, 313, 314, + /* 1420 */ 315, 277, 317, 0, 0, 116, 37, 0, 37, 47, + /* 1430 */ 0, 287, 87, 45, 37, 291, 241, 37, 294, 47, + /* 1440 */ 0, 45, 0, 0, 45, 47, 0, 22, 47, 47, + /* 1450 */ 141, 307, 47, 144, 310, 311, 312, 313, 314, 315, + /* 1460 */ 355, 317, 89, 47, 269, 241, 47, 41, 0, 41, + /* 1470 */ 22, 162, 277, 164, 22, 0, 47, 22, 47, 0, + /* 1480 */ 47, 47, 287, 48, 22, 0, 291, 22, 0, 20, + /* 1490 */ 0, 47, 22, 269, 0, 0, 161, 241, 0, 41, + /* 1500 */ 80, 277, 307, 37, 41, 310, 311, 312, 313, 314, + /* 1510 */ 315, 287, 317, 145, 319, 291, 145, 142, 294, 212, + /* 1520 */ 81, 41, 81, 41, 206, 269, 81, 80, 44, 80, + /* 1530 */ 80, 307, 41, 277, 310, 311, 312, 313, 314, 315, + /* 1540 */ 44, 317, 81, 287, 80, 44, 140, 291, 81, 41, + /* 1550 */ 294, 44, 81, 241, 212, 41, 212, 81, 47, 2, + /* 1560 */ 47, 41, 47, 307, 47, 47, 310, 311, 312, 313, + /* 1570 */ 314, 315, 47, 317, 81, 44, 44, 80, 22, 143, + /* 1580 */ 81, 269, 80, 80, 241, 80, 80, 178, 0, 277, + /* 1590 */ 180, 81, 37, 140, 90, 44, 44, 81, 22, 287, + /* 1600 */ 81, 80, 80, 291, 80, 47, 80, 80, 80, 47, + /* 1610 */ 81, 81, 269, 241, 91, 80, 47, 80, 47, 307, + /* 1620 */ 277, 81, 310, 311, 312, 313, 314, 315, 80, 317, + /* 1630 */ 287, 81, 47, 80, 291, 81, 47, 104, 104, 80, + /* 1640 */ 104, 269, 104, 22, 80, 80, 47, 80, 47, 277, + /* 1650 */ 307, 22, 92, 310, 311, 312, 313, 314, 315, 287, + /* 1660 */ 317, 59, 241, 291, 58, 78, 41, 64, 12, 13, + /* 1670 */ 47, 47, 22, 241, 113, 47, 64, 47, 22, 307, + /* 1680 */ 47, 47, 310, 311, 312, 313, 314, 315, 47, 317, + /* 1690 */ 269, 47, 47, 47, 47, 47, 47, 0, 277, 47, + /* 1700 */ 47, 269, 45, 47, 37, 0, 47, 45, 287, 277, + /* 1710 */ 37, 0, 291, 47, 45, 37, 0, 47, 37, 287, + /* 1720 */ 64, 45, 0, 291, 241, 0, 47, 0, 307, 46, + /* 1730 */ 22, 310, 311, 312, 313, 314, 315, 22, 317, 307, + /* 1740 */ 21, 20, 310, 311, 312, 313, 314, 315, 22, 317, + /* 1750 */ 21, 358, 269, 241, 358, 358, 358, 358, 102, 358, + /* 1760 */ 277, 358, 358, 358, 358, 358, 358, 358, 358, 113, + /* 1770 */ 287, 358, 358, 358, 291, 358, 358, 358, 358, 358, + /* 1780 */ 358, 269, 358, 358, 358, 241, 358, 358, 358, 277, + /* 1790 */ 307, 358, 358, 310, 311, 312, 313, 314, 315, 287, + /* 1800 */ 317, 358, 358, 291, 358, 358, 358, 358, 358, 358, + /* 1810 */ 358, 358, 156, 269, 358, 358, 358, 358, 358, 307, + /* 1820 */ 358, 277, 310, 311, 312, 313, 314, 315, 358, 317, + /* 1830 */ 358, 287, 358, 358, 178, 291, 358, 358, 358, 358, + /* 1840 */ 358, 241, 358, 358, 358, 189, 190, 191, 358, 358, + /* 1850 */ 358, 307, 358, 358, 310, 311, 312, 313, 314, 315, + /* 1860 */ 358, 317, 358, 358, 358, 358, 358, 358, 358, 269, + /* 1870 */ 358, 358, 241, 358, 358, 358, 358, 277, 358, 358, + /* 1880 */ 358, 358, 358, 358, 358, 358, 358, 287, 358, 358, + /* 1890 */ 358, 291, 358, 358, 358, 358, 358, 358, 358, 358, + /* 1900 */ 269, 241, 358, 358, 358, 358, 358, 307, 277, 358, + /* 1910 */ 310, 311, 312, 313, 314, 315, 358, 317, 287, 358, + /* 1920 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 269, + /* 1930 */ 358, 358, 241, 358, 358, 358, 358, 277, 307, 358, + /* 1940 */ 358, 310, 311, 312, 313, 314, 315, 287, 317, 358, + /* 1950 */ 358, 291, 358, 358, 358, 358, 358, 358, 358, 358, + /* 1960 */ 269, 241, 358, 358, 358, 358, 358, 307, 277, 358, + /* 1970 */ 310, 311, 312, 313, 314, 315, 358, 317, 287, 358, + /* 1980 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 269, + /* 1990 */ 358, 358, 358, 358, 358, 358, 358, 277, 307, 358, + /* 2000 */ 358, 310, 311, 312, 313, 314, 315, 287, 317, 358, + /* 2010 */ 358, 291, 241, 358, 358, 358, 358, 358, 358, 358, + /* 2020 */ 358, 358, 358, 241, 358, 358, 358, 307, 358, 358, + /* 2030 */ 310, 311, 312, 313, 314, 315, 358, 317, 358, 358, + /* 2040 */ 269, 358, 358, 358, 358, 358, 358, 358, 277, 358, + /* 2050 */ 358, 269, 358, 358, 358, 358, 358, 358, 287, 277, + /* 2060 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 287, + /* 2070 */ 358, 358, 358, 291, 358, 358, 358, 241, 307, 358, + /* 2080 */ 358, 310, 311, 312, 313, 314, 315, 358, 317, 307, + /* 2090 */ 358, 358, 310, 311, 312, 313, 314, 315, 358, 317, + /* 2100 */ 358, 358, 358, 358, 358, 269, 358, 358, 358, 358, + /* 2110 */ 358, 358, 358, 277, 358, 358, 358, 358, 358, 358, + /* 2120 */ 358, 358, 358, 287, 358, 358, 358, 291, 358, 358, + /* 2130 */ 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + /* 2140 */ 358, 358, 358, 307, 358, 358, 310, 311, 312, 313, + /* 2150 */ 314, 315, 358, 317, }; #define YY_SHIFT_COUNT (604) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1715) +#define YY_SHIFT_MAX (1729) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 826, 0, 0, 48, 96, 96, 96, 96, 280, 280, + /* 0 */ 739, 0, 0, 48, 96, 96, 96, 96, 280, 280, /* 10 */ 96, 96, 328, 376, 560, 376, 376, 376, 376, 376, /* 20 */ 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - /* 30 */ 376, 376, 376, 376, 376, 376, 376, 376, 95, 95, - /* 40 */ 375, 375, 375, 1479, 1479, 1479, 100, 50, 171, 45, - /* 50 */ 45, 342, 342, 246, 171, 171, 45, 45, 45, 45, - /* 60 */ 45, 45, 17, 45, 201, 323, 651, 201, 45, 45, - /* 70 */ 201, 45, 201, 201, 651, 201, 45, 324, 556, 63, - /* 80 */ 14, 14, 13, 479, 422, 479, 479, 479, 479, 479, - /* 90 */ 479, 479, 479, 479, 479, 479, 479, 479, 479, 479, - /* 100 */ 479, 479, 479, 479, 584, 614, 524, 524, 301, 281, - /* 110 */ 432, 432, 432, 447, 281, 720, 651, 201, 201, 651, - /* 120 */ 348, 763, 319, 319, 319, 319, 319, 319, 319, 1384, - /* 130 */ 1039, 377, 349, 28, 104, 230, 465, 466, 735, 102, - /* 140 */ 715, 691, 617, 619, 617, 396, 396, 396, 268, 676, - /* 150 */ 947, 938, 950, 855, 947, 947, 971, 877, 877, 947, - /* 160 */ 1002, 1002, 1005, 17, 651, 17, 1017, 17, 720, 1032, - /* 170 */ 17, 17, 947, 17, 1002, 201, 201, 201, 201, 201, - /* 180 */ 201, 201, 201, 201, 201, 201, 947, 1002, 1013, 1005, - /* 190 */ 324, 931, 651, 324, 1017, 324, 720, 1032, 324, 1075, - /* 200 */ 887, 892, 1013, 887, 892, 1013, 1013, 201, 886, 890, - /* 210 */ 922, 925, 930, 720, 1123, 1104, 918, 933, 917, 918, - /* 220 */ 933, 918, 933, 1080, 892, 1013, 1013, 892, 1013, 1024, - /* 230 */ 720, 1032, 324, 348, 324, 720, 1096, 763, 947, 324, - /* 240 */ 1002, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 244, - /* 250 */ 563, 141, 876, 706, 916, 241, 84, 355, 515, 419, - /* 260 */ 85, 282, 282, 282, 282, 282, 282, 282, 282, 239, - /* 270 */ 469, 470, 554, 648, 574, 36, 36, 36, 36, 792, - /* 280 */ 767, 744, 759, 768, 769, 819, 829, 845, 618, 667, - /* 290 */ 718, 816, 818, 827, 868, 679, 681, 694, 842, 145, - /* 300 */ 844, 455, 846, 849, 852, 863, 871, 858, 867, 879, - /* 310 */ 900, 905, 924, 932, 937, 812, 940, 1189, 1199, 1131, - /* 320 */ 1207, 1163, 1043, 1172, 1173, 1175, 1049, 1228, 1182, 1183, - /* 330 */ 1060, 1232, 1188, 1237, 1191, 1239, 1195, 1243, 1164, 1086, - /* 340 */ 1088, 1135, 1093, 1251, 1252, 1101, 1105, 1255, 1257, 1214, - /* 350 */ 1261, 1263, 1264, 1273, 1280, 1282, 1283, 1284, 1285, 1286, - /* 360 */ 1288, 1289, 1290, 1291, 1292, 1293, 1295, 1296, 1258, 1297, - /* 370 */ 1301, 1302, 1303, 1305, 1306, 1287, 1307, 1311, 1312, 1314, - /* 380 */ 1315, 1316, 1279, 1299, 1281, 1310, 1277, 1323, 1308, 1320, - /* 390 */ 1313, 1304, 1326, 1345, 1347, 1349, 1317, 1350, 1298, 1355, - /* 400 */ 1356, 1319, 1278, 1321, 1359, 1329, 1294, 1324, 1340, 1330, - /* 410 */ 1334, 1325, 1360, 1333, 1336, 1327, 1385, 1386, 1397, 1398, - /* 420 */ 1318, 1328, 1352, 1378, 1401, 1357, 1358, 1361, 1363, 1365, - /* 430 */ 1370, 1366, 1367, 1371, 1412, 1394, 1424, 1399, 1372, 1422, - /* 440 */ 1403, 1379, 1427, 1406, 1430, 1409, 1414, 1432, 1322, 1395, - /* 450 */ 1441, 1332, 1429, 1331, 1335, 1449, 1452, 1454, 1375, 1419, - /* 460 */ 1341, 1416, 1418, 1248, 1381, 1423, 1388, 1390, 1391, 1392, - /* 470 */ 1393, 1434, 1421, 1435, 1400, 1442, 1272, 1405, 1407, 1445, - /* 480 */ 1267, 1453, 1446, 1415, 1456, 1300, 1417, 1448, 1461, 1463, - /* 490 */ 1464, 1466, 1467, 1417, 1514, 1342, 1477, 1438, 1443, 1440, - /* 500 */ 1480, 1447, 1450, 1485, 1509, 1353, 1455, 1457, 1458, 1460, - /* 510 */ 1462, 1404, 1469, 1534, 1500, 1411, 1474, 1451, 1511, 1520, - /* 520 */ 1487, 1489, 1488, 1522, 1491, 1481, 1492, 1527, 1528, 1496, - /* 530 */ 1498, 1530, 1502, 1503, 1547, 1517, 1515, 1551, 1521, 1519, - /* 540 */ 1556, 1524, 1505, 1507, 1510, 1513, 1583, 1526, 1533, 1548, - /* 550 */ 1559, 1550, 1494, 1580, 1609, 1573, 1575, 1570, 1558, 1596, - /* 560 */ 1592, 1594, 1595, 1597, 1600, 1621, 1601, 1611, 1598, 1365, - /* 570 */ 1616, 1370, 1617, 1618, 1619, 1620, 1624, 1625, 1673, 1627, - /* 580 */ 1630, 1648, 1687, 1641, 1645, 1654, 1692, 1651, 1657, 1662, - /* 590 */ 1701, 1660, 1658, 1667, 1708, 1664, 1663, 1714, 1715, 1694, - /* 600 */ 1697, 1698, 1699, 1702, 1705, + /* 30 */ 376, 376, 376, 376, 376, 376, 376, 376, 37, 37, + /* 40 */ 68, 68, 68, 1656, 1656, 1656, 1656, 64, 271, 179, + /* 50 */ 18, 18, 13, 13, 123, 179, 179, 18, 18, 18, + /* 60 */ 18, 18, 18, 35, 18, 182, 190, 314, 182, 18, + /* 70 */ 18, 182, 18, 182, 182, 314, 182, 18, 334, 556, + /* 80 */ 343, 107, 107, 192, 312, 746, 746, 746, 746, 746, + /* 90 */ 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, + /* 100 */ 746, 746, 746, 746, 441, 580, 110, 110, 206, 720, + /* 110 */ 393, 393, 393, 244, 720, 384, 314, 182, 182, 314, + /* 120 */ 356, 466, 549, 549, 549, 549, 549, 549, 549, 1309, + /* 130 */ 294, 197, 21, 78, 268, 279, 517, 583, 694, 292, + /* 140 */ 502, 611, 576, 687, 576, 598, 598, 598, 756, 750, + /* 150 */ 982, 964, 965, 866, 982, 982, 981, 890, 890, 982, + /* 160 */ 1019, 1019, 1032, 35, 314, 35, 1040, 35, 384, 1049, + /* 170 */ 35, 35, 982, 35, 1019, 182, 182, 182, 182, 182, + /* 180 */ 182, 182, 182, 182, 182, 182, 982, 1019, 1016, 1032, + /* 190 */ 334, 957, 314, 334, 1040, 334, 384, 1049, 334, 1114, + /* 200 */ 925, 927, 1016, 925, 927, 1016, 1016, 182, 923, 938, + /* 210 */ 939, 951, 967, 384, 1161, 1146, 961, 972, 966, 961, + /* 220 */ 972, 961, 972, 1118, 927, 1016, 1016, 927, 1016, 1063, + /* 230 */ 384, 1049, 334, 356, 334, 384, 1167, 466, 982, 334, + /* 240 */ 1019, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 635, + /* 250 */ 928, 1184, 1043, 921, 997, 119, 14, 30, 485, 126, + /* 260 */ 498, 354, 354, 354, 354, 354, 354, 354, 354, 309, + /* 270 */ 321, 415, 404, 8, 445, 622, 622, 622, 622, 772, + /* 280 */ 774, 734, 742, 763, 765, 435, 878, 883, 832, 623, + /* 290 */ 724, 830, 857, 863, 879, 725, 751, 787, 865, 796, + /* 300 */ 869, 792, 872, 876, 881, 894, 904, 773, 854, 914, + /* 310 */ 917, 930, 943, 946, 947, 859, 820, 1275, 1276, 1205, + /* 320 */ 1279, 1233, 1107, 1235, 1236, 1237, 1112, 1287, 1242, 1243, + /* 330 */ 1117, 1293, 1247, 1295, 1249, 1297, 1251, 1303, 1225, 1149, + /* 340 */ 1147, 1197, 1163, 1317, 1322, 1171, 1174, 1329, 1330, 1288, + /* 350 */ 1331, 1333, 1334, 1336, 1337, 1338, 1339, 1340, 1341, 1347, + /* 360 */ 1348, 1350, 1351, 1353, 1355, 1356, 1357, 1358, 1304, 1359, + /* 370 */ 1366, 1367, 1376, 1377, 1378, 1321, 1379, 1380, 1381, 1383, + /* 380 */ 1384, 1386, 1349, 1360, 1346, 1385, 1354, 1387, 1361, 1390, + /* 390 */ 1362, 1365, 1393, 1394, 1395, 1403, 1369, 1404, 1352, 1407, + /* 400 */ 1408, 1363, 1364, 1389, 1414, 1382, 1388, 1391, 1423, 1392, + /* 410 */ 1396, 1397, 1424, 1398, 1399, 1400, 1427, 1430, 1440, 1442, + /* 420 */ 1373, 1345, 1401, 1425, 1443, 1402, 1405, 1416, 1419, 1426, + /* 430 */ 1428, 1429, 1431, 1433, 1446, 1448, 1468, 1452, 1435, 1475, + /* 440 */ 1455, 1434, 1479, 1462, 1485, 1465, 1469, 1488, 1368, 1444, + /* 450 */ 1490, 1335, 1470, 1371, 1375, 1494, 1495, 1498, 1420, 1466, + /* 460 */ 1406, 1458, 1463, 1307, 1439, 1480, 1441, 1447, 1449, 1450, + /* 470 */ 1445, 1482, 1484, 1496, 1464, 1491, 1342, 1461, 1467, 1501, + /* 480 */ 1318, 1508, 1507, 1471, 1514, 1344, 1476, 1511, 1513, 1515, + /* 490 */ 1517, 1518, 1525, 1476, 1557, 1409, 1520, 1493, 1497, 1499, + /* 500 */ 1531, 1502, 1503, 1532, 1556, 1410, 1505, 1510, 1516, 1506, + /* 510 */ 1521, 1436, 1522, 1588, 1555, 1453, 1524, 1504, 1551, 1552, + /* 520 */ 1526, 1519, 1527, 1576, 1528, 1523, 1529, 1558, 1562, 1535, + /* 530 */ 1530, 1569, 1537, 1540, 1571, 1548, 1550, 1585, 1553, 1554, + /* 540 */ 1589, 1559, 1533, 1534, 1536, 1538, 1621, 1560, 1564, 1565, + /* 550 */ 1599, 1567, 1561, 1601, 1629, 1602, 1606, 1603, 1587, 1625, + /* 560 */ 1623, 1624, 1628, 1630, 1633, 1650, 1634, 1641, 1612, 1426, + /* 570 */ 1644, 1428, 1645, 1646, 1647, 1648, 1649, 1652, 1697, 1653, + /* 580 */ 1657, 1667, 1705, 1659, 1662, 1673, 1711, 1666, 1669, 1678, + /* 590 */ 1716, 1670, 1676, 1681, 1722, 1679, 1683, 1725, 1727, 1708, + /* 600 */ 1719, 1715, 1726, 1729, 1721, }; #define YY_REDUCE_COUNT (248) -#define YY_REDUCE_MIN (-317) -#define YY_REDUCE_MAX (1849) +#define YY_REDUCE_MIN (-335) +#define YY_REDUCE_MAX (1836) static const short yy_reduce_ofst[] = { - /* 0 */ 38, 489, 564, 625, 731, 806, 839, 901, 315, 964, - /* 10 */ 1018, 1058, 1077, -223, 1133, 90, 678, 955, 1192, 1246, - /* 20 */ 1276, 1309, 1339, 1369, 1420, 1436, 1483, 1501, 1516, 1563, - /* 30 */ 1579, 1626, 1656, 1706, 1736, 1786, 1795, 1849, -191, 1364, - /* 40 */ 23, 390, 460, -224, 235, -282, 257, -280, 197, -141, - /* 50 */ -112, -244, -240, -317, -202, -190, -243, 200, 327, 361, - /* 60 */ 383, 449, -152, 450, -221, 60, -64, -144, 337, 452, - /* 70 */ 55, 508, 78, 223, 47, 117, 511, -250, -177, -312, - /* 80 */ -312, -312, -113, 212, -34, 298, 308, 354, 371, 405, - /* 90 */ 412, 424, 434, 474, 476, 477, 490, 491, 492, 496, - /* 100 */ 520, 521, 522, 542, 70, -139, 161, 289, 326, 399, - /* 110 */ -277, 149, 291, -114, 517, 493, 502, 325, 267, 530, - /* 120 */ 495, 538, -259, -255, 569, 577, 616, 621, 626, 599, - /* 130 */ 661, 652, 562, 581, 631, 583, 660, 660, 701, 704, - /* 140 */ 677, 650, 623, 623, 623, 611, 612, 627, 629, 660, - /* 150 */ 734, 690, 743, 709, 762, 764, 730, 733, 737, 772, - /* 160 */ 780, 781, 728, 782, 747, 783, 746, 796, 774, 766, - /* 170 */ 801, 805, 811, 808, 830, 793, 803, 809, 810, 814, - /* 180 */ 815, 817, 820, 821, 822, 824, 833, 831, 795, 786, - /* 190 */ 837, 797, 813, 847, 807, 851, 828, 823, 854, 791, - /* 200 */ 760, 836, 832, 765, 843, 834, 838, 660, 771, 794, - /* 210 */ 798, 800, 623, 864, 840, 835, 841, 804, 825, 848, - /* 220 */ 850, 857, 853, 856, 866, 878, 881, 870, 882, 885, - /* 230 */ 891, 888, 927, 904, 929, 907, 909, 926, 936, 935, - /* 240 */ 945, 894, 893, 895, 934, 939, 943, 942, 959, + /* 0 */ -190, -238, 489, 520, 308, 616, 679, 731, 790, 841, + /* 10 */ 858, 916, 948, -140, 1001, 1058, 138, 1105, 1144, 1195, + /* 20 */ 1224, 1256, 1312, 1343, 1372, 1421, 1432, 1483, 1512, 1544, + /* 30 */ 1600, 1631, 1660, 1691, 1720, 1771, 1782, 1836, 546, 971, + /* 40 */ 88, -1, 113, -266, -181, 46, 103, 239, -286, -85, + /* 50 */ -163, 87, -240, -223, -335, -334, -253, -49, 85, 135, + /* 60 */ 248, 331, 511, -172, 521, -124, -111, 56, 136, 564, + /* 70 */ 591, -21, 613, 216, 130, 152, 320, 614, -173, -177, + /* 80 */ -256, -256, -256, -188, -105, -86, 213, 261, 287, 370, + /* 90 */ 375, 385, 422, 423, 424, 426, 427, 428, 429, 430, + /* 100 */ 431, 434, 482, 486, -100, 4, 305, 348, 63, 473, + /* 110 */ -83, 432, 455, 355, 476, 94, 492, 457, -8, 447, + /* 120 */ 543, -95, -270, 225, 235, 317, 369, 390, 593, 516, + /* 130 */ 654, 650, 578, 590, 639, 618, 683, 683, 707, 711, + /* 140 */ 684, 659, 629, 629, 629, 619, 626, 628, 664, 683, + /* 150 */ 758, 712, 761, 721, 775, 777, 741, 747, 757, 786, + /* 160 */ 806, 807, 752, 800, 771, 808, 768, 811, 788, 783, + /* 170 */ 821, 822, 825, 826, 835, 814, 815, 816, 817, 827, + /* 180 */ 837, 845, 846, 847, 848, 850, 842, 851, 804, 789, + /* 190 */ 870, 823, 836, 880, 834, 882, 853, 849, 885, 831, + /* 200 */ 798, 855, 868, 818, 871, 875, 888, 683, 819, 838, + /* 210 */ 852, 828, 629, 899, 887, 860, 839, 867, 843, 886, + /* 220 */ 873, 891, 893, 897, 907, 910, 911, 912, 915, 932, + /* 230 */ 945, 944, 983, 980, 986, 969, 976, 991, 1003, 1002, + /* 240 */ 1009, 955, 953, 973, 994, 1008, 1010, 1020, 1035, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, @@ -753,9 +751,9 @@ static const YYACTIONTYPE yy_default[] = { /* 30 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, /* 40 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, /* 50 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 60 */ 1345, 1345, 1414, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 70 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1412, 1552, 1345, - /* 80 */ 1717, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, + /* 60 */ 1345, 1345, 1345, 1414, 1345, 1345, 1345, 1345, 1345, 1345, + /* 70 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1412, 1552, + /* 80 */ 1345, 1717, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, /* 90 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, /* 100 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1414, 1345, /* 110 */ 1728, 1728, 1728, 1412, 1345, 1345, 1345, 1345, 1345, 1345, @@ -1423,42 +1421,42 @@ static const char *const yyTokenName[] = { /* 268 */ "alter_table_options", /* 269 */ "column_name", /* 270 */ "type_name", - /* 271 */ "create_subtable_clause", - /* 272 */ "specific_tags_opt", - /* 273 */ "literal_list", - /* 274 */ "drop_table_clause", - /* 275 */ "col_name_list", - /* 276 */ "table_name", - /* 277 */ "column_def", - /* 278 */ "func_name_list", - /* 279 */ "alter_table_option", - /* 280 */ "col_name", - /* 281 */ "db_name_cond_opt", - /* 282 */ "like_pattern_opt", - /* 283 */ "table_name_cond", - /* 284 */ "from_db_opt", - /* 285 */ "func_name", - /* 286 */ "function_name", - /* 287 */ "index_name", - /* 288 */ "index_options", - /* 289 */ "func_list", - /* 290 */ "duration_literal", - /* 291 */ "sliding_opt", - /* 292 */ "func", - /* 293 */ "expression_list", - /* 294 */ "topic_name", - /* 295 */ "topic_options", - /* 296 */ "query_expression", - /* 297 */ "analyze_opt", - /* 298 */ "explain_options", - /* 299 */ "agg_func_opt", - /* 300 */ "bufsize_opt", - /* 301 */ "stream_name", - /* 302 */ "stream_options", - /* 303 */ "into_opt", - /* 304 */ "dnode_list", - /* 305 */ "signed", - /* 306 */ "signed_literal", + /* 271 */ "signed_literal", + /* 272 */ "create_subtable_clause", + /* 273 */ "specific_tags_opt", + /* 274 */ "literal_list", + /* 275 */ "drop_table_clause", + /* 276 */ "col_name_list", + /* 277 */ "table_name", + /* 278 */ "column_def", + /* 279 */ "func_name_list", + /* 280 */ "alter_table_option", + /* 281 */ "col_name", + /* 282 */ "db_name_cond_opt", + /* 283 */ "like_pattern_opt", + /* 284 */ "table_name_cond", + /* 285 */ "from_db_opt", + /* 286 */ "func_name", + /* 287 */ "function_name", + /* 288 */ "index_name", + /* 289 */ "index_options", + /* 290 */ "func_list", + /* 291 */ "duration_literal", + /* 292 */ "sliding_opt", + /* 293 */ "func", + /* 294 */ "expression_list", + /* 295 */ "topic_name", + /* 296 */ "topic_options", + /* 297 */ "query_expression", + /* 298 */ "analyze_opt", + /* 299 */ "explain_options", + /* 300 */ "agg_func_opt", + /* 301 */ "bufsize_opt", + /* 302 */ "stream_name", + /* 303 */ "stream_options", + /* 304 */ "into_opt", + /* 305 */ "dnode_list", + /* 306 */ "signed", /* 307 */ "literal_func", /* 308 */ "table_alias", /* 309 */ "column_alias", @@ -1638,7 +1636,7 @@ static const char *const yyRuleName[] = { /* 118 */ "alter_table_clause ::= full_table_name DROP TAG column_name", /* 119 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", /* 120 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 121 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", + /* 121 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", /* 122 */ "multi_create_clause ::= create_subtable_clause", /* 123 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", /* 124 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options", @@ -2104,26 +2102,26 @@ static void yy_destructor( case 263: /* table_options */ case 267: /* alter_table_clause */ case 268: /* alter_table_options */ - case 271: /* create_subtable_clause */ - case 274: /* drop_table_clause */ - case 277: /* column_def */ - case 280: /* col_name */ - case 281: /* db_name_cond_opt */ - case 282: /* like_pattern_opt */ - case 283: /* table_name_cond */ - case 284: /* from_db_opt */ - case 285: /* func_name */ - case 288: /* index_options */ - case 290: /* duration_literal */ - case 291: /* sliding_opt */ - case 292: /* func */ - case 295: /* topic_options */ - case 296: /* query_expression */ - case 298: /* explain_options */ - case 302: /* stream_options */ - case 303: /* into_opt */ - case 305: /* signed */ - case 306: /* signed_literal */ + case 271: /* signed_literal */ + case 272: /* create_subtable_clause */ + case 275: /* drop_table_clause */ + case 278: /* column_def */ + case 281: /* col_name */ + case 282: /* db_name_cond_opt */ + case 283: /* like_pattern_opt */ + case 284: /* table_name_cond */ + case 285: /* from_db_opt */ + case 286: /* func_name */ + case 289: /* index_options */ + case 291: /* duration_literal */ + case 292: /* sliding_opt */ + case 293: /* func */ + case 296: /* topic_options */ + case 297: /* query_expression */ + case 299: /* explain_options */ + case 303: /* stream_options */ + case 304: /* into_opt */ + case 306: /* signed */ case 307: /* literal_func */ case 310: /* expression */ case 311: /* pseudo_column */ @@ -2161,7 +2159,7 @@ static void yy_destructor( case 239: /* account_options */ case 240: /* alter_account_options */ case 242: /* alter_account_option */ - case 300: /* bufsize_opt */ + case 301: /* bufsize_opt */ { } @@ -2172,11 +2170,11 @@ static void yy_destructor( case 249: /* dnode_endpoint */ case 250: /* dnode_host_name */ case 269: /* column_name */ - case 276: /* table_name */ - case 286: /* function_name */ - case 287: /* index_name */ - case 294: /* topic_name */ - case 301: /* stream_name */ + case 277: /* table_name */ + case 287: /* function_name */ + case 288: /* index_name */ + case 295: /* topic_name */ + case 302: /* stream_name */ case 308: /* table_alias */ case 309: /* column_alias */ case 315: /* star_func */ @@ -2195,8 +2193,8 @@ static void yy_destructor( break; case 251: /* not_exists_opt */ case 253: /* exists_opt */ - case 297: /* analyze_opt */ - case 299: /* agg_func_opt */ + case 298: /* analyze_opt */ + case 300: /* agg_func_opt */ case 337: /* set_quantifier_opt */ { @@ -2210,13 +2208,13 @@ static void yy_destructor( case 264: /* multi_create_clause */ case 265: /* tags_def */ case 266: /* multi_drop_clause */ - case 272: /* specific_tags_opt */ - case 273: /* literal_list */ - case 275: /* col_name_list */ - case 278: /* func_name_list */ - case 289: /* func_list */ - case 293: /* expression_list */ - case 304: /* dnode_list */ + case 273: /* specific_tags_opt */ + case 274: /* literal_list */ + case 276: /* col_name_list */ + case 279: /* func_name_list */ + case 290: /* func_list */ + case 294: /* expression_list */ + case 305: /* dnode_list */ case 316: /* star_func_para_list */ case 318: /* other_para_list */ case 338: /* select_list */ @@ -2231,7 +2229,7 @@ static void yy_destructor( } break; case 258: /* alter_db_option */ - case 279: /* alter_table_option */ + case 280: /* alter_table_option */ { } @@ -2682,21 +2680,21 @@ static const struct { { 267, -4 }, /* (118) alter_table_clause ::= full_table_name DROP TAG column_name */ { 267, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ { 267, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 267, -6 }, /* (121) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 267, -6 }, /* (121) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ { 264, -1 }, /* (122) multi_create_clause ::= create_subtable_clause */ { 264, -2 }, /* (123) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 271, -10 }, /* (124) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 272, -10 }, /* (124) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ { 266, -1 }, /* (125) multi_drop_clause ::= drop_table_clause */ { 266, -2 }, /* (126) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 274, -2 }, /* (127) drop_table_clause ::= exists_opt full_table_name */ - { 272, 0 }, /* (128) specific_tags_opt ::= */ - { 272, -3 }, /* (129) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 275, -2 }, /* (127) drop_table_clause ::= exists_opt full_table_name */ + { 273, 0 }, /* (128) specific_tags_opt ::= */ + { 273, -3 }, /* (129) specific_tags_opt ::= NK_LP col_name_list NK_RP */ { 260, -1 }, /* (130) full_table_name ::= table_name */ { 260, -3 }, /* (131) full_table_name ::= db_name NK_DOT table_name */ { 261, -1 }, /* (132) column_def_list ::= column_def */ { 261, -3 }, /* (133) column_def_list ::= column_def_list NK_COMMA column_def */ - { 277, -2 }, /* (134) column_def ::= column_name type_name */ - { 277, -4 }, /* (135) column_def ::= column_name type_name COMMENT NK_STRING */ + { 278, -2 }, /* (134) column_def ::= column_name type_name */ + { 278, -4 }, /* (135) column_def ::= column_name type_name COMMENT NK_STRING */ { 270, -1 }, /* (136) type_name ::= BOOL */ { 270, -1 }, /* (137) type_name ::= TINYINT */ { 270, -1 }, /* (138) type_name ::= SMALLINT */ @@ -2732,11 +2730,11 @@ static const struct { { 263, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ { 268, -1 }, /* (169) alter_table_options ::= alter_table_option */ { 268, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ - { 279, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ - { 279, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ - { 275, -1 }, /* (173) col_name_list ::= col_name */ - { 275, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ - { 280, -1 }, /* (175) col_name ::= column_name */ + { 280, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ + { 280, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ + { 276, -1 }, /* (173) col_name_list ::= col_name */ + { 276, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ + { 281, -1 }, /* (175) col_name ::= column_name */ { 238, -2 }, /* (176) cmd ::= SHOW DNODES */ { 238, -2 }, /* (177) cmd ::= SHOW USERS */ { 238, -2 }, /* (178) cmd ::= SHOW DATABASES */ @@ -2765,64 +2763,64 @@ static const struct { { 238, -2 }, /* (201) cmd ::= SHOW SNODES */ { 238, -2 }, /* (202) cmd ::= SHOW CLUSTER */ { 238, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ - { 281, 0 }, /* (204) db_name_cond_opt ::= */ - { 281, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ - { 282, 0 }, /* (206) like_pattern_opt ::= */ - { 282, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ - { 283, -1 }, /* (208) table_name_cond ::= table_name */ - { 284, 0 }, /* (209) from_db_opt ::= */ - { 284, -2 }, /* (210) from_db_opt ::= FROM db_name */ - { 278, -1 }, /* (211) func_name_list ::= func_name */ - { 278, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ - { 285, -1 }, /* (213) func_name ::= function_name */ + { 282, 0 }, /* (204) db_name_cond_opt ::= */ + { 282, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ + { 283, 0 }, /* (206) like_pattern_opt ::= */ + { 283, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ + { 284, -1 }, /* (208) table_name_cond ::= table_name */ + { 285, 0 }, /* (209) from_db_opt ::= */ + { 285, -2 }, /* (210) from_db_opt ::= FROM db_name */ + { 279, -1 }, /* (211) func_name_list ::= func_name */ + { 279, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ + { 286, -1 }, /* (213) func_name ::= function_name */ { 238, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ { 238, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ { 238, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 288, 0 }, /* (217) index_options ::= */ - { 288, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 288, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 289, -1 }, /* (220) func_list ::= func */ - { 289, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ - { 292, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ + { 289, 0 }, /* (217) index_options ::= */ + { 289, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 289, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 290, -1 }, /* (220) func_list ::= func */ + { 290, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ + { 293, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ { 238, -7 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression */ { 238, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name */ { 238, -4 }, /* (225) cmd ::= DROP TOPIC exists_opt topic_name */ - { 295, 0 }, /* (226) topic_options ::= */ - { 295, -3 }, /* (227) topic_options ::= topic_options WITH TABLE */ - { 295, -3 }, /* (228) topic_options ::= topic_options WITH SCHEMA */ - { 295, -3 }, /* (229) topic_options ::= topic_options WITH TAG */ + { 296, 0 }, /* (226) topic_options ::= */ + { 296, -3 }, /* (227) topic_options ::= topic_options WITH TABLE */ + { 296, -3 }, /* (228) topic_options ::= topic_options WITH SCHEMA */ + { 296, -3 }, /* (229) topic_options ::= topic_options WITH TAG */ { 238, -2 }, /* (230) cmd ::= DESC full_table_name */ { 238, -2 }, /* (231) cmd ::= DESCRIBE full_table_name */ { 238, -3 }, /* (232) cmd ::= RESET QUERY CACHE */ { 238, -4 }, /* (233) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 297, 0 }, /* (234) analyze_opt ::= */ - { 297, -1 }, /* (235) analyze_opt ::= ANALYZE */ - { 298, 0 }, /* (236) explain_options ::= */ - { 298, -3 }, /* (237) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 298, -3 }, /* (238) explain_options ::= explain_options RATIO NK_FLOAT */ + { 298, 0 }, /* (234) analyze_opt ::= */ + { 298, -1 }, /* (235) analyze_opt ::= ANALYZE */ + { 299, 0 }, /* (236) explain_options ::= */ + { 299, -3 }, /* (237) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 299, -3 }, /* (238) explain_options ::= explain_options RATIO NK_FLOAT */ { 238, -6 }, /* (239) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ { 238, -10 }, /* (240) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ { 238, -4 }, /* (241) cmd ::= DROP FUNCTION exists_opt function_name */ - { 299, 0 }, /* (242) agg_func_opt ::= */ - { 299, -1 }, /* (243) agg_func_opt ::= AGGREGATE */ - { 300, 0 }, /* (244) bufsize_opt ::= */ - { 300, -2 }, /* (245) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 300, 0 }, /* (242) agg_func_opt ::= */ + { 300, -1 }, /* (243) agg_func_opt ::= AGGREGATE */ + { 301, 0 }, /* (244) bufsize_opt ::= */ + { 301, -2 }, /* (245) bufsize_opt ::= BUFSIZE NK_INTEGER */ { 238, -8 }, /* (246) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ { 238, -4 }, /* (247) cmd ::= DROP STREAM exists_opt stream_name */ - { 303, 0 }, /* (248) into_opt ::= */ - { 303, -2 }, /* (249) into_opt ::= INTO full_table_name */ - { 302, 0 }, /* (250) stream_options ::= */ - { 302, -3 }, /* (251) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 302, -3 }, /* (252) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 302, -3 }, /* (253) stream_options ::= stream_options WATERMARK duration_literal */ + { 304, 0 }, /* (248) into_opt ::= */ + { 304, -2 }, /* (249) into_opt ::= INTO full_table_name */ + { 303, 0 }, /* (250) stream_options ::= */ + { 303, -3 }, /* (251) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 303, -3 }, /* (252) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 303, -3 }, /* (253) stream_options ::= stream_options WATERMARK duration_literal */ { 238, -3 }, /* (254) cmd ::= KILL CONNECTION NK_INTEGER */ { 238, -3 }, /* (255) cmd ::= KILL QUERY NK_INTEGER */ { 238, -3 }, /* (256) cmd ::= KILL TRANSACTION NK_INTEGER */ { 238, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { 238, -4 }, /* (258) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { 238, -3 }, /* (259) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 304, -2 }, /* (260) dnode_list ::= DNODE NK_INTEGER */ - { 304, -3 }, /* (261) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 305, -2 }, /* (260) dnode_list ::= DNODE NK_INTEGER */ + { 305, -3 }, /* (261) dnode_list ::= dnode_list DNODE NK_INTEGER */ { 238, -3 }, /* (262) cmd ::= SYNCDB db_name REPLICA */ { 238, -1 }, /* (263) cmd ::= query_expression */ { 241, -1 }, /* (264) literal ::= NK_INTEGER */ @@ -2833,32 +2831,32 @@ static const struct { { 241, -1 }, /* (269) literal ::= duration_literal */ { 241, -1 }, /* (270) literal ::= NULL */ { 241, -1 }, /* (271) literal ::= NK_QUESTION */ - { 290, -1 }, /* (272) duration_literal ::= NK_VARIABLE */ - { 305, -1 }, /* (273) signed ::= NK_INTEGER */ - { 305, -2 }, /* (274) signed ::= NK_PLUS NK_INTEGER */ - { 305, -2 }, /* (275) signed ::= NK_MINUS NK_INTEGER */ - { 305, -1 }, /* (276) signed ::= NK_FLOAT */ - { 305, -2 }, /* (277) signed ::= NK_PLUS NK_FLOAT */ - { 305, -2 }, /* (278) signed ::= NK_MINUS NK_FLOAT */ - { 306, -1 }, /* (279) signed_literal ::= signed */ - { 306, -1 }, /* (280) signed_literal ::= NK_STRING */ - { 306, -1 }, /* (281) signed_literal ::= NK_BOOL */ - { 306, -2 }, /* (282) signed_literal ::= TIMESTAMP NK_STRING */ - { 306, -1 }, /* (283) signed_literal ::= duration_literal */ - { 306, -1 }, /* (284) signed_literal ::= NULL */ - { 306, -1 }, /* (285) signed_literal ::= literal_func */ - { 273, -1 }, /* (286) literal_list ::= signed_literal */ - { 273, -3 }, /* (287) literal_list ::= literal_list NK_COMMA signed_literal */ + { 291, -1 }, /* (272) duration_literal ::= NK_VARIABLE */ + { 306, -1 }, /* (273) signed ::= NK_INTEGER */ + { 306, -2 }, /* (274) signed ::= NK_PLUS NK_INTEGER */ + { 306, -2 }, /* (275) signed ::= NK_MINUS NK_INTEGER */ + { 306, -1 }, /* (276) signed ::= NK_FLOAT */ + { 306, -2 }, /* (277) signed ::= NK_PLUS NK_FLOAT */ + { 306, -2 }, /* (278) signed ::= NK_MINUS NK_FLOAT */ + { 271, -1 }, /* (279) signed_literal ::= signed */ + { 271, -1 }, /* (280) signed_literal ::= NK_STRING */ + { 271, -1 }, /* (281) signed_literal ::= NK_BOOL */ + { 271, -2 }, /* (282) signed_literal ::= TIMESTAMP NK_STRING */ + { 271, -1 }, /* (283) signed_literal ::= duration_literal */ + { 271, -1 }, /* (284) signed_literal ::= NULL */ + { 271, -1 }, /* (285) signed_literal ::= literal_func */ + { 274, -1 }, /* (286) literal_list ::= signed_literal */ + { 274, -3 }, /* (287) literal_list ::= literal_list NK_COMMA signed_literal */ { 248, -1 }, /* (288) db_name ::= NK_ID */ - { 276, -1 }, /* (289) table_name ::= NK_ID */ + { 277, -1 }, /* (289) table_name ::= NK_ID */ { 269, -1 }, /* (290) column_name ::= NK_ID */ - { 286, -1 }, /* (291) function_name ::= NK_ID */ + { 287, -1 }, /* (291) function_name ::= NK_ID */ { 308, -1 }, /* (292) table_alias ::= NK_ID */ { 309, -1 }, /* (293) column_alias ::= NK_ID */ { 243, -1 }, /* (294) user_name ::= NK_ID */ - { 287, -1 }, /* (295) index_name ::= NK_ID */ - { 294, -1 }, /* (296) topic_name ::= NK_ID */ - { 301, -1 }, /* (297) stream_name ::= NK_ID */ + { 288, -1 }, /* (295) index_name ::= NK_ID */ + { 295, -1 }, /* (296) topic_name ::= NK_ID */ + { 302, -1 }, /* (297) stream_name ::= NK_ID */ { 310, -1 }, /* (298) expression ::= literal */ { 310, -1 }, /* (299) expression ::= pseudo_column */ { 310, -1 }, /* (300) expression ::= column_reference */ @@ -2873,8 +2871,8 @@ static const struct { { 310, -3 }, /* (309) expression ::= expression NK_SLASH expression */ { 310, -3 }, /* (310) expression ::= expression NK_REM expression */ { 310, -3 }, /* (311) expression ::= column_reference NK_ARROW NK_STRING */ - { 293, -1 }, /* (312) expression_list ::= expression */ - { 293, -3 }, /* (313) expression_list ::= expression_list NK_COMMA expression */ + { 294, -1 }, /* (312) expression_list ::= expression */ + { 294, -3 }, /* (313) expression_list ::= expression_list NK_COMMA expression */ { 312, -1 }, /* (314) column_reference ::= column_name */ { 312, -3 }, /* (315) column_reference ::= table_name NK_DOT column_name */ { 311, -1 }, /* (316) pseudo_column ::= ROWTS */ @@ -2970,8 +2968,8 @@ static const struct { { 341, -4 }, /* (406) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ { 341, -6 }, /* (407) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { 341, -8 }, /* (408) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 291, 0 }, /* (409) sliding_opt ::= */ - { 291, -4 }, /* (410) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 292, 0 }, /* (409) sliding_opt ::= */ + { 292, -4 }, /* (410) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ { 346, 0 }, /* (411) fill_opt ::= */ { 346, -4 }, /* (412) fill_opt ::= FILL NK_LP fill_mode NK_RP */ { 346, -6 }, /* (413) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ @@ -2986,7 +2984,7 @@ static const struct { { 348, -3 }, /* (422) group_by_list ::= group_by_list NK_COMMA expression */ { 343, 0 }, /* (423) having_clause_opt ::= */ { 343, -2 }, /* (424) having_clause_opt ::= HAVING search_condition */ - { 296, -4 }, /* (425) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 297, -4 }, /* (425) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { 349, -1 }, /* (426) query_expression_body ::= query_primary */ { 349, -4 }, /* (427) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ { 349, -3 }, /* (428) query_expression_body ::= query_expression_body UNION query_expression_body */ @@ -3501,8 +3499,8 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy172 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy105, &yymsp[0].minor.yy105); } yymsp[-4].minor.yy172 = yylhsminor.yy172; break; - case 121: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy172 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy172, &yymsp[-2].minor.yy105, releaseRawExprNode(pCxt, yymsp[0].minor.yy172)); } + case 121: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy172 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy172, &yymsp[-2].minor.yy105, yymsp[0].minor.yy172); } yymsp[-5].minor.yy172 = yylhsminor.yy172; break; case 123: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 9f8d5b48029f3004736a6ed9b77d14108adcba8c..b68ef2c591e0497c6f32a9ce69c9e1f229b5f92f 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -239,6 +239,10 @@ TEST_F(ParserSelectTest, semanticError) { // TSDB_CODE_PAR_WRONG_VALUE_TYPE run("SELECT timestamp '2010a' FROM t1", TSDB_CODE_PAR_WRONG_VALUE_TYPE, PARSER_STAGE_TRANSLATE); + run("SELECT LAST(*) + SUM(c1) FROM t1", TSDB_CODE_PAR_WRONG_VALUE_TYPE, PARSER_STAGE_TRANSLATE); + + run("SELECT CEIL(LAST(ts, c1)) FROM t1", TSDB_CODE_PAR_WRONG_VALUE_TYPE, PARSER_STAGE_TRANSLATE); + // TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION run("SELECT c2 FROM t1 tt1 join t1 tt2 on COUNT(*) > 0", TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, PARSER_STAGE_TRANSLATE); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index a87c00bea9459de4eea33c8c1e082564231e70ca..1a97d9ab1b898b9b4a5dae1d4bade0e9b6d87bb8 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -248,6 +248,7 @@ static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode) pSubplan->id.groupId = pCxt->groupId; pSubplan->subplanType = SUBPLAN_TYPE_SCAN; pSubplan->pNode = pNode; + pNode->pParent = NULL; return pSubplan; } @@ -408,17 +409,30 @@ static const SSplitRule splitRuleSet[] = {{.pName = "SuperTableScan", .splitFunc static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); +static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { + char* pStr = NULL; + nodesNodeToString(pSubplan, false, &pStr, NULL); + qDebugL("apply %s rule: %s", pRuleName, pStr); + taosMemoryFree(pStr); +} + static int32_t applySplitRule(SLogicSubplan* pSubplan) { SSplitContext cxt = {.queryId = pSubplan->id.queryId, .groupId = pSubplan->id.groupId + 1, .split = false}; + bool split = false; do { - cxt.split = false; + split = false; for (int32_t i = 0; i < splitRuleNum; ++i) { + cxt.split = false; int32_t code = splitRuleSet[i].splitFunc(&cxt, pSubplan); if (TSDB_CODE_SUCCESS != code) { return code; } + if (cxt.split) { + split = true; + dumpLogicSubplan(splitRuleSet[i].pName, pSubplan); + } } - } while (cxt.split); + } while (split); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/planner/test/planSetOpTest.cpp b/source/libs/planner/test/planSetOpTest.cpp index 717384aae69fe26973216c996aef199954225e23..5568d3cfbb994b83c3531957a33fc7ae1ff20eb3 100644 --- a/source/libs/planner/test/planSetOpTest.cpp +++ b/source/libs/planner/test/planSetOpTest.cpp @@ -23,7 +23,12 @@ class PlanSetOpTest : public PlannerTestBase {}; TEST_F(PlanSetOpTest, unionAll) { useDb("root", "test"); + // sql 1: single UNION ALL operator run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20"); + // sql 2: multi UNION ALL operator + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 " + "UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 " + "UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 30"); } TEST_F(PlanSetOpTest, unionAllSubquery) { @@ -44,7 +49,12 @@ TEST_F(PlanSetOpTest, unionAllWithSubquery) { TEST_F(PlanSetOpTest, union) { useDb("root", "test"); + // single UNION operator run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20"); + // multi UNION operator + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 " + "UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 " + "UNION SELECT c1, c2 FROM t1 WHERE c1 > 30"); } TEST_F(PlanSetOpTest, unionContainJoin) { @@ -62,3 +72,12 @@ TEST_F(PlanSetOpTest, unionSubquery) { run("SELECT * FROM (SELECT c1, c2 FROM t1 UNION SELECT c1, c2 FROM t1)"); } + +TEST_F(PlanSetOpTest, bug001) { + useDb("root", "test"); + + run("SELECT c2 FROM t1 WHERE c1 IS NOT NULL GROUP BY c2 " + "UNION " + "SELECT 'abcdefghijklmnopqrstuvwxyz' FROM t1 " + "WHERE 'abcdefghijklmnopqrstuvwxyz' IS NOT NULL GROUP BY 'abcdefghijklmnopqrstuvwxyz'"); +} diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 6a7cb91bb931fc5d0d22e7cefd5c2156fcf4c74a..2d559c6f3b5322e4bd27bd571fc5e6829ccf262c 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -23,9 +23,7 @@ class PlanSubqeuryTest : public PlannerTestBase {}; TEST_F(PlanSubqeuryTest, basic) { useDb("root", "test"); - if (0 == g_skipSql) { - run("SELECT * FROM (SELECT * FROM t1)"); - } + run("SELECT * FROM (SELECT * FROM t1)"); run("SELECT LAST(c1) FROM (SELECT * FROM t1)"); } diff --git a/source/libs/planner/test/planTestMain.cpp b/source/libs/planner/test/planTestMain.cpp index 36f66ddff689ed7f29acc571a34d2a3a7c1e6163..0373ab38d302c5dbc92a9341993b2fb47f7b957f 100644 --- a/source/libs/planner/test/planTestMain.cpp +++ b/source/libs/planner/test/planTestMain.cpp @@ -35,18 +35,19 @@ class PlannerEnv : public testing::Environment { private: void initLog(const char* path) { - dDebugFlag = 143; - vDebugFlag = 0; - mDebugFlag = 143; - cDebugFlag = 0; - jniDebugFlag = 0; - tmrDebugFlag = 135; - uDebugFlag = 135; - rpcDebugFlag = 143; - qDebugFlag = 143; - wDebugFlag = 0; - sDebugFlag = 0; - tsdbDebugFlag = 0; + int32_t logLevel = getLogLevel(); + dDebugFlag = logLevel; + vDebugFlag = logLevel; + mDebugFlag = logLevel; + cDebugFlag = logLevel; + jniDebugFlag = logLevel; + tmrDebugFlag = logLevel; + uDebugFlag = logLevel; + rpcDebugFlag = logLevel; + qDebugFlag = logLevel; + wDebugFlag = logLevel; + sDebugFlag = logLevel; + tsdbDebugFlag = logLevel; tsLogEmbedded = 1; tsAsyncLog = 0; @@ -60,17 +61,26 @@ class PlannerEnv : public testing::Environment { }; static void parseArg(int argc, char* argv[]) { - int opt = 0; - const char* optstring = ""; + int opt = 0; + const char* optstring = ""; + // clang-format off static struct option long_options[] = { - {"dump", optional_argument, NULL, 'd'}, {"skipSql", optional_argument, NULL, 's'}, {0, 0, 0, 0}}; + {"dump", optional_argument, NULL, 'd'}, + {"skipSql", required_argument, NULL, 's'}, + {"log", required_argument, NULL, 'l'}, + {0, 0, 0, 0} + }; + // clang-format on while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { switch (opt) { case 'd': setDumpModule(optarg); break; case 's': - g_skipSql = 1; + setSkipSqlNum(optarg); + break; + case 'l': + setLogLevel(optarg); break; default: break; diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index 94a28f46a82de78fd038f05682f0521796b716fe..6e184fec724ceffbaa186367956d1318c59d2fb9 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -48,6 +48,7 @@ enum DumpModule { DumpModule g_dumpModule = DUMP_MODULE_NOTHING; int32_t g_skipSql = 0; +int32_t g_logLevel = 131; void setDumpModule(const char* pModule) { if (NULL == pModule) { @@ -71,14 +72,26 @@ void setDumpModule(const char* pModule) { } } +void setSkipSqlNum(const char* pNum) { g_skipSql = stoi(optarg); } + +void setLogLevel(const char* pLogLevel) { g_logLevel = stoi(pLogLevel); } + +int32_t getLogLevel() { return g_logLevel; } + class PlannerTestBaseImpl { public: void useDb(const string& acctId, const string& db) { caseEnv_.acctId_ = acctId; caseEnv_.db_ = db; + caseEnv_.nsql_ = g_skipSql; } void run(const string& sql) { + if (caseEnv_.nsql_ > 0) { + --(caseEnv_.nsql_); + return; + } + reset(); try { SQuery* pQuery = nullptr; @@ -109,6 +122,10 @@ class PlannerTestBaseImpl { } void prepare(const string& sql) { + if (caseEnv_.nsql_ > 0) { + return; + } + reset(); try { doParseSql(sql, &stmtEnv_.pQuery_, true); @@ -119,6 +136,10 @@ class PlannerTestBaseImpl { } void bindParams(TAOS_MULTI_BIND* pParams, int32_t colIdx) { + if (caseEnv_.nsql_ > 0) { + return; + } + try { doBindParams(stmtEnv_.pQuery_, pParams, colIdx); } catch (...) { @@ -128,6 +149,11 @@ class PlannerTestBaseImpl { } void exec() { + if (caseEnv_.nsql_ > 0) { + --(caseEnv_.nsql_); + return; + } + try { doParseBoundSql(stmtEnv_.pQuery_); @@ -157,8 +183,9 @@ class PlannerTestBaseImpl { private: struct caseEnv { - string acctId_; - string db_; + string acctId_; + string db_; + int32_t nsql_; }; struct stmtEnv { diff --git a/source/libs/planner/test/planTestUtil.h b/source/libs/planner/test/planTestUtil.h index 5a2050a45e91d262751333e2f8dd12b02690af2e..6b75573fb3f86a91446ef3ad492a51703af4f00f 100644 --- a/source/libs/planner/test/planTestUtil.h +++ b/source/libs/planner/test/planTestUtil.h @@ -37,8 +37,9 @@ class PlannerTestBase : public testing::Test { std::unique_ptr impl_; }; -extern int32_t g_skipSql; - -extern void setDumpModule(const char* pModule); +extern void setDumpModule(const char* pModule); +extern void setSkipSqlNum(const char* pNum); +extern void setLogLevel(const char* pLogLevel); +extern int32_t getLogLevel(); #endif // PLAN_TEST_UTIL_H diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 11851ca5d8928e58e3080499a64a80ede53976e1..f84775f0d7e7b932b60255f05820bf0df99f81e9 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -45,32 +45,10 @@ STaosError errors[] = { {.val = 0, .str = "success"}, #endif -// rpc -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ACTION_IN_PROGRESS, "Action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_REQUIRED, "Authentication required") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, "Authentication failure") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, "Redirect") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NOT_READY, "System not ready") // peer is not ready to process data -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ALREADY_PROCESSED, "Message already processed") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED, "Last session not finished") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MISMATCHED_LINK_ID, "Mismatched meter id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TOO_SLOW, "Processing of request timed out") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, "Number of sessions reached limit") // too many sessions -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, "Unable to establish connection") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_APP_ERROR, "Unexpected generic error in RPC") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_UNEXPECTED_RESPONSE, "Unexpected response") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VALUE, "Invalid value") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TRAN_ID, "Invalid transaction id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_SESSION_ID, "Invalid session id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_MSG_TYPE, "Invalid message type") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, "Invalid response type") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, "Client and server's time is not synchronized") -TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, "Database not ready") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQDN") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VERSION, "Invalid app version") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_PORT_EADDRINUSE, "port already in use") - //common & util +TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, "Action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, "Unexpected generic error") +TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, "Database not ready") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_MEMORY, "Out of Memory") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RANGE, "Out of range") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_SHM_MEM, "Out of Shared memory") @@ -104,6 +82,13 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, "Invalid Ref ID") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, "Ref is already there") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, "Ref is not there") +// rpc +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, "Redirect") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, "Authentication failure") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, "Unable to establish connection") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQDN") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_PORT_EADDRINUSE, "Port already in use") + //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, "Invalid qhandle") diff --git a/source/util/src/thash.c b/source/util/src/thash.c index 4bbf6ccf450ae4c11685d5012d4acdf2348b551e..728b09d3a3d3a2cfc00a471d7281159d3fb4792c 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "thash.h" -#include "taoserror.h" #include "os.h" +#include "taoserror.h" #include "tlog.h" // the add ref count operation may trigger the warning if the reference count is greater than the MAX_WARNING_REF_COUNT @@ -27,36 +27,36 @@ #define HASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * HASH_DEFAULT_LOAD_FACTOR) -#define GET_HASH_NODE_KEY(_n) ((char*)(_n) + sizeof(SHashNode) + (_n)->dataLen) -#define GET_HASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SHashNode)) -#define GET_HASH_PNODE(_n) ((SHashNode *)((char*)(_n) - sizeof(SHashNode))) +#define GET_HASH_NODE_KEY(_n) ((char *)(_n) + sizeof(SHashNode) + (_n)->dataLen) +#define GET_HASH_NODE_DATA(_n) ((char *)(_n) + sizeof(SHashNode)) +#define GET_HASH_PNODE(_n) ((SHashNode *)((char *)(_n) - sizeof(SHashNode))) #define FREE_HASH_NODE(_fp, _n) \ do { \ -/* if (_fp != NULL) { \ - (_fp)(_n); \ - }*/ \ + /* if (_fp != NULL) { \ + (_fp)(_n); \ + }*/ \ taosMemoryFreeClear(_n); \ } while (0); struct SHashNode { - SHashNode *next; - uint32_t hashVal; // the hash value of key - uint32_t dataLen; // length of data - uint32_t keyLen; // length of the key - uint16_t refCount; // reference count - int8_t removed; // flag to indicate removed - char data[]; + SHashNode *next; + uint32_t hashVal; // the hash value of key + uint32_t dataLen; // length of data + uint32_t keyLen; // length of the key + uint16_t refCount; // reference count + int8_t removed; // flag to indicate removed + char data[]; }; typedef struct SHashEntry { - int32_t num; // number of elements in current entry - SRWLatch latch; // entry latch - SHashNode *next; + int32_t num; // number of elements in current entry + SRWLatch latch; // entry latch + SHashNode *next; } SHashEntry; struct SHashObj { - SHashEntry ** hashList; + SHashEntry **hashList; size_t capacity; // number of slots int64_t size; // number of elements in hash table _hash_fn_t hashFp; // hash function @@ -65,7 +65,7 @@ struct SHashObj { SRWLatch lock; // read-write spin lock SHashLockTypeE type; // lock type bool enableUpdate; // enable update - SArray * pMemBlock; // memory block allocated for SHashEntry + SArray *pMemBlock; // memory block allocated for SHashEntry _hash_before_fn_t callbackFp; // function invoked before return the value to caller }; @@ -103,14 +103,14 @@ static FORCE_INLINE void taosHashRUnlock(SHashObj *pHashObj) { taosRUnLockLatch(&pHashObj->lock); } -static FORCE_INLINE void taosHashEntryWLock(const SHashObj *pHashObj, SHashEntry* pe) { +static FORCE_INLINE void taosHashEntryWLock(const SHashObj *pHashObj, SHashEntry *pe) { if (pHashObj->type == HASH_NO_LOCK) { return; } taosWLockLatch(&pe->latch); } -static FORCE_INLINE void taosHashEntryWUnlock(const SHashObj *pHashObj, SHashEntry* pe) { +static FORCE_INLINE void taosHashEntryWUnlock(const SHashObj *pHashObj, SHashEntry *pe) { if (pHashObj->type == HASH_NO_LOCK) { return; } @@ -118,7 +118,7 @@ static FORCE_INLINE void taosHashEntryWUnlock(const SHashObj *pHashObj, SHashEnt taosWUnLockLatch(&pe->latch); } -static FORCE_INLINE void taosHashEntryRLock(const SHashObj *pHashObj, SHashEntry* pe) { +static FORCE_INLINE void taosHashEntryRLock(const SHashObj *pHashObj, SHashEntry *pe) { if (pHashObj->type == HASH_NO_LOCK) { return; } @@ -126,7 +126,7 @@ static FORCE_INLINE void taosHashEntryRLock(const SHashObj *pHashObj, SHashEntry taosRLockLatch(&pe->latch); } -static FORCE_INLINE void taosHashEntryRUnlock(const SHashObj *pHashObj, SHashEntry* pe) { +static FORCE_INLINE void taosHashEntryRUnlock(const SHashObj *pHashObj, SHashEntry *pe) { if (pHashObj->type == HASH_NO_LOCK) { return; } @@ -142,12 +142,11 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { return i; } -static FORCE_INLINE SHashNode * -doSearchInEntryList(SHashObj *pHashObj, SHashEntry *pe, const void *key, size_t keyLen, uint32_t hashVal) { +static FORCE_INLINE SHashNode *doSearchInEntryList(SHashObj *pHashObj, SHashEntry *pe, const void *key, size_t keyLen, + uint32_t hashVal) { SHashNode *pNode = pe->next; while (pNode) { - if ((pNode->keyLen == keyLen) && - ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) && + if ((pNode->keyLen == keyLen) && ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) && pNode->removed == 0) { assert(pNode->hashVal == hashVal); break; @@ -186,7 +185,8 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p * @param pNode the old node with requested key * @param pNewNode the new node with requested key */ -static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry* pe, SHashNode* prev, SHashNode *pNode, SHashNode *pNewNode) { +static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry *pe, SHashNode *prev, SHashNode *pNode, + SHashNode *pNewNode) { assert(pNode->keyLen == pNewNode->keyLen); atomic_sub_fetch_16(&pNode->refCount, 1); @@ -227,9 +227,7 @@ static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj); * @param pHashObj * @return */ -static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj) { - return taosHashGetSize(pHashObj) == 0; -} +static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj) { return taosHashGetSize(pHashObj) == 0; } SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTypeE type) { if (fn == NULL) { @@ -251,7 +249,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp pHashObj->capacity = taosHashCapacity((int32_t)capacity); pHashObj->equalFp = memcmp; - pHashObj->hashFp = fn; + pHashObj->hashFp = fn; pHashObj->type = type; pHashObj->enableUpdate = update; @@ -305,7 +303,7 @@ int32_t taosHashGetSize(const SHashObj *pHashObj) { if (pHashObj == NULL) { return 0; } - return (int32_t)atomic_load_64((int64_t*)&pHashObj->size); + return (int32_t)atomic_load_64((int64_t *)&pHashObj->size); } int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const void *data, size_t size) { @@ -340,10 +338,9 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const vo } #endif - SHashNode* prev = NULL; + SHashNode *prev = NULL; while (pNode) { - if ((pNode->keyLen == keyLen) && - (*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0 && + if ((pNode->keyLen == keyLen) && (*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0 && pNode->removed == 0) { assert(pNode->hashVal == hashVal); break; @@ -391,27 +388,27 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const vo } } -static void* taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void** d, int32_t* size, bool addRef); +static void *taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void **d, int32_t *size, bool addRef); void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) { - void* p = NULL; + void *p = NULL; return taosHashGetImpl(pHashObj, key, keyLen, &p, 0, false); } int32_t taosHashGetDup(SHashObj *pHashObj, const void *key, size_t keyLen, void *destBuf) { terrno = 0; - /*char* p = */taosHashGetImpl(pHashObj, key, keyLen, &destBuf, 0, false); + /*char* p = */ taosHashGetImpl(pHashObj, key, keyLen, &destBuf, 0, false); return terrno; } -int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, void **destBuf, int32_t* size) { +int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, void **destBuf, int32_t *size) { terrno = 0; - /*char* p = */taosHashGetImpl(pHashObj, key, keyLen, destBuf, size, false); + /*char* p = */ taosHashGetImpl(pHashObj, key, keyLen, destBuf, size, false); return terrno; } -void* taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void** d, int32_t* size, bool addRef) { +void *taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void **d, int32_t *size, bool addRef) { if (pHashObj == NULL || taosHashTableEmpty(pHashObj) || keyLen == 0 || key == NULL) { return NULL; } @@ -449,15 +446,15 @@ void* taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void** if (size != NULL) { if (*d == NULL) { - *size = pNode->dataLen; + *size = pNode->dataLen; *d = taosMemoryCalloc(1, *size); if (*d == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } } else if (*size < pNode->dataLen) { - *size = pNode->dataLen; - char* tmp = taosMemoryRealloc(*d, *size); + *size = pNode->dataLen; + char *tmp = taosMemoryRealloc(*d, *size); if (tmp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; @@ -508,13 +505,12 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { return -1; } - int code = -1; + int code = -1; SHashNode *pNode = pe->next; SHashNode *prevNode = NULL; while (pNode) { - if ((pNode->keyLen == keyLen) && - ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) && + if ((pNode->keyLen == keyLen) && ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) && pNode->removed == 0) { code = 0; // it is found @@ -598,14 +594,14 @@ void taosHashCleanup(SHashObj *pHashObj) { } // for profile only -int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj){ +int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj) { if (pHashObj == NULL || taosHashTableEmpty(pHashObj)) { return 0; } int32_t num = 0; - taosHashRLock((SHashObj*) pHashObj); + taosHashRLock((SHashObj *)pHashObj); for (int32_t i = 0; i < pHashObj->size; ++i) { SHashEntry *pEntry = pHashObj->hashList[i]; @@ -616,7 +612,7 @@ int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj){ } } - taosHashRUnlock((SHashObj*) pHashObj); + taosHashRUnlock((SHashObj *)pHashObj); return num; } @@ -627,22 +623,22 @@ void taosHashTableResize(SHashObj *pHashObj) { int32_t newCapacity = (int32_t)(pHashObj->capacity << 1u); if (newCapacity > HASH_MAX_CAPACITY) { -// uDebug("current capacity:%zu, maximum capacity:%d, no resize applied due to limitation is reached", -// pHashObj->capacity, HASH_MAX_CAPACITY); + // uDebug("current capacity:%zu, maximum capacity:%d, no resize applied due to limitation is reached", + // pHashObj->capacity, HASH_MAX_CAPACITY); return; } int64_t st = taosGetTimestampUs(); - void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity); + void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity); if (pNewEntryList == NULL) { -// uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity); + // uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity); return; } pHashObj->hashList = pNewEntryList; size_t inc = newCapacity - pHashObj->capacity; - void * p = taosMemoryCalloc(inc, sizeof(SHashEntry)); + void *p = taosMemoryCalloc(inc, sizeof(SHashEntry)); for (int32_t i = 0; i < inc; ++i) { pHashObj->hashList[i + pHashObj->capacity] = (void *)((char *)p + i * sizeof(SHashEntry)); @@ -653,9 +649,9 @@ void taosHashTableResize(SHashObj *pHashObj) { pHashObj->capacity = newCapacity; for (int32_t idx = 0; idx < pHashObj->capacity; ++idx) { SHashEntry *pe = pHashObj->hashList[idx]; - SHashNode *pNode; - SHashNode *pNext; - SHashNode *pPrev = NULL; + SHashNode *pNode; + SHashNode *pNext; + SHashNode *pPrev = NULL; if (pe->num == 0) { assert(pe->next == NULL); @@ -688,24 +684,25 @@ void taosHashTableResize(SHashObj *pHashObj) { int64_t et = taosGetTimestampUs(); -// uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", (int32_t)pHashObj->capacity, -// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0); + // uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", + // (int32_t)pHashObj->capacity, + // ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0); } SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, size_t dsize, uint32_t hashVal) { - SHashNode *pNewNode = taosMemoryMalloc(sizeof(SHashNode) + keyLen + dsize); + SHashNode *pNewNode = taosMemoryMalloc(sizeof(SHashNode) + keyLen + dsize + 1); if (pNewNode == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pNewNode->keyLen = (uint32_t)keyLen; + pNewNode->keyLen = (uint32_t)keyLen; pNewNode->hashVal = hashVal; pNewNode->dataLen = (uint32_t)dsize; - pNewNode->refCount= 1; + pNewNode->refCount = 1; pNewNode->removed = 0; - pNewNode->next = NULL; + pNewNode->next = NULL; memcpy(GET_HASH_NODE_DATA(pNewNode), pData, dsize); memcpy(GET_HASH_NODE_KEY(pNewNode), key, keyLen); @@ -727,11 +724,12 @@ size_t taosHashGetMemSize(const SHashObj *pHashObj) { return 0; } - return (pHashObj->capacity * (sizeof(SHashEntry) + sizeof(void*))) + sizeof(SHashNode) * taosHashGetSize(pHashObj) + sizeof(SHashObj); + return (pHashObj->capacity * (sizeof(SHashEntry) + sizeof(void *))) + sizeof(SHashNode) * taosHashGetSize(pHashObj) + + sizeof(SHashObj); } -void *taosHashGetKey(void *data, size_t* keyLen) { - SHashNode * node = GET_HASH_PNODE(data); +void *taosHashGetKey(void *data, size_t *keyLen) { + SHashNode *node = GET_HASH_PNODE(data); if (keyLen != NULL) { *keyLen = node->keyLen; } @@ -751,8 +749,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { SHashNode *pNode = pe->next; while (pNode) { - if (pNode == pOld) - break; + if (pNode == pOld) break; prevNode = pNode; pNode = pNode->next; @@ -766,7 +763,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { } atomic_sub_fetch_16(&pOld->refCount, 1); - if (pOld->refCount <=0) { + if (pOld->refCount <= 0) { if (prevNode) { prevNode->next = pOld->next; } else { @@ -778,7 +775,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { FREE_HASH_NODE(pHashObj->freeFp, pOld); } } else { -// uError("pNode:%p data:%p is not there!!!", pNode, p); + // uError("pNode:%p data:%p is not there!!!", pNode, p); } return pNode; @@ -787,7 +784,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { void *taosHashIterate(SHashObj *pHashObj, void *p) { if (pHashObj == NULL) return NULL; - int slot = 0; + int slot = 0; char *data = NULL; // only add the read lock to disable the resize process @@ -865,9 +862,9 @@ void taosHashCancelIterate(SHashObj *pHashObj, void *p) { taosHashRUnlock(pHashObj); } -//TODO remove it +// TODO remove it void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen) { - void* p = NULL; + void *p = NULL; return taosHashGetImpl(pHashObj, key, keyLen, &p, 0, true); } diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 5730efd9e2e7ef37c606736b3e9c189ec7593f70..d0463be710e77e7bf4f9f3d35e66a2acddee42a3 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -1380,8 +1380,8 @@ class TDTestCase: self.tmqCase3(cfgPath, buildPath) self.tmqCase4(cfgPath, buildPath) self.tmqCase5(cfgPath, buildPath) - self.tmqCase6(cfgPath, buildPath) - self.tmqCase7(cfgPath, buildPath) + #self.tmqCase6(cfgPath, buildPath) + #self.tmqCase7(cfgPath, buildPath) #self.tmqCase8(cfgPath, buildPath) #self.tmqCase9(cfgPath, buildPath) #self.tmqCase10(cfgPath, buildPath) diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py new file mode 100644 index 0000000000000000000000000000000000000000..049b297d2df0f54e7d681c6236d942340da2d19f --- /dev/null +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -0,0 +1,1399 @@ + +import taos +import sys +import time +import socket +import os +import threading +from enum import Enum + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +class actionType(Enum): + CREATE_DATABASE = 0 + CREATE_STABLE = 1 + CREATE_CTABLE = 2 + INSERT_DATA = 3 + +class TDTestCase: + hostname = socket.gethostname() + #rpcDebugFlagVal = '143' + #clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + #clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal + #updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + #updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal + #print ("===================: ", updatecfgDict) + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + #tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def newcur(self,cfg,host,port): + user = "root" + password = "taosdata" + con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) + cur=con.cursor() + print(cur) + return cur + + def initConsumerTable(self,cdbName='cdb'): + tdLog.info("create consume database, and consume info table, and consume result table") + tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) + tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) + + tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) + tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) + + def initConsumerInfoTable(self,cdbName='cdb'): + tdLog.info("drop consumeinfo table") + tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) + tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) + + 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) + tdLog.info("consume info sql: %s"%sql) + tdSql.query(sql) + + def selectConsumeResult(self,expectRows,cdbName='cdb'): + resultList=[] + while 1: + tdSql.query("select * from %s.consumeresult"%cdbName) + #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) + if tdSql.getRows() == expectRows: + break + else: + time.sleep(5) + + for i in range(expectRows): + tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) + resultList.append(tdSql.getData(i , 3)) + + return resultList + + def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): + shellCmd = 'nohup ' + if valgrind == 1: + logFile = cfgPath + '/../log/valgrind-tmq.log' + shellCmd = 'nohup valgrind --log-file=' + logFile + shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' + + shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" + tdLog.info(shellCmd) + os.system(shellCmd) + + def create_database(self,tsql, dbName,dropFlag=1,vgroups=4,replica=1): + if dropFlag == 1: + tsql.execute("drop database if exists %s"%(dbName)) + + tsql.execute("create database if not exists %s vgroups %d replica %d"%(dbName, vgroups, replica)) + tdLog.debug("complete to create database %s"%(dbName)) + return + + def create_stable(self,tsql, dbName,stbName): + tsql.execute("create table if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(dbName, stbName)) + tdLog.debug("complete to create %s.%s" %(dbName, stbName)) + return + + def create_ctables(self,tsql, dbName,stbName,ctbNum): + tsql.execute("use %s" %dbName) + pre_create = "create table" + sql = pre_create + #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) + for i in range(ctbNum): + sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1) + if (i > 0) and (i%100 == 0): + tsql.execute(sql) + sql = pre_create + if sql != pre_create: + tsql.execute(sql) + + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) + return + + def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=0): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + if startTs == 0: + t = time.time() + startTs = int(round(t * 1000)) + + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + rowsOfSql = 0 + for i in range(ctbNum): + sql += " %s_%d values "%(stbName,i) + for j in range(rowsPerTbl): + sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) + rowsOfSql += 1 + if (j > 0) and ((rowsOfSql == batchNum) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + rowsOfSql = 0 + if j < rowsPerTbl - 1: + sql = "insert into %s_%d values " %(stbName,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def prepareEnv(self, **parameterDict): + # create new connector for my thread + tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) + + if parameterDict["actionType"] == actionType.CREATE_DATABASE: + self.create_database(tsql, parameterDict["dbName"]) + elif parameterDict["actionType"] == actionType.CREATE_STABLE: + self.create_stable(tsql, parameterDict["dbName"], parameterDict["stbName"]) + elif parameterDict["actionType"] == actionType.CREATE_CTABLE: + self.create_ctables(tsql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + elif parameterDict["actionType"] == actionType.INSERT_DATA: + self.insert_data(tsql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],parameterDict["batchNum"]) + else: + tdLog.exit("not support's action: ", parameterDict["actionType"]) + + return + + def tmqCase1(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 1: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db1', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 100 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + time.sleep(5) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("insert process end, and start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 2: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db2', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + parameterDict2 = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db2', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb2', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict2['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_stable(tdSql, parameterDict2["dbName"], parameterDict2["stbName"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 100 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start create child tables of stb1 and stb2") + parameterDict['actionType'] = actionType.CREATE_CTABLE + parameterDict2['actionType'] = actionType.CREATE_CTABLE + + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) + prepareEnvThread2.start() + + prepareEnvThread.join() + prepareEnvThread2.join() + + tdLog.info("start insert data into child tables of stb1 and stb2") + parameterDict['actionType'] = actionType.INSERT_DATA + parameterDict2['actionType'] = actionType.INSERT_DATA + + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) + prepareEnvThread2.start() + + prepareEnvThread.join() + prepareEnvThread2.join() + + tdLog.info("insert process end, and start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def tmqCase3(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 3: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db3', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 13, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,parameterDict["dbName"],parameterDict["stbName"],parameterDict["ctbNum"],parameterDict["rowsPerTbl"],parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + time.sleep(2) + tdLog.info("drop som child table of stb1") + dropTblNum = 4 + tdSql.query("drop table if exists %s.%s_9"%(parameterDict["dbName"], parameterDict["stbName"])) + tdSql.query("drop table if exists %s.%s_8"%(parameterDict["dbName"], parameterDict["stbName"])) + tdSql.query("drop table if exists %s.%s_7"%(parameterDict["dbName"], parameterDict["stbName"])) + tdSql.query("drop table if exists %s.%s_3"%(parameterDict["dbName"], parameterDict["stbName"])) + + tdLog.info("drop some child tables, then start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + remaindrowcnt = parameterDict["rowsPerTbl"] * (parameterDict["ctbNum"] - dropTblNum) + + if not (totalConsumeRows < expectrowcnt and totalConsumeRows > remaindrowcnt): + tdLog.info("act consume rows: %d, expect consume rows: between %d and %d"%(totalConsumeRows, remaindrowcnt, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 3 end ...... ") + + def tmqCase4(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 4: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db4', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 4 end ...... ") + + def tmqCase5(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 5: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db5', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != (expectrowcnt * (1 + 1/4)): + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 5 end ...... ") + + def tmqCase6(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 6: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db6', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:latest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 6 end ...... ") + + def tmqCase7(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 7: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db7', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:latest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 7 end ...... ") + + def tmqCase8(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 8: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db8', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:latest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume 0 processor") + pollDelay = 10 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume 0 result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 1 processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 2 processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 and 2 result") + expectRows = 3 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt*2: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 8 end ...... ") + + def tmqCase9(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 9: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db9', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:latest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume 0 processor") + pollDelay = 10 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume 0 result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 1 processor") + self.initConsumerInfoTable() + consumerId = 1 + ifManualCommit = 0 + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 2 processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 and 2 result") + expectRows = 3 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt*2: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 9 end ...... ") + + def tmqCase10(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 10: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db10', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:latest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume 0 processor") + pollDelay = 10 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume 0 result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 1 processor") + self.initConsumerInfoTable() + consumerId = 1 + ifManualCommit = 1 + self.insertConsumerInfo(consumerId, expectrowcnt-10000,topicList,keyList,ifcheckdata,ifManualCommit) + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt-10000: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt-10000)) + tdLog.exit("tmq consume rows error!") + + tdLog.info("start consume 2 processor") + self.initConsumerInfoTable() + consumerId = 2 + ifManualCommit = 1 + self.insertConsumerInfo(consumerId, expectrowcnt+10000,topicList,keyList,ifcheckdata,ifManualCommit) + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start one new thread to insert data") + parameterDict['actionType'] = actionType.INSERT_DATA + prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) + prepareEnvThread.start() + prepareEnvThread.join() + + tdLog.info("start to check consume 0 and 1 and 2 result") + expectRows = 3 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt*2: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 10 end ...... ") + + def tmqCase11(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 11: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db11', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:none' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:none' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != 0: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 11 end ...... ") + + def tmqCase12(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 12: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db12', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:none' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 12 end ...... ") + + def tmqCase13(self, cfgPath, buildPath): + tdLog.printNoPrefix("======== test case 13: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db13', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 10000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,\ + parameterDict["dbName"],\ + parameterDict["stbName"],\ + parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],\ + parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt/4,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 5 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt/4: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:none' + self.insertConsumerInfo(consumerId, expectrowcnt/2,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 2 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt*(1/2+1/4): + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*(1/2+1/4))) + tdLog.exit("tmq consume rows error!") + + self.initConsumerInfoTable() + consumerId = 2 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:none' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("again start consume processor") + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + tdLog.info("again check consume result") + expectRows = 3 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + if totalConsumeRows != expectrowcnt: + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 13 end ...... ") + + def run(self): + tdSql.prepare() + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + tdLog.info("cfgPath: %s" % cfgPath) + + #self.tmqCase1(cfgPath, buildPath) + #self.tmqCase2(cfgPath, buildPath) + #self.tmqCase3(cfgPath, buildPath) + #self.tmqCase4(cfgPath, buildPath) + #self.tmqCase5(cfgPath, buildPath) + self.tmqCase6(cfgPath, buildPath) + self.tmqCase7(cfgPath, buildPath) + self.tmqCase8(cfgPath, buildPath) + self.tmqCase9(cfgPath, buildPath) + self.tmqCase10(cfgPath, buildPath) + self.tmqCase11(cfgPath, buildPath) + self.tmqCase12(cfgPath, buildPath) + self.tmqCase13(cfgPath, buildPath) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 06be29a6362b091d24867288096569b8a9732bda..561114a2840e72475e0d1140b5e793acb909c32e 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -65,3 +65,4 @@ python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb1.py python3 ./test.py -f 7-tmq/subscribeStb.py +python3 ./test.py -f 7-tmq/subscribeStb1.py diff --git a/tests/test/c/createTable.c b/tests/test/c/createTable.c index c53ae0136cb2da84fd35634d0011a18a36d57c67..6a0f8e244ebcce79ac60a353df5d5343d58b4b34 100644 --- a/tests/test/c/createTable.c +++ b/tests/test/c/createTable.c @@ -261,7 +261,7 @@ void *threadFunc(void *param) { int64_t startTs = taosGetTimestampUs(); TAOS_RES *pRes = taos_query(con, qstr); code = taos_errno(pRes); - if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) { + if (code != 0) { pError("failed to insert %s_t%" PRId64 ", reason:%s", stbName, t, tstrerror(code)); } taos_free_result(pRes); diff --git a/tests/test/c/tmqDemo.c b/tests/test/c/tmqDemo.c index 96d7741897d2dd3d888585a4ed5a12be53f5c72f..5a972e071a5e28708cfb561ef1015d72ba830219 100644 --- a/tests/test/c/tmqDemo.c +++ b/tests/test/c/tmqDemo.c @@ -233,7 +233,6 @@ int64_t getDirectorySize(char* dir) { int queryDB(TAOS* taos, char* command) { TAOS_RES* pRes = taos_query(taos, command); int code = taos_errno(pRes); - // if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) { if (code != 0) { pError("failed to reason:%s, sql: %s", tstrerror(code), command); taos_free_result(pRes); diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index ab54c819cfe81cee3f5d10c0622478b0e44445b5..e0f58d052f612fca7ad0a257d8e137d8d4a5a1f6 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -258,7 +258,6 @@ static int32_t msg_process(TAOS_RES* msg, int64_t msgIndex, int32_t threadLable) int queryDB(TAOS* taos, char* command) { TAOS_RES* pRes = taos_query(taos, command); int code = taos_errno(pRes); - // if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) { if (code != 0) { pError("failed to reason:%s, sql: %s", tstrerror(code), command); taos_free_result(pRes);