Merge branch '3.0' into feature/stream
This commit is contained in:
commit
a9606ea0eb
|
@ -2463,6 +2463,8 @@ typedef struct {
|
|||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int64_t maxDelay;
|
||||
int64_t watermark;
|
||||
int32_t exprLen; // strlen + 1
|
||||
int32_t tagsFilterLen; // strlen + 1
|
||||
int32_t sqlLen; // strlen + 1
|
||||
|
|
|
@ -158,107 +158,109 @@
|
|||
#define TK_CLUSTER 140
|
||||
#define TK_TRANSACTIONS 141
|
||||
#define TK_DISTRIBUTED 142
|
||||
#define TK_LIKE 143
|
||||
#define TK_INDEX 144
|
||||
#define TK_FUNCTION 145
|
||||
#define TK_INTERVAL 146
|
||||
#define TK_TOPIC 147
|
||||
#define TK_AS 148
|
||||
#define TK_WITH 149
|
||||
#define TK_META 150
|
||||
#define TK_CONSUMER 151
|
||||
#define TK_GROUP 152
|
||||
#define TK_DESC 153
|
||||
#define TK_DESCRIBE 154
|
||||
#define TK_RESET 155
|
||||
#define TK_QUERY 156
|
||||
#define TK_CACHE 157
|
||||
#define TK_EXPLAIN 158
|
||||
#define TK_ANALYZE 159
|
||||
#define TK_VERBOSE 160
|
||||
#define TK_NK_BOOL 161
|
||||
#define TK_RATIO 162
|
||||
#define TK_NK_FLOAT 163
|
||||
#define TK_COMPACT 164
|
||||
#define TK_VNODES 165
|
||||
#define TK_IN 166
|
||||
#define TK_OUTPUTTYPE 167
|
||||
#define TK_AGGREGATE 168
|
||||
#define TK_BUFSIZE 169
|
||||
#define TK_STREAM 170
|
||||
#define TK_INTO 171
|
||||
#define TK_TRIGGER 172
|
||||
#define TK_AT_ONCE 173
|
||||
#define TK_WINDOW_CLOSE 174
|
||||
#define TK_KILL 175
|
||||
#define TK_CONNECTION 176
|
||||
#define TK_TRANSACTION 177
|
||||
#define TK_BALANCE 178
|
||||
#define TK_VGROUP 179
|
||||
#define TK_MERGE 180
|
||||
#define TK_REDISTRIBUTE 181
|
||||
#define TK_SPLIT 182
|
||||
#define TK_SYNCDB 183
|
||||
#define TK_DELETE 184
|
||||
#define TK_NULL 185
|
||||
#define TK_NK_QUESTION 186
|
||||
#define TK_NK_ARROW 187
|
||||
#define TK_ROWTS 188
|
||||
#define TK_TBNAME 189
|
||||
#define TK_QSTARTTS 190
|
||||
#define TK_QENDTS 191
|
||||
#define TK_WSTARTTS 192
|
||||
#define TK_WENDTS 193
|
||||
#define TK_WDURATION 194
|
||||
#define TK_CAST 195
|
||||
#define TK_NOW 196
|
||||
#define TK_TODAY 197
|
||||
#define TK_TIMEZONE 198
|
||||
#define TK_COUNT 199
|
||||
#define TK_LAST_ROW 200
|
||||
#define TK_BETWEEN 201
|
||||
#define TK_IS 202
|
||||
#define TK_NK_LT 203
|
||||
#define TK_NK_GT 204
|
||||
#define TK_NK_LE 205
|
||||
#define TK_NK_GE 206
|
||||
#define TK_NK_NE 207
|
||||
#define TK_MATCH 208
|
||||
#define TK_NMATCH 209
|
||||
#define TK_CONTAINS 210
|
||||
#define TK_JOIN 211
|
||||
#define TK_INNER 212
|
||||
#define TK_SELECT 213
|
||||
#define TK_DISTINCT 214
|
||||
#define TK_WHERE 215
|
||||
#define TK_PARTITION 216
|
||||
#define TK_BY 217
|
||||
#define TK_SESSION 218
|
||||
#define TK_STATE_WINDOW 219
|
||||
#define TK_SLIDING 220
|
||||
#define TK_FILL 221
|
||||
#define TK_VALUE 222
|
||||
#define TK_NONE 223
|
||||
#define TK_PREV 224
|
||||
#define TK_LINEAR 225
|
||||
#define TK_NEXT 226
|
||||
#define TK_HAVING 227
|
||||
#define TK_RANGE 228
|
||||
#define TK_EVERY 229
|
||||
#define TK_ORDER 230
|
||||
#define TK_SLIMIT 231
|
||||
#define TK_SOFFSET 232
|
||||
#define TK_LIMIT 233
|
||||
#define TK_OFFSET 234
|
||||
#define TK_ASC 235
|
||||
#define TK_NULLS 236
|
||||
#define TK_ID 237
|
||||
#define TK_NK_BITNOT 238
|
||||
#define TK_INSERT 239
|
||||
#define TK_VALUES 240
|
||||
#define TK_IMPORT 241
|
||||
#define TK_NK_SEMI 242
|
||||
#define TK_FILE 243
|
||||
#define TK_CONSUMERS 143
|
||||
#define TK_SUBSCRIPTIONS 144
|
||||
#define TK_LIKE 145
|
||||
#define TK_INDEX 146
|
||||
#define TK_FUNCTION 147
|
||||
#define TK_INTERVAL 148
|
||||
#define TK_TOPIC 149
|
||||
#define TK_AS 150
|
||||
#define TK_WITH 151
|
||||
#define TK_META 152
|
||||
#define TK_CONSUMER 153
|
||||
#define TK_GROUP 154
|
||||
#define TK_DESC 155
|
||||
#define TK_DESCRIBE 156
|
||||
#define TK_RESET 157
|
||||
#define TK_QUERY 158
|
||||
#define TK_CACHE 159
|
||||
#define TK_EXPLAIN 160
|
||||
#define TK_ANALYZE 161
|
||||
#define TK_VERBOSE 162
|
||||
#define TK_NK_BOOL 163
|
||||
#define TK_RATIO 164
|
||||
#define TK_NK_FLOAT 165
|
||||
#define TK_COMPACT 166
|
||||
#define TK_VNODES 167
|
||||
#define TK_IN 168
|
||||
#define TK_OUTPUTTYPE 169
|
||||
#define TK_AGGREGATE 170
|
||||
#define TK_BUFSIZE 171
|
||||
#define TK_STREAM 172
|
||||
#define TK_INTO 173
|
||||
#define TK_TRIGGER 174
|
||||
#define TK_AT_ONCE 175
|
||||
#define TK_WINDOW_CLOSE 176
|
||||
#define TK_KILL 177
|
||||
#define TK_CONNECTION 178
|
||||
#define TK_TRANSACTION 179
|
||||
#define TK_BALANCE 180
|
||||
#define TK_VGROUP 181
|
||||
#define TK_MERGE 182
|
||||
#define TK_REDISTRIBUTE 183
|
||||
#define TK_SPLIT 184
|
||||
#define TK_SYNCDB 185
|
||||
#define TK_DELETE 186
|
||||
#define TK_NULL 187
|
||||
#define TK_NK_QUESTION 188
|
||||
#define TK_NK_ARROW 189
|
||||
#define TK_ROWTS 190
|
||||
#define TK_TBNAME 191
|
||||
#define TK_QSTARTTS 192
|
||||
#define TK_QENDTS 193
|
||||
#define TK_WSTARTTS 194
|
||||
#define TK_WENDTS 195
|
||||
#define TK_WDURATION 196
|
||||
#define TK_CAST 197
|
||||
#define TK_NOW 198
|
||||
#define TK_TODAY 199
|
||||
#define TK_TIMEZONE 200
|
||||
#define TK_COUNT 201
|
||||
#define TK_LAST_ROW 202
|
||||
#define TK_BETWEEN 203
|
||||
#define TK_IS 204
|
||||
#define TK_NK_LT 205
|
||||
#define TK_NK_GT 206
|
||||
#define TK_NK_LE 207
|
||||
#define TK_NK_GE 208
|
||||
#define TK_NK_NE 209
|
||||
#define TK_MATCH 210
|
||||
#define TK_NMATCH 211
|
||||
#define TK_CONTAINS 212
|
||||
#define TK_JOIN 213
|
||||
#define TK_INNER 214
|
||||
#define TK_SELECT 215
|
||||
#define TK_DISTINCT 216
|
||||
#define TK_WHERE 217
|
||||
#define TK_PARTITION 218
|
||||
#define TK_BY 219
|
||||
#define TK_SESSION 220
|
||||
#define TK_STATE_WINDOW 221
|
||||
#define TK_SLIDING 222
|
||||
#define TK_FILL 223
|
||||
#define TK_VALUE 224
|
||||
#define TK_NONE 225
|
||||
#define TK_PREV 226
|
||||
#define TK_LINEAR 227
|
||||
#define TK_NEXT 228
|
||||
#define TK_HAVING 229
|
||||
#define TK_RANGE 230
|
||||
#define TK_EVERY 231
|
||||
#define TK_ORDER 232
|
||||
#define TK_SLIMIT 233
|
||||
#define TK_SOFFSET 234
|
||||
#define TK_LIMIT 235
|
||||
#define TK_OFFSET 236
|
||||
#define TK_ASC 237
|
||||
#define TK_NULLS 238
|
||||
#define TK_ID 239
|
||||
#define TK_NK_BITNOT 240
|
||||
#define TK_INSERT 241
|
||||
#define TK_VALUES 242
|
||||
#define TK_IMPORT 243
|
||||
#define TK_NK_SEMI 244
|
||||
#define TK_FILE 245
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -73,10 +73,12 @@ void mndStop(SMnode *pMnode);
|
|||
* @param pMnode The mnode object.
|
||||
* @param pCluster
|
||||
* @param pVgroup
|
||||
* @param pStbInfo
|
||||
* @param pGrant
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant);
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo);
|
||||
|
||||
/**
|
||||
* @brief Get mnode loads for status msg.
|
||||
|
|
|
@ -123,6 +123,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_SELECT_VALUE,
|
||||
FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function
|
||||
FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function
|
||||
FUNCTION_TYPE_TO_COLUMN,
|
||||
|
||||
// distributed splitting functions
|
||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||
|
|
|
@ -109,6 +109,9 @@ typedef struct {
|
|||
char version[MON_VER_LEN];
|
||||
float master_uptime; // day
|
||||
int32_t monitor_interval; // sec
|
||||
int32_t dbs_total;
|
||||
int32_t stbs_total;
|
||||
int64_t tbs_total;
|
||||
int32_t vgroups_total;
|
||||
int32_t vgroups_alive;
|
||||
int32_t vnodes_total;
|
||||
|
@ -135,6 +138,15 @@ typedef struct {
|
|||
SArray *vgroups; // array of SMonVgroupDesc
|
||||
} SMonVgroupInfo;
|
||||
|
||||
typedef struct {
|
||||
char stb_name[TSDB_TABLE_NAME_LEN];
|
||||
char database_name[TSDB_DB_NAME_LEN];
|
||||
} SMonStbDesc;
|
||||
|
||||
typedef struct {
|
||||
SArray *stbs; // array of SMonStbDesc
|
||||
} SMonStbInfo;
|
||||
|
||||
typedef struct {
|
||||
int32_t expire_time;
|
||||
int64_t timeseries_used;
|
||||
|
@ -144,6 +156,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
SMonClusterInfo cluster;
|
||||
SMonVgroupInfo vgroup;
|
||||
SMonStbInfo stb;
|
||||
SMonGrantInfo grant;
|
||||
SMonSysInfo sys;
|
||||
SMonLogs log;
|
||||
|
|
|
@ -28,19 +28,18 @@ extern "C" {
|
|||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_CREATE_TB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_TB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
|
||||
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||
|
||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||
|
@ -234,10 +233,10 @@ typedef struct SShowCreateDatabaseStmt {
|
|||
} SShowCreateDatabaseStmt;
|
||||
|
||||
typedef struct SShowCreateTableStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
void* pCfg; // STableCfg
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
void* pCfg; // STableCfg
|
||||
} SShowCreateTableStmt;
|
||||
|
||||
typedef struct SShowTableDistributedStmt {
|
||||
|
@ -259,6 +258,7 @@ typedef struct SIndexOptions {
|
|||
SNode* pInterval;
|
||||
SNode* pOffset;
|
||||
SNode* pSliding;
|
||||
SNode* pStreamOptions;
|
||||
} SIndexOptions;
|
||||
|
||||
typedef struct SCreateIndexStmt {
|
||||
|
|
|
@ -188,6 +188,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||
QUERY_NODE_KILL_QUERY_STMT,
|
||||
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||
|
@ -284,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
|||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
SListCell* nodesListGetCell(SNodeList* pList, int32_t index);
|
||||
void nodesDestroyList(SNodeList* pList);
|
||||
// Only clear the linked list structure, without releasing the elements inside
|
||||
void nodesClearList(SNodeList* pList);
|
||||
|
|
|
@ -32,6 +32,8 @@ typedef struct SLogicNode {
|
|||
struct SLogicNode* pParent;
|
||||
int32_t optimizedFlag;
|
||||
uint8_t precision;
|
||||
SNode* pLimit;
|
||||
SNode* pSlimit;
|
||||
} SLogicNode;
|
||||
|
||||
typedef enum EScanType {
|
||||
|
@ -92,10 +94,6 @@ typedef struct SProjectLogicNode {
|
|||
SLogicNode node;
|
||||
SNodeList* pProjections;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
int64_t limit;
|
||||
int64_t offset;
|
||||
int64_t slimit;
|
||||
int64_t soffset;
|
||||
} SProjectLogicNode;
|
||||
|
||||
typedef struct SIndefRowsFuncLogicNode {
|
||||
|
@ -248,6 +246,8 @@ typedef struct SPhysiNode {
|
|||
SNode* pConditions;
|
||||
SNodeList* pChildren;
|
||||
struct SPhysiNode* pParent;
|
||||
SNode* pLimit;
|
||||
SNode* pSlimit;
|
||||
} SPhysiNode;
|
||||
|
||||
typedef struct SScanPhysiNode {
|
||||
|
@ -297,10 +297,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
|
|||
typedef struct SProjectPhysiNode {
|
||||
SPhysiNode node;
|
||||
SNodeList* pProjections;
|
||||
int64_t limit;
|
||||
int64_t offset;
|
||||
int64_t slimit;
|
||||
int64_t soffset;
|
||||
} SProjectPhysiNode;
|
||||
|
||||
typedef struct SIndefRowsFuncPhysiNode {
|
||||
|
@ -378,7 +374,7 @@ typedef struct SIntervalPhysiNode {
|
|||
int8_t slidingUnit;
|
||||
} SIntervalPhysiNode;
|
||||
|
||||
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
|
||||
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
|
||||
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
|
||||
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
|
||||
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
|
||||
|
|
|
@ -157,13 +157,13 @@ typedef struct SSyncLogStore {
|
|||
SyncIndex (*getCommitIndex)(struct SSyncLogStore* pLogStore);
|
||||
|
||||
// refactor, log[0 .. n] ==> log[m .. n]
|
||||
int32_t (*syncLogSetBeginIndex)(struct SSyncLogStore* pLogStore, SyncIndex beginIndex);
|
||||
int32_t (*syncLogResetBeginIndex)(struct SSyncLogStore* pLogStore);
|
||||
// int32_t (*syncLogSetBeginIndex)(struct SSyncLogStore* pLogStore, SyncIndex beginIndex);
|
||||
|
||||
SyncIndex (*syncLogBeginIndex)(struct SSyncLogStore* pLogStore);
|
||||
SyncIndex (*syncLogEndIndex)(struct SSyncLogStore* pLogStore);
|
||||
bool (*syncLogIsEmpty)(struct SSyncLogStore* pLogStore);
|
||||
int32_t (*syncLogEntryCount)(struct SSyncLogStore* pLogStore);
|
||||
// bool (*syncLogInRange)(struct SSyncLogStore* pLogStore, SyncIndex index);
|
||||
int32_t (*syncLogRestoreFromSnapshot)(struct SSyncLogStore* pLogStore, SyncIndex index);
|
||||
|
||||
SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore);
|
||||
SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore);
|
||||
|
|
|
@ -539,7 +539,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
|||
const char *pFunc = taosArrayGet(pReq->pFuncs, i);
|
||||
if (tEncodeCStr(&encoder, pFunc) < 0) return -1;
|
||||
}
|
||||
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
|||
if (NULL == pReq->pFuncs) return -1;
|
||||
}
|
||||
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
||||
char* pFunc = NULL;
|
||||
char *pFunc = NULL;
|
||||
if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1;
|
||||
if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
|
|||
if (tEncodeI64(&encoder, pReq->interval) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->offset) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1;
|
||||
|
@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
|
|||
if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1;
|
||||
|
@ -1868,7 +1872,7 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
|||
if (tEncodeI64(&encoder, pRsp->watermark1) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pRsp->watermark2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->ttl) < 0) return -1;
|
||||
|
||||
|
||||
int32_t numOfFuncs = taosArrayGetSize(pRsp->pFuncs);
|
||||
if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1;
|
||||
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
||||
|
@ -1876,19 +1880,19 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
|||
if (tEncodeCStr(&encoder, pFunc) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1;
|
||||
if (pRsp->commentLen > 0) {
|
||||
if (tEncodeCStr(&encoder, pRsp->pComment) < 0) return -1;
|
||||
}
|
||||
|
||||
|
||||
for (int32_t i = 0; i < pRsp->numOfColumns + pRsp->numOfTags; ++i) {
|
||||
SSchema *pSchema = &pRsp->pSchemas[i];
|
||||
if (tEncodeSSchema(&encoder, pSchema) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1;
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1945,7 +1949,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
|
|||
}
|
||||
|
||||
if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, (void**)&pRsp->pTags, NULL) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
@ -1961,7 +1965,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) {
|
|||
taosMemoryFreeClear(pRsp->pComment);
|
||||
taosMemoryFreeClear(pRsp->pSchemas);
|
||||
taosMemoryFreeClear(pRsp->pTags);
|
||||
|
||||
|
||||
taosArrayDestroy(pRsp->pFuncs);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "mmInt.h"
|
||||
|
||||
void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
|
||||
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->grant);
|
||||
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->stb, &pInfo->grant);
|
||||
}
|
||||
|
||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
|
|
|
@ -614,7 +614,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
|
|||
}
|
||||
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||
SMonGrantInfo *pGrantInfo) {
|
||||
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo) {
|
||||
if (mndAcquireRpcRef(pMnode) != 0) return -1;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
@ -623,7 +623,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
pClusterInfo->dnodes = taosArrayInit(sdbGetSize(pSdb, SDB_DNODE), sizeof(SMonDnodeDesc));
|
||||
pClusterInfo->mnodes = taosArrayInit(sdbGetSize(pSdb, SDB_MNODE), sizeof(SMonMnodeDesc));
|
||||
pVgroupInfo->vgroups = taosArrayInit(sdbGetSize(pSdb, SDB_VGROUP), sizeof(SMonVgroupDesc));
|
||||
if (pClusterInfo->dnodes == NULL || pClusterInfo->mnodes == NULL || pVgroupInfo->vgroups == NULL) {
|
||||
pStbInfo->stbs = taosArrayInit(sdbGetSize(pSdb, SDB_STB), sizeof(SMonStbDesc));
|
||||
if (pClusterInfo->dnodes == NULL || pClusterInfo->mnodes == NULL || pVgroupInfo->vgroups == NULL ||
|
||||
pStbInfo->stbs == NULL) {
|
||||
mndReleaseRpcRef(pMnode);
|
||||
return -1;
|
||||
}
|
||||
|
@ -632,6 +634,8 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
tstrncpy(pClusterInfo->version, version, sizeof(pClusterInfo->version));
|
||||
pClusterInfo->monitor_interval = tsMonitorInterval;
|
||||
pClusterInfo->connections_total = mndGetNumOfConnections(pMnode);
|
||||
pClusterInfo->dbs_total = sdbGetSize(pSdb, SDB_DB);
|
||||
pClusterInfo->stbs_total = sdbGetSize(pSdb, SDB_STB);
|
||||
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
|
@ -681,6 +685,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
if (pIter == NULL) break;
|
||||
|
||||
pClusterInfo->vgroups_total++;
|
||||
pClusterInfo->tbs_total += pVgroup->numOfTables;
|
||||
|
||||
SMonVgroupDesc desc = {0};
|
||||
desc.vgroup_id = pVgroup->vgId;
|
||||
|
@ -711,6 +716,27 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
|
||||
// stb info
|
||||
pIter = NULL;
|
||||
while (1) {
|
||||
SStbObj *pStb = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
SMonStbDesc desc = {0};
|
||||
|
||||
SName name1 = {0};
|
||||
tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
tNameGetDbName(&name1, desc.database_name);
|
||||
|
||||
SName name2 = {0};
|
||||
tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
tstrncpy(desc.stb_name, tNameGetTableName(&name2), TSDB_TABLE_NAME_LEN);
|
||||
|
||||
taosArrayPush(pStbInfo->stbs, &desc);
|
||||
sdbRelease(pSdb, pStb);
|
||||
}
|
||||
|
||||
// grant info
|
||||
pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 86400000.0f;
|
||||
pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed;
|
||||
|
|
|
@ -3581,6 +3581,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
|
|||
return pList;
|
||||
}
|
||||
|
||||
static int64_t getLimit(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
||||
|
||||
static int64_t getOffset(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
||||
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
||||
|
@ -3593,8 +3597,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
||||
|
||||
SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc);
|
||||
SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset};
|
||||
SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset};
|
||||
SLimit limit = {.limit = getLimit(pProjPhyNode->node.pLimit), .offset = getOffset(pProjPhyNode->node.pLimit)};
|
||||
SLimit slimit = {.limit = getLimit(pProjPhyNode->node.pSlimit), .offset = getOffset(pProjPhyNode->node.pSlimit)};
|
||||
|
||||
pInfo->limit = limit;
|
||||
pInfo->slimit = slimit;
|
||||
|
|
|
@ -390,6 +390,10 @@ SSDataBlock* doGroupSort(SOperatorInfo* pOperator) {
|
|||
pInfo->hasGroupId = true;
|
||||
|
||||
pInfo->prefetchedSortInput = pOperator->pDownstream[0]->fpSet.getNextFn(pOperator->pDownstream[0]);
|
||||
if (pInfo->prefetchedSortInput == NULL) {
|
||||
doSetOperatorCompleted(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
pInfo->currGroupId = pInfo->prefetchedSortInput->info.groupId;
|
||||
pInfo->childOpStatus = CHILD_OP_NEW_GROUP;
|
||||
beginSortGroup(pOperator);
|
||||
|
@ -463,7 +467,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort
|
|||
pInfo->pColMatchInfo = pColMatchColInfo;
|
||||
pOperator->name = "GroupSortOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT;
|
||||
pOperator->blocking = true;
|
||||
pOperator->blocking = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
|
|
|
@ -4117,6 +4117,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
|
|||
goto _error;
|
||||
}
|
||||
|
||||
miaInfo->groupIntervalHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_NO_LOCK);
|
||||
|
||||
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
|
||||
|
||||
iaInfo->win = pTaskInfo->window;
|
||||
|
|
|
@ -79,7 +79,8 @@ static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_
|
|||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para1Type) || !IS_NUMERIC_TYPE(para2Type)) {
|
||||
if ((!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) ||
|
||||
(!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -109,13 +110,13 @@ static int32_t translateLogarithm(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
|||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para1Type)) {
|
||||
if (!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (2 == numOfParams) {
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para2Type)) {
|
||||
if (!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
@ -1856,7 +1857,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "last_row",
|
||||
.type = FUNCTION_TYPE_LAST_ROW,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||
.translateFunc = translateLastRow,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minmaxFunctionSetup,
|
||||
|
@ -2023,7 +2024,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "diff",
|
||||
.type = FUNCTION_TYPE_DIFF,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||
.translateFunc = translateDiff,
|
||||
.getEnvFunc = getDiffFuncEnv,
|
||||
.initFunc = diffFunctionSetup,
|
||||
|
@ -2033,7 +2034,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "statecount",
|
||||
.type = FUNCTION_TYPE_STATE_COUNT,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||
.translateFunc = translateStateCount,
|
||||
.getEnvFunc = getStateFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -2043,7 +2044,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "stateduration",
|
||||
.type = FUNCTION_TYPE_STATE_DURATION,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||
.translateFunc = translateStateDuration,
|
||||
.getEnvFunc = getStateFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -2053,7 +2054,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "csum",
|
||||
.type = FUNCTION_TYPE_CSUM,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||
.translateFunc = translateCsum,
|
||||
.getEnvFunc = getCsumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -2063,7 +2064,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "mavg",
|
||||
.type = FUNCTION_TYPE_MAVG,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||
.translateFunc = translateMavg,
|
||||
.getEnvFunc = getMavgFuncEnv,
|
||||
.initFunc = mavgFunctionSetup,
|
||||
|
|
|
@ -561,7 +561,7 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
// check for overflow
|
||||
if (IS_FLOAT_TYPE(type) && (isinf(pSumRes->dsum) || isnan(pSumRes->dsum))) {
|
||||
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||
numOfElem = 0;
|
||||
}
|
||||
|
||||
_sum_over:
|
||||
|
@ -927,7 +927,7 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
// check for overflow
|
||||
if (isinf(pAvgRes->result) || isnan(pAvgRes->result)) {
|
||||
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||
GET_RES_INFO(pCtx)->numOfRes = 0;
|
||||
}
|
||||
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
|
@ -1776,6 +1776,11 @@ int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
pStddevRes->result = sqrt(fabs(pStddevRes->quadraticDSum / ((double)pStddevRes->count) - avg * avg));
|
||||
}
|
||||
|
||||
// check for overflow
|
||||
if (isinf(pStddevRes->result) || isnan(pStddevRes->result)) {
|
||||
GET_RES_INFO(pCtx)->numOfRes = 0;
|
||||
}
|
||||
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
}
|
||||
|
||||
|
|
|
@ -613,7 +613,9 @@ int32_t udfdOpenClientRpc() {
|
|||
}
|
||||
|
||||
int32_t udfdCloseClientRpc() {
|
||||
fnInfo("udfd begin closing rpc");
|
||||
rpcClose(global.clientRpc);
|
||||
fnInfo("udfd finish closing rpc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -937,9 +939,8 @@ int main(int argc, char *argv[]) {
|
|||
uv_thread_create(&mnodeConnectThread, udfdConnectMnodeThreadFunc, NULL);
|
||||
|
||||
udfdRun();
|
||||
|
||||
|
||||
removeListeningPipe();
|
||||
uv_thread_join(&mnodeConnectThread);
|
||||
udfdCloseClientRpc();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -201,6 +201,9 @@ static void monGenClusterJson(SMonInfo *pMonitor) {
|
|||
tjsonAddStringToObject(pJson, "version", pInfo->version);
|
||||
tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime);
|
||||
tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval);
|
||||
tjsonAddDoubleToObject(pJson, "dbs_total", pInfo->dbs_total);
|
||||
tjsonAddDoubleToObject(pJson, "tbs_total", pInfo->tbs_total);
|
||||
tjsonAddDoubleToObject(pJson, "stbs_total", pInfo->stbs_total);
|
||||
tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total);
|
||||
tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive);
|
||||
tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total);
|
||||
|
@ -277,6 +280,27 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
|
|||
}
|
||||
}
|
||||
|
||||
static void monGenStbJson(SMonInfo *pMonitor) {
|
||||
SMonStbInfo *pInfo = &pMonitor->mmInfo.stb;
|
||||
if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return;
|
||||
|
||||
SJson *pJson = tjsonAddArrayToObject(pMonitor->pJson, "stb_infos");
|
||||
if (pJson == NULL) return;
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->stbs); ++i) {
|
||||
SJson *pStbJson = tjsonCreateObject();
|
||||
if (pStbJson == NULL) continue;
|
||||
if (tjsonAddItemToArray(pJson, pStbJson) != 0) {
|
||||
tjsonDelete(pStbJson);
|
||||
continue;
|
||||
}
|
||||
|
||||
SMonStbDesc *pStbDesc = taosArrayGet(pInfo->stbs, i);
|
||||
tjsonAddStringToObject(pStbJson, "stb_name", pStbDesc->stb_name);
|
||||
tjsonAddStringToObject(pStbJson, "database_name", pStbDesc->database_name);
|
||||
}
|
||||
}
|
||||
|
||||
static void monGenGrantJson(SMonInfo *pMonitor) {
|
||||
SMonGrantInfo *pInfo = &pMonitor->mmInfo.grant;
|
||||
if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return;
|
||||
|
@ -524,6 +548,7 @@ void monSendReport() {
|
|||
monGenBasicJson(pMonitor);
|
||||
monGenClusterJson(pMonitor);
|
||||
monGenVgroupJson(pMonitor);
|
||||
monGenStbJson(pMonitor);
|
||||
monGenGrantJson(pMonitor);
|
||||
monGenDnodeJson(pMonitor);
|
||||
monGenDiskJson(pMonitor);
|
||||
|
|
|
@ -102,6 +102,9 @@ int32_t tEncodeSMonClusterInfo(SEncoder *encoder, const SMonClusterInfo *pInfo)
|
|||
if (tEncodeCStr(encoder, pInfo->version) < 0) return -1;
|
||||
if (tEncodeFloat(encoder, pInfo->master_uptime) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->monitor_interval) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->dbs_total) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->stbs_total) < 0) return -1;
|
||||
if (tEncodeI64(encoder, pInfo->tbs_total) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->vgroups_total) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->vgroups_alive) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pInfo->vnodes_total) < 0) return -1;
|
||||
|
@ -130,6 +133,9 @@ int32_t tDecodeSMonClusterInfo(SDecoder *decoder, SMonClusterInfo *pInfo) {
|
|||
if (tDecodeCStrTo(decoder, pInfo->version) < 0) return -1;
|
||||
if (tDecodeFloat(decoder, &pInfo->master_uptime) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->monitor_interval) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->dbs_total) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->stbs_total) < 0) return -1;
|
||||
if (tDecodeI64(decoder, &pInfo->tbs_total) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->vgroups_total) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->vgroups_alive) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pInfo->vnodes_total) < 0) return -1;
|
||||
|
@ -203,6 +209,32 @@ int32_t tDecodeSMonVgroupInfo(SDecoder *decoder, SMonVgroupInfo *pInfo) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSMonStbInfo(SEncoder *encoder, const SMonStbInfo *pInfo) {
|
||||
if (tEncodeI32(encoder, taosArrayGetSize(pInfo->stbs)) < 0) return -1;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->stbs); ++i) {
|
||||
SMonStbDesc *pDesc = taosArrayGet(pInfo->stbs, i);
|
||||
if (tEncodeCStr(encoder, pDesc->stb_name) < 0) return -1;
|
||||
if (tEncodeCStr(encoder, pDesc->database_name) < 0) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSMonStbInfo(SDecoder *decoder, SMonStbInfo *pInfo) {
|
||||
int32_t arraySize = 0;
|
||||
if (tDecodeI32(decoder, &arraySize) < 0) return -1;
|
||||
|
||||
pInfo->stbs = taosArrayInit(arraySize, sizeof(SMonStbDesc));
|
||||
if (pInfo->stbs == NULL) return -1;
|
||||
|
||||
for (int32_t i = 0; i < arraySize; ++i) {
|
||||
SMonStbDesc desc = {0};
|
||||
if (tDecodeCStrTo(decoder, desc.stb_name) < 0) return -1;
|
||||
if (tDecodeCStrTo(decoder, desc.database_name) < 0) return -1;
|
||||
taosArrayPush(pInfo->stbs, &desc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSMonGrantInfo(SEncoder *encoder, const SMonGrantInfo *pInfo) {
|
||||
if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1;
|
||||
if (tEncodeI64(encoder, pInfo->timeseries_used) < 0) return -1;
|
||||
|
@ -224,6 +256,7 @@ int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeSMonClusterInfo(&encoder, &pInfo->cluster) < 0) return -1;
|
||||
if (tEncodeSMonVgroupInfo(&encoder, &pInfo->vgroup) < 0) return -1;
|
||||
if (tEncodeSMonStbInfo(&encoder, &pInfo->stb) < 0) return -1;
|
||||
if (tEncodeSMonGrantInfo(&encoder, &pInfo->grant) < 0) return -1;
|
||||
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
||||
if (tEncodeSMonLogs(&encoder, &pInfo->log) < 0) return -1;
|
||||
|
@ -241,6 +274,7 @@ int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeSMonClusterInfo(&decoder, &pInfo->cluster) < 0) return -1;
|
||||
if (tDecodeSMonVgroupInfo(&decoder, &pInfo->vgroup) < 0) return -1;
|
||||
if (tDecodeSMonStbInfo(&decoder, &pInfo->stb) < 0) return -1;
|
||||
if (tDecodeSMonGrantInfo(&decoder, &pInfo->grant) < 0) return -1;
|
||||
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||
|
@ -255,9 +289,11 @@ void tFreeSMonMmInfo(SMonMmInfo *pInfo) {
|
|||
taosArrayDestroy(pInfo->cluster.mnodes);
|
||||
taosArrayDestroy(pInfo->cluster.dnodes);
|
||||
taosArrayDestroy(pInfo->vgroup.vgroups);
|
||||
taosArrayDestroy(pInfo->stb.stbs);
|
||||
pInfo->cluster.mnodes = NULL;
|
||||
pInfo->cluster.dnodes = NULL;
|
||||
pInfo->vgroup.vgroups = NULL;
|
||||
pInfo->stb.stbs = NULL;
|
||||
pInfo->log.logs = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@
|
|||
} \
|
||||
(pDst)->fldname = strdup((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -53,8 +52,7 @@
|
|||
} \
|
||||
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -65,8 +63,7 @@
|
|||
} \
|
||||
(pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -77,8 +74,7 @@
|
|||
} \
|
||||
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -89,27 +85,25 @@
|
|||
} \
|
||||
(pDst)->fldname = cloneFunc((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
|
||||
do { \
|
||||
if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
|
||||
do { \
|
||||
if (TSDB_CODE_SUCCESS != copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static SNode* exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
||||
static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
||||
COPY_OBJECT_FIELD(resType, sizeof(SDataType));
|
||||
COPY_CHAR_ARRAY_FIELD(aliasName);
|
||||
COPY_CHAR_ARRAY_FIELD(userAlias);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||
static int32_t columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_SCALAR_FIELD(tableId);
|
||||
COPY_SCALAR_FIELD(tableType);
|
||||
|
@ -122,10 +116,10 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
|||
COPY_CHAR_ARRAY_FIELD(colName);
|
||||
COPY_SCALAR_FIELD(dataBlockId);
|
||||
COPY_SCALAR_FIELD(slotId);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||
static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_CHAR_POINT_FIELD(literal);
|
||||
COPY_SCALAR_FIELD(isDuration);
|
||||
|
@ -135,7 +129,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
COPY_SCALAR_FIELD(typeData);
|
||||
COPY_SCALAR_FIELD(unit);
|
||||
if (!pSrc->translate) {
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
switch (pSrc->node.resType.type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
|
@ -164,8 +158,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
int32_t len = varDataTLen(pSrc->datum.p) + 1;
|
||||
pDst->datum.p = taosMemoryCalloc(1, len);
|
||||
if (NULL == pDst->datum.p) {
|
||||
nodesDestroyNode((SNode*)pDst);
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(pDst->datum.p, pSrc->datum.p, len);
|
||||
break;
|
||||
|
@ -177,42 +170,42 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) {
|
||||
static int32_t operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_SCALAR_FIELD(opType);
|
||||
CLONE_NODE_FIELD(pLeft);
|
||||
CLONE_NODE_FIELD(pRight);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) {
|
||||
static int32_t logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_SCALAR_FIELD(condType);
|
||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
|
||||
static int32_t functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_CHAR_ARRAY_FIELD(functionName);
|
||||
COPY_SCALAR_FIELD(funcId);
|
||||
COPY_SCALAR_FIELD(funcType);
|
||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||
COPY_SCALAR_FIELD(udfBufSize);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* tableNodeCopy(const STableNode* pSrc, STableNode* pDst) {
|
||||
static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
COPY_CHAR_ARRAY_FIELD(dbName);
|
||||
COPY_CHAR_ARRAY_FIELD(tableName);
|
||||
COPY_CHAR_ARRAY_FIELD(tableAlias);
|
||||
COPY_SCALAR_FIELD(precision);
|
||||
COPY_SCALAR_FIELD(singleTable);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static STableMeta* tableMetaClone(const STableMeta* pSrc) {
|
||||
|
@ -235,101 +228,103 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) {
|
|||
return pDst;
|
||||
}
|
||||
|
||||
static SNode* realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) {
|
||||
static int32_t realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||
COPY_CHAR_ARRAY_FIELD(qualDbName);
|
||||
COPY_SCALAR_FIELD(ratio);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) {
|
||||
static int32_t tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||
CLONE_NODE_FIELD(pSubquery);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) {
|
||||
static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||
COPY_SCALAR_FIELD(joinType);
|
||||
CLONE_NODE_FIELD(pLeft);
|
||||
CLONE_NODE_FIELD(pRight);
|
||||
CLONE_NODE_FIELD(pOnCond);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) {
|
||||
static int32_t targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) {
|
||||
COPY_SCALAR_FIELD(dataBlockId);
|
||||
COPY_SCALAR_FIELD(slotId);
|
||||
CLONE_NODE_FIELD(pExpr);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) {
|
||||
static int32_t groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) {
|
||||
COPY_SCALAR_FIELD(groupingSetType);
|
||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) {
|
||||
static int32_t orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) {
|
||||
CLONE_NODE_FIELD(pExpr);
|
||||
COPY_SCALAR_FIELD(order);
|
||||
COPY_SCALAR_FIELD(nullOrder);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) {
|
||||
static int32_t limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) {
|
||||
COPY_SCALAR_FIELD(limit);
|
||||
COPY_SCALAR_FIELD(offset);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) {
|
||||
static int32_t stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD(pCol);
|
||||
CLONE_NODE_FIELD(pExpr);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
||||
static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD_EX(pCol, SColumnNode*);
|
||||
CLONE_NODE_FIELD_EX(pGap, SValueNode*);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) {
|
||||
static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD(pCol);
|
||||
CLONE_NODE_FIELD(pInterval);
|
||||
CLONE_NODE_FIELD(pOffset);
|
||||
CLONE_NODE_FIELD(pSliding);
|
||||
CLONE_NODE_FIELD(pFill);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
||||
static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
||||
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||
CLONE_NODE_LIST_FIELD(pNodeList);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
||||
static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
||||
COPY_SCALAR_FIELD(mode);
|
||||
CLONE_NODE_FIELD(pValues);
|
||||
CLONE_NODE_FIELD(pWStartTs);
|
||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
||||
static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
||||
CLONE_NODE_LIST_FIELD(pTargets);
|
||||
CLONE_NODE_FIELD(pConditions);
|
||||
CLONE_NODE_LIST_FIELD(pChildren);
|
||||
COPY_SCALAR_FIELD(optimizedFlag);
|
||||
COPY_SCALAR_FIELD(precision);
|
||||
return (SNode*)pDst;
|
||||
CLONE_NODE_FIELD(pLimit);
|
||||
CLONE_NODE_FIELD(pSlimit);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||
static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
||||
|
@ -357,36 +352,32 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
|||
COPY_SCALAR_FIELD(tsColId);
|
||||
COPY_SCALAR_FIELD(filesFactor);
|
||||
CLONE_NODE_LIST_FIELD(pPartTags);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
||||
static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(joinType);
|
||||
CLONE_NODE_FIELD(pOnConditions);
|
||||
COPY_SCALAR_FIELD(isSingleTableJoin);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
|
||||
static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pGroupKeys);
|
||||
CLONE_NODE_LIST_FIELD(pAggFuncs);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) {
|
||||
static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pProjections);
|
||||
COPY_CHAR_ARRAY_FIELD(stmtName);
|
||||
COPY_SCALAR_FIELD(limit);
|
||||
COPY_SCALAR_FIELD(offset);
|
||||
COPY_SCALAR_FIELD(slimit);
|
||||
COPY_SCALAR_FIELD(soffset);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) {
|
||||
static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(modifyType);
|
||||
COPY_SCALAR_FIELD(msgType);
|
||||
|
@ -395,25 +386,25 @@ static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModif
|
|||
COPY_SCALAR_FIELD(tableType);
|
||||
COPY_CHAR_ARRAY_FIELD(tableFName);
|
||||
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) {
|
||||
static int32_t logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(srcGroupId);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) {
|
||||
static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pMergeKeys);
|
||||
CLONE_NODE_LIST_FIELD(pInputs);
|
||||
COPY_SCALAR_FIELD(numOfChannels);
|
||||
COPY_SCALAR_FIELD(srcGroupId);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||
static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(winType);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
|
@ -430,37 +421,37 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
|
|||
COPY_SCALAR_FIELD(watermark);
|
||||
COPY_SCALAR_FIELD(filesFactor);
|
||||
COPY_SCALAR_FIELD(windowAlgo);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
|
||||
static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(mode);
|
||||
CLONE_NODE_FIELD(pWStartTs);
|
||||
CLONE_NODE_FIELD(pValues);
|
||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) {
|
||||
static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pSortKeys);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) {
|
||||
static int32_t logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) {
|
||||
static int32_t logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) {
|
||||
static int32_t logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||
|
@ -468,26 +459,26 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL
|
|||
COPY_SCALAR_FIELD(fillMode);
|
||||
CLONE_NODE_FIELD(pFillValues);
|
||||
CLONE_NODE_FIELD(pTimeSeries);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
||||
static int32_t logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
||||
COPY_OBJECT_FIELD(id, sizeof(SSubplanId));
|
||||
CLONE_NODE_FIELD_EX(pNode, SLogicNode*);
|
||||
COPY_SCALAR_FIELD(subplanType);
|
||||
COPY_SCALAR_FIELD(level);
|
||||
COPY_SCALAR_FIELD(splitFlag);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) {
|
||||
static int32_t physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) {
|
||||
CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*);
|
||||
CLONE_NODE_FIELD(pConditions);
|
||||
CLONE_NODE_LIST_FIELD(pChildren);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
||||
static int32_t physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
||||
|
@ -495,14 +486,14 @@ static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
|||
COPY_SCALAR_FIELD(suid);
|
||||
COPY_SCALAR_FIELD(tableType);
|
||||
COPY_OBJECT_FIELD(tableName, sizeof(SName));
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) {
|
||||
static int32_t physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) {
|
||||
return physiScanCopy(pSrc, pDst);
|
||||
}
|
||||
|
||||
static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) {
|
||||
static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
||||
COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2);
|
||||
COPY_OBJECT_FIELD(scanRange, sizeof(STimeWindow));
|
||||
|
@ -519,18 +510,18 @@ static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhys
|
|||
COPY_SCALAR_FIELD(watermark);
|
||||
COPY_SCALAR_FIELD(tsColId);
|
||||
COPY_SCALAR_FIELD(filesFactor);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) {
|
||||
static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
||||
COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet));
|
||||
COPY_SCALAR_FIELD(showRewrite);
|
||||
COPY_SCALAR_FIELD(accountId);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) {
|
||||
static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pExprs);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
|
@ -539,59 +530,59 @@ static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pD
|
|||
COPY_SCALAR_FIELD(triggerType);
|
||||
COPY_SCALAR_FIELD(watermark);
|
||||
COPY_SCALAR_FIELD(filesFactor);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) {
|
||||
static int32_t physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
||||
COPY_SCALAR_FIELD(interval);
|
||||
COPY_SCALAR_FIELD(offset);
|
||||
COPY_SCALAR_FIELD(sliding);
|
||||
COPY_SCALAR_FIELD(intervalUnit);
|
||||
COPY_SCALAR_FIELD(slidingUnit);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) {
|
||||
static int32_t physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
||||
COPY_SCALAR_FIELD(gap);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) {
|
||||
static int32_t physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pExprs);
|
||||
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
||||
CLONE_NODE_LIST_FIELD(pTargets);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
|
||||
static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
|
||||
COPY_SCALAR_FIELD(dataBlockId);
|
||||
CLONE_NODE_LIST_FIELD(pSlots);
|
||||
COPY_SCALAR_FIELD(totalRowSize);
|
||||
COPY_SCALAR_FIELD(outputRowSize);
|
||||
COPY_SCALAR_FIELD(precision);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) {
|
||||
static int32_t slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) {
|
||||
COPY_SCALAR_FIELD(slotId);
|
||||
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||
COPY_SCALAR_FIELD(reserve);
|
||||
COPY_SCALAR_FIELD(output);
|
||||
COPY_SCALAR_FIELD(tag);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) {
|
||||
static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) {
|
||||
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
|
||||
COPY_SCALAR_FIELD(taskId);
|
||||
COPY_SCALAR_FIELD(schedId);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||
static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||
COPY_SCALAR_FIELD(isDistinct);
|
||||
CLONE_NODE_LIST_FIELD(pProjectionList);
|
||||
CLONE_NODE_FIELD(pFromTable);
|
||||
|
@ -609,116 +600,166 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
|||
COPY_SCALAR_FIELD(isTimeOrderQuery);
|
||||
COPY_SCALAR_FIELD(hasAggFuncs);
|
||||
COPY_SCALAR_FIELD(hasRepeatScanFuncs);
|
||||
return (SNode*)pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* nodesCloneNode(const SNode* pNode) {
|
||||
if (NULL == pNode) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SNode* pDst = nodesMakeNode(nodeType(pNode));
|
||||
if (NULL == pDst) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
case QUERY_NODE_COLUMN:
|
||||
return columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
||||
code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_VALUE:
|
||||
return valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
||||
code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_OPERATOR:
|
||||
return operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst);
|
||||
code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_CONDITION:
|
||||
return logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst);
|
||||
code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_FUNCTION:
|
||||
return functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst);
|
||||
code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_REAL_TABLE:
|
||||
return realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst);
|
||||
code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_TEMP_TABLE:
|
||||
return tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst);
|
||||
code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_JOIN_TABLE:
|
||||
return joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst);
|
||||
code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_GROUPING_SET:
|
||||
return groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst);
|
||||
code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_ORDER_BY_EXPR:
|
||||
return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst);
|
||||
code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LIMIT:
|
||||
return limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst);
|
||||
code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
return stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst);
|
||||
code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
return sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst);
|
||||
code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
return intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst);
|
||||
code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_NODE_LIST:
|
||||
return nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst);
|
||||
code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_FILL:
|
||||
return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
|
||||
code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_TARGET:
|
||||
return targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst);
|
||||
code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_DATABLOCK_DESC:
|
||||
return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
||||
code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_SLOT_DESC:
|
||||
return slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst);
|
||||
code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||
return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
||||
code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
return pDst;
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
break;
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
return selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
||||
code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
||||
code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
||||
code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||
code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||
return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
||||
code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||
return logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst);
|
||||
code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
||||
code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||
return logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst);
|
||||
code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||
return logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst);
|
||||
code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_FILL:
|
||||
return logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst);
|
||||
code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||
return logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst);
|
||||
code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_PARTITION:
|
||||
return logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst);
|
||||
code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC:
|
||||
return logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst);
|
||||
code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
return logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst);
|
||||
code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||
return logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst);
|
||||
code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
return physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst);
|
||||
code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
|
||||
return physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst);
|
||||
code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||
return physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst);
|
||||
code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
||||
return physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst);
|
||||
code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
|
||||
return physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst);
|
||||
code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst);
|
||||
code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
nodesDestroyNode(pDst);
|
||||
nodesError("nodesCloneNode unknown node = %s", nodesNodeName(nodeType(pNode)));
|
||||
return NULL;
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode(pDst);
|
||||
nodesError("nodesCloneNode failed node = %s", nodesNodeName(nodeType(pNode)));
|
||||
return NULL;
|
||||
}
|
||||
return pDst;
|
||||
}
|
||||
|
||||
SNodeList* nodesCloneList(const SNodeList* pList) {
|
||||
|
@ -726,19 +767,15 @@ SNodeList* nodesCloneList(const SNodeList* pList) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SNodeList* pDst = nodesMakeList();
|
||||
if (NULL == pDst) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
SNode* pNode;
|
||||
SNodeList* pDst = NULL;
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pList) {
|
||||
SNode* pNewNode = nodesCloneNode(pNode);
|
||||
if (NULL == pNewNode) {
|
||||
int32_t code = nodesListMakeStrictAppend(&pDst, nodesCloneNode(pNode));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyList(pDst);
|
||||
return NULL;
|
||||
}
|
||||
nodesListAppend(pDst, pNewNode);
|
||||
}
|
||||
return pDst;
|
||||
}
|
||||
|
|
|
@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
|
|||
static const char* jkLogicPlanTargets = "Targets";
|
||||
static const char* jkLogicPlanConditions = "Conditions";
|
||||
static const char* jkLogicPlanChildren = "Children";
|
||||
static const char* jkLogicPlanLimit = "Limit";
|
||||
static const char* jkLogicPlanSlimit = "SLimit";
|
||||
|
||||
static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SLogicNode* pNode = (const SLogicNode*)pObj;
|
||||
|
@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkLogicPlanChildren, pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkLogicPlanLimit, nodeToJson, pNode->pLimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkLogicPlanSlimit, nodeToJson, pNode->pSlimit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkLogicPlanChildren, &pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkLogicPlanLimit, &pNode->pLimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkLogicPlanSlimit, &pNode->pSlimit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
|
|||
}
|
||||
|
||||
static const char* jkProjectLogicPlanProjections = "Projections";
|
||||
static const char* jkProjectLogicPlanLimit = "Limit";
|
||||
static const char* jkProjectLogicPlanOffset = "Offset";
|
||||
static const char* jkProjectLogicPlanSlimit = "SLimit";
|
||||
static const char* jkProjectLogicPlanSoffset = "SOffset";
|
||||
|
||||
static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj;
|
||||
|
@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkProjectLogicPlanProjections, pNode->pProjections);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanLimit, pNode->limit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanOffset, pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSoffset, pNode->soffset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkProjectLogicPlanProjections, &pNode->pProjections);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanLimit, &pNode->limit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanOffset, &pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSoffset, &pNode->soffset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
|
|||
static const char* jkPhysiPlanOutputDataBlockDesc = "OutputDataBlockDesc";
|
||||
static const char* jkPhysiPlanConditions = "Conditions";
|
||||
static const char* jkPhysiPlanChildren = "Children";
|
||||
static const char* jkPhysiPlanLimit = "Limit";
|
||||
static const char* jkPhysiPlanSlimit = "SLimit";
|
||||
|
||||
static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SPhysiNode* pNode = (const SPhysiNode*)pObj;
|
||||
|
@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkPhysiPlanChildren, pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkPhysiPlanLimit, nodeToJson, pNode->pLimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkPhysiPlanSlimit, nodeToJson, pNode->pSlimit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkPhysiPlanChildren, &pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkPhysiPlanLimit, &pNode->pLimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkPhysiPlanSlimit, &pNode->pSlimit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
|
|||
}
|
||||
|
||||
static const char* jkProjectPhysiPlanProjections = "Projections";
|
||||
static const char* jkProjectPhysiPlanLimit = "Limit";
|
||||
static const char* jkProjectPhysiPlanOffset = "Offset";
|
||||
static const char* jkProjectPhysiPlanSlimit = "SLimit";
|
||||
static const char* jkProjectPhysiPlanSoffset = "SOffset";
|
||||
|
||||
static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj;
|
||||
|
@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkProjectPhysiPlanProjections, pNode->pProjections);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanLimit, pNode->limit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanOffset, pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSlimit, pNode->slimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSoffset, pNode->soffset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkProjectPhysiPlanProjections, &pNode->pProjections);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanLimit, &pNode->limit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanOffset, &pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSlimit, &pNode->slimit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSoffset, &pNode->soffset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -3165,6 +3137,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkLimitLimit = "Limit";
|
||||
static const char* jkLimitOffset = "Offset";
|
||||
|
||||
static int32_t limitNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SLimitNode* pNode = (const SLimitNode*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkLimitLimit, pNode->limit);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkLimitOffset, pNode->offset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToLimitNode(const SJson* pJson, void* pObj) {
|
||||
SLimitNode* pNode = (SLimitNode*)pObj;
|
||||
|
||||
int32_t code = tjsonGetBigIntValue(pJson, jkLimitLimit, &pNode->limit);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkLimitOffset, &pNode->offset);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkStateWindowCol = "StateWindowCol";
|
||||
static const char* jkStateWindowExpr = "StateWindowExpr";
|
||||
|
||||
|
@ -4031,7 +4028,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
case QUERY_NODE_ORDER_BY_EXPR:
|
||||
return orderByExprNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LIMIT:
|
||||
break;
|
||||
return limitNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
return stateWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
|
@ -4191,6 +4188,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToTempTableNode(pJson, pObj);
|
||||
case QUERY_NODE_ORDER_BY_EXPR:
|
||||
return jsonToOrderByExprNode(pJson, pObj);
|
||||
case QUERY_NODE_LIMIT:
|
||||
return jsonToLimitNode(pJson, pObj);
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
return jsonToStateWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
|
|
|
@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
||||
|
@ -371,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
|||
|
||||
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); }
|
||||
|
||||
static void destroyExprNode(SExprNode* pExpr) { taosArrayDestroy(pExpr->pAssociation); }
|
||||
|
||||
void nodesDestroyNode(SNode* pNode) {
|
||||
if (NULL == pNode) {
|
||||
return;
|
||||
|
@ -378,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
|
||||
switch (nodeType(pNode)) {
|
||||
case QUERY_NODE_COLUMN: // pProjectRef is weak reference, no need to release
|
||||
destroyExprNode((SExprNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_VALUE: {
|
||||
SValueNode* pValue = (SValueNode*)pNode;
|
||||
destroyExprNode((SExprNode*)pNode);
|
||||
taosMemoryFreeClear(pValue->literal);
|
||||
if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) {
|
||||
taosMemoryFreeClear(pValue->datum.p);
|
||||
|
@ -389,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
}
|
||||
case QUERY_NODE_OPERATOR: {
|
||||
SOperatorNode* pOp = (SOperatorNode*)pNode;
|
||||
destroyExprNode((SExprNode*)pNode);
|
||||
nodesDestroyNode(pOp->pLeft);
|
||||
nodesDestroyNode(pOp->pRight);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_CONDITION:
|
||||
destroyExprNode((SExprNode*)pNode);
|
||||
nodesDestroyList(((SLogicConditionNode*)pNode)->pParameterList);
|
||||
break;
|
||||
case QUERY_NODE_FUNCTION:
|
||||
destroyExprNode((SExprNode*)pNode);
|
||||
nodesDestroyList(((SFunctionNode*)pNode)->pParameterList);
|
||||
break;
|
||||
case QUERY_NODE_REAL_TABLE: {
|
||||
|
@ -644,7 +652,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT: {
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: {
|
||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pDbName);
|
||||
nodesDestroyNode(pStmt->pTbName);
|
||||
|
@ -831,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyList(pPhyNode->pExprs);
|
||||
nodesDestroyList(pPhyNode->pSortKeys);
|
||||
nodesDestroyList(pPhyNode->pTargets);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||
|
@ -1094,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SListCell* nodesListGetCell(SNodeList* pList, int32_t index) {
|
||||
SNode* node;
|
||||
FOREACH(node, pList) {
|
||||
if (0 == index--) {
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void nodesDestroyList(SNodeList* pList) {
|
||||
if (NULL == pList) {
|
||||
return;
|
||||
|
|
|
@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
|||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
||||
SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||
SNode* pStreamOptions);
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName);
|
||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||
|
|
|
@ -388,6 +388,8 @@ cmd ::= SHOW SNODES.
|
|||
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
|
||||
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
|
||||
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
|
||||
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
||||
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
|
||||
|
||||
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
||||
|
@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
|||
// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
|
||||
cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); }
|
||||
|
||||
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); }
|
||||
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); }
|
||||
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E)
|
||||
sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); }
|
||||
|
||||
%type func_list { SNodeList* }
|
||||
%destructor func_list { nodesDestroyList($$); }
|
||||
|
@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
|
|||
|
||||
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
||||
|
||||
sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); }
|
||||
sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
||||
sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
||||
|
||||
/************************************************ create/drop topic ***************************************************/
|
||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
|
||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); }
|
||||
|
|
|
@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset,
|
||||
SNode* pSliding) {
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||
SNode* pStreamOptions) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
|
@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
|
|||
pOptions->pInterval = pInterval;
|
||||
pOptions->pOffset = pOffset;
|
||||
pOptions->pSliding = pSliding;
|
||||
pOptions->pStreamOptions = pStreamOptions;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,6 +380,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
|||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowConsumers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS,
|
||||
pCxt->pMetaCache);
|
||||
|
@ -456,6 +461,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||
pCxt->pStmt = pStmt;
|
||||
switch (nodeType(pStmt)) {
|
||||
|
@ -517,6 +527,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
return collectMetaKeyFromShowConsumers(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
|
@ -538,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
||||
return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -175,17 +175,23 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
|
|||
}
|
||||
}
|
||||
|
||||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||
strcpy(aliasName, ((SExprNode*)pProject)->aliasName);
|
||||
int32_t code = scalarCalculateConstants(pProject, pNew);
|
||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) {
|
||||
strcpy(((SExprNode*)*pNew)->aliasName, aliasName);
|
||||
int32_t size = taosArrayGetSize(pAssociation);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SNode** pCol = taosArrayGetP(pAssociation, i);
|
||||
nodesDestroyNode(*pCol);
|
||||
*pCol = nodesCloneNode(*pNew);
|
||||
if (NULL == *pCol) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(pAssociation);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -196,6 +202,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) {
|
|||
return NULL == ((SExprNode*)pProj)->pAssociation;
|
||||
}
|
||||
|
||||
static SNode* createConstantValue() {
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == pVal) {
|
||||
return NULL;
|
||||
}
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_INT;
|
||||
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
const int32_t val = 1;
|
||||
nodesSetValueNodeValue(pVal, (void*)&val);
|
||||
pVal->translate = true;
|
||||
return (SNode*)pVal;
|
||||
}
|
||||
|
||||
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
||||
SNode* pProj = NULL;
|
||||
WHERE_EACH(pProj, pSelect->pProjectionList) {
|
||||
|
@ -212,6 +231,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
|||
}
|
||||
WHERE_NEXT;
|
||||
}
|
||||
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
||||
return nodesListStrictAppend(pSelect->pProjectionList, createConstantValue());
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ static SKeyword keywordTable[] = {
|
|||
{"CONNECTION", TK_CONNECTION},
|
||||
{"CONNECTIONS", TK_CONNECTIONS},
|
||||
{"CONSUMER", TK_CONSUMER},
|
||||
{"CONSUMERS", TK_CONSUMERS},
|
||||
{"COUNT", TK_COUNT},
|
||||
{"CREATE", TK_CREATE},
|
||||
{"CONTAINS", TK_CONTAINS},
|
||||
|
@ -188,6 +189,7 @@ static SKeyword keywordTable[] = {
|
|||
{"STREAM", TK_STREAM},
|
||||
{"STREAMS", TK_STREAMS},
|
||||
{"STRICT", TK_STRICT},
|
||||
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
|
||||
{"SYNCDB", TK_SYNCDB},
|
||||
{"SYSINFO", TK_SYSINFO},
|
||||
{"TABLE", TK_TABLE},
|
||||
|
|
|
@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
|
|||
if (NULL == pCol) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
setColumnInfoByExpr(pTable, (SExprNode*)pNode, &pCol);
|
||||
nodesListAppend(pList, (SNode*)pCol);
|
||||
SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1);
|
||||
setColumnInfoByExpr(pTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -707,7 +708,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
|||
res = translateColumnUseAlias(pCxt, pCol, &found);
|
||||
}
|
||||
if (DEAL_RES_ERROR != res && !found) {
|
||||
res = translateColumnWithoutPrefix(pCxt, pCol);
|
||||
if (NULL != pCxt->pCurrSetOperator) {
|
||||
res = generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName);
|
||||
} else {
|
||||
res = translateColumnWithoutPrefix(pCxt, pCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -2656,6 +2661,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) {
|
||||
if ((NULL != pLimit && pLimit->offset < 0)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_OFFSET_LESS_ZERO);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
||||
int32_t code = translateQuery(pCxt, pSetOperator->pLeft);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2671,6 +2683,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateSetOperOrderBy(pCxt, pSetOperator);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkSetOperLimit(pCxt, (SLimitNode*)pSetOperator->pLimit);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3566,9 +3581,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) {
|
|||
}
|
||||
*pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN);
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pFuncs) {
|
||||
taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName);
|
||||
}
|
||||
FOREACH(pNode, pFuncs) { taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); }
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3867,6 +3880,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
|
|||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
||||
pReq->slidingUnit =
|
||||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
||||
if (NULL != pStmt->pOptions->pStreamOptions) {
|
||||
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
||||
pReq->maxDelay = (NULL != pStreamOpt->pDelay ? ((SValueNode*)pStreamOpt->pDelay)->datum.i : 0);
|
||||
pReq->watermark = (NULL != pStreamOpt->pWatermark ? ((SValueNode*)pStreamOpt->pWatermark)->datum.i : 0);
|
||||
}
|
||||
|
||||
int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -3888,6 +3906,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
|
|||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
if (NULL != pStmt->pOptions->pStreamOptions) {
|
||||
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
||||
if (NULL != pStreamOpt->pWatermark &&
|
||||
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
}
|
||||
|
||||
SMCreateSmaReq createSmaReq = {0};
|
||||
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -4629,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||
if (NULL == pRoot) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -4683,6 +4712,8 @@ static const char* getSysDbName(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return TSDB_PERFORMANCE_SCHEMA_DB;
|
||||
default:
|
||||
break;
|
||||
|
@ -4738,6 +4769,10 @@ static const char* getSysTableName(ENodeType type) {
|
|||
return TSDB_PERFS_TABLE_APPS;
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
return TSDB_INS_TABLE_DNODE_VARIABLES;
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
return TSDB_PERFS_TABLE_CONSUMERS;
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return TSDB_PERFS_TABLE_SUBSCRIPTIONS;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -5876,6 +5911,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
code = rewriteShow(pCxt, pQuery);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
|
|
|
@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
|
|||
if (pNew->pFuncs) {
|
||||
pNew->pFuncs = taosArrayDup(pNew->pFuncs);
|
||||
}
|
||||
|
||||
|
||||
int32_t schemaSize = (pCfg->numOfColumns + pCfg->numOfTags) * sizeof(SSchema);
|
||||
|
||||
SSchema* pSchema = taosMemoryMalloc(schemaSize);
|
||||
|
@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST
|
|||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
STableCfg* pCfg = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = tableCfgDup(pCfg);
|
||||
if (NULL == *pOutput) {
|
||||
|
@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) {
|
|||
|
||||
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
||||
SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0);
|
||||
if (pRes->code) {
|
||||
if (TSDB_CODE_SUCCESS != pRes->code) {
|
||||
return pRes->code;
|
||||
}
|
||||
|
||||
|
||||
*pDnodes = taosArrayDup((SArray*)pRes->pRes);
|
||||
if (NULL == *pDnodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,95 +25,125 @@
|
|||
#ifdef WINDOWS
|
||||
#define TD_USE_WINSOCK
|
||||
#endif
|
||||
|
||||
#include "mockCatalog.h"
|
||||
|
||||
#include "systable.h"
|
||||
namespace {
|
||||
|
||||
void generateInformationSchema(MockCatalogService* mcs) {
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1)
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_DATABASES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_FUNCTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_INDEXES, TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_STABLES, TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLES, TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "configs", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnode_variables", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("dnode_id", TSDB_DATA_TYPE_INT);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("dnode_id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
}
|
||||
|
||||
void generatePerformanceSchema(MockCatalogService* mcs) {
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "trans", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "streams", TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra
|
|||
return g_mockCatalogService->catalogGetDnodeList(pDnodeList);
|
||||
}
|
||||
|
||||
int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) {
|
||||
int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableCfg** pCfg) {
|
||||
*pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -166,13 +166,10 @@ class MockCatalogServiceImpl {
|
|||
}
|
||||
|
||||
int32_t catalogGetDnodeList(SArray** pDnodes) const {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosArrayInit(dnode_.size(), sizeof(SEpSet));
|
||||
*pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet));
|
||||
for (const auto& dnode : dnode_) {
|
||||
taosArrayPush((SArray*)res.pRes, &dnode.second);
|
||||
taosArrayPush(*pDnodes, &dnode.second);
|
||||
}
|
||||
*pDnodes = taosArrayInit(1, sizeof(SMetaRes));
|
||||
taosArrayPush(*pDnodes, &res);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -200,7 +197,7 @@ class MockCatalogServiceImpl {
|
|||
code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) {
|
||||
code = catalogGetDnodeList(&pMetaData->pDnodeList);
|
||||
code = getAllDnodeList(&pMetaData->pDnodeList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg);
|
||||
|
@ -565,6 +562,14 @@ class MockCatalogServiceImpl {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t getAllDnodeList(SArray** pDnodes) const {
|
||||
SMetaRes res = {0};
|
||||
catalogGetDnodeList((SArray**)&res.pRes);
|
||||
*pDnodes = taosArrayInit(1, sizeof(SMetaRes));
|
||||
taosArrayPush(*pDnodes, &res);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint64_t id_;
|
||||
std::unique_ptr<TableBuilder> builder_;
|
||||
DbMetaCache meta_;
|
||||
|
|
|
@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) {
|
|||
TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
||||
run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
|
||||
run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
||||
run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
|
||||
run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
||||
run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
|
||||
run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
||||
run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
|
||||
// run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)");
|
||||
run("SELECT CSUM(c3) FROM t1 STATE_WINDOW(c1)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC);
|
||||
|
||||
run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, useDefinedFunc) {
|
||||
|
@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) {
|
|||
run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, setOperatorSemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1 ORDER BY ts", TSDB_CODE_PAR_INVALID_COLUMN);
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, informationSchema) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {};
|
|||
// todo SHOW apps
|
||||
// todo SHOW connections
|
||||
|
||||
TEST_F(ParserShowToUseTest, showConsumers) {
|
||||
useDb("root", "test");
|
||||
|
||||
setCheckDdlFunc(
|
||||
[&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); });
|
||||
|
||||
run("SHOW CONSUMERS");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showCreateDatabase) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) {
|
|||
run("SHOW streams");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showSubscriptions) {
|
||||
useDb("root", "test");
|
||||
|
||||
setCheckDdlFunc(
|
||||
[&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); });
|
||||
|
||||
run("SHOW SUBSCRIPTIONS");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showTransactions) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
typedef struct SLogicPlanContext {
|
||||
SPlanContext* pPlanCxt;
|
||||
SLogicNode* pCurrRoot;
|
||||
} SLogicPlanContext;
|
||||
|
||||
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**);
|
||||
|
@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t
|
|||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||
pNode->precision = precision;
|
||||
code = pushLogicNode(pCxt, pRoot, pNode);
|
||||
pCxt->pCurrRoot = pNode;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pNode);
|
||||
|
@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
|||
return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot);
|
||||
}
|
||||
|
||||
static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols,
|
||||
int8_t tableType) {
|
||||
static EScanType getScanType(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pScanPseudoCols,
|
||||
SNodeList* pScanCols, int8_t tableType) {
|
||||
if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) {
|
||||
return SCAN_TYPE_STREAM;
|
||||
}
|
||||
|
||||
if (pSelect->hasLastRowFunc) {
|
||||
return SCAN_TYPE_LAST_ROW;
|
||||
}
|
||||
|
||||
if (NULL == pScanCols) {
|
||||
// select count(*) from t
|
||||
return NULL == pScanPseudoCols
|
||||
|
@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM);
|
||||
}
|
||||
|
||||
pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType);
|
||||
pScan->scanType = getScanType(pCxt, pSelect, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
||||
|
@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable,
|
||||
SLogicNode** pLogicNode) {
|
||||
SScanLogicNode* pScan = NULL;
|
||||
int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan);
|
||||
|
||||
SNodeList* pFuncs = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pScan->scanType = SCAN_TYPE_LAST_ROW;
|
||||
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createColumnByLastRow(pFuncs, &pScan->pScanCols);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pScan;
|
||||
} else {
|
||||
nodesDestroyNode((SNode*)pScan);
|
||||
}
|
||||
nodesDestroyList(pFuncs);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable,
|
||||
SLogicNode** pLogicNode) {
|
||||
return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode);
|
||||
|
@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
SLogicNode** pLogicNode) {
|
||||
switch (nodeType(pTable)) {
|
||||
case QUERY_NODE_REAL_TABLE:
|
||||
if (pSelect->hasLastRowFunc) {
|
||||
return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
||||
} else {
|
||||
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
||||
}
|
||||
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
||||
case QUERY_NODE_TEMP_TABLE:
|
||||
return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode);
|
||||
case QUERY_NODE_JOIN_TABLE:
|
||||
|
@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
|||
}
|
||||
pNode->precision = pSelect->precision;
|
||||
*pLogicNode = pNode;
|
||||
pCxt->pCurrRoot = pNode;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) {
|
||||
code = nodesListMakeStrictAppend(&pFill->node.pTargets,
|
||||
nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)));
|
||||
}
|
||||
|
||||
pFill->mode = pFillNode->mode;
|
||||
pFill->timeRange = pFillNode->timeRange;
|
||||
|
@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL == pSort->node.pTargets) {
|
||||
code = nodesListMakeStrictAppend(&pSort->node.pTargets,
|
||||
nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)));
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSort->pSortKeys = nodesCloneList(pSelect->pOrderByList);
|
||||
|
@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NULL != pSelect->pLimit) {
|
||||
pProject->limit = pSelect->pLimit->limit;
|
||||
pProject->offset = pSelect->pLimit->offset;
|
||||
} else {
|
||||
pProject->limit = -1;
|
||||
pProject->offset = -1;
|
||||
}
|
||||
|
||||
if (NULL != pSelect->pSlimit) {
|
||||
pProject->slimit = ((SLimitNode*)pSelect->pSlimit)->limit;
|
||||
pProject->soffset = ((SLimitNode*)pSelect->pSlimit)->offset;
|
||||
} else {
|
||||
pProject->slimit = -1;
|
||||
pProject->soffset = -1;
|
||||
}
|
||||
pProject->node.pLimit = (SNode*)pSelect->pLimit;
|
||||
pProject->node.pSlimit = (SNode*)pSelect->pSlimit;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
|
||||
int32_t code =
|
||||
nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL == pPartition->node.pTargets) {
|
||||
code = nodesListMakeStrictAppend(&pPartition->node.pTargets, nodesListGetNode(pCxt->pCurrRoot->pTargets, 0));
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList);
|
||||
|
@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pSort->node.pLimit = pSetOperator->pLimit;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
pSort->node.pTargets = nodesCloneList(pSetOperator->pProjectionList);
|
||||
|
@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NULL != pSetOperator->pLimit) {
|
||||
pProject->limit = ((SLimitNode*)pSetOperator->pLimit)->limit;
|
||||
pProject->offset = ((SLimitNode*)pSetOperator->pLimit)->offset;
|
||||
} else {
|
||||
pProject->limit = -1;
|
||||
pProject->offset = -1;
|
||||
if (NULL == pSetOperator->pOrderByList) {
|
||||
pProject->node.pLimit = pSetOperator->pLimit;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NULL == pSetOperator->pOrderByList) {
|
||||
pAgg->node.pLimit = pSetOperator->pLimit;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
pAgg->pGroupKeys = nodesCloneList(pSetOperator->pProjectionList);
|
||||
if (NULL == pAgg->pGroupKeys) {
|
||||
|
|
|
@ -1117,8 +1117,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode;
|
||||
if (-1 != pProjectNode->limit || -1 != pProjectNode->slimit || -1 != pProjectNode->offset ||
|
||||
-1 != pProjectNode->soffset) {
|
||||
if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pPhysiNode->pLimit = pLogicNode->pLimit;
|
||||
pPhysiNode->pSlimit = pLogicNode->pSlimit;
|
||||
|
||||
int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pPhysiNode);
|
||||
|
@ -921,11 +924,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pProject->limit = pProjectLogicNode->limit;
|
||||
pProject->offset = pProjectLogicNode->offset;
|
||||
pProject->slimit = pProjectLogicNode->slimit;
|
||||
pProject->soffset = pProjectLogicNode->soffset;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (0 == LIST_LENGTH(pChildren)) {
|
||||
pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections);
|
||||
|
@ -1199,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
nodesDestroyNode((SNode*)pSort);
|
||||
}
|
||||
|
||||
nodesDestroyList(pPrecalcExprs);
|
||||
nodesDestroyList(pSortKeys);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -1040,6 +1040,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS
|
|||
if (NULL == pExchange->node.pTargets) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
TSWAP(pExchange->node.pLimit, pProject->node.pLimit);
|
||||
|
||||
pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
|
||||
|
|
|
@ -37,13 +37,6 @@ TEST_F(PlanBasicTest, whereClause) {
|
|||
run("SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'");
|
||||
}
|
||||
|
||||
TEST_F(PlanBasicTest, joinClause) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts");
|
||||
run("SELECT t1.c1, t2.c2 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts");
|
||||
}
|
||||
|
||||
TEST_F(PlanBasicTest, func) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ TEST_F(PlanOrderByTest, basic) {
|
|||
run("SELECT c1 AS a FROM t1 ORDER BY a");
|
||||
|
||||
run("SELECT c1 + 10 AS a FROM t1 ORDER BY a");
|
||||
|
||||
run("SELECT 1 FROM t1 ORDER BY c1");
|
||||
}
|
||||
|
||||
TEST_F(PlanOrderByTest, expr) {
|
||||
|
|
|
@ -54,6 +54,14 @@ TEST_F(PlanSetOpTest, unionAllWithOrderBy) {
|
|||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1");
|
||||
}
|
||||
|
||||
TEST_F(PlanSetOpTest, unionAllWithLimit) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20");
|
||||
|
||||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20");
|
||||
}
|
||||
|
||||
TEST_F(PlanSetOpTest, union) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
@ -65,6 +73,14 @@ TEST_F(PlanSetOpTest, union) {
|
|||
"UNION SELECT c1, c2 FROM t1 WHERE c1 > 30");
|
||||
}
|
||||
|
||||
TEST_F(PlanSetOpTest, unionWithLimit) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20");
|
||||
|
||||
run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20");
|
||||
}
|
||||
|
||||
TEST_F(PlanSetOpTest, unionContainJoin) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ TEST_F(PlanSubqeuryTest, basic) {
|
|||
|
||||
run("SELECT NOW() FROM (SELECT * FROM t1)");
|
||||
|
||||
// run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts");
|
||||
run("SELECT * FROM (SELECT NOW() FROM t1)");
|
||||
|
||||
run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts");
|
||||
}
|
||||
|
||||
TEST_F(PlanSubqeuryTest, doubleGroupBy) {
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
#include <string>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "functionMgt.h"
|
||||
#include "getopt.h"
|
||||
#include "mockCatalog.h"
|
||||
#include "parser.h"
|
||||
#include "planTestUtil.h"
|
||||
|
||||
class PlannerEnv : public testing::Environment {
|
||||
|
@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment {
|
|||
initLog(TD_TMP_DIR_PATH "td");
|
||||
}
|
||||
|
||||
virtual void TearDown() { destroyMetaDataEnv(); }
|
||||
virtual void TearDown() {
|
||||
destroyMetaDataEnv();
|
||||
qCleanupKeywordsTable();
|
||||
fmFuncMgtDestroy();
|
||||
taosCloseLog();
|
||||
}
|
||||
|
||||
PlannerEnv() {}
|
||||
virtual ~PlannerEnv() {}
|
||||
|
|
|
@ -102,12 +102,15 @@ class PlannerTestBaseImpl {
|
|||
try {
|
||||
SQuery* pQuery = nullptr;
|
||||
doParseSql(sql, &pQuery);
|
||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
||||
|
||||
SPlanContext cxt = {0};
|
||||
setPlanContext(pQuery, &cxt);
|
||||
|
||||
SLogicSubplan* pLogicSubplan = nullptr;
|
||||
doCreateLogicPlan(&cxt, &pLogicSubplan);
|
||||
unique_ptr<SLogicSubplan, void (*)(SLogicSubplan*)> logicSubplan(pLogicSubplan,
|
||||
(void (*)(SLogicSubplan*))nodesDestroyNode);
|
||||
|
||||
doOptimizeLogicPlan(&cxt, pLogicSubplan);
|
||||
|
||||
|
@ -115,9 +118,12 @@ class PlannerTestBaseImpl {
|
|||
|
||||
SQueryLogicPlan* pLogicPlan = nullptr;
|
||||
doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan);
|
||||
unique_ptr<SQueryLogicPlan, void (*)(SQueryLogicPlan*)> logicPlan(pLogicPlan,
|
||||
(void (*)(SQueryLogicPlan*))nodesDestroyNode);
|
||||
|
||||
SQueryPlan* pPlan = nullptr;
|
||||
doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan);
|
||||
unique_ptr<SQueryPlan, void (*)(SQueryPlan*)> plan(pPlan, (void (*)(SQueryPlan*))nodesDestroyNode);
|
||||
|
||||
dump(g_dumpModule);
|
||||
} catch (...) {
|
||||
|
@ -345,8 +351,9 @@ class PlannerTestBaseImpl {
|
|||
}
|
||||
|
||||
void doCreatePhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan) {
|
||||
SArray* pExecNodeList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr));
|
||||
DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, pExecNodeList);
|
||||
unique_ptr<SArray, void (*)(SArray*)> execNodeList((SArray*)taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr)),
|
||||
(void (*)(SArray*))taosArrayDestroy);
|
||||
DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, execNodeList.get());
|
||||
res_.physiPlan_ = toString((SNode*)(*pPlan));
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, (*pPlan)->pSubplans) {
|
||||
|
|
|
@ -36,9 +36,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
if (!IS_NUMERIC_TYPE(type)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
|
@ -119,6 +116,13 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_NULL: {
|
||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||
colDataAppendNULL(pOutputData, i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
colDataAssign(pOutputData, pInputData, pInput->numOfRows, NULL);
|
||||
}
|
||||
|
@ -130,9 +134,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
|
||||
static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SColumnInfoData *pInputData = pInput->columnData;
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
|
@ -142,7 +143,7 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
|
|||
double *out = (double *)pOutputData->pData;
|
||||
|
||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData, i)) {
|
||||
if (colDataIsNull_s(pInputData, i) || IS_NULL_TYPE(type)) {
|
||||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -159,10 +160,6 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
|
|||
}
|
||||
|
||||
static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn_2 valFn) {
|
||||
if (inputNum != 2 || !IS_NUMERIC_TYPE(GET_PARAM_TYPE(&pInput[0])) || !IS_NUMERIC_TYPE(GET_PARAM_TYPE(&pInput[1]))) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SColumnInfoData *pInputData[2];
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
_getDoubleValue_fn_t getValueFn[2];
|
||||
|
@ -175,11 +172,15 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
double *out = (double *)pOutputData->pData;
|
||||
double result;
|
||||
|
||||
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) ||
|
||||
IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
||||
|
||||
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
if (pInput[0].numOfRows == pInput[1].numOfRows) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i) ||
|
||||
colDataIsNull_s(pInputData[1], i)) {
|
||||
colDataIsNull_s(pInputData[1], i) ||
|
||||
hasNullType) {
|
||||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -191,7 +192,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
}
|
||||
}
|
||||
} else if (pInput[0].numOfRows == 1) { //left operand is constant
|
||||
if (colDataIsNull_s(pInputData[0], 0)) {
|
||||
if (colDataIsNull_s(pInputData[0], 0) || hasNullType) {
|
||||
colDataAppendNNULL(pOutputData, 0, pInput[1].numOfRows);
|
||||
} else {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
|
@ -210,7 +211,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
}
|
||||
}
|
||||
} else if (pInput[1].numOfRows == 1) {
|
||||
if (colDataIsNull_s(pInputData[1], 0)) {
|
||||
if (colDataIsNull_s(pInputData[1], 0) || hasNullType) {
|
||||
colDataAppendNNULL(pOutputData, 0, pInput[0].numOfRows);
|
||||
} else {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
|
@ -236,9 +237,6 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
|
||||
static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _float_fn f1, _double_fn d1) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SColumnInfoData *pInputData = pInput->columnData;
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
|
@ -272,6 +270,13 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_NULL: {
|
||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||
colDataAppendNULL(pOutputData, i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
colDataAssign(pOutputData, pInputData, pInput->numOfRows, NULL);
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ extern "C" {
|
|||
#include "trpc.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
#define TIMER_MAX_MS 0x7FFFFFFF
|
||||
#define ENV_TICK_TIMER_MS 1000
|
||||
#define PING_TIMER_MS 1000
|
||||
#define ELECT_TIMER_MS_MIN 500
|
||||
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
||||
#define TIMER_MAX_MS 0x7FFFFFFF
|
||||
#define ENV_TICK_TIMER_MS 1000
|
||||
#define PING_TIMER_MS 1000
|
||||
#define ELECT_TIMER_MS_MIN 1300
|
||||
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
||||
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
|
||||
#define HEARTBEAT_TIMER_MS 100
|
||||
#define HEARTBEAT_TIMER_MS 900
|
||||
|
||||
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ extern "C" {
|
|||
#include "syncInt.h"
|
||||
#include "syncRaftEntry.h"
|
||||
#include "taosdef.h"
|
||||
#include "wal.h"
|
||||
|
||||
typedef struct SSyncLogStoreData {
|
||||
SSyncNode* pSyncNode;
|
||||
SWal* pWal;
|
||||
SyncIndex beginIndex; // valid begin index, default 0, may be set beginIndex > 0
|
||||
SSyncNode* pSyncNode;
|
||||
SWal* pWal;
|
||||
SWalReadHandle* pWalHandle;
|
||||
// SyncIndex beginIndex; // valid begin index, default 0, may be set beginIndex > 0
|
||||
} SSyncLogStoreData;
|
||||
|
||||
SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode);
|
||||
|
|
|
@ -420,44 +420,26 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
|
|||
// prevLogIndex == -1
|
||||
static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries* pMsg) {
|
||||
if (pMsg->prevLogIndex == SYNC_INDEX_INVALID) {
|
||||
if (gRaftDetailLog) {
|
||||
sTrace("syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld", pMsg->prevLogIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SyncIndex myLastIndex = syncNodeGetLastIndex(pSyncNode);
|
||||
if (pMsg->prevLogIndex > myLastIndex) {
|
||||
if (gRaftDetailLog) {
|
||||
sTrace("syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld", pMsg->prevLogIndex,
|
||||
myLastIndex);
|
||||
}
|
||||
sDebug("vgId:%d sync log not ok, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
SyncTerm myPreLogTerm = syncNodeGetPreTerm(pSyncNode, pMsg->prevLogIndex + 1);
|
||||
if (myPreLogTerm == SYNC_TERM_INVALID) {
|
||||
sError("vgId:%d sync get pre term error, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex);
|
||||
sDebug("vgId:%d sync log not ok2, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pMsg->prevLogIndex <= myLastIndex && pMsg->prevLogTerm == myPreLogTerm) {
|
||||
if (gRaftDetailLog) {
|
||||
sTrace(
|
||||
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
|
||||
"myPreLogTerm:%lu",
|
||||
pMsg->prevLogIndex, myLastIndex, pMsg->prevLogTerm, myPreLogTerm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (gRaftDetailLog) {
|
||||
sTrace(
|
||||
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
|
||||
"myPreLogTerm:%lu",
|
||||
pMsg->prevLogIndex, myLastIndex, pMsg->prevLogTerm, myPreLogTerm);
|
||||
}
|
||||
|
||||
sDebug("vgId:%d sync log not ok3, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -466,14 +448,11 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
int32_t code = 0;
|
||||
|
||||
// print log
|
||||
char logBuf[128] = {0};
|
||||
snprintf(logBuf, sizeof(logBuf), "recv SyncAppendEntries, vgId:%d, term:%lu", ths->vgId,
|
||||
ths->pRaftStore->currentTerm);
|
||||
syncAppendEntriesLog2(logBuf, pMsg);
|
||||
syncAppendEntriesLog2("==syncNodeOnAppendEntriesSnapshotCb==", pMsg);
|
||||
|
||||
// if already drop replica, do not process
|
||||
if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) {
|
||||
sInfo("recv SyncAppendEntries maybe replica already dropped");
|
||||
syncNodeEventLog(ths, "recv sync-append-entries, maybe replica already dropped");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -497,7 +476,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
do {
|
||||
bool condition = pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE;
|
||||
if (condition) {
|
||||
sTrace("recv SyncAppendEntries, candidate to follower");
|
||||
syncNodeEventLog(ths, "recv sync-append-entries, candidate to follower");
|
||||
|
||||
syncNodeBecomeFollower(ths, "from candidate by append entries");
|
||||
// do not reply?
|
||||
|
@ -505,6 +484,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
}
|
||||
} while (0);
|
||||
|
||||
#if 0
|
||||
// fake match
|
||||
//
|
||||
// condition1:
|
||||
|
@ -530,7 +510,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
bool condition0 = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) &&
|
||||
syncNodeHasSnapshot(ths);
|
||||
bool condition1 =
|
||||
condition0 && (ths->pLogStore->syncLogEntryCount(ths->pLogStore) == 0) && (pMsg->prevLogIndex > myLastIndex);
|
||||
condition0 && (ths->pLogStore->syncLogEntryCount(ths->pLogStore) == 0) && (pMsg->prevLogIndex > myLastIndex); // donot use syncLogEntryCount!!! use isEmpty
|
||||
bool condition2 = condition0 && (ths->pLogStore->syncLogLastIndex(ths->pLogStore) <= snapshot.lastApplyIndex) &&
|
||||
(pMsg->prevLogIndex > myLastIndex);
|
||||
bool condition3 = condition0 && (pMsg->prevLogIndex < snapshot.lastApplyIndex);
|
||||
|
@ -538,11 +518,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
bool condition = condition1 || condition2 || condition3 || condition4;
|
||||
|
||||
if (condition) {
|
||||
sTrace(
|
||||
"recv SyncAppendEntries, fake match, myLastIndex:%ld, syncLogBeginIndex:%ld, syncLogEndIndex:%ld, "
|
||||
"condition1:%d, condition2:%d, condition3:%d, condition4:%d",
|
||||
myLastIndex, ths->pLogStore->syncLogBeginIndex(ths->pLogStore),
|
||||
ths->pLogStore->syncLogEndIndex(ths->pLogStore), condition1, condition2, condition3, condition4);
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%ld, pre-term:%lu",
|
||||
pMsg->prevLogIndex, pMsg->prevLogTerm);
|
||||
syncNodeEventLog(ths, logBuf);
|
||||
|
||||
// prepare response msg
|
||||
SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId);
|
||||
|
@ -562,6 +541,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
return ret;
|
||||
}
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
// fake match2
|
||||
//
|
||||
|
@ -576,8 +556,13 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
bool condition = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) &&
|
||||
(pMsg->prevLogIndex <= ths->commitIndex);
|
||||
if (condition) {
|
||||
sTrace("recv SyncAppendEntries, fake match2, msg-prevLogIndex:%ld, my-commitIndex:%ld", pMsg->prevLogIndex,
|
||||
ths->commitIndex);
|
||||
do {
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"recv sync-append-entries, fake match2, pre-index:%ld, pre-term:%lu, datalen:%d", pMsg->prevLogIndex,
|
||||
pMsg->prevLogTerm, pMsg->dataLen);
|
||||
syncNodeEventLog(ths, logBuf);
|
||||
} while (0);
|
||||
|
||||
SyncIndex matchIndex = ths->commitIndex;
|
||||
bool hasAppendEntries = pMsg->dataLen > 0;
|
||||
|
@ -605,6 +590,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
code = syncNodePreCommit(ths, pAppendEntry);
|
||||
ASSERT(code == 0);
|
||||
|
||||
// update match index
|
||||
matchIndex = pMsg->prevLogIndex + 1;
|
||||
|
||||
syncEntryDestory(pAppendEntry);
|
||||
|
@ -650,11 +636,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
bool condition = condition1 || condition2;
|
||||
|
||||
if (condition) {
|
||||
sTrace(
|
||||
"recv SyncAppendEntries, not match, syncLogBeginIndex:%ld, syncLogEndIndex:%ld, condition1:%d, "
|
||||
"condition2:%d, logOK:%d",
|
||||
ths->pLogStore->syncLogBeginIndex(ths->pLogStore), ths->pLogStore->syncLogEndIndex(ths->pLogStore),
|
||||
condition1, condition2, logOK);
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, not match, pre-index:%ld, pre-term:%lu, datalen:%d",
|
||||
pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen);
|
||||
syncNodeEventLog(ths, logBuf);
|
||||
|
||||
// prepare response msg
|
||||
SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId);
|
||||
|
@ -693,8 +678,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
|
|||
// has entries in SyncAppendEntries msg
|
||||
bool hasAppendEntries = pMsg->dataLen > 0;
|
||||
|
||||
sTrace("recv SyncAppendEntries, match, myLastIndex:%ld, hasExtraEntries:%d, hasAppendEntries:%d", myLastIndex,
|
||||
hasExtraEntries, hasAppendEntries);
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, match, pre-index:%ld, pre-term:%lu, datalen:%d",
|
||||
pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen);
|
||||
syncNodeEventLog(ths, logBuf);
|
||||
|
||||
if (hasExtraEntries) {
|
||||
// make log same, rollback deleted entries
|
||||
|
|
|
@ -101,32 +101,27 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
|
|||
int32_t ret = 0;
|
||||
|
||||
// print log
|
||||
char logBuf[128] = {0};
|
||||
snprintf(logBuf, sizeof(logBuf), "recv SyncAppendEntriesReply, vgId:%d, term:%lu", ths->vgId,
|
||||
ths->pRaftStore->currentTerm);
|
||||
syncAppendEntriesReplyLog2(logBuf, pMsg);
|
||||
syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplySnapshotCb==", pMsg);
|
||||
|
||||
// if already drop replica, do not process
|
||||
if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) {
|
||||
sInfo("recv SyncAppendEntriesReply, maybe replica already dropped");
|
||||
return ret;
|
||||
syncNodeEventLog(ths, "recv sync-append-entries-reply, maybe replica already dropped");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// drop stale response
|
||||
if (pMsg->term < ths->pRaftStore->currentTerm) {
|
||||
sTrace("recv SyncAppendEntriesReply, drop stale response, receive_term:%lu current_term:%lu", pMsg->term,
|
||||
ths->pRaftStore->currentTerm);
|
||||
return ret;
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%lu, drop stale response", pMsg->term);
|
||||
syncNodeEventLog(ths, logBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
syncIndexMgrLog2("recv SyncAppendEntriesReply, before pNextIndex:", ths->pNextIndex);
|
||||
syncIndexMgrLog2("recv SyncAppendEntriesReply, before pMatchIndex:", ths->pMatchIndex);
|
||||
if (gRaftDetailLog) {
|
||||
SSnapshot snapshot;
|
||||
ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot);
|
||||
sTrace("recv SyncAppendEntriesReply, before snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu",
|
||||
snapshot.lastApplyIndex, snapshot.lastApplyTerm);
|
||||
syncNodeEventLog(ths, "recv sync-append-entries-reply, before");
|
||||
}
|
||||
syncIndexMgrLog2("recv sync-append-entries-reply, before pNextIndex:", ths->pNextIndex);
|
||||
syncIndexMgrLog2("recv sync-append-entries-reply, before pMatchIndex:", ths->pMatchIndex);
|
||||
|
||||
// no need this code, because if I receive reply.term, then I must have sent for that term.
|
||||
// if (pMsg->term > ths->pRaftStore->currentTerm) {
|
||||
|
@ -134,12 +129,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
|
|||
// }
|
||||
|
||||
if (pMsg->term > ths->pRaftStore->currentTerm) {
|
||||
char logBuf[128] = {0};
|
||||
snprintf(logBuf, sizeof(logBuf), "recv SyncAppendEntriesReply, error term, receive_term:%lu current_term:%lu",
|
||||
pMsg->term, ths->pRaftStore->currentTerm);
|
||||
syncNodeLog2(logBuf, ths);
|
||||
sError("%s", logBuf);
|
||||
return ret;
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%lu", pMsg->term);
|
||||
syncNodeErrorLog(ths, logBuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(pMsg->term == ths->pRaftStore->currentTerm);
|
||||
|
@ -228,8 +221,11 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
|
|||
}
|
||||
}
|
||||
|
||||
syncIndexMgrLog2("recv SyncAppendEntriesReply, after pNextIndex:", ths->pNextIndex);
|
||||
syncIndexMgrLog2("recv SyncAppendEntriesReply, after pMatchIndex:", ths->pMatchIndex);
|
||||
if (gRaftDetailLog) {
|
||||
syncNodeEventLog(ths, "recv sync-append-entries-reply, after");
|
||||
}
|
||||
syncIndexMgrLog2("recv sync-append-entries-reply, after pNextIndex:", ths->pNextIndex);
|
||||
syncIndexMgrLog2("recv sync-append-entries-reply, after pMatchIndex:", ths->pMatchIndex);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -416,7 +416,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
|
|||
}
|
||||
}
|
||||
sMeta->lastConfigIndex = lastIndex;
|
||||
sTrace("vgId:%d, get snapshot meta by index:%" PRId64 " lastConfigIndex:%" PRId64, pSyncNode->vgId, snapshotIndex,
|
||||
sTrace("vgId:%d, get snapshot meta by index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, snapshotIndex,
|
||||
sMeta->lastConfigIndex);
|
||||
|
||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||
|
@ -433,8 +433,9 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
|
|||
lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i];
|
||||
}
|
||||
}
|
||||
sTrace("vgId:%d, sync get snapshot last config index, index:%ld lcindex:%ld", pSyncNode->vgId, snapshotLastApplyIndex,
|
||||
lastIndex);
|
||||
|
||||
sTrace("sync syncNodeGetSnapshotConfigIndex index:%ld lastConfigIndex:%ld", snapshotLastApplyIndex, lastIndex);
|
||||
return lastIndex;
|
||||
}
|
||||
|
||||
|
@ -1310,6 +1311,10 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
|||
SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore);
|
||||
|
||||
char* pCfgStr = syncCfg2SimpleStr(&(pSyncNode->pRaftCfg->cfg));
|
||||
char* printStr = "";
|
||||
if (pCfgStr != NULL) {
|
||||
printStr = pCfgStr;
|
||||
}
|
||||
|
||||
if (userStrLen < 256) {
|
||||
char logBuf[256 + 256];
|
||||
|
@ -1317,11 +1322,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
|||
snprintf(logBuf, sizeof(logBuf),
|
||||
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
|
||||
"replica-num:%d, "
|
||||
"lconfig:%ld, changing:%d, %s",
|
||||
"lconfig:%ld, changing:%d, restore:%d, %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex,
|
||||
pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
pSyncNode->changing, pCfgStr);
|
||||
pSyncNode->changing, pSyncNode->restoreFinish, printStr);
|
||||
} else {
|
||||
snprintf(logBuf, sizeof(logBuf), "%s", str);
|
||||
}
|
||||
|
@ -1334,11 +1339,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
|||
snprintf(s, len,
|
||||
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
|
||||
"replica-num:%d, "
|
||||
"lconfig:%ld, changing:%d, %s",
|
||||
"lconfig:%ld, changing:%d, restore:%d, %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex,
|
||||
pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
pSyncNode->changing, pCfgStr);
|
||||
pSyncNode->changing, pSyncNode->restoreFinish, printStr);
|
||||
} else {
|
||||
snprintf(s, len, "%s", str);
|
||||
}
|
||||
|
@ -1398,14 +1403,34 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
|
|||
char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
|
||||
int len = 256;
|
||||
char* s = (char*)taosMemoryMalloc(len);
|
||||
|
||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||
if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
}
|
||||
SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
|
||||
SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore);
|
||||
|
||||
snprintf(s, len,
|
||||
"syncNode: vgId:%d, currentTerm:%lu, commitIndex:%ld, state:%d %s, isStandBy:%d, "
|
||||
"electTimerLogicClock:%lu, "
|
||||
"electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d, replicaNum:%d",
|
||||
pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state,
|
||||
syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock,
|
||||
pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum);
|
||||
"vgId:%d, sync %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
|
||||
"replica-num:%d, "
|
||||
"lconfig:%ld, changing:%d, restore:%d",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy,
|
||||
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
|
||||
|
||||
/*
|
||||
snprintf(s, len,
|
||||
"syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, "
|
||||
"lc:%lu, "
|
||||
"lc-user:%lu, "
|
||||
"ems:%d, replica-num:%d, restore:%d, changing:%d",
|
||||
pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state,
|
||||
syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock,
|
||||
pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum,
|
||||
pSyncNode->restoreFinish, pSyncNode->changing);
|
||||
*/
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -1957,17 +1982,21 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
|
|||
taosMemoryFree(pPreEntry);
|
||||
return preTerm;
|
||||
} else {
|
||||
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1};
|
||||
if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
if (snapshot.lastApplyIndex == preIndex) {
|
||||
return snapshot.lastApplyTerm;
|
||||
}
|
||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1};
|
||||
if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
if (snapshot.lastApplyIndex == preIndex) {
|
||||
return snapshot.lastApplyTerm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "sync node get pre term error, index:%ld", index);
|
||||
syncNodeErrorLog(pSyncNode, logBuf);
|
||||
} while (0);
|
||||
|
||||
return SYNC_TERM_INVALID;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,26 +107,30 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) {
|
|||
}
|
||||
|
||||
char *syncCfg2SimpleStr(SSyncCfg *pSyncCfg) {
|
||||
int32_t len = 512;
|
||||
char *s = taosMemoryMalloc(len);
|
||||
memset(s, 0, len);
|
||||
if (pSyncCfg != NULL) {
|
||||
int32_t len = 512;
|
||||
char *s = taosMemoryMalloc(len);
|
||||
memset(s, 0, len);
|
||||
|
||||
snprintf(s, len, "{replica-num:%d, my-index:%d, ", pSyncCfg->replicaNum, pSyncCfg->myIndex);
|
||||
char *p = s + strlen(s);
|
||||
for (int i = 0; i < pSyncCfg->replicaNum; ++i) {
|
||||
/*
|
||||
if (p + 128 + 32 > s + len) {
|
||||
break;
|
||||
snprintf(s, len, "{replica-num:%d, my-index:%d, ", pSyncCfg->replicaNum, pSyncCfg->myIndex);
|
||||
char *p = s + strlen(s);
|
||||
for (int i = 0; i < pSyncCfg->replicaNum; ++i) {
|
||||
/*
|
||||
if (p + 128 + 32 > s + len) {
|
||||
break;
|
||||
}
|
||||
*/
|
||||
char buf[128 + 32];
|
||||
snprintf(buf, sizeof(buf), "%s:%d, ", pSyncCfg->nodeInfo[i].nodeFqdn, pSyncCfg->nodeInfo[i].nodePort);
|
||||
strncpy(p, buf, sizeof(buf));
|
||||
p = s + strlen(s);
|
||||
}
|
||||
*/
|
||||
char buf[128 + 32];
|
||||
snprintf(buf, sizeof(buf), "%s:%d, ", pSyncCfg->nodeInfo[i].nodeFqdn, pSyncCfg->nodeInfo[i].nodePort);
|
||||
strncpy(p, buf, sizeof(buf));
|
||||
p = s + strlen(s);
|
||||
}
|
||||
strcpy(p - 2, "}");
|
||||
strcpy(p - 2, "}");
|
||||
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg) {
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "syncRaftLog.h"
|
||||
#include "syncRaftCfg.h"
|
||||
#include "syncRaftStore.h"
|
||||
#include "wal.h"
|
||||
|
||||
// refactor, log[0 .. n] ==> log[m .. n]
|
||||
static int32_t raftLogSetBeginIndex(struct SSyncLogStore* pLogStore, SyncIndex beginIndex);
|
||||
static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex);
|
||||
// static int32_t raftLogSetBeginIndex(struct SSyncLogStore* pLogStore, SyncIndex beginIndex);
|
||||
static SyncIndex raftLogBeginIndex(struct SSyncLogStore* pLogStore);
|
||||
static SyncIndex raftLogEndIndex(struct SSyncLogStore* pLogStore);
|
||||
static SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore);
|
||||
|
@ -45,31 +45,43 @@ static int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncI
|
|||
static SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore);
|
||||
|
||||
// refactor, log[0 .. n] ==> log[m .. n]
|
||||
/*
|
||||
static int32_t raftLogSetBeginIndex(struct SSyncLogStore* pLogStore, SyncIndex beginIndex) {
|
||||
sTrace("raftLogSetBeginIndex beginIndex:%ld", beginIndex);
|
||||
|
||||
// if beginIndex == 0, donot need call this funciton
|
||||
ASSERT(beginIndex > 0);
|
||||
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
sTrace("vgId:%d, reset wal begin index:%ld", pData->pSyncNode->vgId, beginIndex);
|
||||
|
||||
pData->beginIndex = beginIndex;
|
||||
walRestoreFromSnapshot(pWal, beginIndex - 1);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex) {
|
||||
ASSERT(snapshotIndex >= 0);
|
||||
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
walRestoreFromSnapshot(pWal, snapshotIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SyncIndex raftLogBeginIndex(struct SSyncLogStore* pLogStore) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
return pData->beginIndex;
|
||||
SyncIndex firstVer = walGetFirstVer(pWal);
|
||||
return firstVer;
|
||||
}
|
||||
|
||||
static SyncIndex raftLogEndIndex(struct SSyncLogStore* pLogStore) { return raftLogLastIndex(pLogStore); }
|
||||
|
||||
static bool raftLogIsEmpty(struct SSyncLogStore* pLogStore) {
|
||||
SyncIndex beginIndex = raftLogBeginIndex(pLogStore);
|
||||
SyncIndex endIndex = raftLogEndIndex(pLogStore);
|
||||
return (endIndex < beginIndex);
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
return walIsEmpty(pWal);
|
||||
}
|
||||
|
||||
static int32_t raftLogEntryCount(struct SSyncLogStore* pLogStore) {
|
||||
|
@ -96,23 +108,8 @@ static SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
SyncIndex lastVer = walGetLastVer(pWal);
|
||||
SyncIndex firstVer = walGetFirstVer(pWal);
|
||||
|
||||
if (lastVer < firstVer) {
|
||||
// no record
|
||||
lastIndex = -1;
|
||||
|
||||
} else {
|
||||
if (firstVer >= 0) {
|
||||
lastIndex = lastVer;
|
||||
} else if (firstVer == -1) {
|
||||
lastIndex = -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
return lastIndex;
|
||||
return lastVer;
|
||||
}
|
||||
|
||||
static SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore) {
|
||||
|
@ -122,6 +119,26 @@ static SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore) {
|
|||
return lastVer + 1;
|
||||
}
|
||||
|
||||
static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
if (walIsEmpty(pWal)) {
|
||||
return 0;
|
||||
} else {
|
||||
SSyncRaftEntry* pLastEntry;
|
||||
int32_t code = raftLogGetLastEntry(pLogStore, &pLastEntry);
|
||||
ASSERT(code == 0);
|
||||
ASSERT(pLastEntry != NULL);
|
||||
|
||||
SyncTerm lastTerm = pLastEntry->term;
|
||||
taosMemoryFree(pLastEntry);
|
||||
return lastTerm;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) {
|
||||
SyncTerm lastTerm = 0;
|
||||
if (raftLogEntryCount(pLogStore) == 0) {
|
||||
|
@ -137,6 +154,7 @@ static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) {
|
|||
}
|
||||
return lastTerm;
|
||||
}
|
||||
*/
|
||||
|
||||
static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
|
@ -160,8 +178,12 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
|
|||
const char* errStr = tstrerror(err);
|
||||
int32_t sysErr = errno;
|
||||
const char* sysErrStr = strerror(errno);
|
||||
sError("vgId:%d wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId,
|
||||
pEntry->index, err, err, errStr, sysErr, sysErrStr);
|
||||
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s",
|
||||
pEntry->index, err, err, errStr, sysErr, sysErrStr);
|
||||
syncNodeErrorLog(pData->pSyncNode, logBuf);
|
||||
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
@ -229,7 +251,8 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index,
|
|||
|
||||
*ppEntry = NULL;
|
||||
|
||||
SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
|
||||
// SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
|
||||
SWalReadHandle* pWalHandle = pData->pWalHandle;
|
||||
if (pWalHandle == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -240,12 +263,23 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index,
|
|||
const char* errStr = tstrerror(err);
|
||||
int32_t sysErr = errno;
|
||||
const char* sysErrStr = strerror(errno);
|
||||
sError("vgId:%d wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, index,
|
||||
err, err, errStr, sysErr, sysErrStr);
|
||||
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
do {
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, err,
|
||||
err, errStr, sysErr, sysErrStr);
|
||||
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||
syncNodeEventLog(pData->pSyncNode, logBuf);
|
||||
} else {
|
||||
syncNodeErrorLog(pData->pSyncNode, logBuf);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
/*
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
*/
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -261,9 +295,11 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index,
|
|||
ASSERT((*ppEntry)->dataLen == pWalHandle->pHead->head.bodyLen);
|
||||
memcpy((*ppEntry)->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen);
|
||||
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
/*
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
*/
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -285,6 +321,25 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
ASSERT(ppLastEntry != NULL);
|
||||
|
||||
*ppLastEntry = NULL;
|
||||
if (walIsEmpty(pWal)) {
|
||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||
return -1;
|
||||
} else {
|
||||
SyncIndex lastIndex = raftLogLastIndex(pLogStore);
|
||||
int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry);
|
||||
return code;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry) {
|
||||
*ppLastEntry = NULL;
|
||||
if (raftLogEntryCount(pLogStore) == 0) {
|
||||
|
@ -294,6 +349,7 @@ static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** pp
|
|||
int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry);
|
||||
return code;
|
||||
}
|
||||
*/
|
||||
|
||||
//-------------------------------
|
||||
SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
||||
|
@ -306,16 +362,22 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
pData->pSyncNode = pSyncNode;
|
||||
pData->pWal = pSyncNode->pWal;
|
||||
ASSERT(pData->pWal != NULL);
|
||||
|
||||
SyncIndex firstVer = walGetFirstVer(pData->pWal);
|
||||
SyncIndex lastVer = walGetLastVer(pData->pWal);
|
||||
if (firstVer >= 0) {
|
||||
pData->beginIndex = firstVer;
|
||||
} else if (firstVer == -1) {
|
||||
pData->beginIndex = lastVer + 1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
pData->pWalHandle = walOpenReadHandle(pData->pWal);
|
||||
ASSERT(pData->pWalHandle != NULL);
|
||||
|
||||
/*
|
||||
SyncIndex firstVer = walGetFirstVer(pData->pWal);
|
||||
SyncIndex lastVer = walGetLastVer(pData->pWal);
|
||||
if (firstVer >= 0) {
|
||||
pData->beginIndex = firstVer;
|
||||
} else if (firstVer == -1) {
|
||||
pData->beginIndex = lastVer + 1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
*/
|
||||
|
||||
pLogStore->appendEntry = logStoreAppendEntry;
|
||||
pLogStore->getEntry = logStoreGetEntry;
|
||||
|
@ -325,7 +387,8 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
pLogStore->updateCommitIndex = logStoreUpdateCommitIndex;
|
||||
pLogStore->getCommitIndex = logStoreGetCommitIndex;
|
||||
|
||||
pLogStore->syncLogSetBeginIndex = raftLogSetBeginIndex;
|
||||
// pLogStore->syncLogSetBeginIndex = raftLogSetBeginIndex;
|
||||
pLogStore->syncLogRestoreFromSnapshot = raftLogRestoreFromSnapshot;
|
||||
pLogStore->syncLogBeginIndex = raftLogBeginIndex;
|
||||
pLogStore->syncLogEndIndex = raftLogEndIndex;
|
||||
pLogStore->syncLogIsEmpty = raftLogIsEmpty;
|
||||
|
@ -344,6 +407,11 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
|
||||
void logStoreDestory(SSyncLogStore* pLogStore) {
|
||||
if (pLogStore != NULL) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
if (pData->pWalHandle != NULL) {
|
||||
walCloseReadHandle(pData->pWalHandle);
|
||||
}
|
||||
|
||||
taosMemoryFree(pLogStore->data);
|
||||
taosMemoryFree(pLogStore);
|
||||
}
|
||||
|
@ -368,8 +436,11 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
|
|||
const char* errStr = tstrerror(err);
|
||||
int32_t sysErr = errno;
|
||||
const char* sysErrStr = strerror(errno);
|
||||
sError("vgId:%d wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId,
|
||||
pEntry->index, err, err, errStr, sysErr, sysErrStr);
|
||||
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s",
|
||||
pEntry->index, err, err, errStr, sysErr, sysErrStr);
|
||||
syncNodeErrorLog(pData->pSyncNode, logBuf);
|
||||
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -389,7 +460,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
SWal* pWal = pData->pWal;
|
||||
|
||||
if (index >= SYNC_INDEX_BEGIN && index <= logStoreLastIndex(pLogStore)) {
|
||||
SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
|
||||
// SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
|
||||
SWalReadHandle* pWalHandle = pData->pWalHandle;
|
||||
ASSERT(pWalHandle != NULL);
|
||||
|
||||
int32_t code = walReadWithHandle(pWalHandle, index);
|
||||
|
@ -398,12 +470,20 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
const char* errStr = tstrerror(err);
|
||||
int32_t sysErr = errno;
|
||||
const char* sysErrStr = strerror(errno);
|
||||
sError("vgId:%d wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId,
|
||||
index, err, err, errStr, sysErr, sysErrStr);
|
||||
|
||||
do {
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index,
|
||||
err, err, errStr, sysErr, sysErrStr);
|
||||
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||
syncNodeEventLog(pData->pSyncNode, logBuf);
|
||||
} else {
|
||||
syncNodeErrorLog(pData->pSyncNode, logBuf);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
ASSERT(0);
|
||||
}
|
||||
// ASSERT(walReadWithHandle(pWalHandle, index) == 0);
|
||||
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(pWalHandle->pHead->head.bodyLen);
|
||||
ASSERT(pEntry != NULL);
|
||||
|
@ -417,9 +497,11 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
ASSERT(pEntry->dataLen == pWalHandle->pHead->head.bodyLen);
|
||||
memcpy(pEntry->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen);
|
||||
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
/*
|
||||
int32_t saveErr = terrno;
|
||||
walCloseReadHandle(pWalHandle);
|
||||
terrno = saveErr;
|
||||
*/
|
||||
|
||||
return pEntry;
|
||||
|
||||
|
@ -498,6 +580,7 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) {
|
|||
return pEntry;
|
||||
}
|
||||
|
||||
/*
|
||||
cJSON* logStore2Json(SSyncLogStore* pLogStore) {
|
||||
char u64buf[128] = {0};
|
||||
SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data;
|
||||
|
@ -544,6 +627,57 @@ cJSON* logStore2Json(SSyncLogStore* pLogStore) {
|
|||
cJSON_AddItemToObject(pJson, "SSyncLogStore", pRoot);
|
||||
return pJson;
|
||||
}
|
||||
*/
|
||||
|
||||
cJSON* logStore2Json(SSyncLogStore* pLogStore) {
|
||||
char u64buf[128] = {0};
|
||||
SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data;
|
||||
cJSON* pRoot = cJSON_CreateObject();
|
||||
|
||||
if (pData != NULL && pData->pWal != NULL) {
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode);
|
||||
cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal);
|
||||
cJSON_AddStringToObject(pRoot, "pWal", u64buf);
|
||||
|
||||
SyncIndex beginIndex = raftLogBeginIndex(pLogStore);
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", beginIndex);
|
||||
cJSON_AddStringToObject(pRoot, "beginIndex", u64buf);
|
||||
|
||||
SyncIndex endIndex = raftLogEndIndex(pLogStore);
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", endIndex);
|
||||
cJSON_AddStringToObject(pRoot, "endIndex", u64buf);
|
||||
|
||||
int32_t count = raftLogEntryCount(pLogStore);
|
||||
cJSON_AddNumberToObject(pRoot, "entryCount", count);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", raftLogWriteIndex(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "WriteIndex", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%d", raftLogIsEmpty(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "IsEmpty", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", raftLogLastIndex(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "LastIndex", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", raftLogLastTerm(pLogStore));
|
||||
cJSON_AddStringToObject(pRoot, "LastTerm", u64buf);
|
||||
|
||||
cJSON* pEntries = cJSON_CreateArray();
|
||||
cJSON_AddItemToObject(pRoot, "pEntries", pEntries);
|
||||
|
||||
if (!raftLogIsEmpty(pLogStore)) {
|
||||
for (SyncIndex i = beginIndex; i <= endIndex; ++i) {
|
||||
SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i);
|
||||
cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry));
|
||||
syncEntryDestory(pEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cJSON* pJson = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(pJson, "SSyncLogStore", pRoot);
|
||||
return pJson;
|
||||
}
|
||||
|
||||
char* logStore2Str(SSyncLogStore* pLogStore) {
|
||||
cJSON* pJson = logStore2Json(pLogStore);
|
||||
|
@ -563,7 +697,8 @@ cJSON* logStoreSimple2Json(SSyncLogStore* pLogStore) {
|
|||
snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal);
|
||||
cJSON_AddStringToObject(pRoot, "pWal", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", pData->beginIndex);
|
||||
SyncIndex beginIndex = raftLogBeginIndex(pLogStore);
|
||||
snprintf(u64buf, sizeof(u64buf), "%ld", beginIndex);
|
||||
cJSON_AddStringToObject(pRoot, "beginIndex", u64buf);
|
||||
|
||||
SyncIndex endIndex = raftLogEndIndex(pLogStore);
|
||||
|
|
|
@ -219,6 +219,17 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
|
|||
int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntries* pMsg) {
|
||||
int32_t ret = 0;
|
||||
|
||||
do {
|
||||
char host[128];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port);
|
||||
sDebug(
|
||||
"vgId:%d, send sync-append-entries to %s:%d, term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, commit:%ld, "
|
||||
"datalen:%d",
|
||||
pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm,
|
||||
pMsg->commitIndex, pMsg->dataLen);
|
||||
} while (0);
|
||||
|
||||
SRpcMsg rpcMsg;
|
||||
syncAppendEntries2RpcMsg(pMsg, &rpcMsg);
|
||||
syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg);
|
||||
|
|
|
@ -545,7 +545,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
|||
pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex;
|
||||
}
|
||||
|
||||
pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1);
|
||||
// pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1);
|
||||
pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pSyncNode->pLogStore, pMsg->lastIndex);
|
||||
|
||||
// maybe update lastconfig
|
||||
if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) {
|
||||
|
|
|
@ -113,7 +113,8 @@ void test2() {
|
|||
pLogStore = logStoreCreate(pSyncNode);
|
||||
assert(pLogStore);
|
||||
pSyncNode->pLogStore = pLogStore;
|
||||
pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
|
||||
logStoreLog2((char*)"\n\n\ntest2 ----- ", pLogStore);
|
||||
|
||||
if (gAssert) {
|
||||
|
@ -228,7 +229,8 @@ void test4() {
|
|||
assert(pLogStore);
|
||||
pSyncNode->pLogStore = pLogStore;
|
||||
logStoreLog2((char*)"\n\n\ntest4 ----- ", pLogStore);
|
||||
pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
|
||||
|
||||
for (int i = 5; i <= 9; ++i) {
|
||||
int32_t dataLen = 10;
|
||||
|
@ -289,7 +291,8 @@ void test5() {
|
|||
assert(pLogStore);
|
||||
pSyncNode->pLogStore = pLogStore;
|
||||
logStoreLog2((char*)"\n\n\ntest5 ----- ", pLogStore);
|
||||
pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
|
||||
|
||||
for (int i = 5; i <= 9; ++i) {
|
||||
int32_t dataLen = 10;
|
||||
|
@ -363,7 +366,8 @@ void test6() {
|
|||
assert(pLogStore);
|
||||
pSyncNode->pLogStore = pLogStore;
|
||||
logStoreLog2((char*)"\n\n\ntest6 ----- ", pLogStore);
|
||||
pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
|
||||
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
|
||||
|
||||
for (int i = 5; i <= 9; ++i) {
|
||||
int32_t dataLen = 10;
|
||||
|
@ -405,14 +409,32 @@ void test6() {
|
|||
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
|
||||
}
|
||||
|
||||
do {
|
||||
SyncIndex firstVer = walGetFirstVer(pWal);
|
||||
SyncIndex lastVer = walGetLastVer(pWal);
|
||||
bool isEmpty = walIsEmpty(pWal);
|
||||
printf("before -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty);
|
||||
} while (0);
|
||||
|
||||
logStoreDestory(pLogStore);
|
||||
cleanup();
|
||||
|
||||
|
||||
|
||||
// restart
|
||||
init();
|
||||
pLogStore = logStoreCreate(pSyncNode);
|
||||
assert(pLogStore);
|
||||
pSyncNode->pLogStore = pLogStore;
|
||||
|
||||
|
||||
do {
|
||||
SyncIndex firstVer = walGetFirstVer(pWal);
|
||||
SyncIndex lastVer = walGetLastVer(pWal);
|
||||
bool isEmpty = walIsEmpty(pWal);
|
||||
printf("after -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty);
|
||||
} while (0);
|
||||
|
||||
logStoreLog2((char*)"\n\n\ntest6 restart ----- ", pLogStore);
|
||||
|
||||
if (gAssert) {
|
||||
|
@ -432,17 +454,20 @@ void test6() {
|
|||
int main(int argc, char** argv) {
|
||||
tsAsyncLog = 0;
|
||||
sDebugFlag = DEBUG_TRACE + DEBUG_INFO + DEBUG_SCREEN + DEBUG_FILE;
|
||||
gRaftDetailLog = true;
|
||||
|
||||
if (argc == 2) {
|
||||
gAssert = atoi(argv[1]);
|
||||
}
|
||||
sTrace("gAssert : %d", gAssert);
|
||||
|
||||
/*
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
*/
|
||||
test6();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -312,7 +312,8 @@ void test5() {
|
|||
pSyncNode->pLogStore = pLogStore;
|
||||
logStoreLog2((char*)"\n\n\ntest5 ----- ", pLogStore);
|
||||
|
||||
pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, 6);
|
||||
//pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, 6);
|
||||
pLogStore->syncLogRestoreFromSnapshot(pSyncNode->pLogStore, 5);
|
||||
for (int i = 6; i <= 10; ++i) {
|
||||
int32_t dataLen = 10;
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
|
||||
|
@ -372,6 +373,7 @@ void test5() {
|
|||
int main(int argc, char** argv) {
|
||||
tsAsyncLog = 0;
|
||||
sDebugFlag = DEBUG_TRACE + DEBUG_INFO + DEBUG_SCREEN + DEBUG_FILE;
|
||||
gRaftDetailLog = true;
|
||||
|
||||
if (argc == 2) {
|
||||
gAssert = atoi(argv[1]);
|
||||
|
|
|
@ -272,14 +272,23 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
|
|||
}
|
||||
}
|
||||
|
||||
if (ver > pRead->pWal->vers.lastVer || ver < pRead->pWal->vers.firstVer) {
|
||||
wError("invalid version: % " PRId64 ", first ver %ld, last ver %ld", ver, pRead->pWal->vers.firstVer,
|
||||
pRead->pWal->vers.lastVer);
|
||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(taosValidFile(pRead->pReadLogTFile) == true);
|
||||
|
||||
code = taosReadFile(pRead->pReadLogTFile, pRead->pHead, sizeof(SWalHead));
|
||||
if (code != sizeof(SWalHead)) {
|
||||
if (code < 0)
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
else
|
||||
else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
ASSERT(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -304,8 +313,10 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
|
|||
pRead->pHead->head.bodyLen) {
|
||||
if (code < 0)
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
else
|
||||
else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
ASSERT(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
ASSERT(code == 0);
|
||||
if (code != 0) {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
if (head.head.version != ver) {
|
||||
|
|
|
@ -21,45 +21,39 @@ class ClusterDnodes(TDDnodes):
|
|||
self.testCluster = False
|
||||
self.valgrind = 0
|
||||
self.killValgrind = 1
|
||||
self.independent = True
|
||||
self.dnodeNums = 5
|
||||
|
||||
# def getTDDnodes(dnodeNums):
|
||||
|
||||
# return
|
||||
|
||||
|
||||
class ConfigureyCluster:
|
||||
"""configure dnodes and return TDDnodes list, it can """
|
||||
"""This will create defined number of dnodes and create a cluset.
|
||||
at the same time, it will return TDDnodes list: dnodes, """
|
||||
hostname= socket.gethostname()
|
||||
|
||||
def __init__(self):
|
||||
self.dnodes = None
|
||||
self.dnodes_nums = 5
|
||||
self.dnodes = []
|
||||
self.dnodeNums = 5
|
||||
self.independent = True
|
||||
self.start_port = 6030
|
||||
self.startPort = 6030
|
||||
self.portStep = 100
|
||||
hostname1= socket.gethostname()
|
||||
self.mnodeNums = 0
|
||||
|
||||
def configure_cluster(self ,dnodes_nums=5,independent=True,start_port=6030,portStep=100,hostname="%s"%hostname1):
|
||||
self.start_port=int(start_port)
|
||||
def configure_cluster(self ,dnodeNums=5,mnodeNums=0,startPort=6030,portStep=100,hostname="%s"%hostname):
|
||||
self.startPort=int(startPort)
|
||||
self.portStep=int(portStep)
|
||||
self.hostname=hostname
|
||||
self.dnodes_nums = int(dnodes_nums)
|
||||
self.independent = independent
|
||||
self.dnodeNums = int(dnodeNums)
|
||||
self.mnodeNums = int(mnodeNums)
|
||||
self.dnodes = []
|
||||
start_port_sec = 6130
|
||||
for num in range(1, (self.dnodes_nums+1)):
|
||||
startPort_sec = int(startPort+portStep)
|
||||
for num in range(1, (self.dnodeNums+1)):
|
||||
dnode = TDDnode(num)
|
||||
dnode.addExtraCfg("firstEp", f"{hostname}:{self.start_port}")
|
||||
dnode.addExtraCfg("firstEp", f"{hostname}:{self.startPort}")
|
||||
dnode.addExtraCfg("fqdn", f"{hostname}")
|
||||
dnode.addExtraCfg("serverPort", f"{self.start_port + (num-1)*self.portStep}")
|
||||
# dnode.addExtraCfg("monitorFqdn", hostname)
|
||||
# dnode.addExtraCfg("monitorPort", 7043)
|
||||
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||
# configure three dnoe don't support vnodes
|
||||
if self.dnodes_nums > 4 :
|
||||
if self.independent and (num < 4):
|
||||
dnode.addExtraCfg("supportVnodes", 0)
|
||||
dnode.addExtraCfg("serverPort", f"{self.startPort + (num-1)*self.portStep}")
|
||||
dnode.addExtraCfg("secondEp", f"{hostname}:{startPort_sec}")
|
||||
|
||||
# configure dnoe of independent mnodes
|
||||
if num <= self.mnodeNums and self.mnodeNums != 0 :
|
||||
dnode.addExtraCfg("supportVnodes", 0)
|
||||
# print(dnode)
|
||||
self.dnodes.append(dnode)
|
||||
return self.dnodes
|
||||
|
@ -69,24 +63,7 @@ class ConfigureyCluster:
|
|||
for dnode in self.dnodes[1:]:
|
||||
# print(dnode.cfgDict)
|
||||
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
|
||||
print(dnode_id)
|
||||
tdSql.execute(" create dnode '%s';"%dnode_id)
|
||||
# count=0
|
||||
# while count < 10:
|
||||
# time.sleep(1)
|
||||
# tdSql.query("show dnodes;")
|
||||
# if tdSql.checkRows(self.dnodes_nums) :
|
||||
# print("mnode is three nodes")
|
||||
# if tdSql.queryResult[0][4]=='leader' :
|
||||
# if tdSql.queryResult[2][4]=='offline':
|
||||
# if tdSql.queryResult[1][2]=='follower':
|
||||
# print("stop mnodes on dnode 3 successfully in 10s")
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("stop mnodes on dnode 3 failed in 10s")
|
||||
# return -1
|
||||
checkstatus=False
|
||||
|
||||
|
||||
|
||||
|
@ -97,206 +74,19 @@ class ConfigureyCluster:
|
|||
tdSql.query("show dnodes")
|
||||
# tdLog.debug(tdSql.queryResult)
|
||||
status=0
|
||||
for i in range(self.dnodes_nums):
|
||||
for i in range(self.dnodeNums):
|
||||
if tdSql.queryResult[i][4] == "ready":
|
||||
status+=1
|
||||
tdLog.debug(status)
|
||||
# tdLog.debug(status)
|
||||
|
||||
if status == self.dnodes_nums:
|
||||
tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodes_nums)
|
||||
if status == self.dnodeNums:
|
||||
tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodeNums)
|
||||
break
|
||||
count+=1
|
||||
time.sleep(1)
|
||||
else:
|
||||
tdLog.debug("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodes_nums)
|
||||
tdLog.debug("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodeNums)
|
||||
return -1
|
||||
|
||||
|
||||
cluster = ConfigureyCluster()
|
||||
|
||||
# def start(self ,dnodes_nums):
|
||||
|
||||
# self.TDDnodes = ClusterDnodes(dnodes)
|
||||
# self.TDDnodes.init("")
|
||||
# self.TDDnodes.setTestCluster(testCluster)
|
||||
# self.TDDnodes.setValgrind(valgrind)
|
||||
# self.TDDnodes.stopAll()
|
||||
# for dnode in self.TDDnodes.dnodes:
|
||||
# self.TDDnodes.deploy(dnode.index,{})
|
||||
|
||||
# for dnode in self.TDDnodes.dnodes:
|
||||
# self.TDDnodes.starttaosd(dnode.index)
|
||||
|
||||
# # create cluster
|
||||
# for dnode in self.TDDnodes.dnodes[1:]:
|
||||
# # print(dnode.cfgDict)
|
||||
# dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
|
||||
# dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0]
|
||||
# dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1]
|
||||
# cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
|
||||
# print(cmd)
|
||||
# os.system(cmd)
|
||||
|
||||
# time.sleep(2)
|
||||
# tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
|
||||
|
||||
# def buildcluster(self,dnodenumber):
|
||||
# self.depoly_cluster(dnodenumber)
|
||||
# self.master_dnode = self.TDDnodes.dnodes[0]
|
||||
# self.host=self.master_dnode.cfgDict["fqdn"]
|
||||
# conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
|
||||
# tdSql.init(conn1.cursor())
|
||||
|
||||
# def checkdnodes(self,dnodenumber):
|
||||
# count=0
|
||||
# while count < 10:
|
||||
# time.sleep(1)
|
||||
# statusReadyBumber=0
|
||||
# tdSql.query("show dnodes;")
|
||||
# if tdSql.checkRows(dnodenumber) :
|
||||
# print("dnode is %d nodes"%dnodenumber)
|
||||
# for i in range(dnodenumber):
|
||||
# if tdSql.queryResult[i][4] !='ready' :
|
||||
# status=tdSql.queryResult[i][4]
|
||||
# print("dnode:%d status is %s "%(i,status))
|
||||
# break
|
||||
# else:
|
||||
# statusReadyBumber+=1
|
||||
# print(statusReadyBumber)
|
||||
# if statusReadyBumber == dnodenumber :
|
||||
# print("all of %d mnodes is ready in 10s "%dnodenumber)
|
||||
# return True
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("%d mnodes is not ready in 10s "%dnodenumber)
|
||||
# return False
|
||||
|
||||
|
||||
# def check3mnode(self):
|
||||
# count=0
|
||||
# while count < 10:
|
||||
# time.sleep(1)
|
||||
# tdSql.query("show mnodes;")
|
||||
# if tdSql.checkRows(3) :
|
||||
# print("mnode is three nodes")
|
||||
# if tdSql.queryResult[0][2]=='leader' :
|
||||
# if tdSql.queryResult[1][2]=='follower':
|
||||
# if tdSql.queryResult[2][2]=='follower':
|
||||
# print("three mnodes is ready in 10s")
|
||||
# break
|
||||
# elif tdSql.queryResult[0][2]=='follower' :
|
||||
# if tdSql.queryResult[1][2]=='leader':
|
||||
# if tdSql.queryResult[2][2]=='follower':
|
||||
# print("three mnodes is ready in 10s")
|
||||
# break
|
||||
# elif tdSql.queryResult[0][2]=='follower' :
|
||||
# if tdSql.queryResult[1][2]=='follower':
|
||||
# if tdSql.queryResult[2][2]=='leader':
|
||||
# print("three mnodes is ready in 10s")
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("three mnodes is not ready in 10s ")
|
||||
# return -1
|
||||
|
||||
# tdSql.query("show mnodes;")
|
||||
# tdSql.checkRows(3)
|
||||
# tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
# tdSql.checkData(0,3,'ready')
|
||||
# tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
# tdSql.checkData(1,3,'ready')
|
||||
# tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||
# tdSql.checkData(2,3,'ready')
|
||||
|
||||
# def check3mnode1off(self):
|
||||
# count=0
|
||||
# while count < 10:
|
||||
# time.sleep(1)
|
||||
# tdSql.query("show mnodes;")
|
||||
# if tdSql.checkRows(3) :
|
||||
# print("mnode is three nodes")
|
||||
# if tdSql.queryResult[0][2]=='offline' :
|
||||
# if tdSql.queryResult[1][2]=='leader':
|
||||
# if tdSql.queryResult[2][2]=='follower':
|
||||
# print("stop mnodes on dnode 2 successfully in 10s")
|
||||
# break
|
||||
# elif tdSql.queryResult[1][2]=='follower':
|
||||
# if tdSql.queryResult[2][2]=='leader':
|
||||
# print("stop mnodes on dnode 2 successfully in 10s")
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("stop mnodes on dnode 2 failed in 10s ")
|
||||
# return -1
|
||||
# tdSql.error("drop mnode on dnode 1;")
|
||||
|
||||
# tdSql.query("show mnodes;")
|
||||
# tdSql.checkRows(3)
|
||||
# tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
# tdSql.checkData(0,2,'offline')
|
||||
# tdSql.checkData(0,3,'ready')
|
||||
# tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
# tdSql.checkData(1,3,'ready')
|
||||
# tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||
# tdSql.checkData(2,3,'ready')
|
||||
|
||||
# def check3mnode2off(self):
|
||||
# count=0
|
||||
# while count < 40:
|
||||
# time.sleep(1)
|
||||
# tdSql.query("show mnodes;")
|
||||
# if tdSql.checkRows(3) :
|
||||
# print("mnode is three nodes")
|
||||
# if tdSql.queryResult[0][2]=='leader' :
|
||||
# if tdSql.queryResult[1][2]=='offline':
|
||||
# if tdSql.queryResult[2][2]=='follower':
|
||||
# print("stop mnodes on dnode 2 successfully in 10s")
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("stop mnodes on dnode 2 failed in 10s ")
|
||||
# return -1
|
||||
# tdSql.error("drop mnode on dnode 2;")
|
||||
|
||||
# tdSql.query("show mnodes;")
|
||||
# tdSql.checkRows(3)
|
||||
# tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
# tdSql.checkData(0,2,'leader')
|
||||
# tdSql.checkData(0,3,'ready')
|
||||
# tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
# tdSql.checkData(1,2,'offline')
|
||||
# tdSql.checkData(1,3,'ready')
|
||||
# tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||
# tdSql.checkData(2,2,'follower')
|
||||
# tdSql.checkData(2,3,'ready')
|
||||
|
||||
# def check3mnode3off(self):
|
||||
# count=0
|
||||
# while count < 10:
|
||||
# time.sleep(1)
|
||||
# tdSql.query("show mnodes;")
|
||||
# if tdSql.checkRows(3) :
|
||||
# print("mnode is three nodes")
|
||||
# if tdSql.queryResult[0][2]=='leader' :
|
||||
# if tdSql.queryResult[2][2]=='offline':
|
||||
# if tdSql.queryResult[1][2]=='follower':
|
||||
# print("stop mnodes on dnode 3 successfully in 10s")
|
||||
# break
|
||||
# count+=1
|
||||
# else:
|
||||
# print("stop mnodes on dnode 3 failed in 10s")
|
||||
# return -1
|
||||
# tdSql.error("drop mnode on dnode 3;")
|
||||
# tdSql.query("show mnodes;")
|
||||
# tdSql.checkRows(3)
|
||||
# tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
# tdSql.checkData(0,2,'leader')
|
||||
# tdSql.checkData(0,3,'ready')
|
||||
# tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
# tdSql.checkData(1,2,'follower')
|
||||
# tdSql.checkData(1,3,'ready')
|
||||
# tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||
# tdSql.checkData(2,2,'offline')
|
||||
# tdSql.checkData(2,3,'ready')
|
||||
|
||||
cluster = ConfigureyCluster()
|
|
@ -12,6 +12,8 @@ sql connect
|
|||
print =============== show dnodes
|
||||
sleep 2000
|
||||
sql create database db vgroups 2;
|
||||
sql use db;
|
||||
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd";
|
||||
sleep 2000
|
||||
|
||||
print =============== create drop qnode 1
|
||||
|
|
|
@ -159,13 +159,10 @@ class TDTestCase:
|
|||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
tdSql.checkData(1,2,'offline')
|
||||
tdSql.checkData(1,3,'ready')
|
||||
tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||
tdSql.checkData(2,2,'follower')
|
||||
tdSql.checkData(2,3,'ready')
|
||||
|
||||
def check3mnode3off(self):
|
||||
|
@ -265,13 +262,6 @@ class TDTestCase:
|
|||
while stopcount <= 2:
|
||||
for i in range(dnodenumber):
|
||||
tdDnodes[i].stoptaosd()
|
||||
# if i == 1 :
|
||||
# self.check3mnode2off()
|
||||
# elif i == 2 :
|
||||
# self.check3mnode3off()
|
||||
# elif i == 0:
|
||||
# self.check3mnode1off()
|
||||
|
||||
tdDnodes[i].starttaosd()
|
||||
# self.check3mnode()
|
||||
stopcount+=1
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
|
||||
from ntpath import join
|
||||
import taos
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import os
|
||||
import threading
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
from util.common import *
|
||||
from util.cluster import *
|
||||
|
||||
sys.path.append("./7-tmq")
|
||||
from tmqCommon import *
|
||||
|
||||
class TDTestCase:
|
||||
def __init__(self):
|
||||
self.dnodes = 5
|
||||
self.mnodes = 3
|
||||
self.idIndex = 0
|
||||
self.roleIndex = 2
|
||||
self.mnodeStatusIndex = 3
|
||||
self.mnodeEpIndex = 1
|
||||
self.dnodeStatusIndex = 4
|
||||
self.mnodeCheckCnt = 10
|
||||
self.host = socket.gethostname()
|
||||
self.startPort = 6030
|
||||
self.portStep = 100
|
||||
self.dnodeOfLeader = 0
|
||||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||
|
||||
def checkDnodesStatusAndCreateMnode(self,dnodeNumbers):
|
||||
count=0
|
||||
while count < dnodeNumbers:
|
||||
tdSql.query("show dnodes")
|
||||
# tdLog.debug(tdSql.queryResult)
|
||||
dCnt = 0
|
||||
for i in range(dnodeNumbers):
|
||||
if tdSql.queryResult[i][self.dnodeStatusIndex] != "ready":
|
||||
break
|
||||
else:
|
||||
dCnt += 1
|
||||
if dCnt == dnodeNumbers:
|
||||
break
|
||||
time.sleep(1)
|
||||
tdLog.debug("............... waiting for all dnodes ready!")
|
||||
|
||||
tdLog.info("==============create two new mnodes ========")
|
||||
tdSql.execute("create mnode on dnode 2")
|
||||
tdSql.execute("create mnode on dnode 3")
|
||||
self.check3mnode()
|
||||
return
|
||||
|
||||
def check3mnode(self):
|
||||
count=0
|
||||
while count < self.mnodeCheckCnt:
|
||||
time.sleep(1)
|
||||
tdSql.query("show mnodes;")
|
||||
if tdSql.checkRows(self.mnodes) :
|
||||
tdLog.debug("mnode is three nodes")
|
||||
else:
|
||||
tdLog.exit("mnode number is correct")
|
||||
|
||||
roleOfMnode0 = tdSql.queryResult[0][self.roleIndex]
|
||||
roleOfMnode1 = tdSql.queryResult[1][self.roleIndex]
|
||||
roleOfMnode2 = tdSql.queryResult[2][self.roleIndex]
|
||||
|
||||
if roleOfMnode0=='leader' and roleOfMnode1=='follower' and roleOfMnode2 == 'follower' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode0=='follower' and roleOfMnode1=='leader' and roleOfMnode2 == 'follower' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode0=='follower' and roleOfMnode1=='follower' and roleOfMnode2 == 'leader' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex]
|
||||
break
|
||||
else:
|
||||
count+=1
|
||||
else:
|
||||
tdLog.exit("three mnodes is not ready in 10s ")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(self.mnodes)
|
||||
tdSql.checkData(0,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort))
|
||||
tdSql.checkData(0,self.mnodeStatusIndex,'ready')
|
||||
tdSql.checkData(1,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort+self.portStep))
|
||||
tdSql.checkData(1,self.mnodeStatusIndex,'ready')
|
||||
tdSql.checkData(2,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort+self.portStep*2))
|
||||
tdSql.checkData(2,self.mnodeStatusIndex,'ready')
|
||||
|
||||
def check3mnode1off(self):
|
||||
count=0
|
||||
while count < self.mnodeCheckCnt:
|
||||
time.sleep(1)
|
||||
tdSql.query("show mnodes")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
# if tdSql.checkRows(self.mnodes) :
|
||||
# tdLog.debug("mnode is three nodes")
|
||||
# else:
|
||||
# tdLog.exit("mnode number is correct")
|
||||
|
||||
roleOfMnode0 = tdSql.queryResult[0][self.roleIndex]
|
||||
roleOfMnode1 = tdSql.queryResult[1][self.roleIndex]
|
||||
roleOfMnode2 = tdSql.queryResult[2][self.roleIndex]
|
||||
|
||||
if roleOfMnode0=='offline' :
|
||||
if roleOfMnode1=='leader' and roleOfMnode2 == 'follower' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode1=='follower' and roleOfMnode2 == 'leader' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode1=='offline' :
|
||||
if roleOfMnode0=='leader' and roleOfMnode2 == 'follower' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode0=='follower' and roleOfMnode2 == 'leader' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode2=='offline' :
|
||||
if roleOfMnode0=='leader' and roleOfMnode1 == 'follower' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex]
|
||||
break
|
||||
elif roleOfMnode0=='follower' and roleOfMnode1 == 'leader' :
|
||||
self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex]
|
||||
break
|
||||
|
||||
count+=1
|
||||
else:
|
||||
tdLog.exit("three mnodes is not ready in 10s ")
|
||||
|
||||
def checkFileContent(self, consumerId, queryString):
|
||||
buildPath = tdCom.getBuildPath()
|
||||
cfgPath = tdCom.getClientCfgPath()
|
||||
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
|
||||
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
|
||||
tdLog.info(cmdStr)
|
||||
os.system(cmdStr)
|
||||
|
||||
consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
|
||||
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))
|
||||
|
||||
consumeFile = open(consumeRowsFile, mode='r')
|
||||
queryFile = open(dstFile, mode='r')
|
||||
|
||||
# skip first line for it is schema
|
||||
queryFile.readline()
|
||||
|
||||
while True:
|
||||
dst = queryFile.readline()
|
||||
src = consumeFile.readline()
|
||||
|
||||
if dst:
|
||||
if dst != src:
|
||||
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
|
||||
else:
|
||||
break
|
||||
return
|
||||
|
||||
def tmqCase1(self):
|
||||
tdLog.printNoPrefix("======== test case 1: ")
|
||||
paraDict = {'dbName': 'db1',
|
||||
'dropFlag': 1,
|
||||
'event': '',
|
||||
'vgroups': 4,
|
||||
'stbName': 'stb',
|
||||
'colPrefix': 'c',
|
||||
'tagPrefix': 't',
|
||||
'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}, {'type': 'TIMESTAMP', 'count':1}],
|
||||
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||
'ctbPrefix': 'ctb',
|
||||
'ctbNum': 1,
|
||||
'rowsPerTbl': 100000,
|
||||
'batchNum': 10,
|
||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||
'pollDelay': 10,
|
||||
'showMsg': 1,
|
||||
'showRow': 1}
|
||||
|
||||
topicNameList = ['topic1']
|
||||
expectRowsList = []
|
||||
tmqCom.initConsumerTable()
|
||||
tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1)
|
||||
tdLog.info("create stb")
|
||||
tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema'])
|
||||
tdLog.info("create ctb")
|
||||
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
|
||||
tdLog.info("async insert data")
|
||||
pThread = tmqCom.asyncInsertData(paraDict)
|
||||
|
||||
tdLog.info("create topics from stb with filter")
|
||||
queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
||||
sqlString = "create topic %s as %s" %(topicNameList[0], queryString)
|
||||
tdLog.info("create topic sql: %s"%sqlString)
|
||||
tdSql.execute(sqlString)
|
||||
|
||||
# init consume info, and start tmq_sim, then check consume result
|
||||
tdLog.info("insert consume info to consume processor")
|
||||
consumerId = 0
|
||||
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
|
||||
topicList = topicNameList[0]
|
||||
ifcheckdata = 1
|
||||
ifManualCommit = 1
|
||||
keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'
|
||||
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||
|
||||
tdLog.info("start consume processor")
|
||||
tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'])
|
||||
|
||||
tdLog.info("wait the notify info of start consume")
|
||||
tmqCom.getStartConsumeNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("start switch mnode ................")
|
||||
tdDnodes = cluster.dnodes
|
||||
|
||||
tdLog.info("1. stop dnode 0")
|
||||
tdDnodes[0].stoptaosd()
|
||||
time.sleep(10)
|
||||
self.check3mnode1off()
|
||||
|
||||
tdLog.info("2. start dnode 0")
|
||||
tdDnodes[0].starttaosd()
|
||||
self.check3mnode()
|
||||
|
||||
tdLog.info("3. stop dnode 1")
|
||||
tdDnodes[1].stoptaosd()
|
||||
time.sleep(10)
|
||||
self.check3mnode1off()
|
||||
|
||||
tdLog.info("switch end and wait insert data end ................")
|
||||
pThread.join()
|
||||
|
||||
tdLog.info("check the consume result")
|
||||
tdSql.query(queryString)
|
||||
expectRowsList.append(tdSql.getRows())
|
||||
|
||||
expectRows = 1
|
||||
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||
|
||||
if expectRowsList[0] != resultList[0]:
|
||||
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
|
||||
tdLog.exit("0 tmq consume rows error!")
|
||||
|
||||
self.checkFileContent(consumerId, queryString)
|
||||
|
||||
time.sleep(10)
|
||||
for i in range(len(topicNameList)):
|
||||
tdSql.query("drop topic %s"%topicNameList[i])
|
||||
|
||||
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("======== Notes: must add '-N 5' for run the script ========")
|
||||
self.checkDnodesStatusAndCreateMnode(self.dnodes)
|
||||
self.tmqCase1()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
event = threading.Event()
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -204,6 +204,35 @@ class TMQCom:
|
|||
tdLog.debug("insert data ............ [OK]")
|
||||
return
|
||||
|
||||
def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||
tdLog.debug("start to insert data ............")
|
||||
tsql.execute("use %s" %dbName)
|
||||
pre_insert = "insert into "
|
||||
sql = pre_insert
|
||||
|
||||
t = time.time()
|
||||
startTs = int(round(t * 1000))
|
||||
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||
for i in range(ctbNum):
|
||||
sql += " %s%d values "%(ctbPrefix,i)
|
||||
for j in range(rowsPerTbl):
|
||||
if (j % 2 == 0):
|
||||
sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, j, j)
|
||||
else:
|
||||
sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, -j, j)
|
||||
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
|
||||
tsql.execute(sql)
|
||||
if j < rowsPerTbl - 1:
|
||||
sql = "insert into %s%d values " %(ctbPrefix,i)
|
||||
else:
|
||||
sql = "insert into "
|
||||
#end sql
|
||||
if sql != pre_insert:
|
||||
#print("insert sql:%s"%sql)
|
||||
tsql.execute(sql)
|
||||
tdLog.debug("insert data ............ [OK]")
|
||||
return
|
||||
|
||||
def insert_data_interlaceByMultiTbl(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs=0):
|
||||
tdLog.debug("start to insert data ............")
|
||||
tsql.execute("use %s" %dbName)
|
||||
|
@ -291,6 +320,17 @@ class TMQCom:
|
|||
pThread.start()
|
||||
return pThread
|
||||
|
||||
def threadFunctionForInsert(self, **paraDict):
|
||||
# create new connector for new tdSql instance in my thread
|
||||
newTdSql = tdCom.newTdSql()
|
||||
self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
||||
return
|
||||
|
||||
def asyncInsertData(self, paraDict):
|
||||
pThread = threading.Thread(target=self.threadFunctionForInsert, kwargs=paraDict)
|
||||
pThread.start()
|
||||
return pThread
|
||||
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class TDTestCase:
|
|||
tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
||||
|
||||
tdLog.info("create topics from stb with filter")
|
||||
queryString = "select ts, c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
||||
queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
||||
sqlString = "create topic %s as %s" %(topicNameList[0], queryString)
|
||||
tdLog.info("create topic sql: %s"%sqlString)
|
||||
tdSql.execute(sqlString)
|
||||
|
|
|
@ -112,7 +112,7 @@ python3 ./test.py -f 2-query/twa.py
|
|||
|
||||
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
||||
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3
|
||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
|
||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||
|
||||
|
@ -134,3 +134,4 @@ python3 ./test.py -f 7-tmq/schema.py
|
|||
python3 ./test.py -f 7-tmq/stbFilter.py
|
||||
python3 ./test.py -f 7-tmq/tmqCheckData.py
|
||||
python3 ./test.py -f 7-tmq/tmqUdf.py
|
||||
#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5
|
||||
|
|
|
@ -60,10 +60,11 @@ if __name__ == "__main__":
|
|||
stop = 0
|
||||
restart = False
|
||||
dnodeNums = 1
|
||||
mnodeNums = 0
|
||||
updateCfgDict = {}
|
||||
execCmd = ""
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums'])
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums'])
|
||||
for key, value in opts:
|
||||
if key in ['-h', '--help']:
|
||||
tdLog.printNoPrefix(
|
||||
|
@ -79,7 +80,8 @@ if __name__ == "__main__":
|
|||
tdLog.printNoPrefix('-d update cfg dict, base64 json str')
|
||||
tdLog.printNoPrefix('-k not kill valgrind processer')
|
||||
tdLog.printNoPrefix('-e eval str to run')
|
||||
tdLog.printNoPrefix('-N create dnodes numbers clusters')
|
||||
tdLog.printNoPrefix('-N create dnodes numbers in clusters')
|
||||
tdLog.printNoPrefix('-M create mnode numbers in clusters')
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -133,6 +135,9 @@ if __name__ == "__main__":
|
|||
if key in ['-N', '--dnodeNums']:
|
||||
dnodeNums = value
|
||||
|
||||
if key in ['-M', '--mnodeNums']:
|
||||
mnodeNums = value
|
||||
|
||||
if not execCmd == "":
|
||||
tdDnodes.init(deployPath)
|
||||
print(execCmd)
|
||||
|
@ -244,9 +249,8 @@ if __name__ == "__main__":
|
|||
tdDnodes.start(1)
|
||||
tdCases.logSql(logSql)
|
||||
else :
|
||||
print("start cluster and dnodes number")
|
||||
|
||||
dnodeslist = cluster.configure_cluster(dnodes_nums=dnodeNums,independent=True)
|
||||
tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums))
|
||||
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums)
|
||||
tdDnodes = ClusterDnodes(dnodeslist)
|
||||
tdDnodes.init(deployPath, masterIp)
|
||||
tdDnodes.setTestCluster(testCluster)
|
||||
|
|
|
@ -453,7 +453,17 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex)
|
|||
int32_t precision = taos_result_precision(msg);
|
||||
const char* tbName = tmq_get_table_name(msg);
|
||||
|
||||
dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision);
|
||||
#if 0
|
||||
// get schema
|
||||
//============================== stub =================================================//
|
||||
for (int32_t i = 0; i < numOfFields; i++) {
|
||||
taosFprintfFile(g_fp, "%02d: name: %s, type: %d, len: %d\n", i, fields[i].name, fields[i].type, fields[i].bytes);
|
||||
}
|
||||
//============================== stub =================================================//
|
||||
#endif
|
||||
|
||||
dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision);
|
||||
|
||||
taos_print_row(buf, row, fields, numOfFields);
|
||||
|
||||
if (0 != g_stConfInfo.showRowFlag) {
|
||||
|
@ -656,12 +666,13 @@ void* consumeThreadFunc(void* param) {
|
|||
pInfo->taos = taos_connect(NULL, "root", "taosdata", NULL, 0);
|
||||
if (pInfo->taos == NULL) {
|
||||
taosFprintfFile(g_fp, "taos_connect() fail, can not notify and save consume result to main scripte\n");
|
||||
exit(-1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
build_consumer(pInfo);
|
||||
build_topic_list(pInfo);
|
||||
if ((NULL == pInfo->tmq) || (NULL == pInfo->topicList)) {
|
||||
taosFprintfFile(g_fp, "create consumer fail! tmq is null or topicList is null\n");
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -669,7 +680,9 @@ void* consumeThreadFunc(void* param) {
|
|||
int32_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList);
|
||||
if (err != 0) {
|
||||
pError("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||
exit(-1);
|
||||
taosFprintfFile(g_fp, "tmq_subscribe()! reason: %s\n", tmq_err2str(err));
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmq_list_destroy(pInfo->topicList);
|
||||
|
@ -688,14 +701,13 @@ void* consumeThreadFunc(void* param) {
|
|||
err = tmq_unsubscribe(pInfo->tmq);
|
||||
if (err != 0) {
|
||||
pError("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||
/*pInfo->consumeMsgCnt = -1;*/
|
||||
/*return NULL;*/
|
||||
taosFprintfFile(g_fp, "tmq_unsubscribe()! reason: %s\n", tmq_err2str(err));
|
||||
}
|
||||
|
||||
err = tmq_consumer_close(pInfo->tmq);
|
||||
if (err != 0) {
|
||||
pError("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err));
|
||||
/*exit(-1);*/
|
||||
taosFprintfFile(g_fp, "tmq_consumer_close()! reason: %s\n", tmq_err2str(err));
|
||||
}
|
||||
pInfo->tmq = NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue