Merge remote-tracking branch 'origin/3.0' into feature/qnode
This commit is contained in:
commit
71365eb53d
|
@ -71,8 +71,8 @@ ELSE ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (${SANITIZER} MATCHES "true")
|
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_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 -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 -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!")
|
MESSAGE(STATUS "Will compile with Address Sanitizer!")
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
|
@ -190,7 +190,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
||||||
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
||||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows);
|
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);
|
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows);
|
||||||
void colDataTrim(SColumnInfoData* pColumnInfoData);
|
void colDataTrim(SColumnInfoData* pColumnInfoData);
|
||||||
|
|
|
@ -2524,7 +2524,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
|
||||||
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
|
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
|
||||||
buf = taosDecodeFixedI32(buf, &pRsp->blockNum);
|
buf = taosDecodeFixedI32(buf, &pRsp->blockNum);
|
||||||
pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void*));
|
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->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void*));
|
||||||
pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void*));
|
pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void*));
|
||||||
if (pRsp->blockNum != 0) {
|
if (pRsp->blockNum != 0) {
|
||||||
|
|
|
@ -233,19 +233,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
#define qDebug(...) \
|
#define qDebug(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qTrace(...) \
|
#define qTrace(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_TRACE) { \
|
if (qDebugFlag & DEBUG_TRACE) { \
|
||||||
taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qDebugL(...) \
|
#define qDebugL(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
|
@ -39,64 +39,50 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SUCCESS 0
|
#define TSDB_CODE_SUCCESS 0
|
||||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
#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
|
//common & util
|
||||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0100)
|
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001)
|
||||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0101)
|
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0002)
|
||||||
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0102)
|
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||||
#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0103)
|
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0010)
|
||||||
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0104)
|
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011)
|
||||||
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0105)
|
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012)
|
||||||
#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0106)
|
#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0013)
|
||||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0107)
|
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0014)
|
||||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0108)
|
#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0015)
|
||||||
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0109)
|
#define TSDB_CODE_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0016)
|
||||||
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x010A)
|
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0017)
|
||||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x010B)
|
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0018)
|
||||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x010C)
|
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0019)
|
||||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x010D)
|
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x001A)
|
||||||
#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x010E)
|
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x001B)
|
||||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x010F)
|
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x001C)
|
||||||
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110)
|
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x001D)
|
||||||
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0111)
|
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x001E)
|
||||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0112)
|
#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x001F)
|
||||||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0113)
|
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0020)
|
||||||
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0114)
|
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0021)
|
||||||
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0115)
|
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0022)
|
||||||
#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0116)
|
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0023)
|
||||||
#define TSDB_CODE_NEED_RETRY TAOS_DEF_ERROR_CODE(0, 0x0117)
|
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0024)
|
||||||
#define TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE TAOS_DEF_ERROR_CODE(0, 0x0118)
|
#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, 0x0140)
|
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0040)
|
||||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0141)
|
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0041)
|
||||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0152)
|
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0042)
|
||||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0153)
|
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0043)
|
||||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0154)
|
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0044)
|
||||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0155)
|
#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
|
//client
|
||||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||||
|
@ -296,8 +282,8 @@ int32_t* taosGetErrno();
|
||||||
// dnode
|
// dnode
|
||||||
#define TSDB_CODE_NODE_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0400)
|
#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_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401)
|
||||||
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403)
|
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0402)
|
||||||
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0404)
|
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403)
|
||||||
|
|
||||||
// vnode
|
// vnode
|
||||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
||||||
|
|
|
@ -341,7 +341,7 @@ size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) {
|
||||||
|
|
||||||
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; }
|
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) {
|
if (pDataBlock == NULL || pDataBlock->info.rows <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,8 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock) {
|
||||||
return -1;
|
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) {
|
if (pColInfoData->info.type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,10 +134,10 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
||||||
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
||||||
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||||
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
||||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
void dmProcessFetchRsp(SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmNodes.c
|
// dmNodes.c
|
||||||
int32_t dmOpenNode(SMgmtWrapper *pWrapper);
|
int32_t dmOpenNode(SMgmtWrapper *pWrapper);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "dmNodes.h"
|
#include "dmNodes.h"
|
||||||
|
#include "qworker.h"
|
||||||
|
|
||||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||||
|
@ -279,38 +280,42 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus)
|
||||||
|
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
dDebug("msg:%p, net test req will be processed", 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);
|
rsp.pCont = rpcMallocCont(pMsg->contLen);
|
||||||
if (rsp.pCont == NULL) {
|
if (rsp.pCont == NULL) {
|
||||||
rsp.code = TSDB_CODE_OUT_OF_MEMORY;
|
rsp.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
rsp.contLen = pMsg->contLen;
|
rsp.contLen = pMsg->contLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
dDebug("msg:%p, server startup status req will be processed", pMsg);
|
dDebug("msg:%p, server startup status req will be processed", pMsg);
|
||||||
|
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
dmGetServerStartupStatus(pDnode, &statusRsp);
|
dmGetServerStartupStatus(pDnode, &statusRsp);
|
||||||
|
|
||||||
SRpcMsg rspMsg = {.info = pMsg->info};
|
SRpcMsg rsp = {.info = pMsg->info};
|
||||||
int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
int32_t contLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
||||||
if (rspLen < 0) {
|
if (contLen < 0) {
|
||||||
rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
rsp.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _OVER;
|
} else {
|
||||||
|
rsp.pCont = rpcMallocCont(contLen);
|
||||||
|
if (rsp.pCont != NULL) {
|
||||||
|
tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp);
|
||||||
|
rsp.contLen = contLen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pRsp = rpcMallocCont(rspLen);
|
rpcSendResponse(&rsp);
|
||||||
if (pRsp == NULL) {
|
rpcFreeCont(pMsg->pCont);
|
||||||
rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSServerStatusRsp(pRsp, rspLen, &statusRsp);
|
void dmProcessFetchRsp(SRpcMsg *pMsg) {
|
||||||
rspMsg.pCont = pRsp;
|
qWorkerProcessFetchRsp(NULL, NULL, pMsg);
|
||||||
rspMsg.contLen = rspLen;
|
// rpcFreeCont(pMsg->pCont);
|
||||||
|
|
||||||
_OVER:
|
|
||||||
rpcSendResponse(&rspMsg);
|
|
||||||
}
|
}
|
|
@ -148,7 +148,8 @@ static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg
|
||||||
} else if (remain < 8 + headLen + bodyLen) {
|
} else if (remain < 8 + headLen + bodyLen) {
|
||||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
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 + 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);
|
queue->tail = bodyLen - (remain - 8 - headLen);
|
||||||
} else {
|
} else {
|
||||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
||||||
|
@ -312,12 +313,7 @@ static void *dmConsumChildQueue(void *param) {
|
||||||
code = dmProcessNodeMsg(pWrapper, pMsg);
|
code = dmProcessNodeMsg(pWrapper, pMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pMsg, terrstr());
|
dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pMsg, terrstr());
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {.code = (terrno != 0 ? terrno : code), .info = pMsg->info};
|
||||||
.code = (terrno != 0 ? terrno : code),
|
|
||||||
.pCont = pMsg->info.rsp,
|
|
||||||
.contLen = pMsg->info.rspLen,
|
|
||||||
.info = pMsg->info,
|
|
||||||
};
|
|
||||||
dmPutToProcPQueue(proc, &rsp, DND_FUNC_RSP);
|
dmPutToProcPQueue(proc, &rsp, DND_FUNC_RSP);
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
|
@ -469,8 +465,18 @@ void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
|
||||||
taosMsleep(retry);
|
taosMsleep(retry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
pMsg->pCont = NULL;
|
||||||
|
pMsg->contLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,10 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "qworker.h"
|
|
||||||
|
|
||||||
#define INTERNAL_USER "_dnd"
|
static void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet);
|
||||||
#define INTERNAL_CKEY "_key"
|
static void dmSendRsp(SRpcMsg *pMsg);
|
||||||
#define INTERNAL_SECRET "_pwd"
|
static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
static inline int32_t dmBuildNodeMsg(SRpcMsg *pMsg, SRpcMsg *pRpc) {
|
static inline int32_t dmBuildNodeMsg(SRpcMsg *pMsg, SRpcMsg *pRpc) {
|
||||||
SRpcConnInfo connInfo = {0};
|
SRpcConnInfo connInfo = {0};
|
||||||
|
@ -52,46 +51,39 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SRpcMsg *pMsg = NULL;
|
SRpcMsg *pMsg = NULL;
|
||||||
bool needRelease = false;
|
|
||||||
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)];
|
|
||||||
SMgmtWrapper *pWrapper = 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),
|
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.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) {
|
if (pRpc->msgType == TDMT_DND_NET_TEST) {
|
||||||
dmProcessNetTestReq(pDnode, pRpc);
|
dmProcessNetTestReq(pDnode, pRpc);
|
||||||
goto _OVER_JUST_FREE;
|
return;
|
||||||
} else if (pRpc->msgType == TDMT_MND_SYSTABLE_RETRIEVE_RSP || pRpc->msgType == TDMT_VND_FETCH_RSP) {
|
} else if (pRpc->msgType == TDMT_MND_SYSTABLE_RETRIEVE_RSP || pRpc->msgType == TDMT_VND_FETCH_RSP) {
|
||||||
qWorkerProcessFetchRsp(NULL, NULL, pRpc);
|
dmProcessFetchRsp(pRpc);
|
||||||
goto _OVER_JUST_FREE;
|
return;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDnode->status != DND_STAT_RUNNING) {
|
if (pDnode->status != DND_STAT_RUNNING) {
|
||||||
if (pRpc->msgType == TDMT_DND_SERVER_STATUS) {
|
if (pRpc->msgType == TDMT_DND_SERVER_STATUS) {
|
||||||
dmProcessServerStartupStatus(pDnode, pRpc);
|
dmProcessServerStartupStatus(pDnode, pRpc);
|
||||||
goto _OVER_JUST_FREE;
|
return;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
goto _OVER_RSP_FREE;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsReq(pRpc) && pRpc->pCont == NULL) {
|
if (IsReq(pRpc) && pRpc->pCont == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER_RSP_FREE;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle->defaultNtype == NODE_END) {
|
if (pHandle->defaultNtype == NODE_END) {
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
goto _OVER_RSP_FREE;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
pWrapper = &pDnode->wrappers[pHandle->defaultNtype];
|
pWrapper = &pDnode->wrappers[pHandle->defaultNtype];
|
||||||
if (pHandle->needCheckVgId) {
|
if (pHandle->needCheckVgId) {
|
||||||
|
@ -106,15 +98,15 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER_RSP_FREE;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmMarkWrapper(pWrapper) != 0) {
|
if (dmMarkWrapper(pWrapper) != 0) {
|
||||||
goto _OVER_RSP_FREE;
|
pWrapper = NULL;
|
||||||
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
needRelease = true;
|
|
||||||
pRpc->info.wrapper = pWrapper;
|
pRpc->info.wrapper = pWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,24 +126,23 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code == 0) {
|
if (code != 0) {
|
||||||
if (pWrapper != NULL && InParentProc(pWrapper)) {
|
|
||||||
dTrace("msg:%p, is freed after push to cqueue", pMsg);
|
|
||||||
taosFreeQitem(pMsg);
|
|
||||||
rpcFreeCont(pRpc->pCont);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dError("msg:%p, failed to process since %s", pMsg, terrstr());
|
dError("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
|
|
||||||
if (IsReq(pRpc)) {
|
if (IsReq(pRpc)) {
|
||||||
if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) {
|
SRpcMsg rsp = {.code = code, .info = pRpc->info};
|
||||||
if (pRpc->msgType > TDMT_MND_MSG && pRpc->msgType < TDMT_VND_MSG) {
|
|
||||||
code = TSDB_CODE_NODE_REDIRECT;
|
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);
|
dTrace("msg:%p, is freed", pMsg);
|
||||||
|
@ -159,20 +150,8 @@ _OVER:
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needRelease) {
|
|
||||||
dmReleaseWrapper(pWrapper);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode) {
|
int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
@ -218,13 +197,25 @@ static inline void dmSendRsp(SRpcMsg *pMsg) {
|
||||||
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
||||||
if (InChildProc(pWrapper)) {
|
if (InChildProc(pWrapper)) {
|
||||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP);
|
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP);
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
pMsg->pCont = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
rpcSendResponse(pMsg);
|
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) {
|
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
SMEpSet msg = {.epSet = *pNewEpSet};
|
SMEpSet msg = {.epSet = *pNewEpSet};
|
||||||
|
@ -246,8 +237,6 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) {
|
||||||
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
||||||
if (InChildProc(pWrapper)) {
|
if (InChildProc(pWrapper)) {
|
||||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_REGIST);
|
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_REGIST);
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
pMsg->pCont = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +264,6 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.user = INTERNAL_USER;
|
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
rpcInit.rfp = rpcRfp;
|
rpcInit.rfp = rpcRfp;
|
||||||
|
|
||||||
|
@ -343,34 +331,3 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) {
|
||||||
};
|
};
|
||||||
return msgCb;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ int32_t dmReadEps(SDnodeData *pData);
|
||||||
int32_t dmWriteEps(SDnodeData *pData);
|
int32_t dmWriteEps(SDnodeData *pData);
|
||||||
void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps);
|
void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps);
|
||||||
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
||||||
|
void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -314,6 +314,17 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
taosThreadRwlockUnlock(&pData->lock);
|
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) {
|
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
taosThreadRwlockWrlock(&pData->lock);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
pData->mnodeEps = *pEpSet;
|
pData->mnodeEps = *pEpSet;
|
||||||
|
|
|
@ -994,9 +994,6 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
|
||||||
pAction->msgSent = 0;
|
pAction->msgSent = 0;
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = terrno;
|
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());
|
mError("trans:%d, action:%d not send since %s", pTrans->id, action, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,12 +483,12 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||||
goto _err;
|
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;
|
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pSchema->sver++;
|
pSchema->sver++;
|
||||||
pColumn->bytes = pAlterTbReq->bytes;
|
pColumn->bytes = pAlterTbReq->colModBytes;
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
|
|
|
@ -2775,7 +2775,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
|
||||||
|
|
||||||
win->ekey = key;
|
win->ekey = key;
|
||||||
if (rv != TD_ROW_SVER(row)) {
|
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);
|
rv = TD_ROW_SVER(row);
|
||||||
}
|
}
|
||||||
numOfRows += mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, &curRows, row, NULL, numOfCols, pCheckInfo->tableId,
|
numOfRows += mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, &curRows, row, NULL, numOfCols, pCheckInfo->tableId,
|
||||||
|
|
|
@ -77,7 +77,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
pVnode->path = (char *)&pVnode[1];
|
pVnode->path = (char *)&pVnode[1];
|
||||||
strcpy(pVnode->path, path);
|
strcpy(pVnode->path, path);
|
||||||
pVnode->config = info.config;
|
pVnode->config = info.config;
|
||||||
pVnode->state = info.state;
|
pVnode->state.committed = info.state.committed;
|
||||||
|
pVnode->state.applied = info.state.committed;
|
||||||
pVnode->pTfs = pTfs;
|
pVnode->pTfs = pTfs;
|
||||||
pVnode->msgCb = msgCb;
|
pVnode->msgCb = msgCb;
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "trpc.h"
|
|
||||||
#include "query.h"
|
|
||||||
#include "tname.h"
|
|
||||||
#include "catalogInt.h"
|
#include "catalogInt.h"
|
||||||
|
#include "query.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "tname.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
int32_t ctgActUpdateVg(SCtgMetaAction *action);
|
int32_t ctgActUpdateVg(SCtgMetaAction *action);
|
||||||
int32_t ctgActUpdateTbl(SCtgMetaAction *action);
|
int32_t ctgActUpdateTbl(SCtgMetaAction *action);
|
||||||
|
@ -28,37 +28,10 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action);
|
||||||
|
|
||||||
extern SCtgDebug gCTGDebug;
|
extern SCtgDebug gCTGDebug;
|
||||||
SCatalogMgmt gCtgMgmt = {0};
|
SCatalogMgmt gCtgMgmt = {0};
|
||||||
SCtgAction gCtgAction[CTG_ACT_MAX] = {{
|
SCtgAction gCtgAction[CTG_ACT_MAX] = {
|
||||||
CTG_ACT_UPDATE_VG,
|
{CTG_ACT_UPDATE_VG, "update vgInfo", ctgActUpdateVg}, {CTG_ACT_UPDATE_TBL, "update tbMeta", ctgActUpdateTbl},
|
||||||
"update vgInfo",
|
{CTG_ACT_REMOVE_DB, "remove DB", ctgActRemoveDB}, {CTG_ACT_REMOVE_STB, "remove stbMeta", ctgActRemoveStb},
|
||||||
ctgActUpdateVg
|
{CTG_ACT_REMOVE_TBL, "remove tbMeta", ctgActRemoveTbl}, {CTG_ACT_UPDATE_USER, "update user", ctgActUpdateUser}};
|
||||||
},
|
|
||||||
{
|
|
||||||
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) {
|
void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
|
||||||
if (NULL == mgmt->slots) {
|
if (NULL == mgmt->slots) {
|
||||||
|
@ -76,7 +49,6 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
|
||||||
taosMemoryFreeClear(mgmt->slots);
|
taosMemoryFreeClear(mgmt->slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ctgFreeTableMetaCache(SCtgTbMetaCache *cache) {
|
void ctgFreeTableMetaCache(SCtgTbMetaCache *cache) {
|
||||||
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
||||||
if (cache->stbCache) {
|
if (cache->stbCache) {
|
||||||
|
@ -171,8 +143,6 @@ void ctgFreeHandle(SCatalog* pCtg) {
|
||||||
taosMemoryFree(pCtg);
|
taosMemoryFree(pCtg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ctgWaitAction(SCtgMetaAction *action) {
|
void ctgWaitAction(SCtgMetaAction *action) {
|
||||||
while (true) {
|
while (true) {
|
||||||
tsem_wait(&gCtgMgmt.queue.rspSem);
|
tsem_wait(&gCtgMgmt.queue.rspSem);
|
||||||
|
@ -204,7 +174,6 @@ void ctgPopAction(SCtgMetaAction **action) {
|
||||||
*action = &node->action;
|
*action = &node->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgPushAction(SCatalog *pCtg, SCtgMetaAction *action) {
|
int32_t ctgPushAction(SCatalog *pCtg, SCtgMetaAction *action) {
|
||||||
SCtgQNode *node = taosMemoryCalloc(1, sizeof(SCtgQNode));
|
SCtgQNode *node = taosMemoryCalloc(1, sizeof(SCtgQNode));
|
||||||
if (NULL == node) {
|
if (NULL == node) {
|
||||||
|
@ -235,7 +204,6 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgPushRmDBMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId) {
|
int32_t ctgPushRmDBMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_DB};
|
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_DB};
|
||||||
|
@ -266,8 +234,8 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgPushRmStbMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid,
|
||||||
int32_t ctgPushRmStbMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq) {
|
bool syncReq) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_STB, .syncReq = syncReq};
|
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_STB, .syncReq = syncReq};
|
||||||
SCtgRemoveStbMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveStbMsg));
|
SCtgRemoveStbMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveStbMsg));
|
||||||
|
@ -294,8 +262,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgPushRmTblMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq) {
|
int32_t ctgPushRmTblMsgInQueue(SCatalog *pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_TBL, .syncReq = syncReq};
|
SCtgMetaAction action = {.act = CTG_ACT_REMOVE_TBL, .syncReq = syncReq};
|
||||||
|
@ -423,7 +389,6 @@ int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (NULL == dbCache->vgInfo) {
|
if (NULL == dbCache->vgInfo) {
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->vgLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->vgLock);
|
||||||
|
|
||||||
|
@ -449,18 +414,11 @@ int32_t ctgWAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) { taosHashRelease(pCtg->dbCache, dbCache); }
|
||||||
taosHashRelease(pCtg->dbCache, dbCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ctgReleaseVgInfo(SCtgDBCache *dbCache) {
|
void ctgReleaseVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_READ, &dbCache->vgLock); }
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->vgLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ctgWReleaseVgInfo(SCtgDBCache *dbCache) {
|
|
||||||
CTG_UNLOCK(CTG_WRITE, &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, '.');
|
char *p = strchr(dbFName, '.');
|
||||||
|
@ -504,7 +462,6 @@ int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache)
|
||||||
CTG_RET(ctgAcquireDBCacheImpl(pCtg, dbFName, pCache, false));
|
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;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
|
@ -585,8 +542,8 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetDBVgInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, SBuildUseDBInput *input,
|
||||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, SBuildUseDBInput *input, SUseDbOutput *out) {
|
SUseDbOutput *out) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
|
@ -660,7 +617,8 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *indexName, SIndexInfo *out) {
|
int32_t ctgGetIndexInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *indexName,
|
||||||
|
SIndexInfo *out) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
|
@ -697,7 +655,8 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *funcName, SFuncInfo **out) {
|
int32_t ctgGetUdfInfoFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *funcName,
|
||||||
|
SFuncInfo **out) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
|
@ -740,7 +699,8 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEp
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *user, SGetUserAuthRsp *authRsp) {
|
int32_t ctgGetUserDbAuthFromMnode(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *user,
|
||||||
|
SGetUserAuthRsp *authRsp) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
|
@ -777,7 +737,6 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
if (NULL == pCtg->dbCache) {
|
||||||
*exist = 0;
|
*exist = 0;
|
||||||
|
@ -814,8 +773,8 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetTableMetaFromCache(SCatalog *pCtg, const SName *pTableName, STableMeta **pTableMeta, bool *inCache,
|
||||||
int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, bool *inCache, int32_t flag, uint64_t *dbId) {
|
int32_t flag, uint64_t *dbId) {
|
||||||
if (NULL == pCtg->dbCache) {
|
if (NULL == pCtg->dbCache) {
|
||||||
ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname);
|
ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname);
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -839,7 +798,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
||||||
|
|
||||||
int32_t sz = 0;
|
int32_t sz = 0;
|
||||||
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
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);
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
|
|
||||||
if (NULL == *pTableMeta) {
|
if (NULL == *pTableMeta) {
|
||||||
|
@ -864,7 +824,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
||||||
return TSDB_CODE_SUCCESS;
|
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);
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
|
||||||
|
@ -881,7 +842,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
taosMemoryFreeClear(*pTableMeta);
|
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);
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +913,8 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const char* dbFName, const char
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
if (NULL == pCtg->userCache) {
|
||||||
ctgDebug("empty user auth cache, user:%s", user);
|
ctgDebug("empty user auth cache, user:%s", user);
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -1000,7 +963,8 @@ _return:
|
||||||
return TSDB_CODE_SUCCESS;
|
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};
|
SBuildTableMetaInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName};
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
SEpSet *pVnodeEpSet = NULL;
|
SEpSet *pVnodeEpSet = NULL;
|
||||||
|
@ -1031,7 +995,8 @@ int32_t ctgGetTableMetaFromMnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet*
|
||||||
return TSDB_CODE_SUCCESS;
|
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);
|
CTG_ERR_RET(rpcRsp.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,15 +1011,18 @@ int32_t ctgGetTableMetaFromMnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet*
|
||||||
return TSDB_CODE_SUCCESS;
|
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];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
tNameGetFullDbName(pTableName, dbFName);
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
|
||||||
return ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, dbFName, (char *)pTableName->tname, output);
|
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) {
|
int32_t ctgGetTableMetaFromVnodeImpl(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName,
|
||||||
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName || NULL == vgroupInfo || NULL == output) {
|
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);
|
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,13 +1031,15 @@ int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet*
|
||||||
|
|
||||||
ctgDebug("try to get table meta from vnode, dbFName:%s, tbName:%s", dbFName, tNameGetTableName(pTableName));
|
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)};
|
SBuildTableMetaInput bInput = {
|
||||||
|
.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)};
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
int32_t code = queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)](&bInput, &msg, 0, &msgLen);
|
int32_t code = queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)](&bInput, &msg, 0, &msgLen);
|
||||||
if (code) {
|
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);
|
CTG_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,13 +1059,15 @@ int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet*
|
||||||
return TSDB_CODE_SUCCESS;
|
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);
|
CTG_ERR_RET(rpcRsp.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)](output, rpcRsp.pCont, rpcRsp.contLen);
|
code = queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)](output, rpcRsp.pCont, rpcRsp.contLen);
|
||||||
if (code) {
|
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);
|
CTG_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,7 +1075,8 @@ int32_t ctgGetTableMetaFromVnodeImpl(SCatalog* pCtg, void *pTrans, const SEpSet*
|
||||||
return TSDB_CODE_SUCCESS;
|
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 code = 0;
|
||||||
int32_t retryNum = 0;
|
int32_t retryNum = 0;
|
||||||
|
|
||||||
|
@ -1217,7 +1190,8 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == vgInfo) {
|
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);
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,7 +1240,6 @@ int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
|
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
|
||||||
mgmt->slotRIdx = 0;
|
mgmt->slotRIdx = 0;
|
||||||
mgmt->slotNum = rentSec / CTG_RENT_SLOT_SECOND;
|
mgmt->slotNum = rentSec / CTG_RENT_SLOT_SECOND;
|
||||||
|
@ -1285,7 +1258,6 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) {
|
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) {
|
||||||
int16_t widx = abs((int)(id % mgmt->slotNum));
|
int16_t widx = abs((int)(id % mgmt->slotNum));
|
||||||
|
|
||||||
|
@ -1296,7 +1268,8 @@ int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size)
|
||||||
if (NULL == slot->meta) {
|
if (NULL == slot->meta) {
|
||||||
slot->meta = taosArrayInit(CTG_DEFAULT_RENT_SLOT_SIZE, size);
|
slot->meta = taosArrayInit(CTG_DEFAULT_RENT_SLOT_SIZE, size);
|
||||||
if (NULL == slot->meta) {
|
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);
|
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1316,7 +1289,8 @@ _return:
|
||||||
CTG_RET(code);
|
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));
|
int16_t widx = abs((int)(id % mgmt->slotNum));
|
||||||
|
|
||||||
SCtgRentSlot *slot = &mgmt->slots[widx];
|
SCtgRentSlot *slot = &mgmt->slots[widx];
|
||||||
|
@ -1329,7 +1303,8 @@ int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t si
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot->needSort) {
|
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);
|
taosArraySort(slot->meta, sortCompare);
|
||||||
slot->needSort = false;
|
slot->needSort = false;
|
||||||
qDebug("meta slot sorted, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta));
|
qDebug("meta slot sorted, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta));
|
||||||
|
@ -1337,7 +1312,8 @@ int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t si
|
||||||
|
|
||||||
void *orig = taosArraySearch(slot->meta, &id, searchCompare, TD_EQ);
|
void *orig = taosArraySearch(slot->meta, &id, searchCompare, TD_EQ);
|
||||||
if (NULL == orig) {
|
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);
|
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,7 +1326,8 @@ _return:
|
||||||
CTG_UNLOCK(CTG_WRITE, &slot->lock);
|
CTG_UNLOCK(CTG_WRITE, &slot->lock);
|
||||||
|
|
||||||
if (code) {
|
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));
|
CTG_RET(ctgMetaRentAdd(mgmt, meta, id, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1392,7 +1369,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) {
|
int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) {
|
||||||
int16_t ridx = atomic_add_fetch_16(&mgmt->slotRIdx, 1);
|
int16_t ridx = atomic_add_fetch_16(&mgmt->slotRIdx, 1);
|
||||||
if (ridx >= mgmt->slotNum) {
|
if (ridx >= mgmt->slotNum) {
|
||||||
|
@ -1468,13 +1444,15 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
|
||||||
SCtgDBCache newDBCache = {0};
|
SCtgDBCache newDBCache = {0};
|
||||||
newDBCache.dbId = dbId;
|
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) {
|
if (NULL == newDBCache.tbCache.metaCache) {
|
||||||
ctgError("taosHashInit %d metaCache failed", gCtgMgmt.cfg.maxTblCacheNum);
|
ctgError("taosHashInit %d metaCache failed", gCtgMgmt.cfg.maxTblCacheNum);
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
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) {
|
if (NULL == newDBCache.tbCache.stbCache) {
|
||||||
ctgError("taosHashInit %d stbCache failed", gCtgMgmt.cfg.maxTblCacheNum);
|
ctgError("taosHashInit %d stbCache failed", gCtgMgmt.cfg.maxTblCacheNum);
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
@ -1511,7 +1489,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ctgRemoveStbRent(SCatalog *pCtg, SCtgTbMetaCache *cache) {
|
void ctgRemoveStbRent(SCatalog *pCtg, SCtgTbMetaCache *cache) {
|
||||||
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
||||||
if (cache->stbCache) {
|
if (cache->stbCache) {
|
||||||
|
@ -1520,7 +1497,8 @@ void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) {
|
||||||
uint64_t *suid = NULL;
|
uint64_t *suid = NULL;
|
||||||
suid = taosHashGetKey(pIter, NULL);
|
suid = taosHashGetKey(pIter, NULL);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) {
|
if (TSDB_CODE_SUCCESS ==
|
||||||
|
ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) {
|
||||||
ctgDebug("stb removed from rent, suid:%" PRIx64, *suid);
|
ctgDebug("stb removed from rent, suid:%" PRIx64, *suid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1530,7 +1508,6 @@ void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) {
|
||||||
CTG_UNLOCK(CTG_WRITE, &cache->stbLock);
|
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;
|
uint64_t dbId = dbCache->dbId;
|
||||||
|
|
||||||
|
@ -1558,7 +1535,6 @@ int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgGetAddDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SCtgDBCache **pCache) {
|
int32_t ctgGetAddDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SCtgDBCache **pCache) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
@ -1600,7 +1576,6 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgUpdateDBVgInfo(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SDBVgInfo **pDbInfo) {
|
int32_t ctgUpdateDBVgInfo(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SDBVgInfo **pDbInfo) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SDBVgInfo *dbInfo = *pDbInfo;
|
SDBVgInfo *dbInfo = *pDbInfo;
|
||||||
|
@ -1610,8 +1585,8 @@ int32_t ctgUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SD
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbInfo->vgVersion < 0 || taosHashGetSize(dbInfo->vgHash) <= 0) {
|
if (dbInfo->vgVersion < 0 || taosHashGetSize(dbInfo->vgHash) <= 0) {
|
||||||
ctgError("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d",
|
ctgError("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d", dbFName, dbInfo->vgHash,
|
||||||
dbFName, dbInfo->vgHash, dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash));
|
dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash));
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,14 +1605,16 @@ int32_t ctgUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SD
|
||||||
|
|
||||||
if (dbCache->vgInfo) {
|
if (dbCache->vgInfo) {
|
||||||
if (dbInfo->vgVersion < dbCache->vgInfo->vgVersion) {
|
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);
|
ctgWReleaseVgInfo(dbCache);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbInfo->vgVersion == dbCache->vgInfo->vgVersion && dbInfo->numOfTable == dbCache->vgInfo->numOfTable) {
|
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);
|
ctgWReleaseVgInfo(dbCache);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1657,13 +1634,14 @@ int32_t ctgUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId, SD
|
||||||
dbCache = NULL;
|
dbCache = NULL;
|
||||||
|
|
||||||
strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
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);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, uint64_t dbId, char *tbName,
|
||||||
int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, uint64_t dbId, char *tbName, STableMeta *meta, int32_t metaSize) {
|
STableMeta *meta, int32_t metaSize) {
|
||||||
SCtgTbMetaCache *tbCache = &dbCache->tbCache;
|
SCtgTbMetaCache *tbCache = &dbCache->tbCache;
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &tbCache->metaLock);
|
CTG_LOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
@ -1680,7 +1658,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
if (orig) {
|
if (orig) {
|
||||||
origType = orig->tableType;
|
origType = orig->tableType;
|
||||||
|
|
||||||
if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) {
|
if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion &&
|
||||||
|
orig->tversion >= meta->tversion) {
|
||||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1722,7 +1701,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
CTG_CACHE_STAT_ADD(tblNum, 1);
|
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);
|
ctgdShowTableMeta(pCtg, tbName, meta);
|
||||||
|
|
||||||
if (!isStb) {
|
if (!isStb) {
|
||||||
|
@ -1744,9 +1724,11 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
|
|
||||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
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.dbFName, dbFName);
|
||||||
strcpy(metaRent.stbName, tbName);
|
strcpy(metaRent.stbName, tbName);
|
||||||
CTG_ERR_RET(ctgMetaRentAdd(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableMetaVersion)));
|
CTG_ERR_RET(ctgMetaRentAdd(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableMetaVersion)));
|
||||||
|
@ -1787,13 +1769,11 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) {
|
||||||
pIter = taosHashIterate(src->vgHash, pIter);
|
pIter = taosHashIterate(src->vgHash, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetDBVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *dbFName, SCtgDBCache **dbCache,
|
||||||
|
SDBVgInfo **pInfo) {
|
||||||
int32_t ctgGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SCtgDBCache** dbCache, SDBVgInfo **pInfo) {
|
|
||||||
bool inCache = false;
|
bool inCache = false;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1869,8 +1849,6 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, c
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) {
|
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) {
|
||||||
*pOutput = taosMemoryMalloc(sizeof(STableMetaOutput));
|
*pOutput = taosMemoryMalloc(sizeof(STableMetaOutput));
|
||||||
if (NULL == *pOutput) {
|
if (NULL == *pOutput) {
|
||||||
|
@ -1895,9 +1873,8 @@ int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput)
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName) {
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1896,8 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
|
||||||
if (CTG_FLAG_IS_SYS_DB(flag)) {
|
if (CTG_FLAG_IS_SYS_DB(flag)) {
|
||||||
ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName));
|
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)) {
|
} else if (CTG_FLAG_IS_STB(flag)) {
|
||||||
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(pTableName));
|
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(pTableName));
|
||||||
|
|
||||||
|
@ -1972,9 +1950,11 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CTG_IS_META_TABLE(output->metaType)) {
|
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 {
|
} 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) {
|
if (pOutput) {
|
||||||
|
@ -1993,7 +1973,8 @@ _return:
|
||||||
CTG_RET(code);
|
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) {
|
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pTableMeta) {
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
@ -2013,7 +1994,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
||||||
int32_t tbType = 0;
|
int32_t tbType = 0;
|
||||||
|
|
||||||
if (inCache) {
|
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;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2027,7 +2009,6 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
||||||
CTG_FLAG_SET_STB(flag, tbType);
|
CTG_FLAG_SET_STB(flag, tbType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
CTG_ERR_JRET(ctgRefreshTblMeta(pCtg, pRpc, pMgmtEps, pTableName, flag, &output, false));
|
CTG_ERR_JRET(ctgRefreshTblMeta(pCtg, pRpc, pMgmtEps, pTableName, flag, &output, false));
|
||||||
|
|
||||||
|
@ -2095,7 +2076,8 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass) {
|
int32_t ctgChkAuth(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const char *user, const char *dbFName,
|
||||||
|
AUTH_TYPE type, bool *pass) {
|
||||||
bool inCache = false;
|
bool inCache = false;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -2135,7 +2117,6 @@ _return:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgActUpdateVg(SCtgMetaAction *action) {
|
int32_t ctgActUpdateVg(SCtgMetaAction *action) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgUpdateVgMsg *msg = action->data;
|
SCtgUpdateVgMsg *msg = action->data;
|
||||||
|
@ -2162,7 +2143,8 @@ int32_t ctgActRemoveDB(SCtgMetaAction *action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbCache->dbId != msg->dbId) {
|
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;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2175,7 +2157,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgActUpdateTbl(SCtgMetaAction *action) {
|
int32_t ctgActUpdateTbl(SCtgMetaAction *action) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgUpdateTblMsg *msg = action->data;
|
SCtgUpdateTblMsg *msg = action->data;
|
||||||
|
@ -2202,11 +2183,13 @@ int32_t ctgActUpdateTbl(SCtgMetaAction *action) {
|
||||||
if (CTG_IS_META_TABLE(output->metaType) || CTG_IS_META_BOTH(output->metaType)) {
|
if (CTG_IS_META_TABLE(output->metaType) || CTG_IS_META_BOTH(output->metaType)) {
|
||||||
int32_t metaSize = CTG_META_SIZE(output->tbMeta);
|
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)) {
|
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:
|
_return:
|
||||||
|
@ -2221,7 +2204,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgActRemoveStb(SCtgMetaAction *action) {
|
int32_t ctgActRemoveStb(SCtgMetaAction *action) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgRemoveStbMsg *msg = action->data;
|
SCtgRemoveStbMsg *msg = action->data;
|
||||||
|
@ -2234,13 +2216,15 @@ int32_t ctgActRemoveStb(SCtgMetaAction *action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->dbId && (dbCache->dbId != msg->dbId)) {
|
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;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
||||||
if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) {
|
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 {
|
} else {
|
||||||
CTG_CACHE_STAT_SUB(stblNum, 1);
|
CTG_CACHE_STAT_SUB(stblNum, 1);
|
||||||
}
|
}
|
||||||
|
@ -2280,7 +2264,8 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbCache->dbId != msg->dbId) {
|
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;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2309,7 +2294,8 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) {
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
if (NULL == pCtg->userCache) {
|
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) {
|
if (NULL == pCtg->userCache) {
|
||||||
ctgError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum);
|
ctgError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum);
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -2326,7 +2312,7 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) {
|
||||||
userAuth.readDbs = msg->userAuth.readDbs;
|
userAuth.readDbs = msg->userAuth.readDbs;
|
||||||
userAuth.writeDbs = msg->userAuth.writeDbs;
|
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);
|
ctgError("taosHashPut user %s to cache failed", msg->userAuth.user);
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
@ -2356,7 +2342,6 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
||||||
taosHashCleanup(msg->userAuth.createdDbs);
|
taosHashCleanup(msg->userAuth.createdDbs);
|
||||||
taosHashCleanup(msg->userAuth.readDbs);
|
taosHashCleanup(msg->userAuth.readDbs);
|
||||||
taosHashCleanup(msg->userAuth.writeDbs);
|
taosHashCleanup(msg->userAuth.writeDbs);
|
||||||
|
@ -2366,7 +2351,6 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *ctgUpdateThreadFunc(void *param) {
|
void *ctgUpdateThreadFunc(void *param) {
|
||||||
setThreadName("catalog");
|
setThreadName("catalog");
|
||||||
|
|
||||||
|
@ -2410,7 +2394,6 @@ void* ctgUpdateThreadFunc(void* param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgStartUpdateThread() {
|
int32_t ctgStartUpdateThread() {
|
||||||
TdThreadAttr thAttr;
|
TdThreadAttr thAttr;
|
||||||
taosThreadAttrInit(&thAttr);
|
taosThreadAttrInit(&thAttr);
|
||||||
|
@ -2425,7 +2408,8 @@ int32_t ctgStartUpdateThread() {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) {
|
int32_t ctgGetTableDistVgInfo(SCatalog *pCtg, void *pRpc, const SEpSet *pMgmtEps, const SName *pTableName,
|
||||||
|
SArray **pVgList) {
|
||||||
STableMeta *tbMeta = NULL;
|
STableMeta *tbMeta = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVgroupInfo vgroupInfo = {0};
|
SVgroupInfo vgroupInfo = {0};
|
||||||
|
@ -2534,7 +2518,8 @@ int32_t catalogInit(SCatalogCfg *cfg) {
|
||||||
gCtgMgmt.cfg.stbRentSec = CTG_DEFAULT_RENT_SECOND;
|
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) {
|
if (NULL == gCtgMgmt.pCluster) {
|
||||||
qError("taosHashInit %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER);
|
qError("taosHashInit %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER);
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
@ -2559,7 +2544,8 @@ int32_t catalogInit(SCatalogCfg *cfg) {
|
||||||
|
|
||||||
CTG_ERR_RET(ctgStartUpdateThread());
|
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;
|
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->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB));
|
||||||
CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE));
|
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) {
|
if (NULL == clusterCtg->dbCache) {
|
||||||
qError("taosHashInit %d dbCache failed", CTG_DEFAULT_CACHE_DB_NUMBER);
|
qError("taosHashInit %d dbCache failed", CTG_DEFAULT_CACHE_DB_NUMBER);
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
@ -2684,7 +2671,8 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == dbFName || NULL == pRpc || NULL == pMgmtEps || NULL == vgroupList) {
|
if (NULL == pCtg || NULL == dbFName || NULL == pRpc || NULL == pMgmtEps || NULL == vgroupList) {
|
||||||
|
@ -2723,7 +2711,6 @@ _return:
|
||||||
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -2741,7 +2728,6 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -2764,9 +2750,7 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet) {
|
int32_t catalogUpdateVgEpSet(SCatalog *pCtg, const char *dbFName, int32_t vgId, SEpSet *epSet) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t catalogRemoveTableMeta(SCatalog *pCtg, const SName *pTableName) {
|
int32_t catalogRemoveTableMeta(SCatalog *pCtg, const SName *pTableName) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
@ -2809,7 +2793,6 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -2832,17 +2815,20 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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;
|
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_ENTER();
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_UNKNOWN_STB));
|
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_ENTER();
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_STB));
|
CTG_API_LEAVE(ctgGetTableMeta(pCtg, pTrans, pMgmtEps, pTableName, pTableMeta, CTG_FLAG_STB));
|
||||||
|
@ -2884,9 +2870,8 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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;
|
*sver = -1;
|
||||||
|
|
||||||
if (NULL == pCtg->dbCache) {
|
if (NULL == pCtg->dbCache) {
|
||||||
|
@ -2942,7 +2927,8 @@ int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t*
|
||||||
if ((*stbMeta)->suid != *suid) {
|
if ((*stbMeta)->suid != *suid) {
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
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);
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3011,7 +2997,6 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm
|
||||||
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -3022,23 +3007,28 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmt
|
||||||
CTG_API_LEAVE(ctgRefreshDBVgInfo(pCtg, pTrans, pMgmtEps, dbFName));
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName) {
|
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTableName) {
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
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_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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pVgList) {
|
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pVgList) {
|
||||||
|
@ -3056,7 +3046,8 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
|
||||||
code = ctgGetTableDistVgInfo(pCtg, pRpc, pMgmtEps, pTableName, pVgList);
|
code = ctgGetTableDistVgInfo(pCtg, pRpc, pMgmtEps, pTableName, pVgList);
|
||||||
if (code) {
|
if (code) {
|
||||||
if (TSDB_CODE_CTG_VG_META_MISMATCH == 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};
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
tNameGetFullDbName(pTableName, dbFName);
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
@ -3074,8 +3065,8 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName,
|
||||||
int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) {
|
SVgroupInfo *pVgroup) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (CTG_IS_SYS_DBNAME(pTableName->dbname)) {
|
if (CTG_IS_SYS_DBNAME(pTableName->dbname)) {
|
||||||
|
@ -3108,8 +3099,8 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogGetAllMeta(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SCatalogReq *pReq,
|
||||||
int32_t catalogGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SCatalogReq* pReq, SMetaData* pRsp) {
|
SMetaData *pRsp) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pReq || NULL == pRsp) {
|
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pReq || NULL == pRsp) {
|
||||||
|
@ -3232,7 +3223,6 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion **users, uint32_
|
||||||
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -3243,7 +3233,8 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
||||||
CTG_API_LEAVE(ctgGetDBCfgFromMnode(pCtg, pRpc, pMgmtEps, dbFName, pDbCfg));
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == indexName || NULL == pInfo) {
|
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == indexName || NULL == pInfo) {
|
||||||
|
@ -3277,7 +3268,8 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
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();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == user || NULL == dbFName || NULL == pass) {
|
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == user || NULL == dbFName || NULL == pass) {
|
||||||
|
@ -3302,7 +3294,6 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) {
|
||||||
CTG_API_LEAVE(ctgPushUpdateUserMsgInQueue(pCtg, pAuth, false));
|
CTG_API_LEAVE(ctgPushUpdateUserMsgInQueue(pCtg, pAuth, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void catalogDestroy(void) {
|
void catalogDestroy(void) {
|
||||||
qInfo("start to destroy catalog");
|
qInfo("start to destroy catalog");
|
||||||
|
|
||||||
|
@ -3346,5 +3337,3 @@ void catalogDestroy(void) {
|
||||||
qInfo("catalog destroyed");
|
qInfo("catalog destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1903,7 +1903,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SArray* pColMatchIn
|
||||||
filterFreeInfo(filter);
|
filterFreeInfo(filter);
|
||||||
|
|
||||||
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
|
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) {
|
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);
|
qDebug("%s result generated, rows:%d, groupId:%"PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, pBlock->info.groupId);
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2797,7 +2797,9 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.rows = numOfRows;
|
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;
|
int64_t el = taosGetTimestampUs() - startTs;
|
||||||
|
|
||||||
|
|
|
@ -553,7 +553,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->pageIndex += 1;
|
pInfo->pageIndex += 1;
|
||||||
|
|
||||||
blockDataUpdateTsWindow(pInfo->binfo.pRes);
|
blockDataUpdateTsWindow(pInfo->binfo.pRes, 0);
|
||||||
pInfo->binfo.pRes->info.groupId = pGroupInfo->groupId;
|
pInfo->binfo.pRes->info.groupId = pGroupInfo->groupId;
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -689,7 +689,7 @@ static SSDataBlock* getUpdateDataBlock(SStreamBlockScanInfo* pInfo, bool inverti
|
||||||
}
|
}
|
||||||
pDataBlock->info.rows = size;
|
pDataBlock->info.rows = size;
|
||||||
pDataBlock->info.type = STREAM_REPROCESS;
|
pDataBlock->info.type = STREAM_REPROCESS;
|
||||||
blockDataUpdateTsWindow(pDataBlock);
|
blockDataUpdateTsWindow(pDataBlock, 0);
|
||||||
taosArrayClear(pInfo->tsArray);
|
taosArrayClear(pInfo->tsArray);
|
||||||
return pDataBlock;
|
return pDataBlock;
|
||||||
}
|
}
|
||||||
|
@ -899,7 +899,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
rows = pBlockInfo->rows;
|
rows = pBlockInfo->rows;
|
||||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
||||||
blockDataUpdateTsWindow(pInfo->pRes);
|
blockDataUpdateTsWindow(pInfo->pRes, 0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -972,9 +972,10 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->primaryTsIndex = 0; // TODO(liuyao) get it from physical plan
|
pInfo->primaryTsIndex = 0; // TODO(liuyao) get it from physical plan
|
||||||
|
if (pSTInfo->interval.interval > 0) {
|
||||||
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, 10000); // TODO(liuyao) get watermark from physical plan
|
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, 10000); // TODO(liuyao) get watermark from physical plan
|
||||||
if (pInfo->pUpdateInfo == NULL) {
|
} else {
|
||||||
goto _error;
|
pInfo->pUpdateInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->readHandle = *pHandle;
|
pInfo->readHandle = *pHandle;
|
||||||
|
|
|
@ -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) {
|
uint64_t tableGroupId) {
|
||||||
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info;
|
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info;
|
||||||
|
|
||||||
|
@ -639,13 +639,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
// int32_t prevIndex = pResultRowInfo->curPos;
|
// int32_t prevIndex = pResultRowInfo->curPos;
|
||||||
|
|
||||||
TSKEY* tsCols = NULL;
|
TSKEY* tsCols = NULL;
|
||||||
if (pSDataBlock->pDataBlock != NULL) {
|
if (pBlock->pDataBlock != NULL) {
|
||||||
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
tsCols = (int64_t*)pColDataInfo->pData;
|
tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
|
|
||||||
|
if (tsCols != NULL) {
|
||||||
|
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t startPos = 0;
|
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,
|
STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval,
|
||||||
pInfo->interval.precision, &pInfo->win);
|
pInfo->interval.precision, &pInfo->win);
|
||||||
|
@ -670,7 +674,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
int32_t forwardStep = 0;
|
int32_t forwardStep = 0;
|
||||||
TSKEY ekey = ascScan? win.ekey:win.skey;
|
TSKEY ekey = ascScan? win.ekey:win.skey;
|
||||||
forwardStep =
|
forwardStep =
|
||||||
getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order);
|
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order);
|
||||||
ASSERT(forwardStep > 0);
|
ASSERT(forwardStep > 0);
|
||||||
|
|
||||||
// prev time window not interpolation yet.
|
// prev time window not interpolation yet.
|
||||||
|
@ -686,7 +690,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
}
|
}
|
||||||
|
|
||||||
STimeWindow w = pRes->win;
|
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,
|
pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup,
|
||||||
pTaskInfo);
|
pTaskInfo);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -694,17 +698,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP));
|
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);
|
tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP);
|
||||||
|
|
||||||
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
|
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
|
||||||
setNotInterpoWindowKey(pInfo->binfo.pCtx, pOperatorInfo->numOfExprs, RESULT_ROW_START_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
|
// 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,
|
pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup,
|
||||||
pTaskInfo);
|
pTaskInfo);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -714,17 +718,17 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// window start key interpolation
|
// 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);
|
pInfo->order, false);
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
|
||||||
doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardStep, tsCols,
|
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;
|
STimeWindow nextWin = win;
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
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) {
|
if (startPos < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -748,20 +752,20 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
|
|
||||||
ekey = ascScan? nextWin.ekey:nextWin.skey;
|
ekey = ascScan? nextWin.ekey:nextWin.skey;
|
||||||
forwardStep =
|
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
|
// 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);
|
pInfo->order, false);
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
||||||
doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardStep, tsCols,
|
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) {
|
if (pInfo->timeWindowInterpo) {
|
||||||
int32_t rowIndex = ascScan ? (pSDataBlock->info.rows - 1) : 0;
|
int32_t rowIndex = ascScan ? (pBlock->info.rows - 1) : 0;
|
||||||
saveDataBlockLastRow(pInfo->pRow, pSDataBlock->pDataBlock, rowIndex, pSDataBlock->info.numOfCols);
|
saveDataBlockLastRow(pInfo->pRow, pBlock->pDataBlock, rowIndex, pBlock->info.numOfCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pUpdated;
|
return pUpdated;
|
||||||
|
@ -939,7 +943,6 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
STimeWindow win = pTaskInfo->window;
|
|
||||||
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -952,6 +955,8 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true);
|
||||||
|
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||||
|
|
||||||
doStateWindowAggImpl(pOperator, pInfo, pBlock);
|
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
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, MAIN_SCAN, true);
|
||||||
|
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||||
|
|
||||||
doSessionWindowAggImpl(pOperator, pInfo, pBlock);
|
doSessionWindowAggImpl(pOperator, pInfo, pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->current += 1;
|
pInfo->current += 1;
|
||||||
|
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ alter_table_clause(A) ::=
|
||||||
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); }
|
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) ::=
|
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* }
|
%type multi_create_clause { SNodeList* }
|
||||||
%destructor multi_create_clause { nodesDestroyList($$); }
|
%destructor multi_create_clause { nodesDestroyList($$); }
|
||||||
|
@ -448,7 +448,7 @@ agg_func_opt(A) ::= AGGREGATE.
|
||||||
%type bufsize_opt { int32_t }
|
%type bufsize_opt { int32_t }
|
||||||
%destructor bufsize_opt { }
|
%destructor bufsize_opt { }
|
||||||
bufsize_opt(A) ::= . { A = 0; }
|
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 **************************************************/
|
/************************************************ create/drop stream **************************************************/
|
||||||
cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A)
|
cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A)
|
||||||
|
|
|
@ -694,8 +694,22 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
return translateValueImpl(pCxt, pVal, pVal->node.resType);
|
return translateValueImpl(pCxt, pVal, pVal->node.resType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
static bool isMultiResFunc(SNode* pNode) {
|
||||||
if (nodesIsUnaryOp(pOp)) {
|
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 (OP_TYPE_MINUS == pOp->opType) {
|
||||||
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
|
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
||||||
|
@ -708,9 +722,10 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDealRes translateArithmeticOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->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 ||
|
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) {
|
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
|
@ -731,7 +746,12 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||||
}
|
}
|
||||||
} else if (nodesIsComparisonOp(pOp)) {
|
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) {
|
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);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
}
|
}
|
||||||
|
@ -748,12 +768,36 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
}
|
}
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||||
} else if (nodesIsJsonOp(pOp)) {
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
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);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
}
|
}
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
|
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_JSON].bytes;
|
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)) {
|
||||||
|
return translateComparisonOperator(pCxt, pOp);
|
||||||
|
} else if (nodesIsJsonOp(pOp)) {
|
||||||
|
return translateJsonOperator(pCxt, pOp);
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -808,6 +852,13 @@ static bool hasInvalidFuncNesting(SNodeList* pParameterList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
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,
|
SFmGetFuncInfoParam param = {.pCtg = pCxt->pParseCxt->pCatalog,
|
||||||
.pRpc = pCxt->pParseCxt->pTransporter,
|
.pRpc = pCxt->pParseCxt->pTransporter,
|
||||||
.pMgmtEps = &pCxt->pParseCxt->mgmtEpSet,
|
.pMgmtEps = &pCxt->pParseCxt->mgmtEpSet,
|
||||||
|
@ -926,9 +977,10 @@ typedef struct SCheckExprForGroupByCxt {
|
||||||
STranslateContext* pTranslateCxt;
|
STranslateContext* pTranslateCxt;
|
||||||
int32_t selectFuncNum;
|
int32_t selectFuncNum;
|
||||||
bool hasSelectValFunc;
|
bool hasSelectValFunc;
|
||||||
|
bool hasOtherAggFunc;
|
||||||
} SCheckExprForGroupByCxt;
|
} SCheckExprForGroupByCxt;
|
||||||
|
|
||||||
static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, bool* pHasSelectValFunc, SNode** pNode) {
|
static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -942,9 +994,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, bool* pHasSel
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
*pNode = (SNode*)pFunc;
|
*pNode = (SNode*)pFunc;
|
||||||
if (NULL != pHasSelectValFunc) {
|
|
||||||
*pHasSelectValFunc = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyNode(pFunc);
|
nodesDestroyNode(pFunc);
|
||||||
}
|
}
|
||||||
|
@ -956,8 +1005,12 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) {
|
if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
pCxt->selectFuncNum += isSelectFunc(*pNode) ? 1 : 0;
|
if (isSelectFunc(*pNode)) {
|
||||||
if (pCxt->selectFuncNum > 1 && pCxt->hasSelectValFunc) {
|
++(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));
|
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
||||||
}
|
}
|
||||||
if (isAggFunc(*pNode) && !isDistinctOrderBy(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 (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
if (pCxt->selectFuncNum > 1) {
|
if (pCxt->selectFuncNum > 1 || pCxt->hasOtherAggFunc) {
|
||||||
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
||||||
} else {
|
} else {
|
||||||
return rewriteColToSelectValFunc(pCxt->pTranslateCxt, &pCxt->hasSelectValFunc, pNode);
|
pCxt->hasSelectValFunc = true;
|
||||||
|
return rewriteColToSelectValFunc(pCxt->pTranslateCxt, pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isAggFunc(*pNode) && isDistinctOrderBy(pCxt->pTranslateCxt)) {
|
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) {
|
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);
|
nodesRewriteExpr(pNode, doCheckExprForGroupBy, &cxt);
|
||||||
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
|
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
|
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
|
||||||
|
@ -995,7 +1050,8 @@ static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList
|
||||||
if (NULL == getGroupByList(pCxt)) {
|
if (NULL == getGroupByList(pCxt)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
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);
|
nodesRewriteExprs(pList, doCheckExprForGroupBy, &cxt);
|
||||||
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
|
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
|
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
|
||||||
|
@ -1008,7 +1064,7 @@ static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode);
|
return rewriteColToSelectValFunc((STranslateContext*)pContext, pNode);
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1027,11 +1083,16 @@ typedef struct CheckAggColCoexistCxt {
|
||||||
bool existCol;
|
bool existCol;
|
||||||
bool existNonstdFunc;
|
bool existNonstdFunc;
|
||||||
int32_t selectFuncNum;
|
int32_t selectFuncNum;
|
||||||
|
bool existOtherAggFunc;
|
||||||
} CheckAggColCoexistCxt;
|
} CheckAggColCoexistCxt;
|
||||||
|
|
||||||
static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
|
static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
|
||||||
CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)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)) {
|
if (isAggFunc(pNode)) {
|
||||||
pCxt->existAggFunc = true;
|
pCxt->existAggFunc = true;
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
|
@ -1050,13 +1111,17 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
||||||
if (NULL != pSelect->pGroupByList) {
|
if (NULL != pSelect->pGroupByList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
CheckAggColCoexistCxt cxt = {
|
CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt,
|
||||||
.pTranslateCxt = pCxt, .existAggFunc = false, .existCol = false, .existNonstdFunc = false};
|
.existAggFunc = false,
|
||||||
|
.existCol = false,
|
||||||
|
.existNonstdFunc = false,
|
||||||
|
.selectFuncNum = 0,
|
||||||
|
.existOtherAggFunc = false};
|
||||||
nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt);
|
nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt);
|
||||||
if (!pSelect->isDistinct) {
|
if (!pSelect->isDistinct) {
|
||||||
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
||||||
}
|
}
|
||||||
if (1 == cxt.selectFuncNum) {
|
if (1 == cxt.selectFuncNum && !cxt.existOtherAggFunc) {
|
||||||
return rewriteColsToSelectValFunc(pCxt, pSelect);
|
return rewriteColsToSelectValFunc(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
if ((cxt.selectFuncNum > 1 || cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) {
|
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;
|
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) {
|
static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
||||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
|
@ -1872,7 +1925,7 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dataTypeEqual(const SDataType* l, const SDataType* r) {
|
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) {
|
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;
|
SName tableName;
|
||||||
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
|
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
|
||||||
collectUseTable(&tableName, pCxt->pTables);
|
int32_t code = collectUseTable(&tableName, pCxt->pTables);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
return buildRollupAst(pCxt, pStmt, pReq);
|
code = buildRollupAst(pCxt, pStmt, pReq);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
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);
|
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) {
|
static SDataType schemaToDataType(SSchema* pSchema) {
|
||||||
SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes, .precision = 0, .scale = 0};
|
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 = colDataBytesToValueDataBytes(pSchema->type, pSchema->bytes);
|
||||||
dt.bytes -= VARSTR_HEADER_SIZE;
|
|
||||||
} else if (TSDB_DATA_TYPE_NCHAR == dt.type) {
|
|
||||||
dt.bytes = (dt.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
|
||||||
}
|
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4441,7 +4501,8 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
|
||||||
SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName);
|
SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName);
|
||||||
if (NULL == pSchema) {
|
if (NULL == pSchema) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName);
|
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);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_MODIFY_COL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -239,6 +239,10 @@ TEST_F(ParserSelectTest, semanticError) {
|
||||||
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
|
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
|
||||||
run("SELECT timestamp '2010a' FROM t1", TSDB_CODE_PAR_WRONG_VALUE_TYPE, PARSER_STAGE_TRANSLATE);
|
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
|
// 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,
|
run("SELECT c2 FROM t1 tt1 join t1 tt2 on COUNT(*) > 0", TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION,
|
||||||
PARSER_STAGE_TRANSLATE);
|
PARSER_STAGE_TRANSLATE);
|
||||||
|
|
|
@ -248,6 +248,7 @@ static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode)
|
||||||
pSubplan->id.groupId = pCxt->groupId;
|
pSubplan->id.groupId = pCxt->groupId;
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
pSubplan->pNode = pNode;
|
pSubplan->pNode = pNode;
|
||||||
|
pNode->pParent = NULL;
|
||||||
return pSubplan;
|
return pSubplan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,17 +409,30 @@ static const SSplitRule splitRuleSet[] = {{.pName = "SuperTableScan", .splitFunc
|
||||||
|
|
||||||
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
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) {
|
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
||||||
SSplitContext cxt = {.queryId = pSubplan->id.queryId, .groupId = pSubplan->id.groupId + 1, .split = false};
|
SSplitContext cxt = {.queryId = pSubplan->id.queryId, .groupId = pSubplan->id.groupId + 1, .split = false};
|
||||||
|
bool split = false;
|
||||||
do {
|
do {
|
||||||
cxt.split = false;
|
split = false;
|
||||||
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
||||||
|
cxt.split = false;
|
||||||
int32_t code = splitRuleSet[i].splitFunc(&cxt, pSubplan);
|
int32_t code = splitRuleSet[i].splitFunc(&cxt, pSubplan);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
if (cxt.split) {
|
||||||
|
split = true;
|
||||||
|
dumpLogicSubplan(splitRuleSet[i].pName, pSubplan);
|
||||||
}
|
}
|
||||||
} while (cxt.split);
|
}
|
||||||
|
} while (split);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@ class PlanSetOpTest : public PlannerTestBase {};
|
||||||
TEST_F(PlanSetOpTest, unionAll) {
|
TEST_F(PlanSetOpTest, unionAll) {
|
||||||
useDb("root", "test");
|
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");
|
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) {
|
TEST_F(PlanSetOpTest, unionAllSubquery) {
|
||||||
|
@ -44,7 +49,12 @@ TEST_F(PlanSetOpTest, unionAllWithSubquery) {
|
||||||
TEST_F(PlanSetOpTest, union) {
|
TEST_F(PlanSetOpTest, union) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
// single UNION operator
|
||||||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20");
|
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) {
|
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)");
|
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'");
|
||||||
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ class PlanSubqeuryTest : public PlannerTestBase {};
|
||||||
TEST_F(PlanSubqeuryTest, basic) {
|
TEST_F(PlanSubqeuryTest, basic) {
|
||||||
useDb("root", "test");
|
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)");
|
run("SELECT LAST(c1) FROM (SELECT * FROM t1)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,18 +35,19 @@ class PlannerEnv : public testing::Environment {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLog(const char* path) {
|
void initLog(const char* path) {
|
||||||
dDebugFlag = 143;
|
int32_t logLevel = getLogLevel();
|
||||||
vDebugFlag = 0;
|
dDebugFlag = logLevel;
|
||||||
mDebugFlag = 143;
|
vDebugFlag = logLevel;
|
||||||
cDebugFlag = 0;
|
mDebugFlag = logLevel;
|
||||||
jniDebugFlag = 0;
|
cDebugFlag = logLevel;
|
||||||
tmrDebugFlag = 135;
|
jniDebugFlag = logLevel;
|
||||||
uDebugFlag = 135;
|
tmrDebugFlag = logLevel;
|
||||||
rpcDebugFlag = 143;
|
uDebugFlag = logLevel;
|
||||||
qDebugFlag = 143;
|
rpcDebugFlag = logLevel;
|
||||||
wDebugFlag = 0;
|
qDebugFlag = logLevel;
|
||||||
sDebugFlag = 0;
|
wDebugFlag = logLevel;
|
||||||
tsdbDebugFlag = 0;
|
sDebugFlag = logLevel;
|
||||||
|
tsdbDebugFlag = logLevel;
|
||||||
tsLogEmbedded = 1;
|
tsLogEmbedded = 1;
|
||||||
tsAsyncLog = 0;
|
tsAsyncLog = 0;
|
||||||
|
|
||||||
|
@ -62,15 +63,24 @@ class PlannerEnv : public testing::Environment {
|
||||||
static void parseArg(int argc, char* argv[]) {
|
static void parseArg(int argc, char* argv[]) {
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
const char* optstring = "";
|
const char* optstring = "";
|
||||||
|
// clang-format off
|
||||||
static struct option long_options[] = {
|
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) {
|
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
setDumpModule(optarg);
|
setDumpModule(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
g_skipSql = 1;
|
setSkipSqlNum(optarg);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
setLogLevel(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -48,6 +48,7 @@ enum DumpModule {
|
||||||
|
|
||||||
DumpModule g_dumpModule = DUMP_MODULE_NOTHING;
|
DumpModule g_dumpModule = DUMP_MODULE_NOTHING;
|
||||||
int32_t g_skipSql = 0;
|
int32_t g_skipSql = 0;
|
||||||
|
int32_t g_logLevel = 131;
|
||||||
|
|
||||||
void setDumpModule(const char* pModule) {
|
void setDumpModule(const char* pModule) {
|
||||||
if (NULL == 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 {
|
class PlannerTestBaseImpl {
|
||||||
public:
|
public:
|
||||||
void useDb(const string& acctId, const string& db) {
|
void useDb(const string& acctId, const string& db) {
|
||||||
caseEnv_.acctId_ = acctId;
|
caseEnv_.acctId_ = acctId;
|
||||||
caseEnv_.db_ = db;
|
caseEnv_.db_ = db;
|
||||||
|
caseEnv_.nsql_ = g_skipSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const string& sql) {
|
void run(const string& sql) {
|
||||||
|
if (caseEnv_.nsql_ > 0) {
|
||||||
|
--(caseEnv_.nsql_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
try {
|
try {
|
||||||
SQuery* pQuery = nullptr;
|
SQuery* pQuery = nullptr;
|
||||||
|
@ -109,6 +122,10 @@ class PlannerTestBaseImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare(const string& sql) {
|
void prepare(const string& sql) {
|
||||||
|
if (caseEnv_.nsql_ > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
try {
|
try {
|
||||||
doParseSql(sql, &stmtEnv_.pQuery_, true);
|
doParseSql(sql, &stmtEnv_.pQuery_, true);
|
||||||
|
@ -119,6 +136,10 @@ class PlannerTestBaseImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindParams(TAOS_MULTI_BIND* pParams, int32_t colIdx) {
|
void bindParams(TAOS_MULTI_BIND* pParams, int32_t colIdx) {
|
||||||
|
if (caseEnv_.nsql_ > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doBindParams(stmtEnv_.pQuery_, pParams, colIdx);
|
doBindParams(stmtEnv_.pQuery_, pParams, colIdx);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -128,6 +149,11 @@ class PlannerTestBaseImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec() {
|
void exec() {
|
||||||
|
if (caseEnv_.nsql_ > 0) {
|
||||||
|
--(caseEnv_.nsql_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doParseBoundSql(stmtEnv_.pQuery_);
|
doParseBoundSql(stmtEnv_.pQuery_);
|
||||||
|
|
||||||
|
@ -159,6 +185,7 @@ class PlannerTestBaseImpl {
|
||||||
struct caseEnv {
|
struct caseEnv {
|
||||||
string acctId_;
|
string acctId_;
|
||||||
string db_;
|
string db_;
|
||||||
|
int32_t nsql_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stmtEnv {
|
struct stmtEnv {
|
||||||
|
|
|
@ -37,8 +37,9 @@ class PlannerTestBase : public testing::Test {
|
||||||
std::unique_ptr<PlannerTestBaseImpl> impl_;
|
std::unique_ptr<PlannerTestBaseImpl> 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
|
#endif // PLAN_TEST_UTIL_H
|
||||||
|
|
|
@ -45,32 +45,10 @@ STaosError errors[] = {
|
||||||
{.val = 0, .str = "success"},
|
{.val = 0, .str = "success"},
|
||||||
#endif
|
#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
|
//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_MEMORY, "Out of Memory")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RANGE, "Out of range")
|
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RANGE, "Out of range")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_SHM_MEM, "Out of Shared memory")
|
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_ALREADY_EXIST, "Ref is already there")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, "Ref is not 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
|
//client
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, "Invalid qhandle")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, "Invalid qhandle")
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "taoserror.h"
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include "tlog.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
|
// the add ref count operation may trigger the warning if the reference count is greater than the MAX_WARNING_REF_COUNT
|
||||||
|
@ -142,12 +142,11 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE SHashNode *
|
static FORCE_INLINE SHashNode *doSearchInEntryList(SHashObj *pHashObj, SHashEntry *pe, const void *key, size_t keyLen,
|
||||||
doSearchInEntryList(SHashObj *pHashObj, SHashEntry *pe, const void *key, size_t keyLen, uint32_t hashVal) {
|
uint32_t hashVal) {
|
||||||
SHashNode *pNode = pe->next;
|
SHashNode *pNode = pe->next;
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
if ((pNode->keyLen == keyLen) &&
|
if ((pNode->keyLen == keyLen) && ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) &&
|
||||||
((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) &&
|
|
||||||
pNode->removed == 0) {
|
pNode->removed == 0) {
|
||||||
assert(pNode->hashVal == hashVal);
|
assert(pNode->hashVal == hashVal);
|
||||||
break;
|
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 pNode the old node with requested key
|
||||||
* @param pNewNode the new 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);
|
assert(pNode->keyLen == pNewNode->keyLen);
|
||||||
|
|
||||||
atomic_sub_fetch_16(&pNode->refCount, 1);
|
atomic_sub_fetch_16(&pNode->refCount, 1);
|
||||||
|
@ -227,9 +227,7 @@ static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj);
|
||||||
* @param pHashObj
|
* @param pHashObj
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj) {
|
static FORCE_INLINE bool taosHashTableEmpty(const SHashObj *pHashObj) { return taosHashGetSize(pHashObj) == 0; }
|
||||||
return taosHashGetSize(pHashObj) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTypeE type) {
|
SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTypeE type) {
|
||||||
if (fn == NULL) {
|
if (fn == NULL) {
|
||||||
|
@ -342,8 +340,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const vo
|
||||||
|
|
||||||
SHashNode *prev = NULL;
|
SHashNode *prev = NULL;
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
if ((pNode->keyLen == keyLen) &&
|
if ((pNode->keyLen == keyLen) && (*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0 &&
|
||||||
(*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0 &&
|
|
||||||
pNode->removed == 0) {
|
pNode->removed == 0) {
|
||||||
assert(pNode->hashVal == hashVal);
|
assert(pNode->hashVal == hashVal);
|
||||||
break;
|
break;
|
||||||
|
@ -513,8 +510,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
|
||||||
SHashNode *prevNode = NULL;
|
SHashNode *prevNode = NULL;
|
||||||
|
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
if ((pNode->keyLen == keyLen) &&
|
if ((pNode->keyLen == keyLen) && ((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) &&
|
||||||
((*(pHashObj->equalFp))(GET_HASH_NODE_KEY(pNode), key, keyLen) == 0) &&
|
|
||||||
pNode->removed == 0) {
|
pNode->removed == 0) {
|
||||||
code = 0; // it is found
|
code = 0; // it is found
|
||||||
|
|
||||||
|
@ -688,12 +684,13 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
||||||
|
|
||||||
int64_t et = taosGetTimestampUs();
|
int64_t et = taosGetTimestampUs();
|
||||||
|
|
||||||
// uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", (int32_t)pHashObj->capacity,
|
// 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);
|
// ((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 *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) {
|
if (pNewNode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -727,7 +724,8 @@ size_t taosHashGetMemSize(const SHashObj *pHashObj) {
|
||||||
return 0;
|
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) {
|
void *taosHashGetKey(void *data, size_t *keyLen) {
|
||||||
|
@ -751,8 +749,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) {
|
||||||
|
|
||||||
SHashNode *pNode = pe->next;
|
SHashNode *pNode = pe->next;
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
if (pNode == pOld)
|
if (pNode == pOld) break;
|
||||||
break;
|
|
||||||
|
|
||||||
prevNode = pNode;
|
prevNode = pNode;
|
||||||
pNode = pNode->next;
|
pNode = pNode->next;
|
||||||
|
|
|
@ -1380,8 +1380,8 @@ class TDTestCase:
|
||||||
self.tmqCase3(cfgPath, buildPath)
|
self.tmqCase3(cfgPath, buildPath)
|
||||||
self.tmqCase4(cfgPath, buildPath)
|
self.tmqCase4(cfgPath, buildPath)
|
||||||
self.tmqCase5(cfgPath, buildPath)
|
self.tmqCase5(cfgPath, buildPath)
|
||||||
self.tmqCase6(cfgPath, buildPath)
|
#self.tmqCase6(cfgPath, buildPath)
|
||||||
self.tmqCase7(cfgPath, buildPath)
|
#self.tmqCase7(cfgPath, buildPath)
|
||||||
#self.tmqCase8(cfgPath, buildPath)
|
#self.tmqCase8(cfgPath, buildPath)
|
||||||
#self.tmqCase9(cfgPath, buildPath)
|
#self.tmqCase9(cfgPath, buildPath)
|
||||||
#self.tmqCase10(cfgPath, buildPath)
|
#self.tmqCase10(cfgPath, buildPath)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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/subscribeDb.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb1.py
|
python3 ./test.py -f 7-tmq/subscribeDb1.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeStb.py
|
python3 ./test.py -f 7-tmq/subscribeStb.py
|
||||||
|
python3 ./test.py -f 7-tmq/subscribeStb1.py
|
||||||
|
|
|
@ -261,7 +261,7 @@ void *threadFunc(void *param) {
|
||||||
int64_t startTs = taosGetTimestampUs();
|
int64_t startTs = taosGetTimestampUs();
|
||||||
TAOS_RES *pRes = taos_query(con, qstr);
|
TAOS_RES *pRes = taos_query(con, qstr);
|
||||||
code = taos_errno(pRes);
|
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));
|
pError("failed to insert %s_t%" PRId64 ", reason:%s", stbName, t, tstrerror(code));
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
|
@ -233,7 +233,6 @@ int64_t getDirectorySize(char* dir) {
|
||||||
int queryDB(TAOS* taos, char* command) {
|
int queryDB(TAOS* taos, char* command) {
|
||||||
TAOS_RES* pRes = taos_query(taos, command);
|
TAOS_RES* pRes = taos_query(taos, command);
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
// if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) {
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
pError("failed to reason:%s, sql: %s", tstrerror(code), command);
|
pError("failed to reason:%s, sql: %s", tstrerror(code), command);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
|
@ -258,7 +258,6 @@ static int32_t msg_process(TAOS_RES* msg, int64_t msgIndex, int32_t threadLable)
|
||||||
int queryDB(TAOS* taos, char* command) {
|
int queryDB(TAOS* taos, char* command) {
|
||||||
TAOS_RES* pRes = taos_query(taos, command);
|
TAOS_RES* pRes = taos_query(taos, command);
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
// if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) {
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
pError("failed to reason:%s, sql: %s", tstrerror(code), command);
|
pError("failed to reason:%s, sql: %s", tstrerror(code), command);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
Loading…
Reference in New Issue