merge from 3.0
This commit is contained in:
commit
0ff5b63f4c
|
@ -35,6 +35,7 @@ def abort_previous(){
|
|||
def pre_test(){
|
||||
sh'hostname'
|
||||
sh '''
|
||||
date
|
||||
sudo rmtaos || echo "taosd has not installed"
|
||||
'''
|
||||
sh '''
|
||||
|
@ -60,8 +61,9 @@ def pre_test(){
|
|||
sh '''
|
||||
cd ${WKC}
|
||||
git checkout 3.0
|
||||
[ -d contrib/bdb ] && cd contrib/bdb && git clean -fxd && cd ../..
|
||||
'''
|
||||
}
|
||||
}
|
||||
else{
|
||||
sh '''
|
||||
cd ${WKC}
|
||||
|
@ -98,7 +100,7 @@ pipeline {
|
|||
}
|
||||
stages {
|
||||
stage('pre_build'){
|
||||
agent{label 'slave3_0'}
|
||||
agent{label " slave3_0 || slave15 || slave16 || slave17 "}
|
||||
options { skipDefaultCheckout() }
|
||||
when {
|
||||
changeRequest()
|
||||
|
|
|
@ -36,7 +36,14 @@ IF (TD_WINDOWS)
|
|||
ENDIF ()
|
||||
|
||||
ELSE ()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -g3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -g3")
|
||||
|
||||
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||
ELSE ()
|
||||
ADD_DEFINITIONS("-msse4.2 -mfma")
|
||||
ENDIF ()
|
||||
|
||||
ENDIF ()
|
||||
|
|
|
@ -7,31 +7,53 @@ SET(TD_LINUX FALSE)
|
|||
SET(TD_WINDOWS FALSE)
|
||||
SET(TD_DARWIN FALSE)
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
MESSAGE("Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX MATCHES 1)
|
||||
set(CXX_COMPILER_IS_GNU TRUE)
|
||||
else()
|
||||
set(CXX_COMPILER_IS_GNU FALSE)
|
||||
endif()
|
||||
|
||||
SET(TD_LINUX TRUE)
|
||||
SET(OSTYPE "Linux")
|
||||
ADD_DEFINITIONS("-DLINUX")
|
||||
MESSAGE("Current system name is ${CMAKE_SYSTEM_NAME}.")
|
||||
|
||||
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
SET(TD_LINUX_64 TRUE)
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
IF (${CXX_COMPILER_IS_GNU})
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
ELSE ()
|
||||
SET(TD_LINUX_32 TRUE)
|
||||
ADD_DEFINITIONS("-Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-unknown-warning-option")
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup")
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
|
||||
ENDIF ()
|
||||
|
||||
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
SET(TD_DARWIN TRUE)
|
||||
SET(OSTYPE "macOS")
|
||||
ADD_DEFINITIONS("-DDARWIN")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||
MESSAGE("Current system arch is arm64")
|
||||
SET(TD_DARWIN_64 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_64")
|
||||
SET(TD_LINUX TRUE)
|
||||
SET(OSTYPE "Linux")
|
||||
ADD_DEFINITIONS("-DLINUX")
|
||||
|
||||
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
SET(TD_LINUX_64 TRUE)
|
||||
ELSE ()
|
||||
SET(TD_LINUX_32 TRUE)
|
||||
ENDIF ()
|
||||
|
||||
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
SET(TD_DARWIN TRUE)
|
||||
SET(OSTYPE "macOS")
|
||||
ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare -Wno-return-type")
|
||||
|
||||
MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
MESSAGE("Current system arch is arm64")
|
||||
SET(TD_DARWIN_64 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_64")
|
||||
ENDIF ()
|
||||
|
||||
ADD_DEFINITIONS("-DHAVE_UNISTD_H")
|
||||
ENDIF ()
|
||||
|
||||
ADD_DEFINITIONS("-DHAVE_UNISTD_H")
|
||||
|
||||
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
SET(TD_WINDOWS TRUE)
|
||||
|
@ -45,6 +67,7 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|||
SET(TD_WINDOWS_32 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_WINDOWS_32")
|
||||
ENDIF ()
|
||||
|
||||
ENDIF()
|
||||
|
||||
MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}")
|
||||
|
|
|
@ -127,6 +127,11 @@ target_include_directories(
|
|||
# zlib
|
||||
set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_SUPPORT_DIR}/EnableCMP0048.txt.in")
|
||||
add_subdirectory(zlib)
|
||||
target_include_directories(
|
||||
zlibstatic
|
||||
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/zlib
|
||||
)
|
||||
target_include_directories(
|
||||
zlib
|
||||
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib
|
||||
|
|
|
@ -54,14 +54,12 @@ typedef struct SColumnDataAgg {
|
|||
} SColumnDataAgg;
|
||||
|
||||
typedef struct SDataBlockInfo {
|
||||
STimeWindow window;
|
||||
int32_t rows;
|
||||
int32_t rowSize;
|
||||
int32_t numOfCols;
|
||||
union {
|
||||
int64_t uid;
|
||||
int64_t blockId;
|
||||
};
|
||||
STimeWindow window;
|
||||
int32_t rows;
|
||||
int32_t rowSize;
|
||||
int16_t numOfCols;
|
||||
int16_t hasVarCol;
|
||||
union {int64_t uid; int64_t blockId;};
|
||||
} SDataBlockInfo;
|
||||
|
||||
typedef struct SConstantItem {
|
||||
|
@ -73,10 +71,10 @@ typedef struct SConstantItem {
|
|||
|
||||
// info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList);
|
||||
typedef struct SSDataBlock {
|
||||
SColumnDataAgg* pBlockAgg;
|
||||
SArray* pDataBlock; // SArray<SColumnInfoData>
|
||||
SArray* pConstantList; // SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
|
||||
SDataBlockInfo info;
|
||||
SColumnDataAgg *pBlockAgg;
|
||||
SArray *pDataBlock; // SArray<SColumnInfoData>
|
||||
SArray *pConstantList; // SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
|
||||
SDataBlockInfo info;
|
||||
} SSDataBlock;
|
||||
|
||||
typedef struct SVarColAttr {
|
||||
|
@ -99,13 +97,15 @@ typedef struct SColumnInfoData {
|
|||
|
||||
static FORCE_INLINE int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
|
||||
int64_t tbUid = pBlock->info.uid;
|
||||
int32_t numOfCols = pBlock->info.numOfCols;
|
||||
int16_t numOfCols = pBlock->info.numOfCols;
|
||||
int16_t hasVarCol = pBlock->info.hasVarCol;
|
||||
int32_t rows = pBlock->info.rows;
|
||||
int32_t sz = taosArrayGetSize(pBlock->pDataBlock);
|
||||
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI64(buf, tbUid);
|
||||
tlen += taosEncodeFixedI32(buf, numOfCols);
|
||||
tlen += taosEncodeFixedI16(buf, numOfCols);
|
||||
tlen += taosEncodeFixedI16(buf, hasVarCol);
|
||||
tlen += taosEncodeFixedI32(buf, rows);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
|
@ -123,7 +123,8 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
|
|||
int32_t sz;
|
||||
|
||||
buf = taosDecodeFixedI64(buf, &pBlock->info.uid);
|
||||
buf = taosDecodeFixedI32(buf, &pBlock->info.numOfCols);
|
||||
buf = taosDecodeFixedI16(buf, &pBlock->info.numOfCols);
|
||||
buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol);
|
||||
buf = taosDecodeFixedI32(buf, &pBlock->info.rows);
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData));
|
||||
|
@ -247,7 +248,7 @@ typedef struct SGroupbyExpr {
|
|||
|
||||
typedef struct SFunctParam {
|
||||
int32_t type;
|
||||
SColumn* pCol;
|
||||
SColumn *pCol;
|
||||
SVariant param;
|
||||
} SFunctParam;
|
||||
|
||||
|
@ -265,12 +266,12 @@ typedef struct SResSchame {
|
|||
typedef struct SExprBasicInfo {
|
||||
SResSchema resSchema;
|
||||
int16_t numOfParams; // argument value of each function
|
||||
SFunctParam* pParam;
|
||||
SFunctParam *pParam;
|
||||
} SExprBasicInfo;
|
||||
|
||||
typedef struct SExprInfo {
|
||||
struct SExprBasicInfo base;
|
||||
struct tExprNode* pExpr;
|
||||
struct SExprBasicInfo base;
|
||||
struct tExprNode *pExpr;
|
||||
} SExprInfo;
|
||||
|
||||
typedef struct SStateWindow {
|
||||
|
|
|
@ -117,7 +117,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
|
||||
int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
void blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol);
|
||||
void blockDataClearup(SSDataBlock* pDataBlock);
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock);
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
|
|
|
@ -1151,8 +1151,8 @@ typedef struct {
|
|||
char name[TSDB_TOPIC_FNAME_LEN];
|
||||
int8_t igExists;
|
||||
char* sql;
|
||||
char* physicalPlan;
|
||||
char* logicalPlan;
|
||||
char* ast;
|
||||
char subscribeDbName[TSDB_DB_NAME_LEN];
|
||||
} SCMCreateTopicReq;
|
||||
|
||||
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
|
||||
|
@ -1911,11 +1911,12 @@ typedef struct {
|
|||
int8_t slidingUnit;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change.
|
||||
uint16_t exprLen;
|
||||
uint16_t tagsFilterLen;
|
||||
int32_t exprLen;
|
||||
int32_t tagsFilterLen;
|
||||
int64_t indexUid;
|
||||
tb_uid_t tableUid; // super/child/common table uid
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
char* expr; // sma expression
|
||||
char* tagsFilter;
|
||||
|
@ -2017,11 +2018,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
|||
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
|
||||
tlen += taosEncodeString(buf, pSma->indexName);
|
||||
tlen += taosEncodeString(buf, pSma->timezone);
|
||||
tlen += taosEncodeFixedU16(buf, pSma->exprLen);
|
||||
tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen);
|
||||
tlen += taosEncodeFixedI32(buf, pSma->exprLen);
|
||||
tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->tableUid);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->interval);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->offset);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->sliding);
|
||||
|
||||
if (pSma->exprLen > 0) {
|
||||
|
@ -2051,11 +2053,12 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
|||
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
|
||||
buf = taosDecodeStringTo(buf, pSma->indexName);
|
||||
buf = taosDecodeStringTo(buf, pSma->timezone);
|
||||
buf = taosDecodeFixedU16(buf, &pSma->exprLen);
|
||||
buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen);
|
||||
buf = taosDecodeFixedI32(buf, &pSma->exprLen);
|
||||
buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->tableUid);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->interval);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->offset);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->sliding);
|
||||
|
||||
if (pSma->exprLen > 0) {
|
||||
|
|
|
@ -25,6 +25,17 @@ extern "C" {
|
|||
|
||||
#define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y')
|
||||
|
||||
#define TIME_UNIT_NANOSECOND 'b'
|
||||
#define TIME_UNIT_MICROSECOND 'u'
|
||||
#define TIME_UNIT_MILLISECOND 'a'
|
||||
#define TIME_UNIT_SECOND 's'
|
||||
#define TIME_UNIT_MINUTE 'm'
|
||||
#define TIME_UNIT_HOUR 'h'
|
||||
#define TIME_UNIT_DAY 'd'
|
||||
#define TIME_UNIT_WEEK 'w'
|
||||
#define TIME_UNIT_MONTH 'n'
|
||||
#define TIME_UNIT_YEAR 'y'
|
||||
|
||||
/*
|
||||
* @return timestamp decided by global conf variable, tsTimePrecision
|
||||
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
|
||||
|
|
|
@ -48,108 +48,114 @@
|
|||
#define TK_DNODES 30
|
||||
#define TK_NK_ID 31
|
||||
#define TK_NK_IPTOKEN 32
|
||||
#define TK_DATABASE 33
|
||||
#define TK_DATABASES 34
|
||||
#define TK_USE 35
|
||||
#define TK_IF 36
|
||||
#define TK_NOT 37
|
||||
#define TK_EXISTS 38
|
||||
#define TK_BLOCKS 39
|
||||
#define TK_CACHE 40
|
||||
#define TK_CACHELAST 41
|
||||
#define TK_COMP 42
|
||||
#define TK_DAYS 43
|
||||
#define TK_FSYNC 44
|
||||
#define TK_MAXROWS 45
|
||||
#define TK_MINROWS 46
|
||||
#define TK_KEEP 47
|
||||
#define TK_PRECISION 48
|
||||
#define TK_QUORUM 49
|
||||
#define TK_REPLICA 50
|
||||
#define TK_TTL 51
|
||||
#define TK_WAL 52
|
||||
#define TK_VGROUPS 53
|
||||
#define TK_SINGLE_STABLE 54
|
||||
#define TK_STREAM_MODE 55
|
||||
#define TK_TABLE 56
|
||||
#define TK_NK_LP 57
|
||||
#define TK_NK_RP 58
|
||||
#define TK_STABLE 59
|
||||
#define TK_TABLES 60
|
||||
#define TK_STABLES 61
|
||||
#define TK_USING 62
|
||||
#define TK_TAGS 63
|
||||
#define TK_NK_DOT 64
|
||||
#define TK_NK_COMMA 65
|
||||
#define TK_COMMENT 66
|
||||
#define TK_BOOL 67
|
||||
#define TK_TINYINT 68
|
||||
#define TK_SMALLINT 69
|
||||
#define TK_INT 70
|
||||
#define TK_INTEGER 71
|
||||
#define TK_BIGINT 72
|
||||
#define TK_FLOAT 73
|
||||
#define TK_DOUBLE 74
|
||||
#define TK_BINARY 75
|
||||
#define TK_TIMESTAMP 76
|
||||
#define TK_NCHAR 77
|
||||
#define TK_UNSIGNED 78
|
||||
#define TK_JSON 79
|
||||
#define TK_VARCHAR 80
|
||||
#define TK_MEDIUMBLOB 81
|
||||
#define TK_BLOB 82
|
||||
#define TK_VARBINARY 83
|
||||
#define TK_DECIMAL 84
|
||||
#define TK_SMA 85
|
||||
#define TK_MNODES 86
|
||||
#define TK_NK_FLOAT 87
|
||||
#define TK_NK_BOOL 88
|
||||
#define TK_NK_VARIABLE 89
|
||||
#define TK_BETWEEN 90
|
||||
#define TK_IS 91
|
||||
#define TK_NULL 92
|
||||
#define TK_NK_LT 93
|
||||
#define TK_NK_GT 94
|
||||
#define TK_NK_LE 95
|
||||
#define TK_NK_GE 96
|
||||
#define TK_NK_NE 97
|
||||
#define TK_NK_EQ 98
|
||||
#define TK_LIKE 99
|
||||
#define TK_MATCH 100
|
||||
#define TK_NMATCH 101
|
||||
#define TK_IN 102
|
||||
#define TK_FROM 103
|
||||
#define TK_AS 104
|
||||
#define TK_JOIN 105
|
||||
#define TK_ON 106
|
||||
#define TK_INNER 107
|
||||
#define TK_SELECT 108
|
||||
#define TK_DISTINCT 109
|
||||
#define TK_WHERE 110
|
||||
#define TK_PARTITION 111
|
||||
#define TK_BY 112
|
||||
#define TK_SESSION 113
|
||||
#define TK_STATE_WINDOW 114
|
||||
#define TK_INTERVAL 115
|
||||
#define TK_SLIDING 116
|
||||
#define TK_FILL 117
|
||||
#define TK_VALUE 118
|
||||
#define TK_NONE 119
|
||||
#define TK_PREV 120
|
||||
#define TK_LINEAR 121
|
||||
#define TK_NEXT 122
|
||||
#define TK_GROUP 123
|
||||
#define TK_HAVING 124
|
||||
#define TK_ORDER 125
|
||||
#define TK_SLIMIT 126
|
||||
#define TK_SOFFSET 127
|
||||
#define TK_LIMIT 128
|
||||
#define TK_OFFSET 129
|
||||
#define TK_ASC 130
|
||||
#define TK_DESC 131
|
||||
#define TK_NULLS 132
|
||||
#define TK_FIRST 133
|
||||
#define TK_LAST 134
|
||||
#define TK_QNODE 33
|
||||
#define TK_ON 34
|
||||
#define TK_QNODES 35
|
||||
#define TK_DATABASE 36
|
||||
#define TK_DATABASES 37
|
||||
#define TK_USE 38
|
||||
#define TK_IF 39
|
||||
#define TK_NOT 40
|
||||
#define TK_EXISTS 41
|
||||
#define TK_BLOCKS 42
|
||||
#define TK_CACHE 43
|
||||
#define TK_CACHELAST 44
|
||||
#define TK_COMP 45
|
||||
#define TK_DAYS 46
|
||||
#define TK_FSYNC 47
|
||||
#define TK_MAXROWS 48
|
||||
#define TK_MINROWS 49
|
||||
#define TK_KEEP 50
|
||||
#define TK_PRECISION 51
|
||||
#define TK_QUORUM 52
|
||||
#define TK_REPLICA 53
|
||||
#define TK_TTL 54
|
||||
#define TK_WAL 55
|
||||
#define TK_VGROUPS 56
|
||||
#define TK_SINGLE_STABLE 57
|
||||
#define TK_STREAM_MODE 58
|
||||
#define TK_TABLE 59
|
||||
#define TK_NK_LP 60
|
||||
#define TK_NK_RP 61
|
||||
#define TK_STABLE 62
|
||||
#define TK_TABLES 63
|
||||
#define TK_STABLES 64
|
||||
#define TK_USING 65
|
||||
#define TK_TAGS 66
|
||||
#define TK_NK_DOT 67
|
||||
#define TK_NK_COMMA 68
|
||||
#define TK_COMMENT 69
|
||||
#define TK_BOOL 70
|
||||
#define TK_TINYINT 71
|
||||
#define TK_SMALLINT 72
|
||||
#define TK_INT 73
|
||||
#define TK_INTEGER 74
|
||||
#define TK_BIGINT 75
|
||||
#define TK_FLOAT 76
|
||||
#define TK_DOUBLE 77
|
||||
#define TK_BINARY 78
|
||||
#define TK_TIMESTAMP 79
|
||||
#define TK_NCHAR 80
|
||||
#define TK_UNSIGNED 81
|
||||
#define TK_JSON 82
|
||||
#define TK_VARCHAR 83
|
||||
#define TK_MEDIUMBLOB 84
|
||||
#define TK_BLOB 85
|
||||
#define TK_VARBINARY 86
|
||||
#define TK_DECIMAL 87
|
||||
#define TK_SMA 88
|
||||
#define TK_INDEX 89
|
||||
#define TK_FULLTEXT 90
|
||||
#define TK_FUNCTION 91
|
||||
#define TK_INTERVAL 92
|
||||
#define TK_TOPIC 93
|
||||
#define TK_AS 94
|
||||
#define TK_MNODES 95
|
||||
#define TK_NK_FLOAT 96
|
||||
#define TK_NK_BOOL 97
|
||||
#define TK_NK_VARIABLE 98
|
||||
#define TK_BETWEEN 99
|
||||
#define TK_IS 100
|
||||
#define TK_NULL 101
|
||||
#define TK_NK_LT 102
|
||||
#define TK_NK_GT 103
|
||||
#define TK_NK_LE 104
|
||||
#define TK_NK_GE 105
|
||||
#define TK_NK_NE 106
|
||||
#define TK_NK_EQ 107
|
||||
#define TK_LIKE 108
|
||||
#define TK_MATCH 109
|
||||
#define TK_NMATCH 110
|
||||
#define TK_IN 111
|
||||
#define TK_FROM 112
|
||||
#define TK_JOIN 113
|
||||
#define TK_INNER 114
|
||||
#define TK_SELECT 115
|
||||
#define TK_DISTINCT 116
|
||||
#define TK_WHERE 117
|
||||
#define TK_PARTITION 118
|
||||
#define TK_BY 119
|
||||
#define TK_SESSION 120
|
||||
#define TK_STATE_WINDOW 121
|
||||
#define TK_SLIDING 122
|
||||
#define TK_FILL 123
|
||||
#define TK_VALUE 124
|
||||
#define TK_NONE 125
|
||||
#define TK_PREV 126
|
||||
#define TK_LINEAR 127
|
||||
#define TK_NEXT 128
|
||||
#define TK_GROUP 129
|
||||
#define TK_HAVING 130
|
||||
#define TK_ORDER 131
|
||||
#define TK_SLIMIT 132
|
||||
#define TK_SOFFSET 133
|
||||
#define TK_LIMIT 134
|
||||
#define TK_OFFSET 135
|
||||
#define TK_ASC 136
|
||||
#define TK_DESC 137
|
||||
#define TK_NULLS 138
|
||||
#define TK_FIRST 139
|
||||
#define TK_LAST 140
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -295,19 +295,8 @@ typedef struct SMultiFunctionsDesc {
|
|||
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, SResultDataInfo* pInfo, int16_t extLength,
|
||||
bool isSuperTable);
|
||||
|
||||
/**
|
||||
* If the given name is a valid built-in sql function, the value of true will be returned.
|
||||
* @param name
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
int32_t qIsBuiltinFunction(const char* name, int32_t len, bool* scalarFunction);
|
||||
|
||||
bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* functionId);
|
||||
|
||||
bool qIsAggregateFunction(const char* functionName);
|
||||
bool qIsSelectivityFunction(const char* functionName);
|
||||
|
||||
tExprNode* exprTreeFromBinary(const void* data, size_t size);
|
||||
|
||||
void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc);
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include "querynodes.h"
|
||||
|
||||
typedef struct SDatabaseOptions {
|
||||
ENodeType type;
|
||||
int32_t numOfBlocks;
|
||||
int32_t cacheBlockSize;
|
||||
int8_t cachelast;
|
||||
|
@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt {
|
|||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
bool ignoreExists;
|
||||
SDatabaseOptions options;
|
||||
SDatabaseOptions* pOptions;
|
||||
} SCreateDatabaseStmt;
|
||||
|
||||
typedef struct SUseDatabaseStmt {
|
||||
|
@ -60,7 +61,14 @@ typedef struct SDropDatabaseStmt {
|
|||
bool ignoreNotExists;
|
||||
} SDropDatabaseStmt;
|
||||
|
||||
typedef struct SAlterDatabaseStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
SDatabaseOptions* pOptions;
|
||||
} SAlterDatabaseStmt;
|
||||
|
||||
typedef struct STableOptions {
|
||||
ENodeType type;
|
||||
int32_t keep;
|
||||
int32_t ttl;
|
||||
char comments[TSDB_STB_COMMENT_LEN];
|
||||
|
@ -81,7 +89,7 @@ typedef struct SCreateTableStmt {
|
|||
bool ignoreExists;
|
||||
SNodeList* pCols;
|
||||
SNodeList* pTags;
|
||||
STableOptions options;
|
||||
STableOptions* pOptions;
|
||||
} SCreateTableStmt;
|
||||
|
||||
typedef struct SCreateSubTableClause {
|
||||
|
@ -155,6 +163,58 @@ typedef struct SShowStmt {
|
|||
char dbName[TSDB_DB_NAME_LEN];
|
||||
} SShowStmt;
|
||||
|
||||
typedef enum EIndexType {
|
||||
INDEX_TYPE_SMA = 1,
|
||||
INDEX_TYPE_FULLTEXT
|
||||
} EIndexType;
|
||||
|
||||
typedef struct SIndexOptions {
|
||||
ENodeType type;
|
||||
SNodeList* pFuncs;
|
||||
SNode* pInterval;
|
||||
SNode* pOffset;
|
||||
SNode* pSliding;
|
||||
} SIndexOptions;
|
||||
|
||||
typedef struct SCreateIndexStmt {
|
||||
ENodeType type;
|
||||
EIndexType indexType;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
SNodeList* pCols;
|
||||
SIndexOptions* pOptions;
|
||||
} SCreateIndexStmt;
|
||||
|
||||
typedef struct SDropIndexStmt {
|
||||
ENodeType type;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
} SDropIndexStmt;
|
||||
|
||||
typedef struct SCreateQnodeStmt {
|
||||
ENodeType type;
|
||||
int32_t dnodeId;
|
||||
} SCreateQnodeStmt;
|
||||
|
||||
typedef struct SDropQnodeStmt {
|
||||
ENodeType type;
|
||||
int32_t dnodeId;
|
||||
} SDropQnodeStmt;
|
||||
|
||||
typedef struct SCreateTopicStmt {
|
||||
ENodeType type;
|
||||
char topicName[TSDB_TABLE_NAME_LEN];
|
||||
char subscribeDbName[TSDB_DB_NAME_LEN];
|
||||
bool ignoreExists;
|
||||
SNode* pQuery;
|
||||
} SCreateTopicStmt;
|
||||
|
||||
typedef struct SDropTopicStmt {
|
||||
ENodeType type;
|
||||
char topicName[TSDB_TABLE_NAME_LEN];
|
||||
bool ignoreNotExists;
|
||||
} SDropTopicStmt;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,9 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SLOT_DESC,
|
||||
QUERY_NODE_COLUMN_DEF,
|
||||
QUERY_NODE_DOWNSTREAM_SOURCE,
|
||||
QUERY_NODE_DATABASE_OPTIONS,
|
||||
QUERY_NODE_TABLE_OPTIONS,
|
||||
QUERY_NODE_INDEX_OPTIONS,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR,
|
||||
|
@ -74,6 +77,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_VNODE_MODIF_STMT,
|
||||
QUERY_NODE_CREATE_DATABASE_STMT,
|
||||
QUERY_NODE_DROP_DATABASE_STMT,
|
||||
QUERY_NODE_ALTER_DATABASE_STMT,
|
||||
QUERY_NODE_SHOW_DATABASES_STMT, // temp
|
||||
QUERY_NODE_CREATE_TABLE_STMT,
|
||||
QUERY_NODE_CREATE_SUBTABLE_CLAUSE,
|
||||
|
@ -93,6 +97,13 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_DNODES_STMT,
|
||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
QUERY_NODE_SHOW_MNODES_STMT,
|
||||
QUERY_NODE_SHOW_QNODES_STMT,
|
||||
QUERY_NODE_CREATE_INDEX_STMT,
|
||||
QUERY_NODE_DROP_INDEX_STMT,
|
||||
QUERY_NODE_CREATE_QNODE_STMT,
|
||||
QUERY_NODE_DROP_QNODE_STMT,
|
||||
QUERY_NODE_CREATE_TOPIC_STMT,
|
||||
QUERY_NODE_DROP_TOPIC_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN,
|
||||
|
@ -185,6 +196,9 @@ const char* nodesNodeName(ENodeType type);
|
|||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -93,6 +93,8 @@ typedef struct SWindowLogicNode {
|
|||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int8_t intervalUnit;
|
||||
int8_t slidingUnit;
|
||||
SFillNode* pFill;
|
||||
} SWindowLogicNode;
|
||||
|
||||
|
@ -203,7 +205,7 @@ typedef struct SDownstreamSourceNode {
|
|||
|
||||
typedef struct SExchangePhysiNode {
|
||||
SPhysiNode node;
|
||||
int32_t srcGroupId; // group id of datasource suplans
|
||||
int32_t srcGroupId; // group id of datasource suplans
|
||||
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
||||
} SExchangePhysiNode;
|
||||
|
||||
|
@ -211,9 +213,11 @@ typedef struct SIntervalPhysiNode {
|
|||
SPhysiNode node;
|
||||
SNodeList* pExprs; // these are expression list of parameter expression of function
|
||||
SNodeList* pFuncs;
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int8_t intervalUnit;
|
||||
int8_t slidingUnit;
|
||||
SFillNode* pFill;
|
||||
} SIntervalPhysiNode;
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct SValueNode {
|
|||
double d;
|
||||
char* p;
|
||||
} datum;
|
||||
char unit;
|
||||
} SValueNode;
|
||||
|
||||
typedef struct SOperatorNode {
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct SQuery {
|
|||
SSchema* pResSchema;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
int32_t msgType;
|
||||
bool streamQuery;
|
||||
} SQuery;
|
||||
|
||||
int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef struct SPlanContext {
|
|||
uint64_t queryId;
|
||||
int32_t acctId;
|
||||
SNode* pAstRoot;
|
||||
bool streamQuery;
|
||||
} SPlanContext;
|
||||
|
||||
// Create the physical plan for the query, according to the AST.
|
||||
|
|
|
@ -29,7 +29,6 @@ extern "C" {
|
|||
|
||||
extern int tsRpcHeadSize;
|
||||
|
||||
|
||||
typedef struct SRpcConnInfo {
|
||||
uint32_t clientIp;
|
||||
uint16_t clientPort;
|
||||
|
@ -46,7 +45,6 @@ typedef struct SRpcMsg {
|
|||
void * ahandle; // app handle set by client
|
||||
} SRpcMsg;
|
||||
|
||||
|
||||
typedef struct SRpcInit {
|
||||
uint16_t localPort; // local port
|
||||
char * label; // for debug purpose
|
||||
|
@ -71,9 +69,11 @@ typedef struct SRpcInit {
|
|||
// call back to keep conn or not
|
||||
bool (*pfp)(void *parent, tmsg_t msgType);
|
||||
|
||||
// to support Send messages multiple times on a link
|
||||
//
|
||||
void* (*mfp)(void *parent, tmsg_t msgType);
|
||||
// to support Send messages multiple times on a link
|
||||
void *(*mfp)(void *parent, tmsg_t msgType);
|
||||
|
||||
// call back to handle except when query/fetch in progress
|
||||
bool (*efp)(void *parent, tmsg_t msgType);
|
||||
|
||||
void *parent;
|
||||
} SRpcInit;
|
||||
|
@ -94,7 +94,7 @@ int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
|||
void rpcCancelRequest(int64_t rid);
|
||||
|
||||
// just release client conn to rpc instance, no close sock
|
||||
void rpcReleaseHandle(void *handle);
|
||||
void rpcReleaseHandle(void *handle, int8_t type);
|
||||
|
||||
void rpcRefHandle(void *handle, int8_t type);
|
||||
void rpcUnrefHandle(void *handle, int8_t type);
|
||||
|
|
|
@ -22,6 +22,8 @@ extern "C" {
|
|||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#include <unistd.h>
|
||||
|
@ -34,7 +36,12 @@ extern "C" {
|
|||
#include <sys/utsname.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#if defined(DARWIN)
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
#include <argp.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -54,9 +61,12 @@ extern "C" {
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <wchar.h>
|
||||
#include <termios.h>
|
||||
#include <wctype.h>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_OS_EOK_H
|
||||
#define TDENGINE_OS_EOK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
enum EPOLL_EVENTS
|
||||
{
|
||||
EPOLLIN = 0x001,
|
||||
#define EPOLLIN EPOLLIN
|
||||
EPOLLPRI = 0x002,
|
||||
#define EPOLLPRI EPOLLPRI
|
||||
EPOLLOUT = 0x004,
|
||||
#define EPOLLOUT EPOLLOUT
|
||||
EPOLLRDNORM = 0x040,
|
||||
#define EPOLLRDNORM EPOLLRDNORM
|
||||
EPOLLRDBAND = 0x080,
|
||||
#define EPOLLRDBAND EPOLLRDBAND
|
||||
EPOLLWRNORM = 0x100,
|
||||
#define EPOLLWRNORM EPOLLWRNORM
|
||||
EPOLLWRBAND = 0x200,
|
||||
#define EPOLLWRBAND EPOLLWRBAND
|
||||
EPOLLMSG = 0x400,
|
||||
#define EPOLLMSG EPOLLMSG
|
||||
EPOLLERR = 0x008,
|
||||
#define EPOLLERR EPOLLERR
|
||||
EPOLLHUP = 0x010,
|
||||
#define EPOLLHUP EPOLLHUP
|
||||
EPOLLRDHUP = 0x2000,
|
||||
#define EPOLLRDHUP EPOLLRDHUP
|
||||
EPOLLEXCLUSIVE = 1u << 28,
|
||||
#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE
|
||||
EPOLLWAKEUP = 1u << 29,
|
||||
#define EPOLLWAKEUP EPOLLWAKEUP
|
||||
EPOLLONESHOT = 1u << 30,
|
||||
#define EPOLLONESHOT EPOLLONESHOT
|
||||
EPOLLET = 1u << 31
|
||||
#define EPOLLET EPOLLET
|
||||
};
|
||||
|
||||
/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
|
||||
#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
|
||||
#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
|
||||
#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
|
||||
|
||||
|
||||
typedef union epoll_data
|
||||
{
|
||||
void *ptr;
|
||||
int fd;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
} epoll_data_t;
|
||||
|
||||
struct epoll_event
|
||||
{
|
||||
uint32_t events; /* Epoll events */
|
||||
epoll_data_t data; /* User data variable */
|
||||
};
|
||||
|
||||
int epoll_create(int size);
|
||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
|
||||
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);
|
||||
int epoll_close(int epfd);
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_
|
||||
|
|
@ -49,6 +49,15 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count);
|
|||
#define PATH_MAX 256
|
||||
#endif
|
||||
|
||||
typedef int32_t FileFd;
|
||||
|
||||
typedef struct TdFile {
|
||||
pthread_rwlock_t rwlock;
|
||||
int refId;
|
||||
FileFd fd;
|
||||
FILE *fp;
|
||||
} * TdFilePtr, TdFile;
|
||||
|
||||
typedef struct TdFile *TdFilePtr;
|
||||
|
||||
#define TD_FILE_CTEATE 0x0001
|
||||
|
@ -101,8 +110,16 @@ int64_t taosCopyFile(const char *from, const char *to);
|
|||
int32_t taosRemoveFile(const char *path);
|
||||
|
||||
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
|
||||
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
typedef int32_t SocketFd;
|
||||
|
||||
int64_t taosSendFile(SocketFd fdDst, FileFd pFileSrc, int64_t *offset, int64_t size);
|
||||
int64_t taosFSendFile(FILE *pFileOut, FILE *pFileIn, int64_t *offset, int64_t size);
|
||||
#else
|
||||
int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size);
|
||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
||||
#endif
|
||||
|
||||
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length);
|
||||
bool taosValidFile(TdFilePtr pFile);
|
||||
|
|
|
@ -38,12 +38,12 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if defined (_TD_DARWIN_64)
|
||||
#define pthread_rwlock_t pthread_mutex_t
|
||||
#define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL)
|
||||
#define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock)
|
||||
#define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock)
|
||||
#define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock)
|
||||
#define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock)
|
||||
// #define pthread_rwlock_t pthread_mutex_t
|
||||
// #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL)
|
||||
// #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock)
|
||||
// #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock)
|
||||
// #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock)
|
||||
// #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock)
|
||||
|
||||
#define pthread_spinlock_t pthread_mutex_t
|
||||
#define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL)
|
||||
|
|
|
@ -33,8 +33,15 @@
|
|||
#include <winbase.h>
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
#include <osEok.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -49,7 +56,29 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
#define htobe64 htonll
|
||||
// #define htobe64 htonll
|
||||
|
||||
# include <libkern/OSByteOrder.h>
|
||||
|
||||
# define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
# define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
# define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
# define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
|
||||
# define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
# define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
# define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
# define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
|
||||
# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
# define htole64(x) OSSwapHostToLittleInt64(x)
|
||||
# define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
# define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
|
||||
# define __BYTE_ORDER BYTE_ORDER
|
||||
# define __BIG_ENDIAN BIG_ENDIAN
|
||||
# define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
# define __PDP_ENDIAN PDP_ENDIAN
|
||||
#endif
|
||||
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef _TD_OS_SYSINFO_H_
|
||||
#define _TD_OS_SYSINFO_H_
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -52,7 +53,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen);
|
|||
char *taosGetCmdlineByPID(int32_t pid);
|
||||
void taosSetCoreDump(bool enable);
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if !defined(LINUX)
|
||||
|
||||
#define _UTSNAME_LENGTH 65
|
||||
#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
|
||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
|||
typedef void SJson;
|
||||
|
||||
SJson* tjsonCreateObject();
|
||||
SJson* tjsonCreateArray();
|
||||
void tjsonDelete(SJson* pJson);
|
||||
|
||||
SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName);
|
||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "parser.h"
|
||||
#include "planner.h"
|
||||
#include "query.h"
|
||||
#include "taos.h"
|
||||
#include "tcommon.h"
|
||||
|
@ -229,6 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t
|
|||
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
||||
|
||||
int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery);
|
||||
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList);
|
||||
|
||||
// --- heartbeat
|
||||
// global, called by mgmt
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "parser.h"
|
||||
#include "planner.h"
|
||||
#include "scheduler.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tdef.h"
|
||||
|
@ -211,7 +209,6 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
setErrno(pRequest, code);
|
||||
|
||||
free(pMsg->pData);
|
||||
sem_post(&pRequest->body.rspSem);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
free(pMsg->pData);
|
||||
setErrno(pRequest, code);
|
||||
sem_post(&pRequest->body.rspSem);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
free(pMsg->pData);
|
||||
sem_post(&pRequest->body.rspSem);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -486,17 +486,15 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
|||
CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
|
||||
CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return);
|
||||
|
||||
SQueryStmtInfo* pQueryStmtInfo = (SQueryStmtInfo*)pQueryNode;
|
||||
pQueryStmtInfo->info.continueQuery = true;
|
||||
pQueryNode->streamQuery = true;
|
||||
|
||||
// todo check for invalid sql statement and return with error code
|
||||
|
||||
SSchema* schema = NULL;
|
||||
int32_t numOfCols = 0;
|
||||
CHECK_CODE_GOTO(qCreateQueryDag(pQueryNode, &pRequest->body.pDag, &schema, &numOfCols, NULL, pRequest->requestId),
|
||||
_return);
|
||||
CHECK_CODE_GOTO(getPlan(pRequest, pQueryNode, &pRequest->body.pDag, NULL), _return);
|
||||
|
||||
pStr = qDagToString(pRequest->body.pDag);
|
||||
pStr = qQueryPlanToString(pRequest->body.pDag);
|
||||
if (pStr == NULL) {
|
||||
goto _return;
|
||||
}
|
||||
|
@ -506,7 +504,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
|||
// The topic should be related to a database that the queried table is belonged to.
|
||||
SName name = {0};
|
||||
char dbName[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName);
|
||||
// tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName);
|
||||
|
||||
tNameFromString(&name, dbName, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameFromString(&name, topicName, T_NAME_TABLE);
|
||||
|
|
|
@ -864,7 +864,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs
|
|||
qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn);
|
||||
|
||||
int64_t p1 = taosGetTimestampUs();
|
||||
printf("sort:%ld, rows:%d\n", p1 - p0, pDataBlock->info.rows);
|
||||
printf("sort:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else { // var data type
|
||||
|
@ -912,7 +912,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs
|
|||
copyBackToBlock(pDataBlock, pCols);
|
||||
int64_t p4 = taosGetTimestampUs();
|
||||
|
||||
printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows);
|
||||
printf("sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows);
|
||||
destroyTupleIndex(index);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1017,7 +1017,7 @@ int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) {
|
|||
}
|
||||
|
||||
int32_t varColSort(SColumnInfoData* pColumnInfoData, SBlockOrderInfo* pOrder) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) {
|
||||
|
@ -1055,14 +1055,15 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
copyBackToBlock(pDataBlock, pCols);
|
||||
int64_t p4 = taosGetTimestampUs();
|
||||
|
||||
printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows);
|
||||
printf("sort:%" PRId64 ", create:%" PRId64", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows);
|
||||
// destroyTupleIndex(index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol) {
|
||||
void blockDataClearup(SSDataBlock* pDataBlock) {
|
||||
pDataBlock->info.rows = 0;
|
||||
|
||||
if (hasVarCol) {
|
||||
if (pDataBlock->info.hasVarCol) {
|
||||
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
|
||||
|
@ -1148,7 +1149,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
|
|||
|
||||
SSDataBlock* pBlock = calloc(1, sizeof(SSDataBlock));
|
||||
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||
|
||||
pBlock->info.numOfCols = numOfCols;
|
||||
pBlock->info.hasVarCol = pDataBlock->info.hasVarCol;
|
||||
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData colInfo = {0};
|
||||
|
|
|
@ -1989,11 +1989,9 @@ int32_t tDeserializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pR
|
|||
|
||||
int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTopicReq *pReq) {
|
||||
int32_t sqlLen = 0;
|
||||
int32_t physicalPlanLen = 0;
|
||||
int32_t logicalPlanLen = 0;
|
||||
int32_t astLen = 0;
|
||||
if (pReq->sql != NULL) sqlLen = (int32_t)strlen(pReq->sql);
|
||||
if (pReq->physicalPlan != NULL) physicalPlanLen = (int32_t)strlen(pReq->physicalPlan);
|
||||
if (pReq->logicalPlan != NULL) logicalPlanLen = (int32_t)strlen(pReq->logicalPlan);
|
||||
if (pReq->ast != NULL) astLen = (int32_t)strlen(pReq->ast);
|
||||
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
|
@ -2002,11 +2000,9 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
|
|||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, physicalPlanLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, logicalPlanLen) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -2017,8 +2013,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
|
|||
|
||||
int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicReq *pReq) {
|
||||
int32_t sqlLen = 0;
|
||||
int32_t physicalPlanLen = 0;
|
||||
int32_t logicalPlanLen = 0;
|
||||
int32_t astLen = 0;
|
||||
|
||||
SCoder decoder = {0};
|
||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||
|
@ -2027,17 +2022,20 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
|||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &physicalPlanLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &logicalPlanLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||
|
||||
pReq->sql = calloc(1, sqlLen + 1);
|
||||
pReq->physicalPlan = calloc(1, physicalPlanLen + 1);
|
||||
pReq->logicalPlan = calloc(1, logicalPlanLen + 1);
|
||||
if (pReq->sql == NULL || pReq->physicalPlan == NULL || pReq->logicalPlan == NULL) return -1;
|
||||
if (sqlLen > 0) {
|
||||
pReq->sql = calloc(1, sqlLen + 1);
|
||||
if (pReq->sql == NULL) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
||||
}
|
||||
|
||||
if (astLen > 0) {
|
||||
pReq->ast = calloc(1, astLen + 1);
|
||||
if (pReq->ast == NULL) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->physicalPlan) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->logicalPlan) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tCoderClear(&decoder);
|
||||
|
@ -2046,8 +2044,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
|||
|
||||
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
|
||||
tfree(pReq->sql);
|
||||
tfree(pReq->physicalPlan);
|
||||
tfree(pReq->logicalPlan);
|
||||
tfree(pReq->ast);
|
||||
}
|
||||
|
||||
int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) {
|
||||
|
|
|
@ -353,10 +353,10 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
|
|||
for (int i = 0; i < src2->numOfCols; i++) {
|
||||
SCellVal sVal = {0};
|
||||
ASSERT(target->cols[i].type == src2->cols[i].type);
|
||||
if (src2->cols[i].len > 0 && !isNull(src2->cols[i].pData, src2->cols[i].type)) {
|
||||
if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) {
|
||||
TASSERT(0);
|
||||
}
|
||||
if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2) < 0) {
|
||||
TASSERT(0);
|
||||
}
|
||||
if (src2->cols[i].len > 0 && !tdValTypeIsNull(sVal.valType)) {
|
||||
tdAppendValToDataCol(&(target->cols[i]), sVal.valType, sVal.val, target->numOfRows, target->maxPoints);
|
||||
} else if (!forceSetNull && key1 == key2 && src1->cols[i].len > 0) {
|
||||
if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) {
|
||||
|
|
|
@ -845,7 +845,11 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
|
|||
|
||||
int64_t offset = getDataStartOffset();
|
||||
int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset;
|
||||
#if defined(_TD_DARWIN_64)
|
||||
int64_t written = taosFSendFile(pDestBuf->pFile->fp, pSrcBuf->pFile->fp, &offset, size);
|
||||
#else
|
||||
int64_t written = taosFSendFile(pDestBuf->pFile, pSrcBuf->pFile, &offset, size);
|
||||
#endif
|
||||
|
||||
if (written == -1 || written != size) {
|
||||
return -1;
|
||||
|
|
|
@ -96,12 +96,12 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
|
|||
CM_ENCODE_OVER:
|
||||
tfree(buf);
|
||||
if (terrno != 0) {
|
||||
mError("consumer:%ld, failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||
mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mTrace("consumer:%ld, encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer);
|
||||
mTrace("consumer:%" PRId64 ", encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer);
|
||||
return pRaw;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
|
|||
CM_DECODE_OVER:
|
||||
tfree(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("consumer:%ld, failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||
mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||
tfree(pRow);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -149,17 +149,17 @@ CM_DECODE_OVER:
|
|||
}
|
||||
|
||||
static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) {
|
||||
mTrace("consumer:%ld, perform insert action", pConsumer->consumerId);
|
||||
mTrace("consumer:%" PRId64 ", perform insert action", pConsumer->consumerId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) {
|
||||
mTrace("consumer:%ld, perform delete action", pConsumer->consumerId);
|
||||
mTrace("consumer:%" PRId64 ", perform delete action", pConsumer->consumerId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) {
|
||||
mTrace("consumer:%ld, perform update action", pOldConsumer->consumerId);
|
||||
mTrace("consumer:%" PRId64 ", perform update action", pOldConsumer->consumerId);
|
||||
|
||||
// TODO handle update
|
||||
/*taosWLockLatch(&pOldConsumer->lock);*/
|
||||
|
|
|
@ -1292,11 +1292,11 @@ static int32_t mndGetDbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMe
|
|||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema[cols].name, "update");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
// pShow->bytes[cols] = 1;
|
||||
// pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
// strcpy(pSchema[cols].name, "update");
|
||||
// pSchema[cols].bytes = pShow->bytes[cols];
|
||||
// cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
@ -1432,9 +1432,9 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3
|
|||
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int8_t *)pWrite = pDb->cfg.update;
|
||||
cols++;
|
||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
// *(int8_t *)pWrite = pDb->cfg.update;
|
||||
// cols++;
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pDb);
|
||||
|
|
|
@ -448,7 +448,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) {
|
|||
for (int32_t i = 0; i < taosArrayGetSize(pRebSub->lostConsumers); i++) {
|
||||
int64_t lostConsumerId = *(int64_t *)taosArrayGet(pRebSub->lostConsumers, i);
|
||||
|
||||
mInfo("mq remove lost consumer %ld", lostConsumerId);
|
||||
mInfo("mq remove lost consumer %" PRId64 "", lostConsumerId);
|
||||
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pSub->consumers); j++) {
|
||||
SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, j);
|
||||
|
@ -479,7 +479,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) {
|
|||
else
|
||||
vgThisConsumerAfterRb = vgEachConsumer;
|
||||
|
||||
mInfo("mq consumer:%ld, connectted vgroup number change from %d to %d", pSubConsumer->consumerId,
|
||||
mInfo("mq consumer:%" PRId64 ", connectted vgroup number change from %d to %d", pSubConsumer->consumerId,
|
||||
vgThisConsumerBeforeRb, vgThisConsumerAfterRb);
|
||||
|
||||
while (taosArrayGetSize(pSubConsumer->vgInfo) > vgThisConsumerAfterRb) {
|
||||
|
@ -503,7 +503,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) {
|
|||
atomic_store_32(&pRebConsumer->status, MQ_CONSUMER_STATUS__IDLE);
|
||||
}
|
||||
|
||||
mInfo("mq consumer:%ld, status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status);
|
||||
mInfo("mq consumer:%" PRId64 ", status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status);
|
||||
|
||||
SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pRebConsumer);
|
||||
sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY);
|
||||
|
@ -537,13 +537,13 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) {
|
|||
mndSplitSubscribeKey(pSub->key, topic, cgroup);
|
||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic);
|
||||
|
||||
mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, topic,
|
||||
mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, topic,
|
||||
pConsumerEp->consumerId);
|
||||
|
||||
mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp);
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
} else {
|
||||
mInfo("mq rebalance: assign vgroup %d, from consumer %ld to consumer %ld", pConsumerEp->vgId,
|
||||
mInfo("mq rebalance: assign vgroup %d, from consumer %" PRId64 " to consumer %" PRId64 "", pConsumerEp->vgId,
|
||||
pConsumerEp->oldConsumerId, pConsumerEp->consumerId);
|
||||
|
||||
mndPersistRebalanceMsg(pMnode, pTrans, pConsumerEp);
|
||||
|
@ -1099,7 +1099,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
|
|||
SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, cgroup, newTopicName);
|
||||
bool createSub = false;
|
||||
if (pSub == NULL) {
|
||||
mDebug("create new subscription by consumer %ld, group: %s, topic %s", consumerId, cgroup, newTopicName);
|
||||
mDebug("create new subscription by consumer %" PRId64 ", group: %s, topic %s", consumerId, cgroup, newTopicName);
|
||||
pSub = mndCreateSubscription(pMnode, pTopic, cgroup);
|
||||
createSub = true;
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
|
|||
pConsumerEp->consumerId = consumerId;
|
||||
taosArrayPush(mqSubConsumer.vgInfo, pConsumerEp);
|
||||
if (pConsumerEp->oldConsumerId == -1) {
|
||||
mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, newTopicName,
|
||||
mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, newTopicName,
|
||||
pConsumerEp->consumerId);
|
||||
mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp);
|
||||
} else {
|
||||
|
|
|
@ -236,6 +236,29 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) {
|
||||
if (NULL == pCreate->ast) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pAst = NULL;
|
||||
int32_t code = nodesStringToNode(pCreate->ast, &pAst);
|
||||
|
||||
SQueryPlan* pPlan = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SPlanContext cxt = { .pAstRoot = pAst, .streamQuery = true };
|
||||
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pPlan, false, pStr, NULL);
|
||||
}
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyNode(pPlan);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) {
|
||||
mDebug("topic:%s to create", pCreate->name);
|
||||
SMqTopicObj topicObj = {0};
|
||||
|
@ -247,13 +270,23 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq
|
|||
topicObj.dbUid = pDb->uid;
|
||||
topicObj.version = 1;
|
||||
topicObj.sql = pCreate->sql;
|
||||
topicObj.physicalPlan = pCreate->physicalPlan;
|
||||
topicObj.logicalPlan = pCreate->logicalPlan;
|
||||
topicObj.physicalPlan = "";
|
||||
topicObj.logicalPlan = "";
|
||||
topicObj.sqlLen = strlen(pCreate->sql);
|
||||
|
||||
char* pPlanStr = NULL;
|
||||
if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) {
|
||||
mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
if (NULL != pPlanStr) {
|
||||
topicObj.physicalPlan = pPlanStr;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
tfree(pPlanStr);
|
||||
return -1;
|
||||
}
|
||||
mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name);
|
||||
|
@ -261,6 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq
|
|||
SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj);
|
||||
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
|
||||
tfree(pPlanStr);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
@ -268,10 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq
|
|||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
tfree(pPlanStr);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tfree(pPlanStr);
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ Testbase MndTestDb::test;
|
|||
|
||||
TEST_F(MndTestDb, 01_ShowDb) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_META("show databases", 17);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
|
||||
|
@ -45,7 +45,7 @@ TEST_F(MndTestDb, 01_ShowDb) {
|
|||
CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp");
|
||||
CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast");
|
||||
CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
|
||||
CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
||||
// CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
@ -173,7 +173,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
test.Restart();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
@ -215,7 +215,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
|
@ -255,7 +255,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
|
|
@ -65,8 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql,
|
|||
strcpy(createReq.name, topicName);
|
||||
createReq.igExists = 0;
|
||||
createReq.sql = (char*)sql;
|
||||
createReq.physicalPlan = (char*)"physicalPlan";
|
||||
createReq.logicalPlan = (char*)"logicalPlan";
|
||||
createReq.ast = NULL;
|
||||
|
||||
int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
|
|
@ -196,7 +196,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
||||
if (!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen) != 0) {
|
||||
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
||||
code = TSDB_CODE_CHECKSUM_ERROR;
|
||||
mError("failed to read file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
|
|
|
@ -1062,7 +1062,7 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
|
|||
|
||||
|
||||
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) {
|
||||
int16_t widx = abs(id % mgmt->slotNum);
|
||||
int16_t widx = abs((int)(id % mgmt->slotNum));
|
||||
|
||||
SCtgRentSlot *slot = &mgmt->slots[widx];
|
||||
int32_t code = 0;
|
||||
|
@ -1092,11 +1092,11 @@ _return:
|
|||
}
|
||||
|
||||
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(id % mgmt->slotNum);
|
||||
int16_t widx = abs((int)(id % mgmt->slotNum));
|
||||
|
||||
SCtgRentSlot *slot = &mgmt->slots[widx];
|
||||
int32_t code = 0;
|
||||
|
||||
|
||||
CTG_LOCK(CTG_WRITE, &slot->lock);
|
||||
if (NULL == slot->meta) {
|
||||
qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type);
|
||||
|
@ -1133,7 +1133,7 @@ _return:
|
|||
}
|
||||
|
||||
int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) {
|
||||
int16_t widx = abs(id % mgmt->slotNum);
|
||||
int16_t widx = abs((int)(id % mgmt->slotNum));
|
||||
|
||||
SCtgRentSlot *slot = &mgmt->slots[widx];
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct SGroupResInfo {
|
|||
int32_t totalGroup;
|
||||
int32_t currentGroup;
|
||||
int32_t index;
|
||||
SArray* pRows; // SArray<SResultRow*>
|
||||
SArray* pRows; // SArray<SResultRowPosition*>
|
||||
bool ordered;
|
||||
int32_t position;
|
||||
} SGroupResInfo;
|
||||
|
@ -67,10 +67,15 @@ typedef struct SResultRow {
|
|||
char *key; // start key of current result row
|
||||
} SResultRow;
|
||||
|
||||
typedef struct SResultRowPosition {
|
||||
int32_t pageId;
|
||||
int32_t offset;
|
||||
} SResultRowPosition;
|
||||
|
||||
typedef struct SResultRowInfo {
|
||||
SList* pRows;
|
||||
SResultRow** pResult; // result list
|
||||
// int16_t type:8; // data type for hash key
|
||||
SList *pRows;
|
||||
SResultRowPosition *pPosition;
|
||||
SResultRow **pResult; // result list
|
||||
int32_t size; // number of result set
|
||||
int32_t capacity; // max capacity
|
||||
int32_t curPos; // current active result row index of pResult list
|
||||
|
@ -131,7 +136,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
|
|||
assert(rowOffset >= 0);
|
||||
|
||||
int32_t numOfRows = 1;//(int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery);
|
||||
return ((char *)page->data) + rowOffset + offset * numOfRows;
|
||||
return (char*) page + rowOffset + offset * numOfRows;
|
||||
}
|
||||
|
||||
//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type);
|
||||
|
@ -139,12 +144,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
|
|||
|
||||
__filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr);
|
||||
|
||||
SResultRowPool* initResultRowPool(size_t size);
|
||||
SResultRow* getNewResultRow(SResultRowPool* p);
|
||||
int64_t getResultRowPoolMemSize(SResultRowPool* p);
|
||||
void* destroyResultRowPool(SResultRowPool* p);
|
||||
int32_t getNumOfAllocatedResultRows(SResultRowPool* p);
|
||||
int32_t getNumOfUsedResultRows(SResultRowPool* p);
|
||||
|
||||
typedef struct {
|
||||
SArray* pResult; // SArray<SResPair>
|
||||
|
|
|
@ -240,12 +240,12 @@ typedef struct STaskAttr {
|
|||
SArray* pUdfInfo; // no need to free
|
||||
} STaskAttr;
|
||||
|
||||
typedef int32_t (*__optr_open_fn_t)(void* param);
|
||||
typedef SSDataBlock* (*__optr_fn_t)(void* param, bool* newgroup);
|
||||
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
||||
|
||||
struct SOperatorInfo;
|
||||
|
||||
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* param);
|
||||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* param, bool* newgroup);
|
||||
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
||||
|
||||
typedef struct STaskIdInfo {
|
||||
uint64_t queryId; // this is also a request id
|
||||
uint64_t subplanId;
|
||||
|
@ -275,36 +275,36 @@ typedef struct SExecTaskInfo {
|
|||
} SExecTaskInfo;
|
||||
|
||||
typedef struct STaskRuntimeEnv {
|
||||
jmp_buf env;
|
||||
STaskAttr* pQueryAttr;
|
||||
uint32_t status; // query status
|
||||
void* qinfo;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
void* pTsdbReadHandle;
|
||||
jmp_buf env;
|
||||
STaskAttr* pQueryAttr;
|
||||
uint32_t status; // query status
|
||||
void* qinfo;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
void* pTsdbReadHandle;
|
||||
|
||||
int32_t prevGroupId; // previous executed group id
|
||||
bool enableGroupData;
|
||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SHashObj* pResultRowHashTable; // quick locate the window object for each result
|
||||
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
|
||||
SArray* pResultRowArrayList; // The array list that contains the Result rows
|
||||
char* keyBuf; // window key buffer
|
||||
int32_t prevGroupId; // previous executed group id
|
||||
bool enableGroupData;
|
||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SHashObj* pResultRowHashTable; // quick locate the window object for each result
|
||||
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
|
||||
SArray* pResultRowArrayList; // The array list that contains the Result rows
|
||||
char* keyBuf; // window key buffer
|
||||
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
|
||||
char** prevRow;
|
||||
char** prevRow;
|
||||
SResultRowPool* pool;
|
||||
|
||||
SArray* prevResult; // intermediate result, SArray<SInterResult>
|
||||
STSBuf* pTsBuf; // timestamp filter list
|
||||
STSCursor cur;
|
||||
SArray* prevResult; // intermediate result, SArray<SInterResult>
|
||||
STSBuf* pTsBuf; // timestamp filter list
|
||||
STSCursor cur;
|
||||
|
||||
char* tagVal; // tag value of current data block
|
||||
char* tagVal; // tag value of current data block
|
||||
struct SScalarFunctionSupport* scalarSup;
|
||||
|
||||
SSDataBlock* outputBuf;
|
||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||
struct SOperatorInfo* proot;
|
||||
SGroupResInfo groupResInfo;
|
||||
int64_t currentOffset; // dynamic offset value
|
||||
SGroupResInfo groupResInfo;
|
||||
int64_t currentOffset; // dynamic offset value
|
||||
|
||||
STableQueryInfo* current;
|
||||
SRspResultInfo resultInfo;
|
||||
|
@ -328,7 +328,7 @@ typedef struct SOperatorInfo {
|
|||
char* name; // name, used to show the query execution plan
|
||||
void* info; // extension attribution
|
||||
SExprInfo* pExpr;
|
||||
STaskRuntimeEnv* pRuntimeEnv; // todo remove it
|
||||
STaskRuntimeEnv* pRuntimeEnv; // todo remove it
|
||||
SExecTaskInfo* pTaskInfo;
|
||||
SOperatorCostInfo cost;
|
||||
|
||||
|
@ -365,28 +365,6 @@ typedef struct SQInfo {
|
|||
STaskCostInfo summary;
|
||||
} SQInfo;
|
||||
|
||||
typedef struct STaskParam {
|
||||
char* sql;
|
||||
char* tagCond;
|
||||
char* colCond;
|
||||
char* tbnameCond;
|
||||
char* prevResult;
|
||||
SArray* pTableIdList;
|
||||
SExprBasicInfo** pExpr;
|
||||
SExprBasicInfo** pSecExpr;
|
||||
SExprInfo* pExprs;
|
||||
SExprInfo* pSecExprs;
|
||||
|
||||
SFilterInfo* pFilters;
|
||||
|
||||
SColIndex* pGroupColIndex;
|
||||
SColumnInfo* pTagColumnInfo;
|
||||
SGroupbyExpr* pGroupbyExpr;
|
||||
int32_t tableScanOperator;
|
||||
SArray* pOperator;
|
||||
struct SUdfInfo* pUdfInfo;
|
||||
} STaskParam;
|
||||
|
||||
enum {
|
||||
EX_SOURCE_DATA_NOT_READY = 0x1,
|
||||
EX_SOURCE_DATA_READY = 0x2,
|
||||
|
@ -472,75 +450,75 @@ typedef struct SSysTableScanInfo {
|
|||
} SSysTableScanInfo;
|
||||
|
||||
typedef struct SOptrBasicInfo {
|
||||
SResultRowInfo resultRowInfo;
|
||||
int32_t* rowCellInfoOffset; // offset value for each row result cell info
|
||||
SqlFunctionCtx* pCtx;
|
||||
SSDataBlock* pRes;
|
||||
int32_t capacity;
|
||||
SResultRowInfo resultRowInfo;
|
||||
int32_t* rowCellInfoOffset; // offset value for each row result cell info
|
||||
SqlFunctionCtx* pCtx;
|
||||
SSDataBlock* pRes;
|
||||
int32_t capacity;
|
||||
} SOptrBasicInfo;
|
||||
|
||||
//TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
|
||||
typedef struct SAggSupporter {
|
||||
SHashObj* pResultRowHashTable; // quick locate the window object for each result
|
||||
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
|
||||
SArray* pResultRowArrayList; // The array list that contains the Result rows
|
||||
char* keyBuf; // window key buffer
|
||||
SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object.
|
||||
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
||||
SHashObj* pResultRowHashTable; // quick locate the window object for each result
|
||||
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
|
||||
SArray* pResultRowArrayList; // The array list that contains the Result rows
|
||||
char* keyBuf; // window key buffer
|
||||
SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
||||
} SAggSupporter;
|
||||
|
||||
typedef struct STableIntervalOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SGroupResInfo groupResInfo;
|
||||
SInterval interval;
|
||||
STimeWindow win;
|
||||
int32_t precision;
|
||||
bool timeWindowInterpo;
|
||||
char **pRow;
|
||||
SAggSupporter aggSup;
|
||||
STableQueryInfo *pCurrent;
|
||||
int32_t order;
|
||||
SOptrBasicInfo binfo;
|
||||
SGroupResInfo groupResInfo;
|
||||
SInterval interval;
|
||||
STimeWindow win;
|
||||
int32_t precision;
|
||||
bool timeWindowInterpo;
|
||||
char **pRow;
|
||||
SAggSupporter aggSup;
|
||||
STableQueryInfo *pCurrent;
|
||||
int32_t order;
|
||||
} STableIntervalOperatorInfo;
|
||||
|
||||
typedef struct SAggOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SAggSupporter aggSup;
|
||||
STableQueryInfo *current;
|
||||
uint32_t groupId;
|
||||
SGroupResInfo groupResInfo;
|
||||
STableQueryInfo *pTableQueryInfo;
|
||||
SOptrBasicInfo binfo;
|
||||
SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SAggSupporter aggSup;
|
||||
STableQueryInfo *current;
|
||||
uint32_t groupId;
|
||||
SGroupResInfo groupResInfo;
|
||||
STableQueryInfo *pTableQueryInfo;
|
||||
} SAggOperatorInfo;
|
||||
|
||||
typedef struct SProjectOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SSDataBlock* existDataBlock;
|
||||
SOptrBasicInfo binfo;
|
||||
SSDataBlock *existDataBlock;
|
||||
int32_t threshold;
|
||||
bool hasVarCol;
|
||||
} SProjectOperatorInfo;
|
||||
|
||||
typedef struct SLimitOperatorInfo {
|
||||
int64_t limit;
|
||||
int64_t total;
|
||||
SLimit limit;
|
||||
int64_t currentOffset;
|
||||
int64_t currentRows;
|
||||
} SLimitOperatorInfo;
|
||||
|
||||
typedef struct SSLimitOperatorInfo {
|
||||
int64_t groupTotal;
|
||||
int64_t currentGroupOffset;
|
||||
|
||||
int64_t rowsTotal;
|
||||
int64_t currentOffset;
|
||||
SLimit limit;
|
||||
SLimit slimit;
|
||||
|
||||
char** prevRow;
|
||||
SArray* orderColumnList;
|
||||
bool hasPrev;
|
||||
bool ignoreCurrentGroup;
|
||||
bool multigroupResult;
|
||||
SSDataBlock* pRes; // result buffer
|
||||
SSDataBlock* pPrevBlock;
|
||||
int64_t capacity;
|
||||
int64_t threshold;
|
||||
int64_t groupTotal;
|
||||
int64_t currentGroupOffset;
|
||||
int64_t rowsTotal;
|
||||
int64_t currentOffset;
|
||||
SLimit limit;
|
||||
SLimit slimit;
|
||||
char** prevRow;
|
||||
SArray* orderColumnList;
|
||||
bool hasPrev;
|
||||
bool ignoreCurrentGroup;
|
||||
bool multigroupResult;
|
||||
SSDataBlock* pRes; // result buffer
|
||||
SSDataBlock* pPrevBlock;
|
||||
int64_t capacity;
|
||||
int64_t threshold;
|
||||
} SSLimitOperatorInfo;
|
||||
|
||||
typedef struct SFilterOperatorInfo {
|
||||
|
@ -563,14 +541,15 @@ typedef struct SGroupbyOperatorInfo {
|
|||
char* prevData; // previous group by value
|
||||
} SGroupbyOperatorInfo;
|
||||
|
||||
typedef struct SSWindowOperatorInfo {
|
||||
typedef struct SSessionAggOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SAggSupporter aggSup;
|
||||
STimeWindow curWindow; // current time window
|
||||
TSKEY prevTs; // previous timestamp
|
||||
int32_t numOfRows; // number of rows
|
||||
int32_t start; // start row index
|
||||
bool reptScan; // next round scan
|
||||
} SSWindowOperatorInfo;
|
||||
} SSessionAggOperatorInfo;
|
||||
|
||||
typedef struct SStateWindowOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
|
@ -582,23 +561,6 @@ typedef struct SStateWindowOperatorInfo {
|
|||
bool reptScan;
|
||||
} SStateWindowOperatorInfo;
|
||||
|
||||
typedef struct SDistinctDataInfo {
|
||||
int32_t index;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
} SDistinctDataInfo;
|
||||
|
||||
typedef struct SDistinctOperatorInfo {
|
||||
SHashObj* pSet;
|
||||
SSDataBlock* pRes;
|
||||
bool recordNullVal; // has already record the null value, no need to try again
|
||||
int64_t threshold;
|
||||
int64_t outputCapacity;
|
||||
int32_t totalBytes;
|
||||
char* buf;
|
||||
SArray* pDistinctDataInfo;
|
||||
} SDistinctOperatorInfo;
|
||||
|
||||
typedef struct SSortedMergeOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
bool hasVarCol;
|
||||
|
@ -624,45 +586,61 @@ typedef struct SSortedMergeOperatorInfo {
|
|||
} SSortedMergeOperatorInfo;
|
||||
|
||||
typedef struct SOrderOperatorInfo {
|
||||
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||
SSDataBlock *pDataBlock;
|
||||
bool hasVarCol; // has variable length column, such as binary/varchar/nchar
|
||||
SArray *orderInfo;
|
||||
bool nullFirst;
|
||||
SSortHandle *pSortHandle;
|
||||
|
||||
int32_t bufPageSize;
|
||||
int32_t numOfRowsInRes;
|
||||
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||
SSDataBlock *pDataBlock;
|
||||
bool hasVarCol; // has variable length column, such as binary/varchar/nchar
|
||||
SArray *orderInfo;
|
||||
bool nullFirst;
|
||||
SSortHandle *pSortHandle;
|
||||
int32_t bufPageSize;
|
||||
int32_t numOfRowsInRes;
|
||||
|
||||
// TODO extact struct
|
||||
int64_t startTs; // sort start time
|
||||
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
|
||||
uint64_t totalSize; // total load bytes from remote
|
||||
uint64_t totalRows; // total number of rows
|
||||
uint64_t totalElapsed; // total elapsed time
|
||||
int64_t startTs; // sort start time
|
||||
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
|
||||
uint64_t totalSize; // total load bytes from remote
|
||||
uint64_t totalRows; // total number of rows
|
||||
uint64_t totalElapsed; // total elapsed time
|
||||
} SOrderOperatorInfo;
|
||||
|
||||
typedef struct SDistinctDataInfo {
|
||||
int32_t index;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
} SDistinctDataInfo;
|
||||
|
||||
typedef struct SDistinctOperatorInfo {
|
||||
SHashObj* pSet;
|
||||
SSDataBlock* pRes;
|
||||
bool recordNullVal; // has already record the null value, no need to try again
|
||||
int64_t threshold;
|
||||
int64_t outputCapacity;
|
||||
int32_t totalBytes;
|
||||
char* buf;
|
||||
SArray* pDistinctDataInfo;
|
||||
} SDistinctOperatorInfo;
|
||||
|
||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput,
|
||||
int32_t repeatTime, int32_t reverseTime, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SArray* pOrderVal, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SArray* pExprInfo, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
||||
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, const SArray* pExprInfo, const SSchema* pSchema,
|
||||
int32_t tableType, SEpSet epset, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfDownstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream);
|
||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SInterval* pInterval, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream);
|
||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval,
|
||||
const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
SExprInfo* pExpr, int32_t numOfOutput);
|
||||
SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||
int32_t numOfOutput);
|
||||
|
||||
SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||
int32_t numOfOutput, bool multigroupResult);
|
||||
SOperatorInfo* createGroupbyOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||
|
@ -699,16 +677,13 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
|
|||
void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols);
|
||||
|
||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||
void finalizeQueryResult(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo,
|
||||
int32_t* rowCellInfoOffset);
|
||||
void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||
|
||||
void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity);
|
||||
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||
|
||||
int32_t createQueryFilter(char* data, uint16_t len, SFilterInfo** pFilters);
|
||||
|
||||
int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, STaskParam* param, char* start,
|
||||
int32_t prevResultLen, void* merger);
|
||||
|
||||
int32_t createFilterInfo(STaskAttr* pQueryAttr, uint64_t qId);
|
||||
void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters);
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
|
|||
return false;
|
||||
}
|
||||
|
||||
pBuf->allocSize = sizeof(SRetrieveTableRsp) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows;
|
||||
// struct size + data payload + length for each column
|
||||
pBuf->allocSize = sizeof(SRetrieveTableRsp) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows + pInput->pData->info.numOfCols * sizeof(int32_t);
|
||||
pBuf->pData = malloc(pBuf->allocSize);
|
||||
if (pBuf->pData == NULL) {
|
||||
qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno));
|
||||
|
|
|
@ -23,6 +23,7 @@ static SDataSinkManager gDataSinkManager = {0};
|
|||
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg) {
|
||||
gDataSinkManager.cfg = *cfg;
|
||||
pthread_mutex_init(&gDataSinkManager.mutex, NULL);
|
||||
return 0; // to avoid compiler eror
|
||||
}
|
||||
|
||||
int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHandle) {
|
||||
|
|
|
@ -59,7 +59,8 @@ int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
|
|||
pResultRowInfo->capacity = size;
|
||||
|
||||
pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES);
|
||||
if (pResultRowInfo->pResult == NULL) {
|
||||
pResultRowInfo->pPosition = calloc(pResultRowInfo->capacity, sizeof(SResultRowPosition));
|
||||
if (pResultRowInfo->pResult == NULL || pResultRowInfo->pPosition == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -182,22 +183,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
|||
return rowSize;
|
||||
}
|
||||
|
||||
SResultRowPool* initResultRowPool(size_t size) {
|
||||
SResultRowPool* p = calloc(1, sizeof(SResultRowPool));
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->numOfElemPerBlock = 128;
|
||||
|
||||
p->elemSize = (int32_t) size;
|
||||
p->blockSize = p->numOfElemPerBlock * p->elemSize;
|
||||
p->position.pos = 0;
|
||||
|
||||
p->pData = taosArrayInit(8, POINTER_BYTES);
|
||||
return p;
|
||||
}
|
||||
|
||||
SResultRow* getNewResultRow(SResultRowPool* p) {
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
|
@ -221,132 +206,6 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
|
|||
return ptr;
|
||||
}
|
||||
|
||||
int64_t getResultRowPoolMemSize(SResultRowPool* p) {
|
||||
if (p == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return taosArrayGetSize(p->pData) * p->blockSize;
|
||||
}
|
||||
|
||||
int32_t getNumOfAllocatedResultRows(SResultRowPool* p) {
|
||||
return (int32_t) taosArrayGetSize(p->pData) * p->numOfElemPerBlock;
|
||||
}
|
||||
|
||||
int32_t getNumOfUsedResultRows(SResultRowPool* p) {
|
||||
return getNumOfAllocatedResultRows(p) - p->numOfElemPerBlock + p->position.pos;
|
||||
}
|
||||
|
||||
void* destroyResultRowPool(SResultRowPool* p) {
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t size = taosArrayGetSize(p->pData);
|
||||
for(int32_t i = 0; i < size; ++i) {
|
||||
void** ptr = taosArrayGet(p->pData, i);
|
||||
tfree(*ptr);
|
||||
}
|
||||
|
||||
taosArrayDestroy(p->pData);
|
||||
|
||||
tfree(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void interResToBinary(SBufferWriter* bw, SArray* pRes, int32_t tagLen) {
|
||||
uint32_t numOfGroup = (uint32_t) taosArrayGetSize(pRes);
|
||||
tbufWriteUint32(bw, numOfGroup);
|
||||
tbufWriteUint16(bw, tagLen);
|
||||
|
||||
for(int32_t i = 0; i < numOfGroup; ++i) {
|
||||
SInterResult* pOne = taosArrayGet(pRes, i);
|
||||
if (tagLen > 0) {
|
||||
tbufWriteBinary(bw, pOne->tags, tagLen);
|
||||
}
|
||||
|
||||
uint32_t numOfCols = (uint32_t) taosArrayGetSize(pOne->pResult);
|
||||
tbufWriteUint32(bw, numOfCols);
|
||||
for(int32_t j = 0; j < numOfCols; ++j) {
|
||||
SStddevInterResult* p = taosArrayGet(pOne->pResult, j);
|
||||
uint32_t numOfRows = (uint32_t) taosArrayGetSize(p->pResult);
|
||||
|
||||
tbufWriteUint16(bw, p->colId);
|
||||
tbufWriteUint32(bw, numOfRows);
|
||||
|
||||
for(int32_t k = 0; k < numOfRows; ++k) {
|
||||
// SResPair v = *(SResPair*) taosArrayGet(p->pResult, k);
|
||||
// tbufWriteDouble(bw, v.avg);
|
||||
// tbufWriteInt64(bw, v.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SArray* interResFromBinary(const char* data, int32_t len) {
|
||||
SBufferReader br = tbufInitReader(data, len, false);
|
||||
uint32_t numOfGroup = tbufReadUint32(&br);
|
||||
uint16_t tagLen = tbufReadUint16(&br);
|
||||
|
||||
char* tag = NULL;
|
||||
if (tagLen > 0) {
|
||||
tag = calloc(1, tagLen);
|
||||
}
|
||||
|
||||
SArray* pResult = taosArrayInit(4, sizeof(SInterResult));
|
||||
|
||||
for(int32_t i = 0; i < numOfGroup; ++i) {
|
||||
if (tagLen > 0) {
|
||||
memset(tag, 0, tagLen);
|
||||
tbufReadToBinary(&br, tag, tagLen);
|
||||
}
|
||||
|
||||
uint32_t numOfCols = tbufReadUint32(&br);
|
||||
|
||||
SArray* p = taosArrayInit(numOfCols, sizeof(SStddevInterResult));
|
||||
for(int32_t j = 0; j < numOfCols; ++j) {
|
||||
// int16_t colId = tbufReadUint16(&br);
|
||||
int32_t numOfRows = tbufReadUint32(&br);
|
||||
|
||||
// SStddevInterResult interRes = {.colId = colId, .pResult = taosArrayInit(4, sizeof(struct SResPair)),};
|
||||
for(int32_t k = 0; k < numOfRows; ++k) {
|
||||
// SResPair px = {0};
|
||||
// px.avg = tbufReadDouble(&br);
|
||||
// px.key = tbufReadInt64(&br);
|
||||
//
|
||||
// taosArrayPush(interRes.pResult, &px);
|
||||
}
|
||||
|
||||
// taosArrayPush(p, &interRes);
|
||||
}
|
||||
|
||||
char* p1 = NULL;
|
||||
if (tagLen > 0) {
|
||||
p1 = malloc(tagLen);
|
||||
memcpy(p1, tag, tagLen);
|
||||
}
|
||||
|
||||
SInterResult d = {.pResult = p, .tags = p1,};
|
||||
taosArrayPush(pResult, &d);
|
||||
}
|
||||
|
||||
tfree(tag);
|
||||
return pResult;
|
||||
}
|
||||
|
||||
void freeInterResult(void* param) {
|
||||
SInterResult* pResult = (SInterResult*) param;
|
||||
tfree(pResult->tags);
|
||||
|
||||
int32_t numOfCols = (int32_t) taosArrayGetSize(pResult->pResult);
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SStddevInterResult *p = taosArrayGet(pResult->pResult, i);
|
||||
taosArrayDestroy(p->pResult);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pResult->pResult);
|
||||
}
|
||||
|
||||
void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) {
|
||||
assert(pGroupResInfo != NULL);
|
||||
|
||||
|
@ -360,7 +219,7 @@ void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo)
|
|||
taosArrayDestroy(pGroupResInfo->pRows);
|
||||
}
|
||||
|
||||
pGroupResInfo->pRows = taosArrayFromList(pResultInfo->pResult, pResultInfo->size, POINTER_BYTES);
|
||||
pGroupResInfo->pRows = taosArrayFromList(pResultInfo->pPosition, pResultInfo->size, sizeof(SResultRowPosition));
|
||||
pGroupResInfo->index = 0;
|
||||
assert(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -413,7 +413,7 @@ int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen) {
|
|||
|
||||
void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
|
||||
printf("==================== linear hash ====================\n");
|
||||
printf("total bucket:%d, size:%ld, ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
|
||||
printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
|
||||
|
||||
dBufSetPrintInfo(pHashObj->pBuf);
|
||||
|
||||
|
@ -425,4 +425,4 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
|
|||
} else {
|
||||
dBufPrintStatis(pHashObj->pBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct SSortHandle {
|
|||
|
||||
SArray *pOrderInfo;
|
||||
bool nullFirst;
|
||||
bool hasVarCol;
|
||||
SArray *pOrderedSource;
|
||||
|
||||
_sort_fetch_block_fn_t fetchfp;
|
||||
|
@ -77,6 +76,10 @@ static SSDataBlock* createDataBlock_rv(SSchema* pSchema, int32_t numOfCols) {
|
|||
colInfo.info.bytes = pSchema[i].bytes;
|
||||
colInfo.info.colId = pSchema[i].colId;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfo);
|
||||
|
||||
if (IS_VAR_DATA_TYPE(colInfo.info.type)) {
|
||||
pBlock->info.hasVarCol = true;
|
||||
}
|
||||
}
|
||||
|
||||
return pBlock;
|
||||
|
@ -155,7 +158,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
|
|||
|
||||
while(start < pDataBlock->info.rows) {
|
||||
int32_t stop = 0;
|
||||
blockDataSplitRows(pDataBlock, pHandle->hasVarCol, start, &stop, pHandle->pageSize);
|
||||
blockDataSplitRows(pDataBlock, pDataBlock->info.hasVarCol, start, &stop, pHandle->pageSize);
|
||||
SSDataBlock* p = blockDataExtractBlock(pDataBlock, start, stop - start + 1);
|
||||
if (p == NULL) {
|
||||
return terrno;
|
||||
|
@ -179,7 +182,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
|
|||
start = stop + 1;
|
||||
}
|
||||
|
||||
blockDataClearup(pDataBlock, pHandle->hasVarCol);
|
||||
blockDataClearup(pDataBlock);
|
||||
|
||||
SSDataBlock* pBlock = createOneDataBlock(pDataBlock);
|
||||
int32_t code = doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId);
|
||||
|
@ -309,7 +312,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa
|
|||
}
|
||||
|
||||
static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SMsortComparParam* cmpParam, int32_t capacity) {
|
||||
blockDataClearup(pHandle->pDataBlock, pHandle->hasVarCol);
|
||||
blockDataClearup(pHandle->pDataBlock);
|
||||
|
||||
while(1) {
|
||||
if (cmpParam->numOfSources == pHandle->numOfCompletedSources) {
|
||||
|
@ -475,7 +478,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
|
|||
setBufPageDirty(pPage, true);
|
||||
releaseBufPage(pHandle->pBuf, pPage);
|
||||
|
||||
blockDataClearup(pDataBlock, pHandle->hasVarCol);
|
||||
blockDataClearup(pDataBlock);
|
||||
}
|
||||
|
||||
tMergeTreeDestroy(pHandle->pMergeTree);
|
||||
|
|
|
@ -55,8 +55,7 @@ typedef struct SDummyInputInfo {
|
|||
SSDataBlock* pBlock;
|
||||
} SDummyInputInfo;
|
||||
|
||||
SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
|
||||
SOperatorInfo* pOperator = static_cast<SOperatorInfo*>(param);
|
||||
SSDataBlock* getDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
||||
SDummyInputInfo* pInfo = static_cast<SDummyInputInfo*>(pOperator->info);
|
||||
if (pInfo->current >= pInfo->totalPages) {
|
||||
return NULL;
|
||||
|
@ -87,7 +86,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
|
|||
//
|
||||
// taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
|
||||
} else {
|
||||
blockDataClearup(pInfo->pBlock, true);
|
||||
blockDataClearup(pInfo->pBlock);
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = pInfo->pBlock;
|
||||
|
@ -122,8 +121,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
|
|||
return pBlock;
|
||||
}
|
||||
|
||||
SSDataBlock* get2ColsDummyBlock(void* param, bool* newgroup) {
|
||||
SOperatorInfo* pOperator = static_cast<SOperatorInfo*>(param);
|
||||
SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
||||
SDummyInputInfo* pInfo = static_cast<SDummyInputInfo*>(pOperator->info);
|
||||
if (pInfo->current >= pInfo->totalPages) {
|
||||
return NULL;
|
||||
|
@ -153,7 +151,7 @@ SSDataBlock* get2ColsDummyBlock(void* param, bool* newgroup) {
|
|||
|
||||
taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
|
||||
} else {
|
||||
blockDataClearup(pInfo->pBlock, false);
|
||||
blockDataClearup(pInfo->pBlock);
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = pInfo->pBlock;
|
||||
|
|
|
@ -46,13 +46,6 @@ extern SAggFunctionInfo aggFunc[35];
|
|||
#define DATA_SET_FLAG ',' // to denote the output area has data, not null value
|
||||
#define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG)
|
||||
|
||||
#define TOP_BOTTOM_QUERY_LIMIT 100
|
||||
|
||||
#define QUERY_IS_STABLE_QUERY(type) (((type)&TSDB_QUERY_TYPE_STABLE_QUERY) != 0)
|
||||
#define QUERY_IS_JOIN_QUERY(type) (TSDB_QUERY_HAS_TYPE(type, TSDB_QUERY_TYPE_JOIN_QUERY))
|
||||
#define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0)
|
||||
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
|
||||
|
||||
typedef struct SInterpInfoDetail {
|
||||
TSKEY ts; // interp specified timestamp
|
||||
int8_t type;
|
||||
|
@ -61,9 +54,6 @@ typedef struct SInterpInfoDetail {
|
|||
|
||||
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowEntryInfo)))
|
||||
|
||||
#define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0)
|
||||
#define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0)
|
||||
|
||||
typedef struct STwaInfo {
|
||||
int8_t hasResult; // flag to denote has value
|
||||
double dOutput;
|
||||
|
@ -71,8 +61,6 @@ typedef struct STwaInfo {
|
|||
STimeWindow win;
|
||||
} STwaInfo;
|
||||
|
||||
extern int32_t functionCompatList[]; // compatible check array list
|
||||
|
||||
bool topbot_datablock_filter(SqlFunctionCtx *pCtx, const char *minval, const char *maxval);
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,10 +52,6 @@ static void doFinalizer(SResultRowEntryInfo* pResInfo) { cleanupResultRowEntry(p
|
|||
|
||||
void functionFinalizer(SqlFunctionCtx *pCtx) {
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
if (pResInfo->hasResult != DATA_SET_FLAG) {
|
||||
// setNull(pCtx->pOutput, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes);
|
||||
}
|
||||
|
||||
doFinalizer(pResInfo);
|
||||
}
|
||||
|
||||
|
@ -398,7 +394,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
|
|||
int32_t *pData = (int32_t*)pCol->pData;
|
||||
int32_t *val = (int32_t*) buf;
|
||||
|
||||
for (int32_t i = 0; i < pCtx->size; ++i) {
|
||||
for (int32_t i = start; i < start + numOfRows; ++i) {
|
||||
if ((pCol->hasNull) && colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,415 +0,0 @@
|
|||
#include "os.h"
|
||||
#include "tarray.h"
|
||||
#include "function.h"
|
||||
#include "thash.h"
|
||||
#include "taggfunction.h"
|
||||
|
||||
static SHashObj* functionHashTable = NULL;
|
||||
static SHashObj* udfHashTable = NULL;
|
||||
|
||||
static void doInitFunctionHashTable() {
|
||||
int numOfEntries = tListLen(aggFunc);
|
||||
functionHashTable = taosHashInit(numOfEntries, MurmurHash3_32, false, false);
|
||||
for (int32_t i = 0; i < numOfEntries; i++) {
|
||||
int32_t len = (uint32_t)strlen(aggFunc[i].name);
|
||||
|
||||
SAggFunctionInfo* ptr = &aggFunc[i];
|
||||
taosHashPut(functionHashTable, aggFunc[i].name, len, (void*)&ptr, POINTER_BYTES);
|
||||
}
|
||||
|
||||
/*
|
||||
numOfEntries = tListLen(scalarFunc);
|
||||
for(int32_t i = 0; i < numOfEntries; ++i) {
|
||||
int32_t len = (int32_t) strlen(scalarFunc[i].name);
|
||||
SScalarFunctionInfo* ptr = &scalarFunc[i];
|
||||
taosHashPut(functionHashTable, scalarFunc[i].name, len, (void*)&ptr, POINTER_BYTES);
|
||||
}
|
||||
*/
|
||||
|
||||
udfHashTable = taosHashInit(numOfEntries, MurmurHash3_32, true, true);
|
||||
}
|
||||
|
||||
static pthread_once_t functionHashTableInit = PTHREAD_ONCE_INIT;
|
||||
|
||||
int32_t qIsBuiltinFunction(const char* name, int32_t len, bool* scalarFunction) {
|
||||
pthread_once(&functionHashTableInit, doInitFunctionHashTable);
|
||||
|
||||
SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, name, len);
|
||||
if (pInfo != NULL) {
|
||||
*scalarFunction = ((*pInfo)->type == FUNCTION_TYPE_SCALAR);
|
||||
return (*pInfo)->functionId;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* functionId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool qIsAggregateFunction(const char* functionName) {
|
||||
assert(functionName != NULL);
|
||||
bool scalarfunc = false;
|
||||
qIsBuiltinFunction(functionName, strlen(functionName), &scalarfunc);
|
||||
|
||||
return !scalarfunc;
|
||||
}
|
||||
|
||||
bool qIsSelectivityFunction(const char* functionName) {
|
||||
assert(functionName != NULL);
|
||||
pthread_once(&functionHashTableInit, doInitFunctionHashTable);
|
||||
|
||||
size_t len = strlen(functionName);
|
||||
SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, functionName, len);
|
||||
if (pInfo != NULL) {
|
||||
return ((*pInfo)->status | FUNCSTATE_SELECTIVITY) != 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SAggFunctionInfo* qGetFunctionInfo(const char* name, int32_t len) {
|
||||
pthread_once(&functionHashTableInit, doInitFunctionHashTable);
|
||||
|
||||
SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, name, len);
|
||||
if (pInfo != NULL) {
|
||||
return (*pInfo);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void qAddUdfInfo(uint64_t id, SUdfInfo* pUdfInfo) {
|
||||
int32_t len = (uint32_t)strlen(pUdfInfo->name);
|
||||
taosHashPut(udfHashTable, pUdfInfo->name, len, (void*)&pUdfInfo, POINTER_BYTES);
|
||||
}
|
||||
|
||||
void qRemoveUdfInfo(uint64_t id, SUdfInfo* pUdfInfo) {
|
||||
int32_t len = (uint32_t)strlen(pUdfInfo->name);
|
||||
taosHashRemove(udfHashTable, pUdfInfo->name, len);
|
||||
}
|
||||
|
||||
bool isTagsQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
char* f = *(char**) taosArrayGet(pFunctionIdList, i);
|
||||
|
||||
// todo handle count(tbname) query
|
||||
if (strcmp(f, "project") != 0 && strcmp(f, "count") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// "select count(tbname)" query
|
||||
// if (functId == FUNCTION_COUNT && pExpr->base.colpDesc->colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
// continue;
|
||||
// }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool tscMultiRoundQuery(SArray* pFunctionIdList, int32_t index) {
|
||||
// if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// size_t numOfExprs = (int32_t) getNumOfExprs(pQueryInfo);
|
||||
// for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
// SExprInfo* pExpr = getExprInfo(pQueryInfo, i);
|
||||
// if (pExpr->base.functionId == FUNCTION_STDDEV_DST) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
//}
|
||||
|
||||
bool isProjectionQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
char* f = *(char**) taosArrayGet(pFunctionIdList, i);
|
||||
if (strcmp(f, "project") == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isDiffDerivativeQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_TS_DUMMY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f == FUNCTION_DIFF || f == FUNCTION_DERIVATIVE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isInterpQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_TAG || f == FUNCTION_TS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f != FUNCTION_INTERP) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isArithmeticQueryOnAggResult(SArray* pFunctionIdList) {
|
||||
if (isProjectionQuery(pFunctionIdList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(0);
|
||||
|
||||
// size_t numOfOutput = getNumOfFields(pQueryInfo);
|
||||
// for(int32_t i = 0; i < numOfOutput; ++i) {
|
||||
// SExprInfo* pExprInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i)->pExpr;
|
||||
// if (pExprInfo->pExpr != NULL) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isGroupbyColumn(SGroupbyExpr* pGroupby) {
|
||||
return !pGroupby->groupbyTag;
|
||||
}
|
||||
|
||||
bool isTopBotQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
char* f = *(char**) taosArrayGet(pFunctionIdList, i);
|
||||
if (strcmp(f, "project") == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(f, "top") == 0 || strcmp(f, "bottom") == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isTsCompQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
if (num != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, 0);
|
||||
return f == FUNCTION_TS_COMP;
|
||||
}
|
||||
|
||||
bool isTWAQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_TWA) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isIrateQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_IRATE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStabledev(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_STDDEV_DST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needReverseScan(SArray* pFunctionIdList) {
|
||||
assert(0);
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
if (f == FUNCTION_TS || f == FUNCTION_TS_DUMMY || f == FUNCTION_TAG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if ((f == FUNCTION_FIRST || f == FUNCTION_FIRST_DST) && pQueryInfo->order.order == TSDB_ORDER_DESC) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
if (f == FUNCTION_LAST || f == FUNCTION_LAST_DST) {
|
||||
// the scan order to acquire the last result of the specified column
|
||||
// int32_t order = (int32_t)pExpr->base.param[0].i64;
|
||||
// if (order != pQueryInfo->order.order) {
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isAgg(SArray* pFunctionIdList) {
|
||||
size_t size = taosArrayGetSize(pFunctionIdList);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
char* f = *(char**) taosArrayGet(pFunctionIdList, i);
|
||||
if (strcmp(f, "project") == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (qIsAggregateFunction(f)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isBlockDistQuery(SArray* pFunctionIdList) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
char* f = *(char**) taosArrayGet(pFunctionIdList, 0);
|
||||
return (num == 1 && strcmp(f, "block_dist") == 0);
|
||||
}
|
||||
|
||||
bool isTwoStageSTableQuery(SArray* pFunctionIdList, int32_t tableIndex) {
|
||||
// if (pQueryInfo == NULL) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
||||
// if (pTableMetaInfo == NULL) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // for ordered projection query, iterate all qualified vnodes sequentially
|
||||
// if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, tableIndex)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->command == TSDB_SQL_SELECT) {
|
||||
// return UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isProjectionQueryOnSTable(SArray* pFunctionIdList, int32_t tableIndex) {
|
||||
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
||||
//
|
||||
// /*
|
||||
// * In following cases, return false for non ordered project query on super table
|
||||
// * 1. failed to get tableMeta from server; 2. not a super table; 3. limitation is 0;
|
||||
// * 4. show queries, instead of a select query
|
||||
// */
|
||||
// size_t numOfExprs = getNumOfExprs(pQueryInfo);
|
||||
// if (pTableMetaInfo == NULL || !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) ||
|
||||
// pQueryInfo->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || numOfExprs == 0) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
// int32_t functionId = getExprInfo(pQueryInfo, i)->base.functionId;
|
||||
//
|
||||
// if (functionId < 0) {
|
||||
// SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * functionId - 1);
|
||||
// if (pUdfInfo->funcType == TSDB_FUNC_TYPE_AGGREGATE) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (functionId != FUNCTION_PRJ &&
|
||||
// functionId != FUNCTION_TAGPRJ &&
|
||||
// functionId != FUNCTION_TAG &&
|
||||
// functionId != FUNCTION_TS &&
|
||||
// functionId != FUNCTION_ARITHM &&
|
||||
// functionId != FUNCTION_TS_COMP &&
|
||||
// functionId != FUNCTION_DIFF &&
|
||||
// functionId != FUNCTION_DERIVATIVE &&
|
||||
// functionId != FUNCTION_TS_DUMMY &&
|
||||
// functionId != FUNCTION_TID_TAG) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasTagValOutput(SArray* pFunctionIdList) {
|
||||
size_t size = taosArrayGetSize(pFunctionIdList);
|
||||
|
||||
// if (numOfExprs == 1 && pExpr1->base.functionId == FUNCTION_TS_COMP) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
int32_t functionId = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
|
||||
// ts_comp column required the tag value for join filter
|
||||
if (functionId == FUNCTION_TAG || functionId == FUNCTION_TAGPRJ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//bool timeWindowInterpoRequired(SArray* pFunctionIdList) {
|
||||
// int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
|
||||
// for (int32_t i = 0; i < num; ++i) {
|
||||
// int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
|
||||
// if (f == FUNCTION_TWA || f == FUNCTION_INTERP) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
//}
|
||||
|
||||
void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc) {
|
||||
assert(pFunctionIdList != NULL);
|
||||
|
||||
pDesc->blockDistribution = isBlockDistQuery(pFunctionIdList);
|
||||
if (pDesc->blockDistribution) {
|
||||
return;
|
||||
}
|
||||
|
||||
// pDesc->projectionQuery = isProjectionQuery(pFunctionIdList);
|
||||
// pDesc->onlyTagQuery = isTagsQuery(pFunctionIdList);
|
||||
pDesc->interpQuery = isInterpQuery(pFunctionIdList);
|
||||
pDesc->topbotQuery = isTopBotQuery(pFunctionIdList);
|
||||
pDesc->agg = isAgg(pFunctionIdList);
|
||||
}
|
|
@ -240,6 +240,7 @@ int indexRebuild(SIndex* index, SIndexOpts* opts){
|
|||
#ifdef USE_INVERTED_INDEX
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SIndexOpts* indexOptsCreate() {
|
||||
|
|
|
@ -190,7 +190,10 @@ int indexCacheSchedToMerge(IndexCache* pCache) {
|
|||
schedMsg.msg = NULL;
|
||||
|
||||
taosScheduleTask(indexQhandle, &schedMsg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void indexCacheMakeRoomForWrite(IndexCache* cache) {
|
||||
while (true) {
|
||||
if (cache->occupiedMem * MEM_ESTIMATE_RADIO < MEM_THRESHOLD) {
|
||||
|
|
|
@ -571,6 +571,8 @@ uint64_t fstStateFindInput(FstState* s, FstNode* node, uint8_t b, bool* null) {
|
|||
}
|
||||
fstSliceDestroy(&t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fst node function
|
||||
|
@ -1027,6 +1029,8 @@ Fst* fstCreate(FstSlice* slice) {
|
|||
FST_CREAT_FAILED:
|
||||
free(fst->meta);
|
||||
free(fst);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void fstDestroy(Fst* fst) {
|
||||
if (fst) {
|
||||
|
@ -1286,6 +1290,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallback callback) {
|
||||
|
|
|
@ -151,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) {
|
||||
const SJson* pJsonArray = tjsonGetObjectItem(pJson, pName);
|
||||
static int32_t jsonToNodeListImpl(const SJson* pJsonArray, SNodeList** pList) {
|
||||
int32_t size = (NULL == pJsonArray ? 0 : tjsonGetArraySize(pJsonArray));
|
||||
if (size > 0) {
|
||||
*pList = nodesMakeList();
|
||||
|
@ -176,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList**
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) {
|
||||
return jsonToNodeListImpl(tjsonGetObjectItem(pJson, pName), pList);
|
||||
}
|
||||
|
||||
static const char* jkTableMetaUid = "TableMetaUid";
|
||||
static const char* jkTableMetaSuid = "TableMetaSuid";
|
||||
|
||||
|
@ -580,6 +583,8 @@ static const char* jkIntervalPhysiPlanFuncs = "Funcs";
|
|||
static const char* jkIntervalPhysiPlanInterval = "Interval";
|
||||
static const char* jkIntervalPhysiPlanOffset = "Offset";
|
||||
static const char* jkIntervalPhysiPlanSliding = "Sliding";
|
||||
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
|
||||
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
|
||||
static const char* jkIntervalPhysiPlanFill = "Fill";
|
||||
|
||||
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
||||
|
@ -601,6 +606,12 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSliding, pNode->sliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanIntervalUnit, pNode->intervalUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSlidingUnit, pNode->slidingUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
|
||||
}
|
||||
|
@ -627,6 +638,12 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanSliding, &pNode->sliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetTinyIntValue(pJson, jkIntervalPhysiPlanIntervalUnit, &pNode->intervalUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetTinyIntValue(pJson, jkIntervalPhysiPlanSlidingUnit, &pNode->slidingUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
|
||||
}
|
||||
|
@ -1644,7 +1661,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToSubplan(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN:
|
||||
return jsonToPlan(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
||||
return jsonToPhysiIntervalNode(pJson, pObj);
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
nodesWarn("jsonToSpecificNode unknown node = %s", nodesNodeName(nodeType(pObj)));
|
||||
|
@ -1710,7 +1730,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p
|
|||
}
|
||||
|
||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) {
|
||||
if (NULL == pNode || NULL == pStr || NULL == pLen) {
|
||||
if (NULL == pNode || NULL == pStr) {
|
||||
terrno = TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1730,7 +1750,10 @@ int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_
|
|||
*pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson);
|
||||
tjsonDelete(pJson);
|
||||
|
||||
*pLen = strlen(*pStr) + 1;
|
||||
if (NULL != pLen) {
|
||||
*pLen = strlen(*pStr) + 1;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1750,3 +1773,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) {
|
|||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen) {
|
||||
if (NULL == pList || NULL == pStr || NULL == pLen) {
|
||||
terrno = TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (0 == LIST_LENGTH(pList)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SJson* pJson = tjsonCreateArray();
|
||||
if (NULL == pJson) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pList) {
|
||||
int32_t code = tjsonAddItem(pJson, nodeToJson, pNode);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
*pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson);
|
||||
tjsonDelete(pJson);
|
||||
|
||||
*pLen = strlen(*pStr) + 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList) {
|
||||
if (NULL == pStr || NULL == pList) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SJson* pJson = tjsonParse(pStr);
|
||||
if (NULL == pJson) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int32_t code = jsonToNodeListImpl(pJson, pList);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(*pList);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SColumnDefNode));
|
||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||
return makeNode(type, sizeof(SDownstreamSourceNode));
|
||||
case QUERY_NODE_DATABASE_OPTIONS:
|
||||
return makeNode(type, sizeof(SDatabaseOptions));
|
||||
case QUERY_NODE_TABLE_OPTIONS:
|
||||
return makeNode(type, sizeof(STableOptions));
|
||||
case QUERY_NODE_INDEX_OPTIONS:
|
||||
return makeNode(type, sizeof(SIndexOptions));
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return makeNode(type, sizeof(SSetOperator));
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -86,6 +92,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SCreateDatabaseStmt));
|
||||
case QUERY_NODE_DROP_DATABASE_STMT:
|
||||
return makeNode(type, sizeof(SDropDatabaseStmt));
|
||||
case QUERY_NODE_ALTER_DATABASE_STMT:
|
||||
return makeNode(type, sizeof(SAlterDatabaseStmt));
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_CREATE_TABLE_STMT:
|
||||
|
@ -121,7 +129,20 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
return makeNode(type, sizeof(SCreateIndexStmt));
|
||||
case QUERY_NODE_DROP_INDEX_STMT:
|
||||
return makeNode(type, sizeof(SDropIndexStmt));
|
||||
case QUERY_NODE_CREATE_QNODE_STMT:
|
||||
return makeNode(type, sizeof(SCreateQnodeStmt));
|
||||
case QUERY_NODE_DROP_QNODE_STMT:
|
||||
return makeNode(type, sizeof(SDropQnodeStmt));
|
||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||
return makeNode(type, sizeof(SCreateTopicStmt));
|
||||
case QUERY_NODE_DROP_TOPIC_STMT:
|
||||
return makeNode(type, sizeof(SDropTopicStmt));
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return makeNode(type, sizeof(SScanLogicNode));
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
@ -208,6 +229,14 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
|
|||
case QUERY_NODE_NODE_LIST:
|
||||
nodesClearList(((SNodeListNode*)(*pNode))->pNodeList);
|
||||
break;
|
||||
case QUERY_NODE_INDEX_OPTIONS: {
|
||||
SIndexOptions* pStmt = (SIndexOptions*)*pNode;
|
||||
nodesDestroyList(pStmt->pFuncs);
|
||||
nodesDestroyNode(pStmt->pInterval);
|
||||
nodesDestroyNode(pStmt->pOffset);
|
||||
nodesDestroyNode(pStmt->pSliding);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_SELECT_STMT: {
|
||||
SSelectStmt* pStmt = (SSelectStmt*)*pNode;
|
||||
nodesDestroyList(pStmt->pProjectionList);
|
||||
|
@ -248,6 +277,12 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
|
|||
case QUERY_NODE_CREATE_MULTI_TABLE_STMT:
|
||||
nodesDestroyList(((SCreateMultiTableStmt*)(*pNode))->pSubTables);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT: {
|
||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)*pNode;
|
||||
nodesDestroyNode(pStmt->pOptions);
|
||||
nodesDestroyList(pStmt->pCols);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -109,17 +109,18 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
|
|||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable);
|
||||
SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight);
|
||||
|
||||
SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt);
|
||||
SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal);
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions);
|
||||
SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt);
|
||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal);
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions);
|
||||
SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName);
|
||||
STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal);
|
||||
STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma);
|
||||
SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions);
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal);
|
||||
SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma);
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment);
|
||||
SDataType createDataType(uint8_t type);
|
||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen);
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions);
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions);
|
||||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags);
|
||||
SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables);
|
||||
SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||
|
@ -132,6 +133,13 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int
|
|||
SNode* createDropUserStmt(SAstCreateContext* pCxt, const SToken* pUserName);
|
||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName);
|
||||
SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId);
|
||||
SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId);
|
||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName);
|
||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -42,17 +42,17 @@
|
|||
//%right NK_BITNOT.
|
||||
|
||||
/************************************************ create/alter/drop/show user *****************************************/
|
||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);}
|
||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);}
|
||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);}
|
||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); }
|
||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); }
|
||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
||||
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); }
|
||||
|
||||
/************************************************ create/drop/show dnode **********************************************/
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);}
|
||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);}
|
||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
|
||||
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); }
|
||||
|
||||
%type dnode_endpoint { SToken }
|
||||
|
@ -64,11 +64,17 @@ dnode_endpoint(A) ::= NK_STRING(B).
|
|||
dnode_host_name(A) ::= NK_ID(B). { A = B; }
|
||||
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
|
||||
|
||||
/************************************************ create/drop qnode ***************************************************/
|
||||
cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); }
|
||||
cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); }
|
||||
cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); }
|
||||
|
||||
/************************************************ create/drop/show/use database ***************************************/
|
||||
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
|
||||
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); }
|
||||
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
|
||||
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); }
|
||||
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
|
||||
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= ALTER DATABASE db_name(A) db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
|
||||
|
||||
%type not_exists_opt { bool }
|
||||
%destructor not_exists_opt { }
|
||||
|
@ -80,8 +86,6 @@ not_exists_opt(A) ::= .
|
|||
exists_opt(A) ::= IF EXISTS. { A = true; }
|
||||
exists_opt(A) ::= . { A = false; }
|
||||
|
||||
%type db_options { SDatabaseOptions* }
|
||||
%destructor db_options { tfree($$); }
|
||||
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
|
||||
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); }
|
||||
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); }
|
||||
|
@ -179,8 +183,6 @@ tags_def_opt(A) ::= tags_def(B).
|
|||
%destructor tags_def { nodesDestroyList($$); }
|
||||
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
|
||||
|
||||
%type table_options { STableOptions* }
|
||||
%destructor table_options { tfree($$); }
|
||||
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
|
||||
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
|
||||
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
|
||||
|
@ -194,6 +196,30 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
|
|||
|
||||
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
||||
|
||||
/************************************************ create index ********************************************************/
|
||||
cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); }
|
||||
cmd ::= CREATE FULLTEXT INDEX
|
||||
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); }
|
||||
cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); }
|
||||
|
||||
index_options(A) ::= . { A = NULL; }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); }
|
||||
|
||||
%type func_list { SNodeList* }
|
||||
%destructor func_list { nodesDestroyList($$); }
|
||||
func_list(A) ::= func(B). { A = createNodeList(pCxt, B); }
|
||||
func_list(A) ::= func_list(B) NK_COMMA func(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
||||
|
||||
/************************************************ create/drop topic ***************************************************/
|
||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); }
|
||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); }
|
||||
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
|
||||
|
||||
/************************************************ show vgroups ********************************************************/
|
||||
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
|
||||
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
|
||||
|
@ -248,6 +274,14 @@ column_alias(A) ::= NK_ID(B).
|
|||
%destructor user_name { }
|
||||
user_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
%type index_name { SToken }
|
||||
%destructor index_name { }
|
||||
index_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
%type topic_name { SToken }
|
||||
%destructor topic_name { }
|
||||
topic_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
/************************************************ expression **********************************************************/
|
||||
expression(A) ::= literal(B). { A = B; }
|
||||
//expression(A) ::= NK_QUESTION(B). { A = B; }
|
||||
|
@ -463,13 +497,13 @@ twindow_clause_opt(A) ::=
|
|||
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
||||
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
twindow_clause_opt(A) ::=
|
||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, B, NULL, C, D); }
|
||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
|
||||
twindow_clause_opt(A) ::=
|
||||
INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP
|
||||
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, B, C, D, E); }
|
||||
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); }
|
||||
|
||||
sliding_opt(A) ::= . { A = NULL; }
|
||||
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = B; }
|
||||
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); }
|
||||
|
||||
fill_opt(A) ::= . { A = NULL; }
|
||||
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
|
||||
|
|
|
@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName)
|
|||
return pCxt->valid;
|
||||
}
|
||||
|
||||
static bool checkIndexName(SAstCreateContext* pCxt, const SToken* pIndexName) {
|
||||
if (NULL == pIndexName) {
|
||||
return false;
|
||||
}
|
||||
pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false;
|
||||
return pCxt->valid;
|
||||
}
|
||||
|
||||
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
||||
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
||||
CHECK_OUT_OF_MEM(target);
|
||||
|
@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
|
|||
return (SNode*)setOp;
|
||||
}
|
||||
|
||||
SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
SDatabaseOptions* pOptions = calloc(1, sizeof(SDatabaseOptions));
|
||||
SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->numOfBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
||||
pOptions->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
|
||||
|
@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
|||
pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||
pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION;
|
||||
pOptions->streamMode = TSDB_DEFAULT_DB_STREAM_MODE_OPTION;
|
||||
return pOptions;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal) {
|
||||
return setDbOptionFuncs[type](pCxt, pOptions, pVal);
|
||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal) {
|
||||
return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal);
|
||||
}
|
||||
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions) {
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions) {
|
||||
if (!checkDbName(pCxt, pDbName)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
|
|||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->options = *pOptions;
|
||||
tfree(pOptions);
|
||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
|
@ -792,20 +799,31 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||
STableOptions* pOptions = calloc(1, sizeof(STableOptions));
|
||||
SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions) {
|
||||
if (!checkDbName(pCxt, pDbName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||
STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->keep = TSDB_DEFAULT_KEEP;
|
||||
pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION;
|
||||
return pOptions;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal) {
|
||||
return setTableOptionFuncs[type](pCxt, pOptions, pVal);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal) {
|
||||
return (SNode*)setTableOptionFuncs[type](pCxt, (STableOptions*)pOptions, pVal);
|
||||
}
|
||||
|
||||
STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma) {
|
||||
pOptions->pSma = pSma;
|
||||
SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma) {
|
||||
((STableOptions*)pOptions)->pSma = pSma;
|
||||
return pOptions;
|
||||
}
|
||||
|
||||
|
@ -831,7 +849,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
|||
}
|
||||
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
||||
bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions) {
|
||||
bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) {
|
||||
SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
|
@ -839,9 +857,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
|||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pCols = pCols;
|
||||
pStmt->pTags = pTags;
|
||||
pStmt->options = *pOptions;
|
||||
nodesDestroyList(pOptions->pSma);
|
||||
tfree(pOptions);
|
||||
pStmt->pOptions = (STableOptions*)pOptions;
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
@ -992,3 +1008,72 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
|||
}
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->indexType = type;
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
||||
pStmt->pCols = pCols;
|
||||
pStmt->pOptions = (SIndexOptions*)pOptions;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) {
|
||||
SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->pFuncs = pFuncs;
|
||||
pOptions->pInterval = pInterval;
|
||||
pOptions->pOffset = pOffset;
|
||||
pOptions->pSliding = pSliding;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName) {
|
||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) {
|
||||
SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) {
|
||||
SDropQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_QNODE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName) {
|
||||
SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pQuery = pQuery;
|
||||
if (NULL != pSubscribeDbName) {
|
||||
strncpy(pStmt->subscribeDbName, pSubscribeDbName->z, pSubscribeDbName->n);
|
||||
}
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) {
|
||||
SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
|
|
@ -763,6 +763,8 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
|
|||
// todo construct payload
|
||||
|
||||
tfree(row);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||
|
|
|
@ -59,11 +59,13 @@ static SKeyword keywordTable[] = {
|
|||
{"FLOAT", TK_FLOAT},
|
||||
{"FROM", TK_FROM},
|
||||
{"FSYNC", TK_FSYNC},
|
||||
{"FUNCTION", TK_FUNCTION},
|
||||
{"GROUP", TK_GROUP},
|
||||
{"HAVING", TK_HAVING},
|
||||
{"IF", TK_IF},
|
||||
{"IMPORT", TK_IMPORT},
|
||||
{"IN", TK_IN},
|
||||
{"INDEX", TK_INDEX},
|
||||
{"INNER", TK_INNER},
|
||||
{"INT", TK_INT},
|
||||
{"INSERT", TK_INSERT},
|
||||
|
@ -97,6 +99,8 @@ static SKeyword keywordTable[] = {
|
|||
{"PRECISION", TK_PRECISION},
|
||||
{"PRIVILEGE", TK_PRIVILEGE},
|
||||
{"PREV", TK_PREV},
|
||||
{"QNODE", TK_QNODE},
|
||||
{"QNODES", TK_QNODES},
|
||||
{"QUORUM", TK_QUORUM},
|
||||
{"REPLICA", TK_REPLICA},
|
||||
{"SELECT", TK_SELECT},
|
||||
|
@ -117,6 +121,7 @@ static SKeyword keywordTable[] = {
|
|||
{"TAGS", TK_TAGS},
|
||||
{"TIMESTAMP", TK_TIMESTAMP},
|
||||
{"TINYINT", TK_TINYINT},
|
||||
{"TOPIC", TK_TOPIC},
|
||||
{"TTL", TK_TTL},
|
||||
{"UNION", TK_UNION},
|
||||
{"UNSIGNED", TK_UNSIGNED},
|
||||
|
@ -226,11 +231,9 @@ static SKeyword keywordTable[] = {
|
|||
// {"TBNAME", TK_TBNAME},
|
||||
// {"VNODES", TK_VNODES},
|
||||
// {"PARTITIONS", TK_PARTITIONS},
|
||||
// {"TOPIC", TK_TOPIC},
|
||||
// {"TOPICS", TK_TOPICS},
|
||||
// {"COMPACT", TK_COMPACT},
|
||||
// {"MODIFY", TK_MODIFY},
|
||||
// {"FUNCTION", TK_FUNCTION},
|
||||
// {"FUNCTIONS", TK_FUNCTIONS},
|
||||
// {"OUTPUTTYPE", TK_OUTPUTTYPE},
|
||||
// {"AGGREGATE", TK_AGGREGATE},
|
||||
|
|
|
@ -21,14 +21,6 @@
|
|||
#include "parUtil.h"
|
||||
#include "ttime.h"
|
||||
|
||||
static bool afterGroupBy(ESqlClause clause) {
|
||||
return clause > SQL_CLAUSE_GROUP_BY;
|
||||
}
|
||||
|
||||
static bool beforeHaving(ESqlClause clause) {
|
||||
return clause < SQL_CLAUSE_HAVING;
|
||||
}
|
||||
|
||||
typedef struct STranslateContext {
|
||||
SParseContext* pParseCxt;
|
||||
int32_t errCode;
|
||||
|
@ -41,6 +33,15 @@ typedef struct STranslateContext {
|
|||
} STranslateContext;
|
||||
|
||||
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode);
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode);
|
||||
|
||||
static bool afterGroupBy(ESqlClause clause) {
|
||||
return clause > SQL_CLAUSE_GROUP_BY;
|
||||
}
|
||||
|
||||
static bool beforeHaving(ESqlClause clause) {
|
||||
return clause < SQL_CLAUSE_HAVING;
|
||||
}
|
||||
|
||||
static EDealRes generateDealNodeErrMsg(STranslateContext* pCxt, int32_t errCode, ...) {
|
||||
va_list vArgList;
|
||||
|
@ -254,8 +255,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format
|
|||
|
||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||
if (pVal->isDuration) {
|
||||
char unit = 0;
|
||||
if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) {
|
||||
if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||
}
|
||||
} else {
|
||||
|
@ -768,26 +768,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt
|
|||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, pReq->db);
|
||||
pReq->numOfVgroups = pStmt->options.numOfVgroups;
|
||||
pReq->cacheBlockSize = pStmt->options.cacheBlockSize;
|
||||
pReq->totalBlocks = pStmt->options.numOfBlocks;
|
||||
pReq->daysPerFile = pStmt->options.daysPerFile;
|
||||
pReq->daysToKeep0 = pStmt->options.keep;
|
||||
pReq->numOfVgroups = pStmt->pOptions->numOfVgroups;
|
||||
pReq->cacheBlockSize = pStmt->pOptions->cacheBlockSize;
|
||||
pReq->totalBlocks = pStmt->pOptions->numOfBlocks;
|
||||
pReq->daysPerFile = pStmt->pOptions->daysPerFile;
|
||||
pReq->daysToKeep0 = pStmt->pOptions->keep;
|
||||
pReq->daysToKeep1 = -1;
|
||||
pReq->daysToKeep2 = -1;
|
||||
pReq->minRows = pStmt->options.minRowsPerBlock;
|
||||
pReq->maxRows = pStmt->options.maxRowsPerBlock;
|
||||
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
||||
pReq->maxRows = pStmt->pOptions->maxRowsPerBlock;
|
||||
pReq->commitTime = -1;
|
||||
pReq->fsyncPeriod = pStmt->options.fsyncPeriod;
|
||||
pReq->walLevel = pStmt->options.walLevel;
|
||||
pReq->precision = pStmt->options.precision;
|
||||
pReq->compression = pStmt->options.compressionLevel;
|
||||
pReq->replications = pStmt->options.replica;
|
||||
pReq->quorum = pStmt->options.quorum;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->precision = pStmt->pOptions->precision;
|
||||
pReq->compression = pStmt->pOptions->compressionLevel;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
pReq->quorum = pStmt->pOptions->quorum;
|
||||
pReq->update = -1;
|
||||
pReq->cacheLastRow = pStmt->options.cachelast;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->ignoreExist = pStmt->ignoreExists;
|
||||
pReq->streamMode = pStmt->options.streamMode;
|
||||
pReq->streamMode = pStmt->pOptions->streamMode;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -796,14 +796,14 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
|
|||
buildCreateDbReq(pCxt, pStmt, &createReq);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
@ -819,14 +819,14 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt*
|
|||
dropReq.ignoreNotExists = pStmt->ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropDbReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
@ -834,6 +834,41 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) {
|
||||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, pReq->db);
|
||||
pReq->totalBlocks = pStmt->pOptions->numOfBlocks;
|
||||
pReq->daysToKeep0 = pStmt->pOptions->keep;
|
||||
pReq->daysToKeep1 = -1;
|
||||
pReq->daysToKeep2 = -1;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->quorum = pStmt->pOptions->quorum;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
return;
|
||||
}
|
||||
|
||||
static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt) {
|
||||
SAlterDbReq alterReq = {0};
|
||||
buildAlterDbReq(pCxt, pStmt, &alterReq);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) {
|
||||
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
|
||||
SNode* pNode;
|
||||
|
@ -860,7 +895,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
|
|||
tNameExtractFullName(&tableName, createReq.name);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -868,7 +903,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
|
|||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_STB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -884,14 +919,14 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
|
|||
dropReq.igNotExists = ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_STB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMDropStbReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMDropStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
@ -937,14 +972,14 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
|||
catalogGetDBVgVersion(pCxt->pParseCxt->pCatalog, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq);
|
||||
|
@ -960,14 +995,14 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
|||
strcpy(createReq.pass, pStmt->password);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
@ -986,14 +1021,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
|||
}
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq);
|
||||
|
@ -1006,14 +1041,14 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt)
|
|||
strcpy(dropReq.user, pStmt->useName);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
@ -1027,14 +1062,14 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p
|
|||
createReq.port = pStmt->port;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
@ -1049,14 +1084,14 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
|
|||
dropReq.port = pStmt->port;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
@ -1078,6 +1113,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
|
|||
return TSDB_MGMT_TABLE_VGROUP;
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
return TSDB_MGMT_TABLE_MNODE;
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return TSDB_MGMT_TABLE_QNODE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1094,14 +1131,14 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
|
|||
}
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_SHOW;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq);
|
||||
|
@ -1129,7 +1166,7 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
|
|||
pShowReq->head.vgId = htonl(info->vgId);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = info->epSet;
|
||||
|
@ -1141,6 +1178,192 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
SVCreateTSmaReq createSmaReq = {0};
|
||||
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) ||
|
||||
(NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) ||
|
||||
(NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit;
|
||||
createSmaReq.tSma.slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : 0);
|
||||
strcpy(createSmaReq.tSma.indexName, pStmt->indexName);
|
||||
|
||||
SName name;
|
||||
name.type = TSDB_TABLE_NAME_T;
|
||||
name.acctId = pCxt->pParseCxt->acctId;
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
STableMeta* pMeta = NULL;
|
||||
int32_t code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &name, &pMeta);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.tableUid = pMeta->uid;
|
||||
createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i;
|
||||
createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0);
|
||||
code = nodesListToString(pStmt->pOptions->pFuncs, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
void* pBuf = pCxt->pCmdMsg->pMsg;
|
||||
tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq);
|
||||
tdDestroyTSma(&createSmaReq.tSma);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
if (INDEX_TYPE_SMA == pStmt->indexType) {
|
||||
return translateCreateSmaIndex(pCxt, pStmt);
|
||||
} else {
|
||||
// todo fulltext index
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) {
|
||||
SVDropTSmaReq dropSmaReq = {0};
|
||||
strcpy(dropSmaReq.indexName, pStmt->indexName);
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_VND_DROP_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSVDropTSmaReq(NULL, &dropSmaReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
void* pBuf = pCxt->pCmdMsg->pMsg;
|
||||
tSerializeSVDropTSmaReq(&pBuf, &dropSmaReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) {
|
||||
SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId };
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_DND_CREATE_QNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateDropQnode(STranslateContext* pCxt, SDropQnodeStmt* pStmt) {
|
||||
SDDropQnodeReq dropReq = { .dnodeId = pStmt->dnodeId };
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_DND_DROP_QNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) {
|
||||
SCMCreateTopicReq createReq = {0};
|
||||
|
||||
if (NULL != pStmt->pQuery) {
|
||||
int32_t code = translateQuery(pCxt, pStmt->pQuery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code ) {
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
strcpy(createReq.subscribeDbName, pStmt->subscribeDbName);
|
||||
}
|
||||
|
||||
createReq.sql = strdup(pCxt->pParseCxt->pSql);
|
||||
if (NULL == createReq.sql) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId };
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->topicName);
|
||||
tNameExtractFullName(&name, createReq.name);
|
||||
createReq.igExists = pStmt->ignoreExists;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
tFreeSCMCreateTopicReq(&createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) {
|
||||
SMDropTopicReq dropReq = {0};
|
||||
|
||||
SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId };
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->topicName);
|
||||
tNameExtractFullName(&name, dropReq.name);
|
||||
dropReq.igNotExists = pStmt->ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
|
@ -1153,6 +1376,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_DROP_DATABASE_STMT:
|
||||
code = translateDropDatabase(pCxt, (SDropDatabaseStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_ALTER_DATABASE_STMT:
|
||||
code = translateAlterDatabase(pCxt, (SAlterDatabaseStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TABLE_STMT:
|
||||
code = translateCreateSuperTable(pCxt, (SCreateTableStmt*)pNode);
|
||||
break;
|
||||
|
@ -1186,11 +1412,30 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
code = translateShow(pCxt, (SShowStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
code = translateShowTables(pCxt);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_DROP_INDEX_STMT:
|
||||
code = translateDropIndex(pCxt, (SDropIndexStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_QNODE_STMT:
|
||||
code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_DROP_QNODE_STMT:
|
||||
code = translateDropQnode(pCxt, (SDropQnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||
code = translateCreateTopic(pCxt, (SCreateTopicStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_DROP_TOPIC_STMT:
|
||||
code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -340,6 +340,23 @@ TEST_F(ParserTest, createDatabase) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, alterDatabase) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("alter database wxy_db BLOCKS 200");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("alter database wxy_db "
|
||||
"BLOCKS 200 "
|
||||
"CACHELAST 1 "
|
||||
"FSYNC 200 "
|
||||
"KEEP 200 "
|
||||
"QUORUM 2 "
|
||||
"WAL 1 "
|
||||
);
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, showDatabase) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
|
@ -398,3 +415,57 @@ TEST_F(ParserTest, createTable) {
|
|||
);
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, createSmaIndex) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, dropIndex) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("drop index index1 on t1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, createQnode) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("create qnode on dnode 1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, dropQnode) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("drop qnode on dnode 1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, createTopic) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("create topic tp1 as select * from t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("create topic if not exists tp1 as select * from t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("create topic tp1 as test");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("create topic if not exists tp1 as test");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, dropTopic) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("drop topic tp1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("drop topic if exists tp1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
|
|
@ -310,9 +310,12 @@ static SLogicNode* createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInt
|
|||
pWindow->node.id = pCxt->planNodeId++;
|
||||
|
||||
pWindow->winType = WINDOW_TYPE_INTERVAL;
|
||||
pWindow->interval = ((SValueNode*)pInterval->pInterval)->datum.i;
|
||||
SValueNode* pIntervalNode = (SValueNode*)((SRawExprNode*)(pInterval->pInterval))->pNode;
|
||||
|
||||
pWindow->interval = pIntervalNode->datum.i;
|
||||
pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0);
|
||||
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : 0);
|
||||
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval);
|
||||
|
||||
if (NULL != pInterval->pFill) {
|
||||
pWindow->pFill = nodesCloneNode(pInterval->pFill);
|
||||
CHECK_ALLOC(pWindow->pFill, (SLogicNode*)pWindow);
|
||||
|
@ -422,6 +425,7 @@ static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return NULL; // to avoid compiler error
|
||||
}
|
||||
|
||||
int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) {
|
||||
|
|
|
@ -480,6 +480,9 @@ static SPhysiNode* createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* p
|
|||
pInterval->interval = pWindowLogicNode->interval;
|
||||
pInterval->offset = pWindowLogicNode->offset;
|
||||
pInterval->sliding = pWindowLogicNode->sliding;
|
||||
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
||||
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
|
||||
|
||||
pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill);
|
||||
|
||||
SNodeList* pPrecalcExprs = NULL;
|
||||
|
|
|
@ -792,7 +792,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
|
|||
}
|
||||
|
||||
SFilterGroup *gp = NULL;
|
||||
while (gp = (SFilterGroup *)taosArrayPop(right)) {
|
||||
while ((gp = (SFilterGroup *)taosArrayPop(right)) != NULL) {
|
||||
taosArrayPush(group, gp);
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
|
|||
|
||||
if (taosArrayGetSize(right) <= 0) {
|
||||
SFilterGroup *gp = NULL;
|
||||
while (gp = (SFilterGroup *)taosArrayPop(left)) {
|
||||
while ((gp = (SFilterGroup *)taosArrayPop(left)) != NULL) {
|
||||
taosArrayPush(group, gp);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,6 +239,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (param->num > *rowNum) {
|
||||
|
|
|
@ -282,8 +282,10 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) {
|
|||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
SCH_ERR_RET(schLaunchTasksInFlowCtrlListImpl(pJob, ctrl));
|
||||
int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl);;
|
||||
SCH_ERR_RET(code);
|
||||
|
||||
return code; // to avoid compiler error
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ extern "C" {
|
|||
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
|
||||
//
|
||||
int32_t syncNodeRequestVotePeers(SSyncNode* pSyncNode);
|
||||
|
||||
int32_t syncNodeElect(SSyncNode* pSyncNode);
|
||||
int32_t syncNodeRequestVote(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncRequestVote* pMsg);
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ extern "C" {
|
|||
|
||||
typedef struct SSyncIO {
|
||||
STaosQueue *pMsgQ;
|
||||
STaosQset * pQset;
|
||||
STaosQset *pQset;
|
||||
pthread_t consumerTid;
|
||||
|
||||
void * serverRpc;
|
||||
void * clientRpc;
|
||||
void *serverRpc;
|
||||
void *clientRpc;
|
||||
SEpSet myAddr;
|
||||
|
||||
tmr_h qTimer;
|
||||
|
@ -50,6 +50,7 @@ typedef struct SSyncIO {
|
|||
void *pSyncNode;
|
||||
int32_t (*FpOnSyncPing)(SSyncNode *pSyncNode, SyncPing *pMsg);
|
||||
int32_t (*FpOnSyncPingReply)(SSyncNode *pSyncNode, SyncPingReply *pMsg);
|
||||
int32_t (*FpOnSyncClientRequest)(SSyncNode *pSyncNode, SyncClientRequest *pMsg);
|
||||
int32_t (*FpOnSyncRequestVote)(SSyncNode *pSyncNode, SyncRequestVote *pMsg);
|
||||
int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg);
|
||||
int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg);
|
||||
|
|
|
@ -70,6 +70,9 @@ extern "C" {
|
|||
struct SyncTimeout;
|
||||
typedef struct SyncTimeout SyncTimeout;
|
||||
|
||||
struct SyncClientRequest;
|
||||
typedef struct SyncClientRequest SyncClientRequest;
|
||||
|
||||
struct SyncPing;
|
||||
typedef struct SyncPing SyncPing;
|
||||
|
||||
|
@ -185,6 +188,7 @@ typedef struct SSyncNode {
|
|||
// callback
|
||||
int32_t (*FpOnPing)(SSyncNode* ths, SyncPing* pMsg);
|
||||
int32_t (*FpOnPingReply)(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
int32_t (*FpOnClientRequest)(SSyncNode* ths, SyncClientRequest* pMsg);
|
||||
int32_t (*FpOnRequestVote)(SSyncNode* ths, SyncRequestVote* pMsg);
|
||||
int32_t (*FpOnRequestVoteReply)(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||
int32_t (*FpOnAppendEntries)(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||
|
|
|
@ -52,7 +52,6 @@ extern "C" {
|
|||
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
|
||||
//
|
||||
int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode);
|
||||
|
||||
int32_t syncNodeReplicate(SSyncNode* pSyncNode);
|
||||
int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntries* pMsg);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
|
|||
syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplyCb==", pMsg);
|
||||
|
||||
if (pMsg->term < ths->pRaftStore->currentTerm) {
|
||||
sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm);
|
||||
sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ static void syncEnvTick(void *param, void *tmrId) {
|
|||
if (atomic_load_64(&pSyncEnv->envTickTimerLogicClockUser) <= atomic_load_64(&pSyncEnv->envTickTimerLogicClock)) {
|
||||
++(pSyncEnv->envTickTimerCounter);
|
||||
sTrace(
|
||||
"syncEnvTick do ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, "
|
||||
"syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", "
|
||||
"envTickTimerMS:%d, tmrId:%p",
|
||||
pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter,
|
||||
pSyncEnv->envTickTimerMS, tmrId);
|
||||
|
@ -64,7 +64,7 @@ static void syncEnvTick(void *param, void *tmrId) {
|
|||
taosTmrReset(syncEnvTick, pSyncEnv->envTickTimerMS, pSyncEnv, pSyncEnv->pTimerManager, &pSyncEnv->pEnvTickTimer);
|
||||
} else {
|
||||
sTrace(
|
||||
"syncEnvTick pass ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, "
|
||||
"syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", "
|
||||
"envTickTimerMS:%d, tmrId:%p",
|
||||
pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter,
|
||||
pSyncEnv->envTickTimerMS, tmrId);
|
||||
|
@ -74,7 +74,7 @@ static void syncEnvTick(void *param, void *tmrId) {
|
|||
static SSyncEnv *doSyncEnvStart() {
|
||||
SSyncEnv *pSyncEnv = (SSyncEnv *)malloc(sizeof(SSyncEnv));
|
||||
assert(pSyncEnv != NULL);
|
||||
memset(pSyncEnv, 0, sizeof(pSyncEnv));
|
||||
memset(pSyncEnv, 0, sizeof(SSyncEnv));
|
||||
|
||||
pSyncEnv->envTickTimerCounter = 0;
|
||||
pSyncEnv->envTickTimerMS = ENV_TICK_TIMER_MS;
|
||||
|
|
|
@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io);
|
|||
static int32_t syncIOStartInternal(SSyncIO *io);
|
||||
static int32_t syncIOStopInternal(SSyncIO *io);
|
||||
|
||||
static void * syncIOConsumerFunc(void *param);
|
||||
static void *syncIOConsumerFunc(void *param);
|
||||
static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
|
|||
}
|
||||
|
||||
static void *syncIOConsumerFunc(void *param) {
|
||||
SSyncIO * io = param;
|
||||
SSyncIO *io = param;
|
||||
STaosQall *qall;
|
||||
SRpcMsg * pRpcMsg, rpcMsg;
|
||||
SRpcMsg *pRpcMsg, rpcMsg;
|
||||
qall = taosAllocateQall();
|
||||
|
||||
while (1) {
|
||||
|
@ -273,6 +273,13 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncPingReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == SYNC_CLIENT_REQUEST) {
|
||||
if (io->FpOnSyncClientRequest != NULL) {
|
||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
|
||||
io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == SYNC_REQUEST_VOTE) {
|
||||
if (io->FpOnSyncRequestVote != NULL) {
|
||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
|
||||
|
|
|
@ -42,6 +42,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId);
|
|||
// on message ----
|
||||
static int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg);
|
||||
static int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg);
|
||||
// ---------------------------------
|
||||
|
||||
int32_t syncInit() {
|
||||
|
@ -192,6 +193,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
|
|||
// init callback
|
||||
pSyncNode->FpOnPing = syncNodeOnPingCb;
|
||||
pSyncNode->FpOnPingReply = syncNodeOnPingReplyCb;
|
||||
pSyncNode->FpOnClientRequest = syncNodeOnClientRequestCb;
|
||||
pSyncNode->FpOnRequestVote = syncNodeOnRequestVoteCb;
|
||||
pSyncNode->FpOnRequestVoteReply = syncNodeOnRequestVoteReplyCb;
|
||||
pSyncNode->FpOnAppendEntries = syncNodeOnAppendEntriesCb;
|
||||
|
@ -418,46 +420,46 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
|
|||
|
||||
// tla+ log vars
|
||||
cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore));
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", pSyncNode->commitIndex);
|
||||
cJSON_AddStringToObject(pRoot, "commitIndex", u64buf);
|
||||
|
||||
// ping timer
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer);
|
||||
cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClock);
|
||||
cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClockUser);
|
||||
cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB);
|
||||
cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerCounter);
|
||||
cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf);
|
||||
|
||||
// elect timer
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer);
|
||||
cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClock);
|
||||
cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClockUser);
|
||||
cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB);
|
||||
cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerCounter);
|
||||
cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf);
|
||||
|
||||
// heartbeat timer
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer);
|
||||
cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock);
|
||||
cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClockUser);
|
||||
cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB);
|
||||
cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerCounter);
|
||||
cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf);
|
||||
|
||||
// callback
|
||||
|
@ -632,7 +634,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
|||
taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||
&pSyncNode->pPingTimer);
|
||||
} else {
|
||||
sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%lu, pingTimerLogicClockUser:%lu",
|
||||
sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "",
|
||||
pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser);
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +655,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
|||
taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||
&pSyncNode->pPingTimer);
|
||||
} else {
|
||||
sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%lu, electTimerLogicClockUser:%lu",
|
||||
sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "",
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
||||
}
|
||||
}
|
||||
|
@ -674,7 +676,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
|||
taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||
&pSyncNode->pHeartbeatTimer);
|
||||
} else {
|
||||
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%lu, heartbeatTimerLogicClockUser:%lu",
|
||||
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64 "",
|
||||
pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
||||
}
|
||||
}
|
||||
|
@ -696,3 +698,19 @@ static int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) {
|
|||
syncPingReplyLog2("==syncNodeOnPingReplyCb==", pMsg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
|
||||
int32_t ret = 0;
|
||||
syncClientRequestLog2("==syncNodeOnClientRequestCb==", pMsg);
|
||||
|
||||
if (ths->state == TAOS_SYNC_STATE_LEADER) {
|
||||
SSyncRaftEntry* pEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen);
|
||||
ths->pLogStore->appendEntry(ths->pLogStore, pEntry);
|
||||
syncNodeReplicate(ths);
|
||||
syncEntryDestory(pEntry);
|
||||
} else {
|
||||
// ths->pFsm->FpCommitCb(-1)
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ cJSON* syncTimeout2Json(const SyncTimeout* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
|
||||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->logicClock);
|
||||
cJSON_AddStringToObject(pRoot, "logicClock", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data);
|
||||
|
@ -239,7 +239,7 @@ char* syncTimeout2Str(const SyncTimeout* pMsg) {
|
|||
// for debug ----------------------
|
||||
void syncTimeoutPrint(const SyncTimeout* pMsg) {
|
||||
char* serialized = syncTimeout2Str(pMsg);
|
||||
printf("syncTimeoutPrint | len:%lu | %s \n", strlen(serialized), serialized);
|
||||
printf("syncTimeoutPrint | len:%zu | %s \n", strlen(serialized), serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -364,7 +364,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
|
|||
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||
|
||||
cJSON* pDestId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr);
|
||||
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->destId.addr;
|
||||
|
@ -512,7 +512,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -527,7 +527,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
|
|||
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||
|
||||
cJSON* pDestId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr);
|
||||
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->destId.addr;
|
||||
|
@ -565,27 +565,27 @@ char* syncPingReply2Str(const SyncPingReply* pMsg) {
|
|||
// for debug ----------------------
|
||||
void syncPingReplyPrint(const SyncPingReply* pMsg) {
|
||||
char* serialized = syncPingReply2Str(pMsg);
|
||||
printf("syncPingReplyPrint | len:%lu | %s \n", strlen(serialized), serialized);
|
||||
printf("syncPingReplyPrint | len:%zu | %s \n", strlen(serialized), serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncPingReplyPrint2(char* s, const SyncPingReply* pMsg) {
|
||||
char* serialized = syncPingReply2Str(pMsg);
|
||||
printf("syncPingReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
printf("syncPingReplyPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncPingReplyLog(const SyncPingReply* pMsg) {
|
||||
char* serialized = syncPingReply2Str(pMsg);
|
||||
sTrace("syncPingReplyLog | len:%lu | %s", strlen(serialized), serialized);
|
||||
sTrace("syncPingReplyLog | len:%zu | %s", strlen(serialized), serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncPingReplyLog2(char* s, const SyncPingReply* pMsg) {
|
||||
char* serialized = syncPingReply2Str(pMsg);
|
||||
sTrace("syncPingReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
|
||||
sTrace("syncPingReplyLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
|
@ -670,7 +670,7 @@ cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
|
||||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->seqNum);
|
||||
cJSON_AddStringToObject(pRoot, "seqNum", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak);
|
||||
cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen);
|
||||
|
@ -792,7 +792,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -820,11 +820,11 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
|
|||
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogIndex);
|
||||
cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogTerm);
|
||||
cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf);
|
||||
|
||||
cJSON* pJson = cJSON_CreateObject();
|
||||
|
@ -936,7 +936,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -964,7 +964,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
|
|||
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted);
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -1094,7 +1094,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
|
|||
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||
|
||||
cJSON* pDestId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr);
|
||||
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->destId.addr;
|
||||
|
@ -1108,16 +1108,16 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
|
|||
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogIndex);
|
||||
cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogTerm);
|
||||
cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->commitIndex);
|
||||
cJSON_AddStringToObject(pRoot, "commit_index", u64buf);
|
||||
|
||||
cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen);
|
||||
|
@ -1238,7 +1238,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||
|
||||
cJSON* pSrcId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr);
|
||||
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->srcId.addr;
|
||||
|
@ -1253,7 +1253,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
|
|||
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||
|
||||
cJSON* pDestId = cJSON_CreateObject();
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr);
|
||||
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||
{
|
||||
uint64_t u64 = pMsg->destId.addr;
|
||||
|
@ -1267,10 +1267,10 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
|
|||
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "success", pMsg->success);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->matchIndex);
|
||||
cJSON_AddStringToObject(pRoot, "matchIndex", u64buf);
|
||||
|
||||
cJSON* pJson = cJSON_CreateObject();
|
||||
|
|
|
@ -74,12 +74,12 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
|
|||
cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes);
|
||||
cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType);
|
||||
cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->seqNum);
|
||||
cJSON_AddStringToObject(pRoot, "seqNum", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->index);
|
||||
cJSON_AddStringToObject(pRoot, "index", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen);
|
||||
|
||||
|
@ -107,26 +107,26 @@ char* syncEntry2Str(const SSyncRaftEntry* pEntry) {
|
|||
// for debug ----------------------
|
||||
void syncEntryPrint(const SSyncRaftEntry* pObj) {
|
||||
char* serialized = syncEntry2Str(pObj);
|
||||
printf("syncEntryPrint | len:%lu | %s \n", strlen(serialized), serialized);
|
||||
printf("syncEntryPrint | len:%zu | %s \n", strlen(serialized), serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj) {
|
||||
char* serialized = syncEntry2Str(pObj);
|
||||
printf("syncEntryPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
printf("syncEntryPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncEntryLog(const SSyncRaftEntry* pObj) {
|
||||
char* serialized = syncEntry2Str(pObj);
|
||||
sTrace("syncEntryLog | len:%lu | %s", strlen(serialized), serialized);
|
||||
sTrace("syncEntryLog | len:%zu | %s", strlen(serialized), serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) {
|
||||
char* serialized = syncEntry2Str(pObj);
|
||||
sTrace("syncEntryLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
|
||||
sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized);
|
||||
free(serialized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
pLogStore->getLastTerm = logStoreLastTerm;
|
||||
pLogStore->updateCommitIndex = logStoreUpdateCommitIndex;
|
||||
pLogStore->getCommitIndex = logStoreGetCommitIndex;
|
||||
return pLogStore; // to avoid compiler error
|
||||
}
|
||||
|
||||
void logStoreDestory(SSyncLogStore* pLogStore) {
|
||||
|
@ -58,6 +59,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
|
|||
|
||||
walFsync(pWal, true);
|
||||
free(serialized);
|
||||
return code; // to avoid compiler error
|
||||
}
|
||||
|
||||
SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
||||
|
@ -79,6 +81,7 @@ int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
walRollback(pWal, fromIndex);
|
||||
return 0; // to avoid compiler error
|
||||
}
|
||||
|
||||
SyncIndex logStoreLastIndex(SSyncLogStore* pLogStore) {
|
||||
|
@ -102,6 +105,7 @@ int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
walCommit(pWal, index);
|
||||
return 0; // to avoid compiler error
|
||||
}
|
||||
|
||||
SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore) {
|
||||
|
@ -130,9 +134,9 @@ cJSON* logStore2Json(SSyncLogStore* pLogStore) {
|
|||
cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal);
|
||||
cJSON_AddStringToObject(pRoot, "pWal", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore));
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", logStoreLastIndex(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "LastIndex", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore));
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", logStoreLastTerm(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "LastTerm", u64buf);
|
||||
|
||||
cJSON* pEntries = cJSON_CreateArray();
|
||||
|
@ -181,4 +185,4 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) {
|
|||
char* serialized = logStore2Str(pLogStore);
|
||||
sTrace("logStorePrint | len:%lu | %s | %s", strlen(serialized), s, serialized);
|
||||
free(serialized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg)
|
|||
syncRequestVoteReplyLog2("==syncNodeOnRequestVoteReplyCb==", pMsg);
|
||||
|
||||
if (pMsg->term < ths->pRaftStore->currentTerm) {
|
||||
sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm);
|
||||
sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ cJSON* syncUtilRaftId2Json(const SRaftId* p) {
|
|||
char u64buf[128];
|
||||
cJSON* pRoot = cJSON_CreateObject();
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", p->addr);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr);
|
||||
cJSON_AddStringToObject(pRoot, "addr", u64buf);
|
||||
char host[128];
|
||||
uint16_t port;
|
||||
|
@ -196,4 +196,4 @@ SyncIndex syncUtilMinIndex(SyncIndex a, SyncIndex b) {
|
|||
SyncIndex syncUtilMaxIndex(SyncIndex a, SyncIndex b) {
|
||||
SyncIndex r = a > b ? a : b;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) {
|
|||
cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted);
|
||||
|
||||
cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesGranted->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum);
|
||||
cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader);
|
||||
|
@ -122,27 +122,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) {
|
|||
// for debug -------------------
|
||||
void voteGrantedPrint(SVotesGranted *pObj) {
|
||||
char *serialized = voteGranted2Str(pObj);
|
||||
printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized);
|
||||
printf("voteGrantedPrint | len:%zu | %s \n", strlen(serialized), serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void voteGrantedPrint2(char *s, SVotesGranted *pObj) {
|
||||
char *serialized = voteGranted2Str(pObj);
|
||||
printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
printf("voteGrantedPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void voteGrantedLog(SVotesGranted *pObj) {
|
||||
char *serialized = voteGranted2Str(pObj);
|
||||
sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized);
|
||||
sTrace("voteGrantedLog | len:%zu | %s", strlen(serialized), serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void voteGrantedLog2(char *s, SVotesGranted *pObj) {
|
||||
char *serialized = voteGranted2Str(pObj);
|
||||
sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
|
||||
sTrace("voteGrantedLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) {
|
|||
cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond);
|
||||
cJSON_AddNumberToObject(pRoot, "respondNum", respondNum);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term);
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesRespond->term);
|
||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode);
|
||||
cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf);
|
||||
|
@ -242,26 +242,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) {
|
|||
// for debug -------------------
|
||||
void votesRespondPrint(SVotesRespond *pObj) {
|
||||
char *serialized = votesRespond2Str(pObj);
|
||||
printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized);
|
||||
printf("votesRespondPrint | len:%zu | %s \n", strlen(serialized), serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void votesRespondPrint2(char *s, SVotesRespond *pObj) {
|
||||
char *serialized = votesRespond2Str(pObj);
|
||||
printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
printf("votesRespondPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized);
|
||||
fflush(NULL);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void votesRespondLog(SVotesRespond *pObj) {
|
||||
char *serialized = votesRespond2Str(pObj);
|
||||
sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized);
|
||||
sTrace("votesRespondLog | len:%zu | %s", strlen(serialized), serialized);
|
||||
free(serialized);
|
||||
}
|
||||
|
||||
void votesRespondLog2(char *s, SVotesRespond *pObj) {
|
||||
char *serialized = votesRespond2Str(pObj);
|
||||
sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
|
||||
sTrace("votesRespondLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized);
|
||||
free(serialized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -558,4 +558,6 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {
|
|||
}
|
||||
}
|
||||
tfsUnLock(pTfs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ target_link_libraries(
|
|||
PUBLIC os
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC zlib
|
||||
PUBLIC zlibstatic
|
||||
)
|
||||
if (${BUILD_WITH_UV_TRANS})
|
||||
if (${BUILD_WITH_UV})
|
||||
|
|
|
@ -125,9 +125,8 @@ typedef SRpcInfo STrans;
|
|||
typedef SRpcConnInfo STransHandleInfo;
|
||||
|
||||
typedef struct {
|
||||
SEpSet epSet; // ip list provided by app
|
||||
void* ahandle; // handle provided by app
|
||||
// struct SRpcConn* pConn; // pConn allocated
|
||||
SEpSet epSet; // ip list provided by app
|
||||
void* ahandle; // handle provided by app
|
||||
tmsg_t msgType; // message type
|
||||
uint8_t* pCont; // content provided by app
|
||||
int32_t contLen; // content length
|
||||
|
@ -135,7 +134,7 @@ typedef struct {
|
|||
// int16_t numOfTry; // number of try for different servers
|
||||
// int8_t oldInUse; // server EP inUse passed by app
|
||||
// int8_t redirect; // flag to indicate redirect
|
||||
int8_t connType; // connection type
|
||||
int8_t connType; // connection type cli/srv
|
||||
int64_t rid; // refId returned by taosAddRef
|
||||
|
||||
STransMsg* pRsp; // for synchronous API
|
||||
|
@ -253,6 +252,9 @@ void transUnrefSrvHandle(void* handle);
|
|||
void transRefCliHandle(void* handle);
|
||||
void transUnrefCliHandle(void* handle);
|
||||
|
||||
void transReleaseCliHandle(void* handle);
|
||||
void transReleaseSrvHandle(void* handle);
|
||||
|
||||
void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg);
|
||||
void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg, STransMsg* pRsp);
|
||||
void transSendResponse(const STransMsg* pMsg);
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef struct {
|
|||
int (*afp)(void* parent, char* user, char* spi, char* encrypt, char* secret, char* ckey);
|
||||
bool (*pfp)(void* parent, tmsg_t msgType);
|
||||
void* (*mfp)(void* parent, tmsg_t msgType);
|
||||
bool (*efp)(void* parent, tmsg_t msgType);
|
||||
|
||||
int32_t refCount;
|
||||
void* parent;
|
||||
|
|
|
@ -22,6 +22,11 @@ void* (*taosInitHandle[])(uint32_t ip, uint32_t port, char* label, int numOfThre
|
|||
|
||||
void (*taosCloseHandle[])(void* arg) = {transCloseServer, transCloseClient};
|
||||
|
||||
void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle};
|
||||
void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle};
|
||||
|
||||
void (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transReleaseCliHandle};
|
||||
|
||||
void* rpcOpen(const SRpcInit* pInit) {
|
||||
SRpcInfo* pRpc = calloc(1, sizeof(SRpcInfo));
|
||||
if (pRpc == NULL) {
|
||||
|
@ -36,6 +41,7 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
pRpc->afp = pInit->afp;
|
||||
pRpc->pfp = pInit->pfp;
|
||||
pRpc->mfp = pInit->mfp;
|
||||
pRpc->efp = pInit->efp;
|
||||
|
||||
if (pInit->connType == TAOS_CONN_SERVER) {
|
||||
pRpc->numOfThreads = pInit->numOfThreads > TSDB_MAX_RPC_THREADS ? TSDB_MAX_RPC_THREADS : pInit->numOfThreads;
|
||||
|
@ -126,9 +132,6 @@ void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) {
|
|||
void rpcSendResponse(const SRpcMsg* pMsg) { transSendResponse(pMsg); }
|
||||
int rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return transGetConnInfo((void*)thandle, pInfo); }
|
||||
|
||||
void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle};
|
||||
void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle};
|
||||
|
||||
void rpcRefHandle(void* handle, int8_t type) {
|
||||
assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT);
|
||||
(*taosRefHandle[type])(handle);
|
||||
|
@ -139,6 +142,11 @@ void rpcUnrefHandle(void* handle, int8_t type) {
|
|||
(*taosUnRefHandle[type])(handle);
|
||||
}
|
||||
|
||||
void rpcReleaseHandle(void* handle, int8_t type) {
|
||||
assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT);
|
||||
(*transReleaseHandle[type])(handle);
|
||||
}
|
||||
|
||||
int32_t rpcInit() {
|
||||
// impl later
|
||||
return 0;
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
#include "transComm.h"
|
||||
|
||||
// Normal(default): send/recv msg
|
||||
// Quit: quit rpc inst
|
||||
// Release: release handle to rpc inst
|
||||
typedef enum { Normal, Quit, Release } SCliMsgType;
|
||||
|
||||
typedef struct SCliConn {
|
||||
T_REF_DECLARE()
|
||||
uv_connect_t connReq;
|
||||
|
@ -34,6 +39,10 @@ typedef struct SCliConn {
|
|||
// spi configure
|
||||
char spi;
|
||||
char secured;
|
||||
|
||||
char* ip;
|
||||
uint32_t port;
|
||||
|
||||
// debug and log info
|
||||
struct sockaddr_in addr;
|
||||
struct sockaddr_in locaddr;
|
||||
|
@ -45,6 +54,7 @@ typedef struct SCliMsg {
|
|||
STransMsg msg;
|
||||
queue q;
|
||||
uint64_t st;
|
||||
SCliMsgType type;
|
||||
} SCliMsg;
|
||||
|
||||
typedef struct SCliThrdObj {
|
||||
|
@ -79,7 +89,7 @@ typedef struct SConnList {
|
|||
static void* createConnPool(int size);
|
||||
static void* destroyConnPool(void* pool);
|
||||
static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port);
|
||||
static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn);
|
||||
static void addConnToPool(void* pool, SCliConn* conn);
|
||||
|
||||
// register timer in each thread to clear expire conn
|
||||
static void cliTimeoutCb(uv_timer_t* handle);
|
||||
|
@ -104,6 +114,8 @@ static void cliHandleExcept(SCliConn* conn);
|
|||
// handle req from app
|
||||
static void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd);
|
||||
static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd);
|
||||
static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd);
|
||||
|
||||
static void cliSendQuit(SCliThrdObj* thrd);
|
||||
static void destroyUserdata(STransMsg* userdata);
|
||||
|
||||
|
@ -117,8 +129,8 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
|
|||
|
||||
#define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1)
|
||||
#define CONN_PERSIST_TIME(para) (para * 1000 * 10)
|
||||
|
||||
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)conn->hostThrd)->pTransInst))->label)
|
||||
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
|
||||
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)(conn)->hostThrd)->pTransInst))->label)
|
||||
#define CONN_HANDLE_THREAD_QUIT(conn, thrd) \
|
||||
do { \
|
||||
if (thrd->quit) { \
|
||||
|
@ -188,6 +200,12 @@ void cliHandleResp(SCliConn* conn) {
|
|||
|
||||
conn->secured = pHead->secured;
|
||||
|
||||
if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) {
|
||||
tTrace("except, server continue send while cli ignore it");
|
||||
// transUnrefCliHandle(conn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pCtx == NULL || pCtx->pSem == NULL) {
|
||||
tTrace("%s cli conn %p handle resp", pTransInst->label, conn);
|
||||
(pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
|
||||
|
@ -197,14 +215,13 @@ void cliHandleResp(SCliConn* conn) {
|
|||
tsem_post(pCtx->pSem);
|
||||
}
|
||||
|
||||
uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb);
|
||||
|
||||
if (CONN_NO_PERSIST_BY_APP(conn)) {
|
||||
addConnToPool(pThrd->pool, pCtx->ip, pCtx->port, conn);
|
||||
addConnToPool(pThrd->pool, conn);
|
||||
}
|
||||
destroyCmsg(conn->data);
|
||||
conn->data = NULL;
|
||||
|
||||
uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb);
|
||||
// start thread's timer of conn pool if not active
|
||||
if (!uv_is_active((uv_handle_t*)&pThrd->timer) && pTransInst->idleTime > 0) {
|
||||
// uv_timer_start((uv_timer_t*)&pThrd->timer, cliTimeoutCb, CONN_PERSIST_TIME(pRpc->idleTime) / 2, 0);
|
||||
|
@ -291,6 +308,7 @@ void* destroyConnPool(void* pool) {
|
|||
connList = taosHashIterate((SHashObj*)pool, connList);
|
||||
}
|
||||
taosHashCleanup(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) {
|
||||
|
@ -317,11 +335,11 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) {
|
|||
QUEUE_INIT(&conn->conn);
|
||||
return conn;
|
||||
}
|
||||
static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) {
|
||||
static void addConnToPool(void* pool, SCliConn* conn) {
|
||||
char key[128] = {0};
|
||||
|
||||
tstrncpy(key, ip, strlen(ip));
|
||||
tstrncpy(key + strlen(key), (char*)(&port), sizeof(port));
|
||||
tstrncpy(key, conn->ip, strlen(conn->ip));
|
||||
tstrncpy(key + strlen(key), (char*)(&conn->port), sizeof(conn->port));
|
||||
tTrace("cli conn %p added to conn pool, read buf cap: %d", conn, conn->readBuf.cap);
|
||||
|
||||
STrans* pTransInst = ((SCliThrdObj*)conn->hostThrd)->pTransInst;
|
||||
|
@ -335,6 +353,8 @@ static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) {
|
|||
static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
||||
SCliConn* conn = handle->data;
|
||||
SConnBuffer* pBuf = &conn->readBuf;
|
||||
// avoid conn
|
||||
QUEUE_REMOVE(&conn->conn);
|
||||
transAllocBuffer(pBuf, buf);
|
||||
}
|
||||
static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
||||
|
@ -395,7 +415,7 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
|
|||
}
|
||||
static void cliDestroy(uv_handle_t* handle) {
|
||||
SCliConn* conn = handle->data;
|
||||
|
||||
free(conn->ip);
|
||||
free(conn->stream);
|
||||
tTrace("%s cli conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn);
|
||||
free(conn);
|
||||
|
@ -497,6 +517,22 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
|||
pThrd->quit = true;
|
||||
uv_stop(pThrd->loop);
|
||||
}
|
||||
static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
||||
SCliConn* conn = pMsg->msg.handle;
|
||||
tDebug("%s cli conn %p release to inst", CONN_GET_INST_LABEL(conn), conn);
|
||||
|
||||
destroyCmsg(pMsg);
|
||||
conn->data = NULL;
|
||||
|
||||
transDestroyBuffer(&conn->readBuf);
|
||||
if (conn->persist && T_REF_VAL_GET(conn) >= 2) {
|
||||
conn->persist = false;
|
||||
transUnrefCliHandle(conn);
|
||||
addConnToPool(pThrd->pool, conn);
|
||||
} else {
|
||||
transUnrefCliHandle(conn);
|
||||
}
|
||||
}
|
||||
|
||||
SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
||||
SCliConn* conn = NULL;
|
||||
|
@ -508,7 +544,9 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
|||
} else {
|
||||
STransConnCtx* pCtx = pMsg->ctx;
|
||||
conn = getConnFromPool(pThrd->pool, pCtx->ip, pCtx->port);
|
||||
if (conn != NULL) tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn);
|
||||
if (conn != NULL) {
|
||||
tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn);
|
||||
}
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
@ -524,11 +562,16 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
|||
SCliConn* conn = cliGetConn(pMsg, pThrd);
|
||||
if (conn != NULL) {
|
||||
conn->data = pMsg;
|
||||
conn->hThrdIdx = pCtx->hThrdIdx;
|
||||
|
||||
transDestroyBuffer(&conn->readBuf);
|
||||
cliSend(conn);
|
||||
} else {
|
||||
conn = cliCreateConn(pThrd);
|
||||
conn->data = pMsg;
|
||||
conn->hThrdIdx = pCtx->hThrdIdx;
|
||||
conn->ip = strdup(pMsg->ctx->ip);
|
||||
conn->port = pMsg->ctx->port;
|
||||
|
||||
int ret = transSetConnOption((uv_tcp_t*)conn->stream);
|
||||
if (ret) {
|
||||
|
@ -540,8 +583,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
|||
tTrace("%s cli conn %p try to connect to %s:%d", pTransInst->label, conn, pMsg->ctx->ip, pMsg->ctx->port);
|
||||
uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
|
||||
}
|
||||
|
||||
conn->hThrdIdx = pCtx->hThrdIdx;
|
||||
}
|
||||
static void cliAsyncCb(uv_async_t* handle) {
|
||||
SAsyncItem* item = handle->data;
|
||||
|
@ -560,10 +601,13 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
QUEUE_REMOVE(h);
|
||||
|
||||
SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q);
|
||||
if (pMsg->ctx == NULL) {
|
||||
cliHandleQuit(pMsg, pThrd);
|
||||
} else {
|
||||
|
||||
if (pMsg->type == Normal) {
|
||||
cliHandleReq(pMsg, pThrd);
|
||||
} else if (pMsg->type == Quit) {
|
||||
cliHandleQuit(pMsg, pThrd);
|
||||
} else if (pMsg->type == Release) {
|
||||
cliHandleRelease(pMsg, pThrd);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
@ -576,6 +620,8 @@ static void* cliWorkThread(void* arg) {
|
|||
SCliThrdObj* pThrd = (SCliThrdObj*)arg;
|
||||
setThreadName("trans-cli-work");
|
||||
uv_run(pThrd->loop, UV_RUN_DEFAULT);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) {
|
||||
|
@ -659,8 +705,10 @@ static void transDestroyConnCtx(STransConnCtx* ctx) {
|
|||
void cliSendQuit(SCliThrdObj* thrd) {
|
||||
// cli can stop gracefully
|
||||
SCliMsg* msg = calloc(1, sizeof(SCliMsg));
|
||||
msg->type = Quit;
|
||||
transSendAsync(thrd->asyncPool, &msg->q);
|
||||
}
|
||||
|
||||
int cliRBChoseIdx(STrans* pTransInst) {
|
||||
int64_t index = pTransInst->index;
|
||||
if (pTransInst->index++ >= pTransInst->numOfThreads) {
|
||||
|
@ -690,10 +738,24 @@ void transUnrefCliHandle(void* handle) {
|
|||
return;
|
||||
}
|
||||
int ref = T_REF_DEC((SCliConn*)handle);
|
||||
tDebug("%s cli conn %p ref %d", CONN_GET_INST_LABEL((SCliConn*)handle), handle, ref);
|
||||
if (ref == 0) {
|
||||
cliDestroyConn((SCliConn*)handle, true);
|
||||
}
|
||||
}
|
||||
void transReleaseCliHandle(void* handle) {
|
||||
SCliThrdObj* thrd = CONN_GET_HOST_THREAD(handle);
|
||||
if (thrd == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
STransMsg tmsg = {.handle = handle};
|
||||
SCliMsg* cmsg = calloc(1, sizeof(SCliMsg));
|
||||
cmsg->type = Release;
|
||||
cmsg->msg = tmsg;
|
||||
|
||||
transSendAsync(thrd->asyncPool, &cmsg->q);
|
||||
}
|
||||
|
||||
void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg) {
|
||||
STrans* pTransInst = (STrans*)shandle;
|
||||
|
@ -716,7 +778,7 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p
|
|||
assert(pTransInst->connType == TAOS_CONN_CLIENT);
|
||||
// atomic or not
|
||||
|
||||
SCliMsg* cliMsg = malloc(sizeof(SCliMsg));
|
||||
SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg));
|
||||
cliMsg->ctx = pCtx;
|
||||
cliMsg->msg = *pMsg;
|
||||
cliMsg->st = taosGetTimestampUs();
|
||||
|
@ -741,7 +803,7 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq
|
|||
pCtx->pRsp = pRsp;
|
||||
tsem_init(pCtx->pSem, 0, 0);
|
||||
|
||||
SCliMsg* cliMsg = malloc(sizeof(SCliMsg));
|
||||
SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg));
|
||||
cliMsg->ctx = pCtx;
|
||||
cliMsg->msg = *pReq;
|
||||
cliMsg->st = taosGetTimestampUs();
|
||||
|
|
|
@ -155,14 +155,16 @@ bool transReadComplete(SConnBuffer* connBuf) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {}
|
||||
int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {return 0;}
|
||||
|
||||
int transUnpackMsg(STransMsgHead* msgHead) {}
|
||||
int transUnpackMsg(STransMsgHead* msgHead) {return 0;}
|
||||
int transDestroyBuffer(SConnBuffer* buf) {
|
||||
if (buf->cap > 0) {
|
||||
tfree(buf->buf);
|
||||
}
|
||||
transClearBuffer(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int transSetConnOption(uv_tcp_t* stream) {
|
||||
|
|
|
@ -106,6 +106,8 @@ static void uvStartSendRespInternal(SSrvMsg* smsg);
|
|||
static void uvPrepareSendData(SSrvMsg* msg, uv_buf_t* wb);
|
||||
static void uvStartSendResp(SSrvMsg* msg);
|
||||
|
||||
static void uvNotifyLinkBrokenToApp(SSrvConn* conn);
|
||||
|
||||
static void destroySmsg(SSrvMsg* smsg);
|
||||
// check whether already read complete packet
|
||||
static SSrvConn* createConn(void* hThrd);
|
||||
|
@ -212,7 +214,9 @@ static void uvHandleReq(SSrvConn* pConn) {
|
|||
// pHead = rpcDecompresSTransMsg(pHead);
|
||||
} else {
|
||||
pHead->msgLen = htonl(pHead->msgLen);
|
||||
// impl later
|
||||
if (pHead->secured == 1) {
|
||||
pHead->msgLen -= sizeof(STransUserMsg);
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
|
@ -233,7 +237,7 @@ static void uvHandleReq(SSrvConn* pConn) {
|
|||
ntohs(pConn->locaddr.sin_port), transMsg.contLen);
|
||||
|
||||
STrans* pTransInst = (STrans*)p->shandle;
|
||||
(*((STrans*)p->shandle)->cfp)(pTransInst->parent, &transMsg, NULL);
|
||||
(*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
|
||||
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
|
||||
// auth
|
||||
// validate msg type
|
||||
|
@ -261,13 +265,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
|
|||
tError("server conn %p read error: %s", conn, uv_err_name(nread));
|
||||
if (nread < 0) {
|
||||
conn->broken = true;
|
||||
transUnrefSrvHandle(conn);
|
||||
uvNotifyLinkBrokenToApp(conn);
|
||||
|
||||
// if (conn->ref > 1) {
|
||||
// conn->ref++; // ref > 1 signed that write is in progress
|
||||
// STrans* pTransInst = conn->pTransInst;
|
||||
// if (pTransInst->efp != NULL && (pTransInst->efp)(NULL, conn->inType)) {
|
||||
//}
|
||||
// tError("server conn %p read error: %s", conn, uv_err_name(nread));
|
||||
// destroyConn(conn, true);
|
||||
transUnrefSrvHandle(conn);
|
||||
}
|
||||
}
|
||||
void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
||||
|
@ -289,11 +292,13 @@ void uvOnSendCb(uv_write_t* req, int status) {
|
|||
if (conn->srvMsgs != NULL) {
|
||||
assert(taosArrayGetSize(conn->srvMsgs) >= 1);
|
||||
SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, 0);
|
||||
tTrace("server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs));
|
||||
taosArrayRemove(conn->srvMsgs, 0);
|
||||
destroySmsg(msg);
|
||||
|
||||
// send second data, just use for push
|
||||
if (taosArrayGetSize(conn->srvMsgs) > 0) {
|
||||
tTrace("resent server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs));
|
||||
msg = (SSrvMsg*)taosArrayGetP(conn->srvMsgs, 0);
|
||||
uvStartSendRespInternal(msg);
|
||||
}
|
||||
|
@ -371,6 +376,17 @@ static void uvStartSendResp(SSrvMsg* smsg) {
|
|||
uvStartSendRespInternal(smsg);
|
||||
return;
|
||||
}
|
||||
|
||||
static void uvNotifyLinkBrokenToApp(SSrvConn* conn) {
|
||||
STrans* pTransInst = conn->pTransInst;
|
||||
if (pTransInst->efp != NULL && (*pTransInst->efp)(NULL, conn->inType) && T_REF_VAL_GET(conn) >= 2) {
|
||||
STransMsg transMsg = {0};
|
||||
transMsg.msgType = conn->inType;
|
||||
transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
// transRefSrvHandle(conn);
|
||||
(*pTransInst->cfp)(pTransInst->parent, &transMsg, 0);
|
||||
}
|
||||
}
|
||||
static void destroySmsg(SSrvMsg* smsg) {
|
||||
if (smsg == NULL) {
|
||||
return;
|
||||
|
@ -538,6 +554,8 @@ void* acceptThread(void* arg) {
|
|||
setThreadName("trans-accept");
|
||||
SServerObj* srv = (SServerObj*)arg;
|
||||
uv_run(srv->loop, UV_RUN_DEFAULT);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
static bool addHandleToWorkloop(void* arg) {
|
||||
SWorkThrdObj* pThrd = arg;
|
||||
|
@ -593,6 +611,8 @@ void* workerThread(void* arg) {
|
|||
setThreadName("trans-worker");
|
||||
SWorkThrdObj* pThrd = (SWorkThrdObj*)arg;
|
||||
uv_run(pThrd->loop, UV_RUN_DEFAULT);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SSrvConn* createConn(void* hThrd) {
|
||||
|
@ -639,7 +659,7 @@ static void uvDestroyConn(uv_handle_t* handle) {
|
|||
uv_timer_stop(&conn->pTimer);
|
||||
QUEUE_REMOVE(&conn->queue);
|
||||
free(conn->pTcp);
|
||||
free(conn);
|
||||
// free(conn);
|
||||
|
||||
if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) {
|
||||
uv_loop_close(thrd->loop);
|
||||
|
@ -733,7 +753,7 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
|
|||
}
|
||||
void sendQuitToWorkThrd(SWorkThrdObj* pThrd) {
|
||||
SSrvMsg* srvMsg = calloc(1, sizeof(SSrvMsg));
|
||||
tDebug("send quit msg to work thread");
|
||||
tDebug("server send quit msg to work thread");
|
||||
|
||||
transSendAsync(pThrd->asyncPool, &srvMsg->q);
|
||||
}
|
||||
|
@ -784,6 +804,11 @@ void transUnrefSrvHandle(void* handle) {
|
|||
}
|
||||
// unref srv handle
|
||||
}
|
||||
|
||||
void transReleaseSrvHandle(void* handle) {
|
||||
// do nothing currently
|
||||
//
|
||||
}
|
||||
void transSendResponse(const STransMsg* pMsg) {
|
||||
if (pMsg->handle == NULL) {
|
||||
return;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "rpcLog.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tlog.h"
|
||||
|
@ -29,7 +30,31 @@ const char *ckey = "ckey";
|
|||
class Server;
|
||||
int port = 7000;
|
||||
// server process
|
||||
|
||||
static bool cliPersistHandle(void *parent, tmsg_t msgType) {
|
||||
// client persist handle
|
||||
return msgType == 2 || msgType == 4;
|
||||
}
|
||||
|
||||
typedef struct CbArgs {
|
||||
tmsg_t msgType;
|
||||
} CbArgs;
|
||||
|
||||
static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) {
|
||||
if (msgType == 1 || msgType == 2) {
|
||||
CbArgs *args = (CbArgs *)calloc(1, sizeof(CbArgs));
|
||||
args->msgType = msgType;
|
||||
return args;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// server except
|
||||
static bool handleExcept(void *parent, tmsg_t msgType) {
|
||||
return msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP;
|
||||
}
|
||||
typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
|
||||
static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
// client process;
|
||||
static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
|
@ -61,17 +86,21 @@ class Client {
|
|||
rpcInit_.cfp = cb;
|
||||
this->transCli = rpcOpen(&rpcInit_);
|
||||
}
|
||||
void setPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) {
|
||||
void Stop() {
|
||||
rpcClose(this->transCli);
|
||||
this->transCli = NULL;
|
||||
}
|
||||
void SetPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) {
|
||||
rpcClose(this->transCli);
|
||||
rpcInit_.pfp = pfp;
|
||||
this->transCli = rpcOpen(&rpcInit_);
|
||||
}
|
||||
void setConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
void SetConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
rpcClose(this->transCli);
|
||||
rpcInit_.mfp = mfp;
|
||||
this->transCli = rpcOpen(&rpcInit_);
|
||||
}
|
||||
void setPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
void SetPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
rpcClose(this->transCli);
|
||||
|
||||
rpcInit_.pfp = pfp;
|
||||
|
@ -88,6 +117,15 @@ class Client {
|
|||
SemWait();
|
||||
*resp = this->resp;
|
||||
}
|
||||
void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) {
|
||||
if (req->handle != NULL) {
|
||||
rpcReleaseHandle(req->handle, TAOS_CONN_CLIENT);
|
||||
req->handle = NULL;
|
||||
}
|
||||
SendAndRecv(req, resp);
|
||||
}
|
||||
|
||||
void SendWithHandle(SRpcMsg *req, SRpcMsg *resp) {}
|
||||
void SemWait() { tsem_wait(&this->sem); }
|
||||
void SemPost() { tsem_post(&this->sem); }
|
||||
void Reset() {}
|
||||
|
@ -105,19 +143,20 @@ class Client {
|
|||
class Server {
|
||||
public:
|
||||
Server() {
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.localPort = port;
|
||||
rpcInit.label = (char *)label;
|
||||
rpcInit.numOfThreads = 5;
|
||||
rpcInit.cfp = processReq;
|
||||
rpcInit.user = (char *)user;
|
||||
rpcInit.secret = (char *)secret;
|
||||
rpcInit.ckey = (char *)ckey;
|
||||
rpcInit.spi = 1;
|
||||
rpcInit.connType = TAOS_CONN_SERVER;
|
||||
memset(&rpcInit_, 0, sizeof(rpcInit_));
|
||||
rpcInit_.localPort = port;
|
||||
rpcInit_.label = (char *)label;
|
||||
rpcInit_.numOfThreads = 5;
|
||||
rpcInit_.cfp = processReq;
|
||||
rpcInit_.efp = NULL;
|
||||
rpcInit_.user = (char *)user;
|
||||
rpcInit_.secret = (char *)secret;
|
||||
rpcInit_.ckey = (char *)ckey;
|
||||
rpcInit_.spi = 1;
|
||||
rpcInit_.connType = TAOS_CONN_SERVER;
|
||||
}
|
||||
void Start() {
|
||||
this->transSrv = rpcOpen(&this->rpcInit);
|
||||
this->transSrv = rpcOpen(&this->rpcInit_);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
void Stop() {
|
||||
|
@ -125,6 +164,16 @@ class Server {
|
|||
rpcClose(this->transSrv);
|
||||
this->transSrv = NULL;
|
||||
}
|
||||
void SetExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) {
|
||||
this->Stop();
|
||||
rpcInit_.efp = efp;
|
||||
this->Start();
|
||||
}
|
||||
void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) {
|
||||
this->Stop();
|
||||
rpcInit_.cfp = cfp;
|
||||
this->Start();
|
||||
}
|
||||
void Restart() {
|
||||
this->Stop();
|
||||
this->Start();
|
||||
|
@ -135,7 +184,7 @@ class Server {
|
|||
}
|
||||
|
||||
private:
|
||||
SRpcInit rpcInit;
|
||||
SRpcInit rpcInit_;
|
||||
void * transSrv;
|
||||
};
|
||||
static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
|
@ -146,11 +195,26 @@ static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
rpcMsg.code = 0;
|
||||
rpcSendResponse(&rpcMsg);
|
||||
}
|
||||
|
||||
static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
rpcRefHandle(pMsg->handle, TAOS_CONN_SERVER);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = rpcMallocCont(100);
|
||||
rpcMsg.contLen = 100;
|
||||
rpcMsg.handle = pMsg->handle;
|
||||
rpcMsg.code = 0;
|
||||
rpcSendResponse(&rpcMsg);
|
||||
}
|
||||
}
|
||||
// client process;
|
||||
static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
Client *client = (Client *)parent;
|
||||
client->SetResp(pMsg);
|
||||
client->SemPost();
|
||||
tDebug("received resp");
|
||||
}
|
||||
|
||||
static void initEnv() {
|
||||
|
@ -170,7 +234,7 @@ static void initEnv() {
|
|||
tsAsyncLog = 0;
|
||||
|
||||
std::string path = "/tmp/transport";
|
||||
taosRemoveDir(path.c_str());
|
||||
// taosRemoveDir(path.c_str());
|
||||
taosMkDir(path.c_str());
|
||||
|
||||
tstrncpy(tsLogDir, path.c_str(), PATH_MAX);
|
||||
|
@ -178,6 +242,7 @@ static void initEnv() {
|
|||
printf("failed to init log file\n");
|
||||
}
|
||||
}
|
||||
|
||||
class TransObj {
|
||||
public:
|
||||
TransObj() {
|
||||
|
@ -188,22 +253,43 @@ class TransObj {
|
|||
srv->Start();
|
||||
}
|
||||
|
||||
void RestartCli(CB cb) { cli->Restart(cb); }
|
||||
void StopSrv() { srv->Stop(); }
|
||||
void RestartCli(CB cb) {
|
||||
//
|
||||
cli->Restart(cb);
|
||||
}
|
||||
void StopSrv() {
|
||||
//
|
||||
srv->Stop();
|
||||
}
|
||||
void SetCliPersistFp(bool (*pfp)(void *parent, tmsg_t msgType)) {
|
||||
// do nothing
|
||||
cli->setPersistFP(pfp);
|
||||
cli->SetPersistFP(pfp);
|
||||
}
|
||||
void SetCliMFp(void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
// do nothing
|
||||
cli->setConstructFP(mfp);
|
||||
cli->SetConstructFP(mfp);
|
||||
}
|
||||
void SetMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
void SetCliMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) {
|
||||
// do nothing
|
||||
cli->setPAndMFp(pfp, mfp);
|
||||
cli->SetPAndMFp(pfp, mfp);
|
||||
}
|
||||
// call when link broken, and notify query or fetch stop
|
||||
void SetSrvExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) {
|
||||
////////
|
||||
srv->SetExceptFp(efp);
|
||||
}
|
||||
void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) {
|
||||
///////
|
||||
srv->SetSrvContinueSend(cfp);
|
||||
}
|
||||
void RestartSrv() { srv->Restart(); }
|
||||
void cliStop() {
|
||||
///////
|
||||
cli->Stop();
|
||||
}
|
||||
void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); }
|
||||
void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); }
|
||||
|
||||
~TransObj() {
|
||||
delete cli;
|
||||
delete srv;
|
||||
|
@ -256,29 +342,120 @@ TEST_F(TransEnv, 02StopServer) {
|
|||
tr->cliSendAndRecv(&req, &resp);
|
||||
assert(resp.code != 0);
|
||||
}
|
||||
TEST_F(TransEnv, clientUserDefined) {}
|
||||
TEST_F(TransEnv, clientUserDefined) {
|
||||
tr->RestartSrv();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg req = {0}, resp = {0};
|
||||
req.msgType = 0;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecv(&req, &resp);
|
||||
assert(resp.code == 0);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
}
|
||||
|
||||
TEST_F(TransEnv, cliPersistHandle) {
|
||||
// impl late
|
||||
}
|
||||
TEST_F(TransEnv, srvPersistHandle) {
|
||||
// impl later
|
||||
tr->SetCliPersistFp(cliPersistHandle);
|
||||
SRpcMsg resp = {0};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg req = {.handle = resp.handle};
|
||||
req.msgType = 1;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecv(&req, &resp);
|
||||
if (i == 5) {
|
||||
std::cout << "stop server" << std::endl;
|
||||
tr->StopSrv();
|
||||
}
|
||||
if (i >= 6) {
|
||||
EXPECT_TRUE(resp.code != 0);
|
||||
}
|
||||
}
|
||||
//////////////////
|
||||
}
|
||||
|
||||
TEST_F(TransEnv, srvPersisHandleExcept) {
|
||||
// conn breken
|
||||
TEST_F(TransEnv, cliReleaseHandle) {
|
||||
tr->SetCliPersistFp(cliPersistHandle);
|
||||
|
||||
SRpcMsg resp = {0};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg req = {.handle = resp.handle};
|
||||
req.msgType = 1;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecvNoHandle(&req, &resp);
|
||||
// if (i == 5) {
|
||||
// std::cout << "stop server" << std::endl;
|
||||
// tr->StopSrv();
|
||||
//}
|
||||
// if (i >= 6) {
|
||||
EXPECT_TRUE(resp.code == 0);
|
||||
//}
|
||||
}
|
||||
//////////////////
|
||||
}
|
||||
TEST_F(TransEnv, cliReleaseHandleExcept) {
|
||||
tr->SetCliPersistFp(cliPersistHandle);
|
||||
|
||||
SRpcMsg resp = {0};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg req = {.handle = resp.handle};
|
||||
req.msgType = 1;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecvNoHandle(&req, &resp);
|
||||
if (i == 5) {
|
||||
std::cout << "stop server" << std::endl;
|
||||
tr->StopSrv();
|
||||
}
|
||||
if (i >= 6) {
|
||||
EXPECT_TRUE(resp.code != 0);
|
||||
}
|
||||
}
|
||||
//////////////////
|
||||
}
|
||||
TEST_F(TransEnv, srvContinueSend) {
|
||||
tr->SetSrvContinueSend(processContinueSend);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SRpcMsg req = {0}, resp = {0};
|
||||
req.msgType = 1;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecv(&req, &resp);
|
||||
}
|
||||
taosMsleep(2000);
|
||||
}
|
||||
|
||||
TEST_F(TransEnv, srvPersistHandleExcept) {
|
||||
tr->SetSrvContinueSend(processContinueSend);
|
||||
tr->SetCliPersistFp(cliPersistHandle);
|
||||
SRpcMsg resp = {0};
|
||||
for (int i = 0; i < 5; i++) {
|
||||
SRpcMsg req = {.handle = resp.handle};
|
||||
req.msgType = 1;
|
||||
req.pCont = rpcMallocCont(10);
|
||||
req.contLen = 10;
|
||||
tr->cliSendAndRecv(&req, &resp);
|
||||
if (i > 2) {
|
||||
tr->cliStop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
taosMsleep(2000);
|
||||
// conn broken
|
||||
//
|
||||
}
|
||||
TEST_F(TransEnv, cliPersisHandleExcept) {
|
||||
// conn breken
|
||||
}
|
||||
|
||||
TEST_F(TransEnv, multiCliPersisHandleExcept) {
|
||||
// conn breken
|
||||
}
|
||||
TEST_F(TransEnv, multiSrvPersisHandleExcept) {
|
||||
// conn breken
|
||||
TEST_F(TransEnv, multiCliPersistHandleExcept) {
|
||||
// conn broken
|
||||
}
|
||||
TEST_F(TransEnv, queryExcept) {
|
||||
tr->SetSrvExceptFp(handleExcept);
|
||||
|
||||
// query and conn is broken
|
||||
}
|
||||
TEST_F(TransEnv, noResp) {
|
||||
// no resp
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
|
|||
}
|
||||
|
||||
if (pRead->pHead->head.version != ver) {
|
||||
wError("unexpected wal log version: %ld, read request version:%ld", pRead->pHead->head.version, ver);
|
||||
wError("unexpected wal log version: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver);
|
||||
pRead->curVersion = -1;
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
#define ALLOW_FORBID_FUNC
|
||||
#include "os.h"
|
||||
#include "osSemaphore.h"
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#include <io.h>
|
||||
|
@ -35,26 +36,18 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */
|
|||
#else
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/sendfile.h>
|
||||
|
||||
#if !defined(_TD_DARWIN_64)
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#define LINUX_FILE_NO_TEXT_OPTION 0
|
||||
#define O_TEXT LINUX_FILE_NO_TEXT_OPTION
|
||||
#endif
|
||||
|
||||
typedef int32_t FileFd;
|
||||
|
||||
#define FILE_WITH_LOCK 1
|
||||
|
||||
typedef struct TdFile {
|
||||
#if FILE_WITH_LOCK
|
||||
pthread_rwlock_t rwlock;
|
||||
#endif
|
||||
int refId;
|
||||
FileFd fd;
|
||||
FILE *fp;
|
||||
} * TdFilePtr, TdFile;
|
||||
|
||||
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) {
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
const char *tdengineTmpFileNamePrefix = "tdengine-";
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#define ALLOW_FORBID_FUNC
|
||||
#include "os.h"
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#if defined(WINDOWS)
|
||||
#include <IPHlpApi.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <Winsock2.h>
|
||||
|
@ -37,8 +37,14 @@
|
|||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(DARWIN)
|
||||
#include <dispatch/dispatch.h>
|
||||
#include "osEok.h"
|
||||
#else
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef int32_t SocketFd;
|
||||
|
@ -210,7 +216,7 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
||||
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
||||
#if defined(_TD_GO_DLL_)
|
||||
uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(val >> 32); }
|
||||
#endif
|
||||
|
|
|
@ -570,6 +570,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
|||
case CFG_DTYPE_LOCALE:
|
||||
case CFG_DTYPE_CHARSET:
|
||||
case CFG_DTYPE_TIMEZONE:
|
||||
case CFG_DTYPE_NONE:
|
||||
if (dump) {
|
||||
printf("%s %s %s", src, name, pItem->str);
|
||||
printf("\n");
|
||||
|
@ -655,4 +656,4 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
|||
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||
uInfo("load from apoll url %s", url);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,14 @@ SJson* tjsonCreateObject() {
|
|||
return pJson;
|
||||
}
|
||||
|
||||
SJson* tjsonCreateArray() {
|
||||
SJson* pJson = cJSON_CreateArray();
|
||||
if (pJson == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return pJson;
|
||||
}
|
||||
|
||||
void tjsonDelete(SJson* pJson) {
|
||||
if (pJson != NULL) {
|
||||
cJSON_Delete((cJSON*)pJson);
|
||||
|
|
|
@ -628,7 +628,7 @@ void taosTmrCleanUp(void* handle) {
|
|||
|
||||
tmrCtrls = NULL;
|
||||
unusedTmrCtrl = NULL;
|
||||
#if !defined(WINDOWS)
|
||||
#if defined(LINUX)
|
||||
tmrModuleInit = PTHREAD_ONCE_INIT; // to support restart
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@
|
|||
# ---- dnode
|
||||
./test.sh -f tsim/dnode/basic1.sim
|
||||
|
||||
# ---- insert
|
||||
./test.sh -f tsim/insert/basic0.sim
|
||||
#======================b1-end===============
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue