enh: add json index
This commit is contained in:
commit
36bddebb26
118
Jenkinsfile2
118
Jenkinsfile2
|
@ -4,8 +4,10 @@ import jenkins.model.CauseOfInterruption
|
|||
node {
|
||||
}
|
||||
|
||||
def skipbuild=0
|
||||
def win_stop=0
|
||||
win_test_stage = 0
|
||||
linux_ready = 0
|
||||
linux_node_ip = ""
|
||||
linux_node_pass = ""
|
||||
|
||||
def abortPreviousBuilds() {
|
||||
def currentJobName = env.JOB_NAME
|
||||
|
@ -227,6 +229,16 @@ def pre_test_win(){
|
|||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git submodule update --init --recursive
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
||||
git branch
|
||||
git reset --hard
|
||||
git pull
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
||||
git log -5
|
||||
'''
|
||||
}
|
||||
def pre_test_build_win() {
|
||||
bat '''
|
||||
|
@ -246,8 +258,38 @@ def pre_test_build_win() {
|
|||
jom -j 6 || exit 8
|
||||
time /t
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
||||
python -m pip install .
|
||||
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
||||
'''
|
||||
return 1
|
||||
}
|
||||
def run_win_ctest() {
|
||||
bat '''
|
||||
echo "windows ctest ..."
|
||||
time /t
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
||||
ctest -j 1 || exit 7
|
||||
time /t
|
||||
'''
|
||||
}
|
||||
def run_win_test() {
|
||||
echo "LINUX NODE: ${linux_node_ip} - ${linux_node_pass}"
|
||||
bat '''
|
||||
echo "windows test ..."
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
||||
python -m pip install .
|
||||
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
||||
ls -l C:\\Windows\\System32\\taos.dll
|
||||
time /t
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community\\tests\\system-test
|
||||
echo "node: ''' + linux_node_ip + ''':''' + linux_node_pass + '''"
|
||||
echo "testing ..."
|
||||
test-all.bat "{\\\"host\\\":\\\"''' + linux_node_ip + '''\\\",\\\"port\\\":22,\\\"user\\\":\\\"root\\\",\\\"password\\\":\\\"''' + linux_node_pass + '''\\\",\\\"path\\\":\\\"/var/lib/jenkins/workspace/TDinternal\\\"}"
|
||||
time /t
|
||||
'''
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
|
@ -264,8 +306,22 @@ pipeline {
|
|||
stage('windows test') {
|
||||
agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "}
|
||||
steps {
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 55, unit: 'MINUTES'){
|
||||
pre_test_win()
|
||||
pre_test_build_win()
|
||||
run_win_ctest()
|
||||
script {
|
||||
while(linux_ready == 0) {
|
||||
sleep(8)
|
||||
}
|
||||
}
|
||||
run_win_test()
|
||||
}
|
||||
}
|
||||
script {
|
||||
win_test_stage = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('linux test') {
|
||||
|
@ -275,12 +331,25 @@ pipeline {
|
|||
changeRequest()
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
linux_node_ip = sh (
|
||||
script: 'jq .ip /home/node_info.json | sed "s/\\\"//g"',
|
||||
returnStdout: true
|
||||
).trim()
|
||||
linux_node_pass = sh (
|
||||
script: 'jq .password /home/node_info.json | sed "s/\\\"//g" |sed "s/\\!/^^^^^^^^\\!/g"',
|
||||
returnStdout: true
|
||||
).trim()
|
||||
echo "${linux_node_ip}:${linux_node_pass}"
|
||||
}
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 40, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
script {
|
||||
sh '''
|
||||
cd ${WKC}/tests/parallel_test
|
||||
date
|
||||
rm -rf ${WKC}/debug
|
||||
cd ${WKC}/tests/parallel_test
|
||||
time ./container_build.sh -w ${WKDIR} -t 8 -e
|
||||
rm -f /tmp/cases.task
|
||||
./collect_cases.sh -e
|
||||
|
@ -294,6 +363,49 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 15, unit: 'MINUTES'){
|
||||
script {
|
||||
sh '''
|
||||
echo "packaging ..."
|
||||
date
|
||||
rm -rf ${WKC}/release/*
|
||||
cd ${WKC}/packaging
|
||||
./release.sh -v cluster -n 3.0.0.100 -s static
|
||||
'''
|
||||
sh '''
|
||||
echo "install ..."
|
||||
cd ${WKC}/release
|
||||
tar xzf TDengine-enterprise-server-3.0.0.100-Linux-x64.tar.gz
|
||||
cd TDengine-enterprise-server-3.0.0.100
|
||||
service taosd stop || :
|
||||
rm -rf /var/lib/taos
|
||||
./install.sh -e no
|
||||
'''
|
||||
sh '''
|
||||
echo "checking ..."
|
||||
which taos
|
||||
which taosd
|
||||
rm -rf ${WK}/debug
|
||||
mv ${WKC}/debug ${WK}/
|
||||
'''
|
||||
sh '''
|
||||
echo "install taospy ..."
|
||||
cd ${WKPY}
|
||||
pip3 install .
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
script {
|
||||
linux_ready = 1
|
||||
}
|
||||
script {
|
||||
while(win_test_stage == 0){
|
||||
sleep(12)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,6 +186,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
|||
*(double*)p = *(double*)v;
|
||||
}
|
||||
|
||||
int32_t getJsonValueLen(const char *data);
|
||||
|
||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
||||
|
|
|
@ -2296,6 +2296,11 @@ typedef struct {
|
|||
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
SEpSet epSet;
|
||||
} SVgEpSet;
|
||||
|
||||
typedef struct {
|
||||
int8_t version; // for compatibility(default 0)
|
||||
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
||||
|
@ -2305,6 +2310,7 @@ typedef struct {
|
|||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
int32_t exprLen;
|
||||
int32_t tagsFilterLen;
|
||||
int32_t numOfVgroups;
|
||||
int64_t indexUid;
|
||||
tb_uid_t tableUid; // super/child/common table uid
|
||||
int64_t interval;
|
||||
|
@ -2312,6 +2318,7 @@ typedef struct {
|
|||
int64_t sliding;
|
||||
char* expr; // sma expression
|
||||
char* tagsFilter;
|
||||
SVgEpSet vgEpSet[];
|
||||
} STSma; // Time-range-wise SMA
|
||||
|
||||
typedef STSma SVCreateTSmaReq;
|
||||
|
@ -2397,16 +2404,26 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
|
|||
}
|
||||
|
||||
typedef struct {
|
||||
int64_t tsmaIndexUid;
|
||||
int64_t indexUid;
|
||||
STimeWindow queryWindow;
|
||||
} SVGetTsmaExpWndsReq;
|
||||
|
||||
#define SMA_WNDS_EXPIRE_FLAG (0x1)
|
||||
#define SMA_WNDS_IS_EXPIRE(flag) (((flag)&SMA_WNDS_EXPIRE_FLAG) != 0)
|
||||
#define SMA_WNDS_SET_EXPIRE(flag) ((flag) |= SMA_WNDS_EXPIRE_FLAG)
|
||||
|
||||
typedef struct {
|
||||
int64_t tsmaIndexUid;
|
||||
int64_t indexUid;
|
||||
int8_t flags; // 0x1 all window expired
|
||||
int32_t numExpWnds;
|
||||
TSKEY* expWndsStartTs;
|
||||
TSKEY wndSKeys[];
|
||||
} SVGetTsmaExpWndsRsp;
|
||||
|
||||
int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder* pCoder, const SVGetTsmaExpWndsReq* pReq);
|
||||
int32_t tDecodeSVGetTsmaExpWndsReq(SDecoder* pCoder, SVGetTsmaExpWndsReq* pReq);
|
||||
int32_t tEncodeSVGetTSmaExpWndsRsp(SEncoder* pCoder, const SVGetTsmaExpWndsRsp* pReq);
|
||||
int32_t tDecodeSVGetTsmaExpWndsRsp(SDecoder* pCoder, SVGetTsmaExpWndsRsp* pReq);
|
||||
|
||||
typedef struct {
|
||||
int idx;
|
||||
} SMCreateFullTextReq;
|
||||
|
@ -2670,23 +2687,27 @@ typedef struct {
|
|||
int32_t tEncodeSVSubmitReq(SEncoder* pCoder, const SVSubmitReq* pReq);
|
||||
int32_t tDecodeSVSubmitReq(SDecoder* pCoder, SVSubmitReq* pReq);
|
||||
|
||||
// TDMT_VND_DELETE
|
||||
typedef struct {
|
||||
TSKEY sKey;
|
||||
TSKEY eKey;
|
||||
|
||||
// super table
|
||||
char* stbName;
|
||||
|
||||
// child/normal
|
||||
char* tbName;
|
||||
int64_t delUid;
|
||||
int64_t tbUid; // super/child/normal table
|
||||
int8_t type; // table type
|
||||
int16_t nWnds;
|
||||
char* tbFullName;
|
||||
char* subPlan;
|
||||
STimeWindow wnds[];
|
||||
} SVDeleteReq;
|
||||
|
||||
int32_t tEncodeSVDeleteReq(SEncoder* pCoder, const SVDeleteReq* pReq);
|
||||
int32_t tDecodeSVDeleteReq(SDecoder* pCoder, SVDeleteReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t code;
|
||||
// TODO
|
||||
int64_t affectedRows;
|
||||
} SVDeleteRsp;
|
||||
|
||||
int32_t tEncodeSVDeleteRsp(SEncoder* pCoder, const SVDeleteRsp* pReq);
|
||||
int32_t tDecodeSVDeleteRsp(SDecoder* pCoder, SVDeleteRsp* pReq);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -67,7 +67,6 @@ enum {
|
|||
|
||||
enum {
|
||||
#endif
|
||||
// Requests handled by DNODE
|
||||
TD_NEW_MSG_SEG(TDMT_DND_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_MNODE, "dnode-create-mnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_MNODE, "dnode-drop-mnode", NULL, NULL)
|
||||
|
@ -83,7 +82,6 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_DND_NET_TEST, "net-test", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CONFIG_DNODE, "config-dnode", NULL, NULL)
|
||||
|
||||
// Requests handled by MNODE
|
||||
TD_NEW_MSG_SEG(TDMT_MND_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CONNECT, "connect", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_ACCT, "create-acct", NULL, NULL)
|
||||
|
@ -95,7 +93,6 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_GET_USER_AUTH, "get-user-auth", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_DNODE, "create-dnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_DNODE, "config-dnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_DNODE, "alter-dnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_DNODE, "drop-dnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_MNODE, "create-mnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_MNODE, "alter-mnode", NULL, NULL)
|
||||
|
@ -103,6 +100,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_QNODE, "create-qnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_QNODE, "alter-qnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_QNODE, "drop-qnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_QNODE_LIST, "qnode-list", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_SNODE, "create-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_SNODE, "alter-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_SNODE, "drop-snode", NULL, NULL)
|
||||
|
@ -115,52 +113,52 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_DB, "alter-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SYNC_DB, "sync-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_DB, "compact-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_DB_CFG, "get-db-cfg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_VGROUP_LIST, "vgroup-list", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_FUNC, "create-func", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_FUNC, "retrieve-func", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_FUNC, "drop-func", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_STB, "create-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_STB, "alter-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_STB, "drop-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_META, "table-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_SMA, "create-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_SMA, "drop-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_META, "table-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_VGROUP_LIST, "vgroup-list", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_QNODE_LIST, "qnode-list", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_QUERY, "kill-query", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_CONN, "kill-conn", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_HEARTBEAT, "heartbeat", SClientHbBatchReq, SClientHbBatchRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW, "show", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SYSTABLE_RETRIEVE, "systable-retrieve", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_STATUS, "status", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_TRANS, "kill-trans", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT, "grant", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_AUTH, "auth", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "drop-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SUBSCRIBE, "subscribe", SCMSubscribeReq, SCMSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_ASK_EP, "mq-ask-ep", SMqAskEpReq, SMqAskEpRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_LOST, "mq-consumer-lost", SMqConsumerLostMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "mq-consumer-recover", SMqConsumerRecoverMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "mq-do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "mq-drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "mq-commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_STREAM, "create-stream", SCMCreateStreamReq, SCMCreateStreamRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_STREAM, "alter-stream", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_STREAM, "drop-stream", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_INDEX, "create-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_DB_CFG, "get-db-cfg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_APPLY_MSG, "apply-msg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "drop-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SUBSCRIBE, "subscribe", SCMSubscribeReq, SCMSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_ASK_EP, "ask-ep", SMqAskEpReq, SMqAskEpRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_LOST, "consumer-lost", SMqConsumerLostMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_TRANS, "kill-trans", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_QUERY, "kill-query", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_CONN, "kill-conn", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_HEARTBEAT, "heartbeat", SClientHbBatchReq, SClientHbBatchRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_STATUS, "status", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW, "show", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SYSTABLE_RETRIEVE, "retrieve", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT, "grant", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_AUTH, "auth", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_APPLY_MSG, "mnode-apply", NULL, NULL)
|
||||
|
||||
// Requests handled by VNODE
|
||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY, "query", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_CONTINUE, "query-continue", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_HEARTBEAT, "query-heartbeat", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_FETCH, "fetch", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TABLE, "create-table", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TABLE, "alter-table", NULL, NULL)
|
||||
|
@ -182,67 +180,38 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL)
|
||||
// TD_DEF_MSG_TYPE(TDMT_VND_SHOW_TABLES, "vnode-show-tables", SVShowTablesReq, SVShowTablesRsp)
|
||||
// TD_DEF_MSG_TYPE(TDMT_VND_SHOW_TABLES_FETCH, "vnode-show-tables-fetch", SVShowTablesFetchReq, SVShowTablesFetchRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_CONTINUE, "vnode-query-continue", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_HEARTBEAT, "vnode-query-heartbeat", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_EXPLAIN, "vnode-explain", NULL, NULL)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBSCRIBE, "vnode-subscribe", SMVSubscribeReq, SMVSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_DEPLOY, "vnode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_RUN, "vnode-stream-task-run", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_DISPATCH, "vnode-stream-task-dispatch", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_RECOVER, "vnode-stream-task-recover", NULL, NULL)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_GET_TSMA_EXP_WNDS, "vnode-get-tsma-expired-windows", SVGetTsmaExpWndsReq, SVGetTsmaExpWndsRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_START_WRITE, "start-write", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STOP_WRITE, "stop-write", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CONFIRM_WRITE, "confirm-write", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_TIMEOUT, "vnode-sync-timeout", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_PING, "vnode-sync-ping", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_PING_REPLY, "vnode-sync-ping-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_CLIENT_REQUEST, "vnode-sync-client-request", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_CLIENT_REQUEST_REPLY, "vnode-sync-client-request-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_REQUEST_VOTE, "vnode-sync-request-vote", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_REQUEST_VOTE_REPLY, "vnode-sync-request-vote-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_APPEND_ENTRIES, "vnode-sync-append-entries", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_APPEND_ENTRIES_REPLY, "vnode-sync-append-entries-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_NOOP, "vnode-sync-noop", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_UNKNOWN, "vnode-sync-unknown", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_COMMON_RESPONSE, "vnode-sync-common-response", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_APPLY_MSG, "vnode-sync-apply-msg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_CONFIG_CHANGE, "vnode-sync-config-change", NULL, NULL)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "vnode-alter-config", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "vnode-alter-replica", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "vnode-compact", NULL, NULL)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "vnode-delete-data", SVDeleteReq, SVDeleteRsp)
|
||||
|
||||
// Requests handled by QNODE
|
||||
TD_NEW_MSG_SEG(TDMT_QND_MSG)
|
||||
|
||||
// Requests handled by SNODE
|
||||
TD_NEW_MSG_SEG(TDMT_SND_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||
//TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||
//TD_DEF_MSG_TYPE(TDMT_SND_TASK_PIPE_EXEC, "snode-task-pipe-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||
//TD_DEF_MSG_TYPE(TDMT_SND_TASK_MERGE_EXEC, "snode-task-merge-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||
|
||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_RUN, "snode-stream-task-run", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_DISPATCH, "snode-stream-task-dispatch", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_RECOVER, "snode-stream-task-recover", NULL, NULL)
|
||||
|
||||
// Requests handled by SCHEDULER
|
||||
TD_NEW_MSG_SEG(TDMT_SCH_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "scheduler-link-broken", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
||||
|
||||
// Monitor info exchange between processes
|
||||
TD_NEW_MSG_SEG(TDMT_MON_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL)
|
||||
|
@ -253,6 +222,22 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MON_MM_LOAD, "monitor-mload", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_QM_LOAD, "monitor-qload", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timeout", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE, "sync-request-vote", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE_REPLY, "sync-request-vote-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES, "sync-append-entries", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_REPLY, "sync-append-entries-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_NOOP, "sync-noop", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_UNKNOWN, "sync-unknown", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_COMMON_RESPONSE, "sync-common-response", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_APPLY_MSG, "sync-apply-msg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CONFIG_CHANGE, "sync-config-change", NULL, NULL)
|
||||
|
||||
#if defined(TD_MSG_NUMBER_)
|
||||
TDMT_MAX
|
||||
#endif
|
||||
|
|
|
@ -193,65 +193,66 @@
|
|||
#define TK_REDISTRIBUTE 175
|
||||
#define TK_SPLIT 176
|
||||
#define TK_SYNCDB 177
|
||||
#define TK_NULL 178
|
||||
#define TK_NK_QUESTION 179
|
||||
#define TK_NK_ARROW 180
|
||||
#define TK_ROWTS 181
|
||||
#define TK_TBNAME 182
|
||||
#define TK_QSTARTTS 183
|
||||
#define TK_QENDTS 184
|
||||
#define TK_WSTARTTS 185
|
||||
#define TK_WENDTS 186
|
||||
#define TK_WDURATION 187
|
||||
#define TK_CAST 188
|
||||
#define TK_NOW 189
|
||||
#define TK_TODAY 190
|
||||
#define TK_TIMEZONE 191
|
||||
#define TK_COUNT 192
|
||||
#define TK_FIRST 193
|
||||
#define TK_LAST 194
|
||||
#define TK_LAST_ROW 195
|
||||
#define TK_BETWEEN 196
|
||||
#define TK_IS 197
|
||||
#define TK_NK_LT 198
|
||||
#define TK_NK_GT 199
|
||||
#define TK_NK_LE 200
|
||||
#define TK_NK_GE 201
|
||||
#define TK_NK_NE 202
|
||||
#define TK_MATCH 203
|
||||
#define TK_NMATCH 204
|
||||
#define TK_CONTAINS 205
|
||||
#define TK_JOIN 206
|
||||
#define TK_INNER 207
|
||||
#define TK_SELECT 208
|
||||
#define TK_DISTINCT 209
|
||||
#define TK_WHERE 210
|
||||
#define TK_PARTITION 211
|
||||
#define TK_BY 212
|
||||
#define TK_SESSION 213
|
||||
#define TK_STATE_WINDOW 214
|
||||
#define TK_SLIDING 215
|
||||
#define TK_FILL 216
|
||||
#define TK_VALUE 217
|
||||
#define TK_NONE 218
|
||||
#define TK_PREV 219
|
||||
#define TK_LINEAR 220
|
||||
#define TK_NEXT 221
|
||||
#define TK_HAVING 222
|
||||
#define TK_ORDER 223
|
||||
#define TK_SLIMIT 224
|
||||
#define TK_SOFFSET 225
|
||||
#define TK_LIMIT 226
|
||||
#define TK_OFFSET 227
|
||||
#define TK_ASC 228
|
||||
#define TK_NULLS 229
|
||||
#define TK_ID 230
|
||||
#define TK_NK_BITNOT 231
|
||||
#define TK_INSERT 232
|
||||
#define TK_VALUES 233
|
||||
#define TK_IMPORT 234
|
||||
#define TK_NK_SEMI 235
|
||||
#define TK_FILE 236
|
||||
#define TK_DELETE 178
|
||||
#define TK_NULL 179
|
||||
#define TK_NK_QUESTION 180
|
||||
#define TK_NK_ARROW 181
|
||||
#define TK_ROWTS 182
|
||||
#define TK_TBNAME 183
|
||||
#define TK_QSTARTTS 184
|
||||
#define TK_QENDTS 185
|
||||
#define TK_WSTARTTS 186
|
||||
#define TK_WENDTS 187
|
||||
#define TK_WDURATION 188
|
||||
#define TK_CAST 189
|
||||
#define TK_NOW 190
|
||||
#define TK_TODAY 191
|
||||
#define TK_TIMEZONE 192
|
||||
#define TK_COUNT 193
|
||||
#define TK_FIRST 194
|
||||
#define TK_LAST 195
|
||||
#define TK_LAST_ROW 196
|
||||
#define TK_BETWEEN 197
|
||||
#define TK_IS 198
|
||||
#define TK_NK_LT 199
|
||||
#define TK_NK_GT 200
|
||||
#define TK_NK_LE 201
|
||||
#define TK_NK_GE 202
|
||||
#define TK_NK_NE 203
|
||||
#define TK_MATCH 204
|
||||
#define TK_NMATCH 205
|
||||
#define TK_CONTAINS 206
|
||||
#define TK_JOIN 207
|
||||
#define TK_INNER 208
|
||||
#define TK_SELECT 209
|
||||
#define TK_DISTINCT 210
|
||||
#define TK_WHERE 211
|
||||
#define TK_PARTITION 212
|
||||
#define TK_BY 213
|
||||
#define TK_SESSION 214
|
||||
#define TK_STATE_WINDOW 215
|
||||
#define TK_SLIDING 216
|
||||
#define TK_FILL 217
|
||||
#define TK_VALUE 218
|
||||
#define TK_NONE 219
|
||||
#define TK_PREV 220
|
||||
#define TK_LINEAR 221
|
||||
#define TK_NEXT 222
|
||||
#define TK_HAVING 223
|
||||
#define TK_ORDER 224
|
||||
#define TK_SLIMIT 225
|
||||
#define TK_SOFFSET 226
|
||||
#define TK_LIMIT 227
|
||||
#define TK_OFFSET 228
|
||||
#define TK_ASC 229
|
||||
#define TK_NULLS 230
|
||||
#define TK_ID 231
|
||||
#define TK_NK_BITNOT 232
|
||||
#define TK_INSERT 233
|
||||
#define TK_VALUES 234
|
||||
#define TK_IMPORT 235
|
||||
#define TK_NK_SEMI 236
|
||||
#define TK_FILE 237
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -180,6 +180,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||
QUERY_NODE_KILL_QUERY_STMT,
|
||||
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||
QUERY_NODE_DELETE_STMT,
|
||||
QUERY_NODE_QUERY,
|
||||
|
||||
// logic plan node
|
||||
|
@ -218,6 +219,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION_WINDOW,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW,
|
||||
QUERY_NODE_PHYSICAL_PLAN_PARTITION,
|
||||
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
||||
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
||||
|
|
|
@ -229,6 +229,7 @@ typedef struct STableScanPhysiNode {
|
|||
double ratio;
|
||||
int32_t dataRequired;
|
||||
SNodeList* pDynamicScanFuncs;
|
||||
SNodeList* pPartitionKeys;
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
|
@ -337,6 +338,8 @@ typedef struct SStateWinodwPhysiNode {
|
|||
SNode* pStateKey;
|
||||
} SStateWinodwPhysiNode;
|
||||
|
||||
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;
|
||||
|
||||
typedef struct SSortPhysiNode {
|
||||
SPhysiNode node;
|
||||
SNodeList* pExprs; // these are expression list of order_by_clause and parameter expression of aggregate function
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef struct SColumnNode {
|
|||
int8_t tableType;
|
||||
col_id_t colId;
|
||||
EColumnType colType; // column or tag
|
||||
bool hasIndex;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
char tableAlias[TSDB_TABLE_NAME_LEN];
|
||||
|
@ -258,6 +259,7 @@ typedef struct SSetOperator {
|
|||
SNodeList* pOrderByList; // SOrderByExprNode
|
||||
SNode* pLimit;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
uint8_t precision;
|
||||
} SSetOperator;
|
||||
|
||||
typedef enum ESqlClause {
|
||||
|
@ -272,6 +274,17 @@ typedef enum ESqlClause {
|
|||
SQL_CLAUSE_ORDER_BY
|
||||
} ESqlClause;
|
||||
|
||||
typedef struct SDeleteStmt {
|
||||
ENodeType type; // QUERY_NODE_DELETE_STMT
|
||||
SNode* pFromTable; // FROM clause
|
||||
SNode* pWhere; // WHERE clause
|
||||
SNode* pCountFunc; // count the number of rows affected
|
||||
SNode* pTagIndexCond; // pWhere divided into pTagIndexCond and timeRange
|
||||
STimeWindow timeRange;
|
||||
uint8_t precision;
|
||||
bool deleteZeroRows;
|
||||
} SDeleteStmt;
|
||||
|
||||
typedef enum {
|
||||
PAYLOAD_TYPE_KV = 0,
|
||||
PAYLOAD_TYPE_RAW = 1,
|
||||
|
@ -363,8 +376,11 @@ bool nodesIsRegularOp(const SOperatorNode* pOp);
|
|||
void* nodesGetValueFromNode(SValueNode* pNode);
|
||||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||
char* getFillModeString(EFillMode mode);
|
||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
|
||||
char* nodesGetFillModeString(EFillMode mode);
|
||||
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
||||
int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagCond, SNode** pOtherCond);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ typedef struct {
|
|||
|
||||
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, const SMsgCb *pMsgCb);
|
||||
|
||||
int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg);
|
||||
|
||||
int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
|
||||
|
||||
int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
|
||||
|
|
|
@ -563,7 +563,9 @@ int32_t* taosGetErrno();
|
|||
//scheduler&qworker
|
||||
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501)
|
||||
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502)
|
||||
#define TSDB_CODE_QW_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503)
|
||||
#define TSDB_CODE_SCH_IGNORE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503)
|
||||
#define TSDB_CODE_SCH_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x2504)
|
||||
#define TSDB_CODE_QW_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x2550)
|
||||
|
||||
//parser
|
||||
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
||||
|
@ -647,6 +649,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_COL_JSON TAOS_DEF_ERROR_CODE(0, 0x2652)
|
||||
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2654)
|
||||
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
|
|
@ -1087,7 +1087,7 @@ void* doAsyncFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUc
|
|||
tsem_wait(&pParam->sem);
|
||||
}
|
||||
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS && setupOneRowPtr) {
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS && pResultInfo->numOfRows > 0 && setupOneRowPtr) {
|
||||
doSetOneRowPtr(pResultInfo);
|
||||
pResultInfo->current += 1;
|
||||
}
|
||||
|
@ -1234,7 +1234,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
} else if (jsonInnerType == TD_TAG_JSON) {
|
||||
char* jsonString = parseTagDatatoJson(jsonInnerData);
|
||||
char* jsonString = parseTagDatatoJson(pStart);
|
||||
STR_TO_VARSTR(dst, jsonString);
|
||||
taosMemoryFree(jsonString);
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
|
|
|
@ -66,10 +66,11 @@ void taos_cleanup(void) {
|
|||
|
||||
hbMgrCleanUp();
|
||||
|
||||
rpcCleanup();
|
||||
catalogDestroy();
|
||||
schedulerDestroy();
|
||||
|
||||
rpcCleanup();
|
||||
|
||||
tscInfo("all local resources released");
|
||||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
|
|
|
@ -87,11 +87,12 @@ static const SSysDbTableSchema userDBSchema[] = {
|
|||
{.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "cache_model", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||
{.name = "retension", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
||||
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
|
||||
};
|
||||
|
|
|
@ -99,6 +99,24 @@ void colDataTrim(SColumnInfoData* pColumnInfoData) {
|
|||
// TODO
|
||||
}
|
||||
|
||||
int32_t getJsonValueLen(const char *data) {
|
||||
int32_t dataLen = 0;
|
||||
if (*data == TSDB_DATA_TYPE_NULL) {
|
||||
dataLen = CHAR_BYTES;
|
||||
} else if (*data == TSDB_DATA_TYPE_NCHAR) {
|
||||
dataLen = varDataTLen(data + CHAR_BYTES) + CHAR_BYTES;
|
||||
} else if (*data == TSDB_DATA_TYPE_DOUBLE) {
|
||||
dataLen = DOUBLE_BYTES + CHAR_BYTES;
|
||||
} else if (*data == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = CHAR_BYTES + CHAR_BYTES;
|
||||
} else if (*data == TD_TAG_JSON) { // json string
|
||||
dataLen = ((STag*)(data))->len;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
return dataLen;
|
||||
}
|
||||
|
||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) {
|
||||
ASSERT(pColumnInfoData != NULL);
|
||||
|
||||
|
@ -118,19 +136,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
|
|||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
int32_t dataLen = 0;
|
||||
if (type == TSDB_DATA_TYPE_JSON) {
|
||||
if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||
dataLen = CHAR_BYTES;
|
||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
dataLen = varDataTLen(pData + CHAR_BYTES) + CHAR_BYTES;
|
||||
} else if (*pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
dataLen = DOUBLE_BYTES + CHAR_BYTES;
|
||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = CHAR_BYTES + CHAR_BYTES;
|
||||
} else if (*pData == TD_TAG_JSON) { // json string
|
||||
dataLen = ((STag*)(pData))->len;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
dataLen = getJsonValueLen(pData);
|
||||
}else {
|
||||
dataLen = varDataTLen(pData);
|
||||
}
|
||||
|
|
|
@ -3661,6 +3661,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
|
|||
if (tEncodeCStr(pCoder, pSma->indexName) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pSma->exprLen) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pSma->tagsFilterLen) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pSma->numOfVgroups) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pSma->indexUid) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pSma->tableUid) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pSma->interval) < 0) return -1;
|
||||
|
@ -3672,7 +3673,17 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
|
|||
if (pSma->tagsFilterLen > 0) {
|
||||
if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1;
|
||||
}
|
||||
|
||||
for (int32_t v = 0; v < pSma->numOfVgroups; ++v) {
|
||||
if (tEncodeI32(pCoder, pSma->vgEpSet[v].vgId) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pSma->vgEpSet[v].epSet.inUse) < 0) return -1;
|
||||
int8_t numOfEps = pSma->vgEpSet[v].epSet.numOfEps;
|
||||
if (tEncodeI8(pCoder, numOfEps) < 0) return -1;
|
||||
for (int32_t n = 0; n < numOfEps; ++n) {
|
||||
const SEp *pEp = &pSma->vgEpSet[v].epSet.eps[n];
|
||||
if (tEncodeCStr(pCoder, pEp->fqdn) < 0) return -1;
|
||||
if (tEncodeU16(pCoder, pEp->port) < 0) return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3685,6 +3696,7 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
|||
if (tDecodeCStrTo(pCoder, pSma->indexName) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pSma->exprLen) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pSma->tagsFilterLen) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pSma->numOfVgroups) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1;
|
||||
|
@ -3700,6 +3712,17 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
|||
} else {
|
||||
pSma->tagsFilter = NULL;
|
||||
}
|
||||
for (int32_t v = 0; v < pSma->numOfVgroups; ++v) {
|
||||
if (tDecodeI32(pCoder, &pSma->vgEpSet[v].vgId) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pSma->vgEpSet[v].epSet.inUse) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pSma->vgEpSet[v].epSet.numOfEps) < 0) return -1;
|
||||
int8_t numOfEps = pSma->vgEpSet[v].epSet.numOfEps;
|
||||
for (int32_t n = 0; n < numOfEps; ++n) {
|
||||
SEp *pEp = &pSma->vgEpSet[v].epSet.eps[n];
|
||||
if (tDecodeCStrTo(pCoder, pEp->fqdn) < 0) return -1;
|
||||
if (tDecodeU16(pCoder, &pEp->port) < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3742,6 +3765,111 @@ int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder* pCoder, const SVGetTsmaExpWndsReq* pReq) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI64(pCoder, pReq->indexUid) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->queryWindow.skey) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->queryWindow.ekey) < 0) return -1;
|
||||
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSVGetTsmaExpWndsReq(SDecoder* pCoder, SVGetTsmaExpWndsReq* pReq) {
|
||||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(pCoder, &pReq->indexUid) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->queryWindow.skey) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->queryWindow.ekey) < 0) return -1;
|
||||
|
||||
tEndDecode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSVGetTSmaExpWndsRsp(SEncoder* pCoder, const SVGetTsmaExpWndsRsp* pReq) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI64(pCoder, pReq->indexUid) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pReq->flags) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pReq->numExpWnds) < 0) return -1;
|
||||
for (int32_t i = 0; i < pReq->numExpWnds; ++i) {
|
||||
if (tEncodeI64(pCoder, pReq->wndSKeys[i]) < 0) return -1;
|
||||
}
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSVGetTsmaExpWndsRsp(SDecoder *pCoder, SVGetTsmaExpWndsRsp *pReq) {
|
||||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(pCoder, &pReq->indexUid) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pReq->flags) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pReq->numExpWnds) < 0) return -1;
|
||||
for (int32_t i = 0; i < pReq->numExpWnds; ++i) {
|
||||
if (tDecodeI64(pCoder, &pReq->wndSKeys[i]) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSVDeleteReq(SEncoder* pCoder, const SVDeleteReq* pReq) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI64(pCoder, pReq->delUid) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->tbUid) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pReq->type) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pReq->nWnds) < 0) return -1;
|
||||
if (tEncodeCStr(pCoder, pReq->tbFullName) < 0) return -1;
|
||||
if (tEncodeCStr(pCoder, pReq->subPlan) < 0) return -1;
|
||||
for (int16_t i = 0; i < pReq->nWnds; ++i) {
|
||||
if (tEncodeI64(pCoder, pReq->wnds[i].skey) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->wnds[i].ekey) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSVDeleteReq(SDecoder* pCoder, SVDeleteReq* pReq) {
|
||||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(pCoder, &pReq->delUid) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->tbUid) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pReq->type) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pReq->nWnds) < 0) return -1;
|
||||
if (tDecodeCStr(pCoder, &pReq->tbFullName) < 0) return -1;
|
||||
if (tDecodeCStr(pCoder, &pReq->subPlan) < 0) return -1;
|
||||
for (int16_t i = 0; i < pReq->nWnds; ++i) {
|
||||
if (tDecodeI64(pCoder, &pReq->wnds[i].skey) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->wnds[i].ekey) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSVDeleteRsp(SEncoder* pCoder, const SVDeleteRsp* pReq) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI32(pCoder, pReq->code) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->affectedRows) < 0) return -1;
|
||||
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSVDeleteRsp(SDecoder* pCoder, SVDeleteRsp* pReq) {
|
||||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI32(pCoder, &pReq->code) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->affectedRows) < 0) return -1;
|
||||
|
||||
tEndDecode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateStreamReq *pReq) {
|
||||
int32_t sqlLen = 0;
|
||||
int32_t astLen = 0;
|
||||
|
|
|
@ -56,6 +56,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
|||
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg);
|
||||
|
||||
// mmWorker.c
|
||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
||||
|
|
|
@ -129,12 +129,7 @@ SArray *mmGetMsgHandles() {
|
|||
SArray *pArray = taosArrayInit(64, sizeof(SMgmtHandle));
|
||||
if (pArray == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
// Requests handled by DNODE
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -146,7 +141,6 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
// Requests handled by MNODE
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -159,6 +153,8 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -172,66 +168,65 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_COMPACT_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
// Requests handled by VNODE
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_PING, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_PING_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_CLIENT_REQUEST, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_CLIENT_REQUEST_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_REQUEST_VOTE, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_REQUEST_VOTE_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_APPEND_ENTRIES, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_APPEND_ENTRIES_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
mndPreprocessQueryMsg(pMgmt->pMnode, pMsg);
|
||||
|
||||
return mmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|||
int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,8 @@ static int32_t qmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
qndPreprocessQueryMsg(pMgmt->pQnode, pMsg);
|
||||
|
||||
return qmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -365,15 +365,15 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_PING, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_PING_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_REQUEST_VOTE, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_REQUEST_VOTE_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
SRpcMsg rsp = {0};
|
||||
|
||||
// get original rpc msg
|
||||
assert(pMsg->msgType == TDMT_VND_SYNC_APPLY_MSG);
|
||||
assert(pMsg->msgType == TDMT_SYNC_APPLY_MSG);
|
||||
SyncApplyMsg *pSyncApplyMsg = syncApplyMsgFromRpcMsg2(pMsg);
|
||||
syncApplyMsgLog2("==vmProcessApplyQueue==", pSyncApplyMsg);
|
||||
SRpcMsg originalRpcMsg;
|
||||
|
@ -250,6 +250,8 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
|
||||
switch (qtype) {
|
||||
case QUERY_QUEUE:
|
||||
vnodePreprocessQueryMsg(pVnode->pImpl, pMsg);
|
||||
|
||||
dTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg);
|
||||
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||
break;
|
||||
|
|
|
@ -29,12 +29,18 @@ typedef enum {
|
|||
TRANS_STOP_FUNC_MQ_REB = 4,
|
||||
} ETrnFunc;
|
||||
|
||||
typedef enum {
|
||||
TRANS_ACTION_NULL = 0,
|
||||
TRANS_ACTION_MSG = 1,
|
||||
TRANS_ACTION_RAW = 2,
|
||||
} ETrnAct;
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
int32_t errCode;
|
||||
int32_t acceptableCode;
|
||||
int8_t stage;
|
||||
int8_t actionType; // 0-msg, 1-raw
|
||||
ETrnAct actionType;
|
||||
int8_t rawWritten;
|
||||
int8_t msgSent;
|
||||
int8_t msgReceived;
|
||||
|
@ -57,6 +63,7 @@ void mndTransDrop(STrans *pTrans);
|
|||
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
|
||||
int32_t mndTransAppendNullLog(STrans *pTrans);
|
||||
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
|
||||
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
|
||||
void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen);
|
||||
|
@ -65,7 +72,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname);
|
|||
void mndTransSetSerial(STrans *pTrans);
|
||||
|
||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||
void mndTransProcessRsp(SRpcMsg *pRsp);
|
||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||
void mndTransPullup(SMnode *pMnode);
|
||||
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
|
||||
|
||||
|
|
|
@ -1431,6 +1431,52 @@ const char *mndGetDbStr(const char *src) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
int64_t getValOfDiffPrecision(int8_t unit, int64_t val) {
|
||||
int64_t v = 0;
|
||||
switch(unit) {
|
||||
case 's': v = val / 1000; break;
|
||||
case 'm': v = val / tsTickPerMin[TSDB_TIME_PRECISION_MILLI]; break;
|
||||
case 'h': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 60); break;
|
||||
case 'd': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60); break;
|
||||
case 'w': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60 * 7); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
char* buildRetension(SArray* pRetension) {
|
||||
size_t size = taosArrayGetSize(pRetension);
|
||||
if (size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* p1 = taosMemoryCalloc(1, 100);
|
||||
SRetention* p = taosArrayGet(pRetension, 0);
|
||||
|
||||
int32_t len = 2;
|
||||
|
||||
int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||
int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||
len += sprintf(p1 + len, "%"PRId64"%c:%"PRId64"%c,", v1, p->freqUnit, v2, p->keepUnit);
|
||||
|
||||
p = taosArrayGet(pRetension, 1);
|
||||
|
||||
v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||
v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||
len += sprintf(p1 + len, "%"PRId64"%c:%"PRId64"%c,", v1, p->freqUnit, v2, p->keepUnit);
|
||||
|
||||
p = taosArrayGet(pRetension, 2);
|
||||
|
||||
v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||
v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||
len += sprintf(p1 + len, "%"PRId64"%c:%"PRId64"%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||
|
||||
varDataSetLen(p1, len);
|
||||
return p1;
|
||||
}
|
||||
|
||||
static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables,
|
||||
bool sysDb) {
|
||||
int32_t cols = 0;
|
||||
|
@ -1478,7 +1524,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
const char *src = pDb->cfg.strict ? "strict" : "nostrict";
|
||||
const char *src = pDb->cfg.strict ? "strict" : "no_strict";
|
||||
char strict[24] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(strict, src, strlen(src));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -1526,6 +1572,20 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
STR_WITH_SIZE_TO_VARSTR(strict, src, strlen(src));
|
||||
#if 0
|
||||
char cacheModel[24] = {0};
|
||||
bool null = false;
|
||||
if (pDb->cfg.cacheLastRow == 0) {
|
||||
STR_TO_VARSTR(cacheModel, "no_cache");
|
||||
} else if (pDb->cfg.cacheLastRow == 1) {
|
||||
STR_TO_VARSTR(cacheModel, "last_row_cache")
|
||||
} else {
|
||||
null = true;
|
||||
}
|
||||
colDataAppend(pColInfo, rows, cacheModel, null);
|
||||
#endif
|
||||
colDataAppend(pColInfo, rows, (const char*) &pDb->cfg.cacheLastRow, false);
|
||||
|
||||
char *prec = NULL;
|
||||
|
@ -1555,8 +1615,18 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)statusB, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false);
|
||||
|
||||
char* p = buildRetension(pDb->cfg.pRetensions);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
if (p == NULL) {
|
||||
colDataAppendNULL(pColInfo, rows);
|
||||
} else {
|
||||
colDataAppend(pColInfo, rows, (const char *)p, false);
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -376,35 +376,35 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
|||
syncRpcMsgLog2(logBuf, pMsg);
|
||||
taosMemoryFree(syncNodeStr);
|
||||
|
||||
if (pMsg->msgType == TDMT_VND_SYNC_TIMEOUT) {
|
||||
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnTimeoutCb(pSyncNode, pSyncMsg);
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_PING) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
||||
syncPingDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_PING_REPLY) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
||||
syncPingReplyDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE_REPLY) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnAppendEntriesCb(pSyncNode, pSyncMsg);
|
||||
syncAppendEntriesDestroy(pSyncMsg);
|
||||
} else if (pMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
} else if (pMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||
|
@ -625,7 +625,7 @@ int32_t mndAcquireRpcRef(SMnode *pMnode) {
|
|||
code = -1;
|
||||
} else {
|
||||
int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1);
|
||||
mTrace("mnode rpc is acquired, ref:%d", ref);
|
||||
// mTrace("mnode rpc is acquired, ref:%d", ref);
|
||||
}
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
return code;
|
||||
|
@ -634,7 +634,7 @@ int32_t mndAcquireRpcRef(SMnode *pMnode) {
|
|||
void mndReleaseRpcRef(SMnode *pMnode) {
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
int32_t ref = atomic_sub_fetch_32(&pMnode->rpcRef, 1);
|
||||
mTrace("mnode rpc is released, ref:%d", ref);
|
||||
// mTrace("mnode rpc is released, ref:%d", ref);
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ int32_t mndAcquireSyncRef(SMnode *pMnode) {
|
|||
code = -1;
|
||||
} else {
|
||||
int32_t ref = atomic_add_fetch_32(&pMnode->syncRef, 1);
|
||||
mTrace("mnode sync is acquired, ref:%d", ref);
|
||||
// mTrace("mnode sync is acquired, ref:%d", ref);
|
||||
}
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
return code;
|
||||
|
@ -684,6 +684,6 @@ int32_t mndAcquireSyncRef(SMnode *pMnode) {
|
|||
void mndReleaseSyncRef(SMnode *pMnode) {
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
int32_t ref = atomic_sub_fetch_32(&pMnode->syncRef, 1);
|
||||
mTrace("mnode sync is released, ref:%d", ref);
|
||||
// mTrace("mnode sync is released, ref:%d", ref);
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
}
|
||||
|
|
|
@ -34,9 +34,6 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOld, SMnodeObj *pNe
|
|||
static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessCreateMnodeRsp(SRpcMsg *pRsp);
|
||||
static int32_t mndProcessAlterMnodeRsp(SRpcMsg *pRsp);
|
||||
static int32_t mndProcessDropMnodeRsp(SRpcMsg *pRsp);
|
||||
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter);
|
||||
|
||||
|
@ -53,11 +50,11 @@ int32_t mndInitMnode(SMnode *pMnode) {
|
|||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_MNODE, mndProcessCreateMnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_MNODE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE, mndProcessAlterMnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_MNODE_RSP, mndProcessCreateMnodeRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndProcessAlterMnodeRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndProcessDropMnodeRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
||||
|
@ -367,7 +364,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||
|
||||
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
@ -549,6 +546,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
|||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) goto _OVER;
|
||||
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
@ -616,21 +614,6 @@ _OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateMnodeRsp(SRpcMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessAlterMnodeRsp(SRpcMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropMnodeRsp(SRpcMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
#include "mndMnode.h"
|
||||
#include "qworker.h"
|
||||
|
||||
int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg) {
|
||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
||||
}
|
||||
|
||||
int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
||||
int32_t code = -1;
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
|
|
|
@ -88,12 +88,14 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
|
|||
|
||||
for (int32_t i = 0; i < actionNum; ++i) {
|
||||
STransAction *pAction = taosArrayGet(pArray, i);
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
rawDataLen += (sdbGetRawTotalSize(pAction->pRaw) + sizeof(int32_t));
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
||||
} else {
|
||||
// empty
|
||||
}
|
||||
rawDataLen += sizeof(pAction->actionType);
|
||||
rawDataLen += sizeof(int8_t);
|
||||
}
|
||||
|
||||
return rawDataLen;
|
||||
|
@ -137,18 +139,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,18 +163,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,18 +187,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,6 +260,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
int16_t policy = 0;
|
||||
int16_t conflict = 0;
|
||||
int16_t exec = 0;
|
||||
int8_t actionType = 0;
|
||||
SDB_GET_INT16(pRaw, dataPos, &stage, _OVER)
|
||||
SDB_GET_INT16(pRaw, dataPos, &policy, _OVER)
|
||||
SDB_GET_INT16(pRaw, dataPos, &conflict, _OVER)
|
||||
|
@ -279,9 +288,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||
action.actionType = actionType;
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||
if (action.actionType) {
|
||||
if (action.actionType == TRANS_ACTION_RAW) {
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||
action.pRaw = taosMemoryMalloc(dataLen);
|
||||
|
@ -290,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||
action.pRaw = NULL;
|
||||
} else {
|
||||
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||
|
@ -301,6 +311,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||
action.pCont = NULL;
|
||||
} else {
|
||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,9 +320,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||
action.actionType = actionType;
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||
if (action.actionType) {
|
||||
if (action.actionType == TRANS_ACTION_RAW) {
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||
action.pRaw = taosMemoryMalloc(dataLen);
|
||||
|
@ -319,7 +332,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
||||
action.pRaw = NULL;
|
||||
} else {
|
||||
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||
|
@ -330,6 +343,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
||||
action.pCont = NULL;
|
||||
} else {
|
||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +352,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||
action.actionType = actionType;
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||
if (action.actionType) {
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||
|
@ -348,7 +364,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
||||
action.pRaw = NULL;
|
||||
} else {
|
||||
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||
|
@ -359,6 +375,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
||||
action.pCont = NULL;
|
||||
} else {
|
||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -552,10 +570,12 @@ static void mndTransDropActions(SArray *pArray) {
|
|||
int32_t size = taosArrayGetSize(pArray);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
STransAction *pAction = taosArrayGet(pArray, i);
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
taosMemoryFreeClear(pAction->pRaw);
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
taosMemoryFreeClear(pAction->pCont);
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,27 +603,34 @@ static int32_t mndTransAppendAction(SArray *pArray, STransAction *pAction) {
|
|||
}
|
||||
|
||||
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = true, .pRaw = pRaw};
|
||||
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||
return mndTransAppendAction(pTrans->redoActions, &action);
|
||||
}
|
||||
|
||||
int32_t mndTransAppendNullLog(STrans *pTrans) {
|
||||
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = TRANS_ACTION_NULL};
|
||||
return mndTransAppendAction(pTrans->redoActions, &action);
|
||||
}
|
||||
|
||||
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||
STransAction action = {.stage = TRN_STAGE_UNDO_ACTION, .actionType = true, .pRaw = pRaw};
|
||||
STransAction action = {.stage = TRN_STAGE_UNDO_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||
return mndTransAppendAction(pTrans->undoActions, &action);
|
||||
}
|
||||
|
||||
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||
STransAction action = {.stage = TRN_STAGE_COMMIT_ACTION, .actionType = true, .pRaw = pRaw};
|
||||
STransAction action = {.stage = TRN_STAGE_COMMIT_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||
return mndTransAppendAction(pTrans->commitActions, &action);
|
||||
}
|
||||
|
||||
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction) {
|
||||
pAction->stage = TRN_STAGE_REDO_ACTION;
|
||||
pAction->actionType = TRANS_ACTION_MSG;
|
||||
return mndTransAppendAction(pTrans->redoActions, pAction);
|
||||
}
|
||||
|
||||
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction) {
|
||||
pAction->stage = TRN_STAGE_UNDO_ACTION;
|
||||
pAction->actionType = TRANS_ACTION_MSG;
|
||||
return mndTransAppendAction(pTrans->undoActions, pAction);
|
||||
}
|
||||
|
||||
|
@ -782,7 +809,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
}
|
||||
|
||||
void mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||
SMnode *pMnode = pRsp->info.node;
|
||||
int64_t signature = (int64_t)(pRsp->info.ahandle);
|
||||
int32_t transId = (int32_t)(signature >> 32);
|
||||
|
@ -827,6 +854,7 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
|
|||
|
||||
_OVER:
|
||||
mndReleaseTrans(pMnode, pTrans);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
||||
|
@ -899,10 +927,15 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
|||
}
|
||||
|
||||
static int32_t mndTransExecSingleAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
||||
if (pAction->actionType) {
|
||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||
return mndTransWriteSingleLog(pMnode, pTrans, pAction);
|
||||
} else {
|
||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||
return mndTransSendSingleMsg(pMnode, pTrans, pAction);
|
||||
} else {
|
||||
pAction->rawWritten = 0;
|
||||
pAction->errCode = 0;
|
||||
mDebug("trans:%d, %s:%d null action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,14 @@ int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) {
|
||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return qWorkerPreprocessQueryMsg(pQnode->pQuery, pMsg);
|
||||
}
|
||||
|
||||
int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) {
|
||||
int32_t code = -1;
|
||||
SReadHandle handle = {.pMsgCb = &pQnode->msgCb};
|
||||
|
|
|
@ -56,6 +56,7 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg);
|
|||
int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
||||
int32_t vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
int32_t vnodePreprocessQueryMsg(SVnode * pVnode, SRpcMsg * pMsg);
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||
|
|
|
@ -190,7 +190,15 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int32_t vnodePreprocessQueryMsg(SVnode * pVnode, SRpcMsg * pMsg) {
|
||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return qWorkerPreprocessQueryMsg(pVnode->pQuery, pMsg);
|
||||
}
|
||||
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
vTrace("message in vnode query queue is processing");
|
||||
SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode, .pMsgCb = &pVnode->msgCb};
|
||||
switch (pMsg->msgType) {
|
||||
|
@ -279,56 +287,56 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
|
||||
SRpcMsg *pRpcMsg = pMsg;
|
||||
|
||||
if (pRpcMsg->msgType == TDMT_VND_SYNC_TIMEOUT) {
|
||||
if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnTimeoutCb(pSyncNode, pSyncMsg);
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING) {
|
||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
||||
syncPingDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
||||
syncPingReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
ret = syncNodeOnAppendEntriesCb(pSyncNode, pSyncMsg);
|
||||
syncAppendEntriesDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
||||
|
|
|
@ -328,6 +328,18 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
|
|||
CTG_ERR_JRET(ctgInitGetQnodeTask(pJob, taskIdx++));
|
||||
}
|
||||
|
||||
pJob->refId = taosAddRef(gCtgMgmt.jobPool, pJob);
|
||||
if (pJob->refId < 0) {
|
||||
ctgError("add job to ref failed, error: %s", tstrerror(terrno));
|
||||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
taosAcquireRef(gCtgMgmt.jobPool, pJob->refId);
|
||||
|
||||
qDebug("QID:%" PRIx64 ", job %" PRIx64 " initialized, task num %d", pJob->queryId, pJob->refId, *taskNum);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
|
||||
_return:
|
||||
taosMemoryFreeClear(*job);
|
||||
CTG_RET(code);
|
||||
|
|
|
@ -27,6 +27,10 @@ typedef struct {
|
|||
int32_t bytes;
|
||||
} SGroupKeys, SStateKeys;
|
||||
|
||||
int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList);
|
||||
uint64_t calcGroupId(char* pData, int32_t len);
|
||||
void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex);
|
||||
int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -333,6 +333,12 @@ typedef struct STableScanInfo {
|
|||
double sampleRatio; // data block sample ratio, 1 by default
|
||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
||||
|
||||
SArray* pGroupCols;
|
||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
||||
char* keyBuf; // group by keys for hash
|
||||
int32_t groupKeyLen; // total group by column width
|
||||
SHashObj* pGroupSet; // quick locate the window object for each result
|
||||
|
||||
int32_t curTWinIdx;
|
||||
} STableScanInfo;
|
||||
|
||||
|
@ -360,16 +366,18 @@ typedef struct SCatchSupporter {
|
|||
} SCatchSupporter;
|
||||
|
||||
typedef struct SStreamAggSupporter {
|
||||
SArray* pResultRows; // SResultWindowInfo
|
||||
SArray* pResultRows;
|
||||
int32_t keySize;
|
||||
char* pKeyBuf; // window key buffer
|
||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
||||
SArray* pScanWindow;
|
||||
} SStreamAggSupporter;
|
||||
|
||||
typedef struct SessionWindowSupporter {
|
||||
SStreamAggSupporter* pStreamAggSup;
|
||||
int64_t gap;
|
||||
uint8_t parentType;
|
||||
} SessionWindowSupporter;
|
||||
|
||||
typedef struct SStreamBlockScanInfo {
|
||||
|
@ -400,6 +408,7 @@ typedef struct SStreamBlockScanInfo {
|
|||
SArray* childIds;
|
||||
SessionWindowSupporter sessionSup;
|
||||
bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA.
|
||||
int32_t scanWinIndex;
|
||||
} SStreamBlockScanInfo;
|
||||
|
||||
typedef struct SSysTableScanInfo {
|
||||
|
@ -497,7 +506,7 @@ typedef struct SProjectOperatorInfo {
|
|||
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
|
||||
SOptrBasicInfo binfo;
|
||||
SAggSupporter aggSup;
|
||||
|
||||
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||
SSDataBlock* existDataBlock;
|
||||
SArray* pPseudoColInfo;
|
||||
SLimit limit;
|
||||
|
@ -587,6 +596,11 @@ typedef struct SResultWindowInfo {
|
|||
bool isClosed;
|
||||
} SResultWindowInfo;
|
||||
|
||||
typedef struct SStateWindowInfo {
|
||||
SResultWindowInfo winInfo;
|
||||
SStateKeys stateKey;
|
||||
} SStateWindowInfo;
|
||||
|
||||
typedef struct SStreamSessionAggOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SStreamAggSupporter streamAggSup;
|
||||
|
@ -600,7 +614,7 @@ typedef struct SStreamSessionAggOperatorInfo {
|
|||
SSDataBlock* pDelRes;
|
||||
SHashObj* pStDeleted;
|
||||
void* pDelIterator;
|
||||
SArray* pChildren; // cache for children's result;
|
||||
SArray* pChildren; // cache for children's result; final stream operator
|
||||
} SStreamSessionAggOperatorInfo;
|
||||
|
||||
typedef struct STimeSliceOperatorInfo {
|
||||
|
@ -624,6 +638,22 @@ typedef struct SStateWindowOperatorInfo {
|
|||
// bool reptScan;
|
||||
} SStateWindowOperatorInfo;
|
||||
|
||||
typedef struct SStreamStateAggOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SStreamAggSupporter streamAggSup;
|
||||
SGroupResInfo groupResInfo;
|
||||
int32_t primaryTsIndex; // primary timestamp slot id
|
||||
int32_t order; // current SSDataBlock scan order
|
||||
STimeWindowAggSupp twAggSup;
|
||||
SColumn stateCol; // start row index
|
||||
SqlFunctionCtx* pDummyCtx; // for combine
|
||||
SSDataBlock* pDelRes;
|
||||
SHashObj* pSeDeleted;
|
||||
void* pDelIterator;
|
||||
SArray* pScanWindow;
|
||||
SArray* pChildren; // cache for children's result;
|
||||
} SStreamStateAggOperatorInfo;
|
||||
|
||||
typedef struct SSortedMergeOperatorInfo {
|
||||
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
|
||||
SOptrBasicInfo binfo;
|
||||
|
@ -700,7 +730,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scan
|
|||
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz);
|
||||
|
||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SArray* pColMatchInfo);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||
void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols);
|
||||
void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow);
|
||||
|
@ -727,12 +757,12 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup);
|
||||
|
||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
||||
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SNode* pCondition, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||
SArray* pIndexMap, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
|
@ -781,6 +811,10 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pE
|
|||
SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
||||
SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap,
|
||||
int32_t tsSlotId, STimeWindowAggSupp* pTwAggSupp, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream,
|
||||
SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
#if 0
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
#endif
|
||||
|
@ -832,7 +866,8 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
|
|||
int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
||||
int32_t order);
|
||||
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
||||
int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
||||
int32_t initStateAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize);
|
||||
SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap,
|
||||
int32_t* pIndex);
|
||||
|
|
|
@ -345,7 +345,6 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
// In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
|
||||
// pResultRowInfo object.
|
||||
if (p1 != NULL) {
|
||||
|
||||
// todo
|
||||
pResult = getResultRowByPos(pResultBuf, p1);
|
||||
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset);
|
||||
|
@ -369,7 +368,8 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
|
||||
// add a new result set for a new group
|
||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition));
|
||||
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
|
||||
sizeof(SResultRowPosition));
|
||||
}
|
||||
|
||||
// 2. set the new time window to be the new active time window
|
||||
|
@ -551,7 +551,6 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow
|
|||
colDataAppendInt64(pColData, 4, &pQueryWindow->ekey);
|
||||
}
|
||||
|
||||
|
||||
void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow* pWin,
|
||||
SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol,
|
||||
int32_t numOfTotal, int32_t numOfOutput, int32_t order) {
|
||||
|
@ -1283,7 +1282,6 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
|
|||
hasOtherFunc = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (hasFirstLastFunc && status == BLK_DATA_NOT_LOAD) {
|
||||
|
@ -1765,7 +1763,6 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity, int32_t numOf
|
|||
// if (i > 0) pBInfo->pCtx[i].pTsOutput = pBInfo->pCtx[i - 1].pOutput;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1824,7 +1821,8 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
|||
}
|
||||
|
||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SArray* pColMatchInfo) {
|
||||
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||
if (pFilterNode == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -3669,6 +3667,8 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
longjmp(pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
doFilter(pProjectInfo->pFilterNode, pBlock);
|
||||
|
||||
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order, scanFlag, false);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
||||
|
||||
|
@ -4044,7 +4044,7 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
|
|||
}
|
||||
|
||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num,
|
||||
SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit,
|
||||
SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SNode* pCondition,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
|
@ -4056,8 +4056,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
|
|||
pInfo->slimit = *pSlimit;
|
||||
pInfo->curOffset = pLimit->offset;
|
||||
pInfo->curSOffset = pSlimit->offset;
|
||||
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
pInfo->pFilterNode= pCondition;
|
||||
|
||||
int32_t numOfCols = num;
|
||||
int32_t numOfRows = 4096;
|
||||
|
@ -4259,7 +4259,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
|
||||
pType->precision, pValNode->node.aliasName);
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_VALUE;
|
||||
valueNodeToVariant(pValNode, &pExp->base.pParam[0].param);
|
||||
nodesValueNodeToVariant(pValNode, &pExp->base.pParam[0].param);
|
||||
} else if (type == QUERY_NODE_FUNCTION) {
|
||||
pExp->pExpr->nodeType = QUERY_NODE_FUNCTION;
|
||||
SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr;
|
||||
|
@ -4302,7 +4302,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
} else if (p1->type == QUERY_NODE_VALUE) {
|
||||
SValueNode* pvn = (SValueNode*)p1;
|
||||
pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE;
|
||||
valueNodeToVariant(pvn, &pExp->base.pParam[j].param);
|
||||
nodesValueNodeToVariant(pvn, &pExp->base.pParam[j].param);
|
||||
}
|
||||
}
|
||||
} else if (type == QUERY_NODE_OPERATOR) {
|
||||
|
@ -4387,9 +4387,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
if (pDataReader == NULL && terrno != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SArray* groupKyes = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
||||
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||
SOperatorInfo* pOperator =
|
||||
createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, groupKyes, pTaskInfo);
|
||||
|
||||
STableScanInfo* pScanInfo = pOperator->info;
|
||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||
|
@ -4419,8 +4420,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
}
|
||||
SArray* tableIdList = extractTableIdList(pTableListInfo);
|
||||
|
||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle,
|
||||
tableIdList, pTableScanNode, pTaskInfo, &twSup);
|
||||
SOperatorInfo* pOperator =
|
||||
createStreamScanOperatorInfo(pDataReader, pHandle, tableIdList, pTableScanNode, pTaskInfo, &twSup);
|
||||
|
||||
taosArrayDestroy(tableIdList);
|
||||
return pOperator;
|
||||
|
@ -4486,7 +4487,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset};
|
||||
SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset};
|
||||
pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo);
|
||||
pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pProjPhyNode->node.pConditions, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) {
|
||||
SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode;
|
||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||
|
@ -4519,18 +4520,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
.offset = pIntervalPhyNode->offset,
|
||||
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision};
|
||||
|
||||
STimeWindowAggSupp as = {.waterMark = pIntervalPhyNode->window.watermark,
|
||||
STimeWindowAggSupp as = {
|
||||
.waterMark = pIntervalPhyNode->window.watermark,
|
||||
.calTrigger = pIntervalPhyNode->window.triggerType,
|
||||
.maxTs = INT64_MIN,
|
||||
.winMap = NULL,};
|
||||
.winMap = NULL,
|
||||
};
|
||||
if (isSmaStream(pIntervalPhyNode->window.triggerType)) {
|
||||
if (FLT_LESS(pIntervalPhyNode->window.filesFactor, 1.000000)) {
|
||||
as.calTrigger = STREAM_TRIGGER_AT_ONCE_SMA;
|
||||
} else {
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP);
|
||||
as.winMap = taosHashInit(64, hashFn, true, HASH_NO_LOCK);
|
||||
as.waterMark = getSmaWaterMark(interval.interval,
|
||||
pIntervalPhyNode->window.filesFactor);
|
||||
as.waterMark = getSmaWaterMark(interval.interval, pIntervalPhyNode->window.filesFactor);
|
||||
as.calTrigger = STREAM_TRIGGER_WINDOW_CLOSE_SMA;
|
||||
}
|
||||
}
|
||||
|
@ -4598,6 +4600,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr;
|
||||
SColumn col = extractColumnFromColumnNode(pColNode);
|
||||
pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, &as, tsSlotId, &col, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW == type) {
|
||||
pOptr = createStreamStateAggOperatorInfo(ops[0], pPhyNode, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) {
|
||||
SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*)pPhyNode;
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
@ -5183,14 +5187,17 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
|
||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey,
|
||||
size_t size) {
|
||||
pSup->keySize = sizeof(int64_t) + sizeof(TSKEY);
|
||||
pSup->pKeyBuf = taosMemoryCalloc(1, pSup->keySize);
|
||||
pSup->pResultRows = taosArrayInit(1024, sizeof(SResultWindowInfo));
|
||||
pSup->pResultRows = taosArrayInit(1024, size);
|
||||
if (pSup->pKeyBuf == NULL || pSup->pResultRows == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pSup->pScanWindow = taosArrayInit(4, sizeof(STimeWindow));
|
||||
|
||||
int32_t pageSize = 4096;
|
||||
while (pageSize < pSup->resultRowSize * 4) {
|
||||
pageSize <<= 1u;
|
||||
|
@ -5203,6 +5210,14 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
|
|||
return createDiskbasedBuf(&pSup->pResultBuf, pageSize, bufSize, pKey, TD_TMP_DIR_PATH);
|
||||
}
|
||||
|
||||
int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
|
||||
return initStreamAggSupporter(pSup, pKey, sizeof(SResultWindowInfo));
|
||||
}
|
||||
|
||||
int32_t initStateAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
|
||||
return initStreamAggSupporter(pSup, pKey, sizeof(SStateWindowInfo));
|
||||
}
|
||||
|
||||
int64_t getSmaWaterMark(int64_t interval, double filesFactor) {
|
||||
int64_t waterMark = 0;
|
||||
ASSERT(FLT_GREATEREQUAL(filesFactor, 0.000000));
|
||||
|
@ -5211,8 +5226,7 @@ int64_t getSmaWaterMark(int64_t interval, double filesFactor) {
|
|||
}
|
||||
|
||||
bool isSmaStream(int8_t triggerType) {
|
||||
if (triggerType == STREAM_TRIGGER_AT_ONCE ||
|
||||
triggerType == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||
if (triggerType == STREAM_TRIGGER_AT_ONCE || triggerType == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include "tcompare.h"
|
||||
#include "thash.h"
|
||||
#include "ttypes.h"
|
||||
#include "executorInt.h"
|
||||
|
||||
static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity);
|
||||
static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInfo** pGroupInfo, int32_t len);
|
||||
static uint64_t calcGroupId(char* pData, int32_t len);
|
||||
|
||||
static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
|
||||
SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param;
|
||||
|
@ -37,7 +37,7 @@ static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosArrayDestroy(pInfo->pGroupColVals);
|
||||
}
|
||||
|
||||
static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) {
|
||||
int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) {
|
||||
*pGroupColVals = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
if ((*pGroupColVals) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -93,7 +93,15 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
|
|||
|
||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t dataLen = getJsonValueLen(val);
|
||||
|
||||
if (memcmp(pkey->pData, val, dataLen) == 0){
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
int32_t len = varDataLen(val);
|
||||
if (len == varDataLen(pkey->pData) && memcmp(varDataVal(pkey->pData), varDataVal(val), len) == 0) {
|
||||
continue;
|
||||
|
@ -110,7 +118,7 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
|
|||
return true;
|
||||
}
|
||||
|
||||
static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex) {
|
||||
void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex) {
|
||||
SColumnDataAgg* pColAgg = NULL;
|
||||
|
||||
size_t numOfGroupCols = taosArrayGetSize(pGroupCols);
|
||||
|
@ -129,7 +137,10 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
|
|||
} else {
|
||||
pkey->isNull = false;
|
||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t dataLen = getJsonValueLen(val);
|
||||
memcpy(pkey->pData, val, dataLen);
|
||||
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
memcpy(pkey->pData, val, varDataTLen(val));
|
||||
ASSERT(varDataTLen(val) <= pkey->bytes);
|
||||
} else {
|
||||
|
@ -139,7 +150,7 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
|
||||
int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
|
||||
ASSERT(pKey != NULL);
|
||||
size_t numOfGroupCols = taosArrayGetSize(pGroupColVals);
|
||||
|
||||
|
@ -153,7 +164,11 @@ static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
|
|||
}
|
||||
|
||||
isNull[i] = 0;
|
||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t dataLen = getJsonValueLen(pkey->pData);
|
||||
memcpy(pStart, (pkey->pData), dataLen);
|
||||
pStart += dataLen;
|
||||
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
varDataCopy(pStart, pkey->pData);
|
||||
pStart += varDataTLen(pkey->pData);
|
||||
ASSERT(varDataTLen(pkey->pData) <= pkey->bytes);
|
||||
|
@ -178,7 +193,10 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
|
|||
char* dest = GET_ROWCELL_INTERBUF(pEntryInfo);
|
||||
char* data = colDataGetData(pColInfoData, rowIndex);
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t dataLen = getJsonValueLen(data);
|
||||
memcpy(dest, data, dataLen);
|
||||
} else if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
varDataCopy(dest, data);
|
||||
} else {
|
||||
memcpy(dest, data, pColInfoData->info.bytes);
|
||||
|
@ -341,7 +359,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
|||
|
||||
while(1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pRes);
|
||||
|
||||
bool hasRemain = hashRemainDataInGroupInfo(&pInfo->groupResInfo);
|
||||
if (!hasRemain) {
|
||||
|
@ -409,7 +427,6 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
|
||||
SPartitionOperatorInfo* pInfo = pOperator->info;
|
||||
|
||||
int32_t numOfGroupCols = taosArrayGetSize(pInfo->pGroupCols);
|
||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||
recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j);
|
||||
int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
||||
|
@ -448,6 +465,16 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
if (colDataIsNull_s(pColInfoData, j)) {
|
||||
offset[(*rows)] = -1;
|
||||
contentLen = 0;
|
||||
} else if(pColInfoData->info.type == TSDB_DATA_TYPE_JSON){
|
||||
offset[*rows] = (*columnLen);
|
||||
char* src = colDataGetData(pColInfoData, j);
|
||||
int32_t dataLen = getJsonValueLen(src);
|
||||
|
||||
memcpy(data + (*columnLen), src, dataLen);
|
||||
int32_t v = (data + (*columnLen) + dataLen - (char*)pPage);
|
||||
ASSERT(v > 0);
|
||||
|
||||
contentLen = dataLen;
|
||||
} else {
|
||||
offset[*rows] = (*columnLen);
|
||||
char* src = colDataGetData(pColInfoData, j);
|
||||
|
@ -622,8 +649,13 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
SPartitionOperatorInfo* pInfo = (SPartitionOperatorInfo*)param;
|
||||
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
||||
taosArrayDestroy(pInfo->pGroupCols);
|
||||
for(int i = 0; i < taosArrayGetSize(pInfo->pGroupColVals); i++){
|
||||
SGroupKeys key = *(SGroupKeys*)taosArrayGet(pInfo->pGroupColVals, i);
|
||||
taosMemoryFree(key.pData);
|
||||
}
|
||||
taosArrayDestroy(pInfo->pGroupColVals);
|
||||
taosMemoryFree(pInfo->keyBuf);
|
||||
taosHashCleanup(pInfo->pGroupSet);
|
||||
taosMemoryFree(pInfo->columnOffset);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "ttypes.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#include "executorInt.h"
|
||||
|
||||
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
||||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||
|
||||
|
@ -254,7 +256,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
|
|||
}
|
||||
|
||||
int64_t st = taosGetTimestampMs();
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo);
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||
|
||||
int64_t et = taosGetTimestampMs();
|
||||
pTableScanInfo->readRecorder.filterTime += (et - st);
|
||||
|
@ -373,6 +375,17 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
|||
longjmp(pOperator->pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
recordNewGroupKeys(pTableScanInfo->pGroupCols, pTableScanInfo->pGroupColVals, pBlock, 0);
|
||||
int32_t len = buildGroupKeys(pTableScanInfo->keyBuf, pTableScanInfo->pGroupColVals);
|
||||
|
||||
uint64_t *groupId = taosHashGet(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len);
|
||||
if (groupId) {
|
||||
pBlock->info.groupId = *groupId;
|
||||
}else if(len != 0){
|
||||
pBlock->info.groupId = calcGroupId(pTableScanInfo->keyBuf, len);
|
||||
taosHashPut(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len, &pBlock->info.groupId, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
// current block is filter out according to filter condition, continue load the next block
|
||||
if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) {
|
||||
continue;
|
||||
|
@ -497,21 +510,25 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosMemoryFree(pTableScanInfo->pResBlock);
|
||||
tsdbCleanupReadHandle(pTableScanInfo->dataReader);
|
||||
|
||||
taosArrayDestroy(pTableScanInfo->pGroupCols);
|
||||
for(int i = 0; i < taosArrayGetSize(pTableScanInfo->pGroupColVals); i++){
|
||||
SGroupKeys key = *(SGroupKeys*)taosArrayGet(pTableScanInfo->pGroupColVals, i);
|
||||
taosMemoryFree(key.pData);
|
||||
}
|
||||
taosArrayDestroy(pTableScanInfo->pGroupColVals);
|
||||
taosMemoryFree(pTableScanInfo->keyBuf);
|
||||
taosHashCleanup(pTableScanInfo->pGroupSet);
|
||||
if (pTableScanInfo->pColMatchInfo != NULL) {
|
||||
taosArrayDestroy(pTableScanInfo->pColMatchInfo);
|
||||
}
|
||||
}
|
||||
|
||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader,
|
||||
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) {
|
||||
SReadHandle* readHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo) {
|
||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||
|
@ -522,7 +539,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
|
||||
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return NULL;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
if (pTableScanNode->scan.pScanPseudoCols != NULL) {
|
||||
|
@ -552,6 +569,18 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
pOperator->numOfExprs = numOfCols;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
// for table group
|
||||
pInfo->pGroupCols = groupKyes;
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
pInfo->pGroupSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
|
||||
if (pInfo->pGroupSet == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, groupKyes);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, destroyTableScanOperatorInfo,
|
||||
NULL, NULL, getTableScannerExecInfo);
|
||||
|
||||
|
@ -559,6 +588,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
pOperator->cost.openCost = 0;
|
||||
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo) {
|
||||
|
@ -671,16 +706,23 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
|
|||
taosArrayClear(pInfo->pBlockLists);
|
||||
}
|
||||
|
||||
static bool isSessionWindow(SStreamBlockScanInfo* pInfo) { return pInfo->sessionSup.pStreamAggSup != NULL; }
|
||||
static bool isSessionWindow(SStreamBlockScanInfo* pInfo) {
|
||||
return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW;
|
||||
}
|
||||
|
||||
static bool isStateWindow(SStreamBlockScanInfo* pInfo) {
|
||||
return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW;
|
||||
}
|
||||
|
||||
static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
|
||||
SSDataBlock* pSDB = pInfo->pUpdateRes;
|
||||
if (pInfo->updateResIndex < pSDB->info.rows) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pSDB->pDataBlock, 0);
|
||||
STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX,};
|
||||
bool needRead = false;
|
||||
if (!isStateWindow(pInfo) && pInfo->updateResIndex < pSDB->info.rows) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pSDB->pDataBlock, pInfo->primaryTsIndex);
|
||||
TSKEY* tsCols = (TSKEY*)pColDataInfo->pData;
|
||||
SResultRowInfo dumyInfo;
|
||||
dumyInfo.cur.pageId = -1;
|
||||
STimeWindow win;
|
||||
if (isSessionWindow(pInfo)) {
|
||||
SStreamAggSupporter* pAggSup = pInfo->sessionSup.pStreamAggSup;
|
||||
int64_t gap = pInfo->sessionSup.gap;
|
||||
|
@ -696,15 +738,28 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
|
|||
pInfo->updateResIndex += getNumOfRowsInTimeWindow(&pSDB->info, tsCols, pInfo->updateResIndex, win.ekey,
|
||||
binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
||||
}
|
||||
needRead = true;
|
||||
} else if (isStateWindow(pInfo)) {
|
||||
SArray* pWins = pInfo->sessionSup.pStreamAggSup->pScanWindow;
|
||||
int32_t size = taosArrayGetSize(pWins);
|
||||
if (pInfo->scanWinIndex < size) {
|
||||
win = *(STimeWindow *)taosArrayGet(pWins, pInfo->scanWinIndex);
|
||||
pInfo->scanWinIndex++;
|
||||
needRead = true;
|
||||
} else {
|
||||
pInfo->scanWinIndex = 0;
|
||||
taosArrayClear(pWins);
|
||||
}
|
||||
}
|
||||
if (!needRead) {
|
||||
return false;
|
||||
}
|
||||
STableScanInfo* pTableScanInfo = pInfo->pOperatorDumy->info;
|
||||
pTableScanInfo->cond.twindows[0] = win;
|
||||
pTableScanInfo->curTWinIdx = 0;
|
||||
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
|
||||
pTableScanInfo->scanTimes = 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static SSDataBlock* doDataScan(SStreamBlockScanInfo* pInfo) {
|
||||
|
@ -719,36 +774,39 @@ static SSDataBlock* doDataScan(SStreamBlockScanInfo* pInfo) {
|
|||
return pResult;
|
||||
}
|
||||
|
||||
static SSDataBlock* getUpdateDataBlock(SStreamBlockScanInfo* pInfo, bool invertible) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pInfo->pRes->pDataBlock, pInfo->primaryTsIndex);
|
||||
static void getUpdateDataBlock(SStreamBlockScanInfo* pInfo, bool invertible,
|
||||
SSDataBlock* pBlock, SSDataBlock* pUpdateBlock) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
TSKEY* ts = (TSKEY*)pColDataInfo->pData;
|
||||
for (int32_t i = 0; i < pInfo->pRes->info.rows; i++) {
|
||||
if (updateInfoIsUpdated(pInfo->pUpdateInfo, pInfo->pRes->info.uid, ts[i])) {
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||
if (updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, ts[i])) {
|
||||
taosArrayPush(pInfo->tsArray, ts + i);
|
||||
}
|
||||
}
|
||||
if (!pUpdateBlock) {
|
||||
taosArrayClear(pInfo->tsArray);
|
||||
return;
|
||||
}
|
||||
int32_t size = taosArrayGetSize(pInfo->tsArray);
|
||||
if (size > 0 && invertible) {
|
||||
// TODO(liuyao) get from tsdb
|
||||
// SSDataBlock* p = createOneDataBlock(pInfo->pRes, true);
|
||||
// Todo(liuyao) get from tsdb
|
||||
// SSDataBlock* p = createOneDataBlock(pBlock, true);
|
||||
// p->info.type = STREAM_INVERT;
|
||||
// taosArrayClear(pInfo->tsArray);
|
||||
// return p;
|
||||
SSDataBlock* pDataBlock = createOneDataBlock(pInfo->pRes, false);
|
||||
SColumnInfoData* pCol = (SColumnInfoData*)taosArrayGet(pDataBlock->pDataBlock, 0);
|
||||
SColumnInfoData* pCol = (SColumnInfoData*)taosArrayGet(pUpdateBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
ASSERT(pCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
colInfoDataEnsureCapacity(pCol, 0, size);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
TSKEY* pTs = (TSKEY*)taosArrayGet(pInfo->tsArray, i);
|
||||
colDataAppend(pCol, i, (char*)pTs, false);
|
||||
}
|
||||
pDataBlock->info.rows = size;
|
||||
pDataBlock->info.type = STREAM_REPROCESS;
|
||||
blockDataUpdateTsWindow(pDataBlock, 0);
|
||||
pUpdateBlock->info.rows = size;
|
||||
pUpdateBlock->info.type = STREAM_REPROCESS;
|
||||
blockDataUpdateTsWindow(pUpdateBlock, 0);
|
||||
taosArrayClear(pInfo->tsArray);
|
||||
return pDataBlock;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||
|
@ -780,16 +838,27 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
|||
} else if (pInfo->scanMode == STREAM_SCAN_FROM_UPDATERES) {
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER;
|
||||
if (!isStateWindow(pInfo)) {
|
||||
prepareDataScan(pInfo);
|
||||
}
|
||||
return pInfo->pUpdateRes;
|
||||
} else if (pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER) {
|
||||
} else {
|
||||
if (isStateWindow(pInfo) &&
|
||||
taosArrayGetSize(pInfo->sessionSup.pStreamAggSup->pScanWindow) > 0) {
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER;
|
||||
pInfo->updateResIndex = pInfo->pUpdateRes->info.rows;
|
||||
prepareDataScan(pInfo);
|
||||
}
|
||||
if (pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER) {
|
||||
SSDataBlock* pSDB = doDataScan(pInfo);
|
||||
if (pSDB == NULL) {
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||
} else {
|
||||
getUpdateDataBlock(pInfo, true, pSDB, NULL);
|
||||
return pSDB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
@ -859,7 +928,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
|||
addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes);
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes);
|
||||
blockDataUpdateTsWindow(pInfo->pRes, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -871,7 +940,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
|||
if (rows == 0) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
} else if (pInfo->pUpdateInfo) {
|
||||
SSDataBlock* upRes = getUpdateDataBlock(pInfo, true);
|
||||
SSDataBlock* upRes = createOneDataBlock(pInfo->pRes, false);
|
||||
getUpdateDataBlock(pInfo, true, pInfo->pRes, upRes);
|
||||
if (upRes) {
|
||||
pInfo->pUpdateRes = upRes;
|
||||
if (upRes->info.type == STREAM_REPROCESS) {
|
||||
|
@ -901,7 +971,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
|
|||
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
||||
|
||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, NULL, pTaskInfo);
|
||||
|
||||
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
||||
|
||||
|
@ -915,6 +985,9 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
|
|||
|
||||
int16_t colId = id->colId;
|
||||
taosArrayPush(pColIds, &colId);
|
||||
if (id->colId == pTableScanNode->tsColId) {
|
||||
pInfo->primaryTsIndex = id->targetSlotId;
|
||||
}
|
||||
}
|
||||
|
||||
// set the extract column id to streamHandle
|
||||
|
@ -939,7 +1012,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
|
|||
pTwSup->waterMark = getSmaWaterMark(pSTInfo->interval.interval,
|
||||
pTableScanNode->filesFactor);
|
||||
}
|
||||
pInfo->primaryTsIndex = 0; // pTableScanNode->tsColId;
|
||||
|
||||
if (pSTInfo->interval.interval > 0 && pDataReader) {
|
||||
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark);
|
||||
} else {
|
||||
|
|
|
@ -22,14 +22,15 @@
|
|||
#include "thash.h"
|
||||
#include "ttime.h"
|
||||
|
||||
#include "function.h"
|
||||
#include "tdatablock.h"
|
||||
#include "executorInt.h"
|
||||
#include "function.h"
|
||||
#include "querynodes.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tfill.h"
|
||||
|
||||
#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC)
|
||||
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) ((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
|
||||
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) \
|
||||
((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
|
||||
|
||||
static void setTagsValue(SFillInfo* pFillInfo, void** data, int32_t genRows) {
|
||||
for (int32_t j = 0; j < pFillInfo->numOfCols; ++j) {
|
||||
|
@ -60,7 +61,8 @@ static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex)
|
|||
|
||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||
|
||||
static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSDataBlock* pSrcBlock, int64_t ts, bool outOfBound) {
|
||||
static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* pSrcBlock, int64_t ts,
|
||||
bool outOfBound) {
|
||||
SPoint point1, point2, point;
|
||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||
|
||||
|
@ -167,7 +169,8 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSData
|
|||
|
||||
// setTagsValue(pFillInfo, data, index);
|
||||
SInterval* pInterval = &pFillInfo->interval;
|
||||
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||
pFillInfo->currentKey =
|
||||
taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||
pFillInfo->numOfCurrent++;
|
||||
}
|
||||
|
||||
|
@ -236,9 +239,11 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next);
|
||||
}
|
||||
|
||||
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && pFillInfo->numOfCurrent < outputRows) {
|
||||
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||
pFillInfo->numOfCurrent < outputRows) {
|
||||
// fill the gap between two input rows
|
||||
while (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && pFillInfo->numOfCurrent < outputRows) {
|
||||
while (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||
pFillInfo->numOfCurrent < outputRows) {
|
||||
doFillOneRowResult(pFillInfo, pBlock, pFillInfo->pSrcBlock, ts, false);
|
||||
}
|
||||
|
||||
|
@ -298,7 +303,8 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
// set the tag value for final result
|
||||
// setTagsValue(pFillInfo, data, pFillInfo->numOfCurrent);
|
||||
SInterval* pInterval = &pFillInfo->interval;
|
||||
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||
pFillInfo->currentKey =
|
||||
taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||
|
||||
pFillInfo->index += 1;
|
||||
pFillInfo->numOfCurrent += 1;
|
||||
|
@ -399,7 +405,8 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
}
|
||||
|
||||
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, const char* id) {
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
|
||||
const char* id) {
|
||||
if (fillType == TSDB_FILL_NONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -414,12 +421,24 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
|||
pFillInfo->order = order;
|
||||
|
||||
switch (fillType) {
|
||||
case FILL_MODE_NONE: pFillInfo->type = TSDB_FILL_NONE; break;
|
||||
case FILL_MODE_PREV: pFillInfo->type = TSDB_FILL_PREV; break;
|
||||
case FILL_MODE_NULL: pFillInfo->type = TSDB_FILL_NULL; break;
|
||||
case FILL_MODE_LINEAR: pFillInfo->type = TSDB_FILL_LINEAR;break;
|
||||
case FILL_MODE_NEXT: pFillInfo->type = TSDB_FILL_NEXT; break;
|
||||
case FILL_MODE_VALUE: pFillInfo->type = TSDB_FILL_SET_VALUE; break;
|
||||
case FILL_MODE_NONE:
|
||||
pFillInfo->type = TSDB_FILL_NONE;
|
||||
break;
|
||||
case FILL_MODE_PREV:
|
||||
pFillInfo->type = TSDB_FILL_PREV;
|
||||
break;
|
||||
case FILL_MODE_NULL:
|
||||
pFillInfo->type = TSDB_FILL_NULL;
|
||||
break;
|
||||
case FILL_MODE_LINEAR:
|
||||
pFillInfo->type = TSDB_FILL_LINEAR;
|
||||
break;
|
||||
case FILL_MODE_NEXT:
|
||||
pFillInfo->type = TSDB_FILL_NEXT;
|
||||
break;
|
||||
case FILL_MODE_VALUE:
|
||||
pFillInfo->type = TSDB_FILL_SET_VALUE;
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return NULL;
|
||||
|
@ -524,12 +543,8 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
|
|||
int64_t numOfRes = -1;
|
||||
if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set.
|
||||
TSKEY lastKey = tsList[pFillInfo->numOfRows - 1];
|
||||
numOfRes = taosTimeCountInterval(
|
||||
lastKey,
|
||||
pFillInfo->currentKey,
|
||||
pFillInfo->interval.sliding,
|
||||
pFillInfo->interval.slidingUnit,
|
||||
pFillInfo->interval.precision);
|
||||
numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding,
|
||||
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
|
||||
numOfRes += 1;
|
||||
assert(numOfRes >= numOfRows);
|
||||
} else { // reach the end of data
|
||||
|
@ -537,19 +552,16 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
|
|||
(ekey1 > pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) {
|
||||
return 0;
|
||||
}
|
||||
numOfRes = taosTimeCountInterval(
|
||||
ekey1,
|
||||
pFillInfo->currentKey,
|
||||
pFillInfo->interval.sliding,
|
||||
pFillInfo->interval.slidingUnit,
|
||||
pFillInfo->interval.precision);
|
||||
numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding,
|
||||
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
|
||||
numOfRes += 1;
|
||||
}
|
||||
|
||||
return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes;
|
||||
}
|
||||
|
||||
int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* point1, SPoint* point2, int32_t inputType) {
|
||||
int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* point1, SPoint* point2,
|
||||
int32_t inputType) {
|
||||
double v1 = -1, v2 = -1;
|
||||
GET_TYPED_DATA(v1, double, inputType, point1->val);
|
||||
GET_TYPED_DATA(v2, double, inputType, point2->val);
|
||||
|
@ -574,16 +586,16 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
|
|||
assert(numOfRes == pFillInfo->numOfCurrent);
|
||||
}
|
||||
|
||||
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64", current:%d, total:%d, %p",
|
||||
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey, pFillInfo->numOfCurrent,
|
||||
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64",
|
||||
// current:%d, total:%d, %p",
|
||||
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
|
||||
// pFillInfo->numOfCurrent,
|
||||
// pFillInfo->numOfTotal, pFillInfo->handle);
|
||||
|
||||
return numOfRes;
|
||||
}
|
||||
|
||||
int64_t getFillInfoStart(struct SFillInfo *pFillInfo) {
|
||||
return pFillInfo->start;
|
||||
}
|
||||
int64_t getFillInfoStart(struct SFillInfo* pFillInfo) { return pFillInfo->start; }
|
||||
|
||||
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* pValNode) {
|
||||
SFillColInfo* pFillCol = taosMemoryCalloc(numOfOutput, sizeof(SFillColInfo));
|
||||
|
@ -603,7 +615,7 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
|
|||
int32_t index = (i >= len) ? (len - 1) : i;
|
||||
|
||||
SValueNode* pv = (SValueNode*)nodesListGetNode(pValNode->pNodeList, index);
|
||||
valueNodeToVariant(pv, &pFillCol[i].fillVal);
|
||||
nodesValueNodeToVariant(pv, &pFillCol[i].fillVal);
|
||||
}
|
||||
|
||||
if (pExprInfo->base.numOfParams > 0) {
|
||||
|
|
|
@ -10,7 +10,7 @@ typedef enum SResultTsInterpType {
|
|||
} SResultTsInterpType;
|
||||
|
||||
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator);
|
||||
static SSDataBlock* doStreamSessionWindowAgg(SOperatorInfo* pOperator);
|
||||
static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator);
|
||||
|
||||
static int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo);
|
||||
|
||||
|
@ -2097,12 +2097,13 @@ void initDummyFunction(SqlFunctionCtx* pDummy, SqlFunctionCtx* pCtx, int32_t num
|
|||
pDummy[i].functionId = pCtx[i].functionId;
|
||||
}
|
||||
}
|
||||
void initDownStream(SOperatorInfo* downstream, SStreamSessionAggOperatorInfo* pInfo) {
|
||||
void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, int64_t gap,
|
||||
int64_t waterMark, uint8_t type) {
|
||||
ASSERT(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
||||
SStreamBlockScanInfo* pScanInfo = downstream->info;
|
||||
pScanInfo->sessionSup =
|
||||
(SessionWindowSupporter){.pStreamAggSup = &pInfo->streamAggSup, .gap = pInfo->gap};
|
||||
pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 60000 * 60 * 6);
|
||||
(SessionWindowSupporter){.pStreamAggSup = pAggSup, .gap = gap, .parentType = type};
|
||||
pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, waterMark);
|
||||
}
|
||||
|
||||
SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
||||
|
@ -2118,7 +2119,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
|||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
|
||||
code = initStreamAggSupporter(&pInfo->streamAggSup, "StreamSessionAggOperatorInfo");
|
||||
code = initSessionAggSupporter(&pInfo->streamAggSup, "StreamSessionAggOperatorInfo");
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -2158,11 +2159,12 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
|||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfExprs = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionWindowAgg,
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg,
|
||||
NULL, NULL, destroyStreamSessionAggOperatorInfo, aggEncodeResultRow,
|
||||
aggDecodeResultRow, NULL);
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
initDownStream(downstream, pInfo);
|
||||
initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap,
|
||||
pInfo->twAggSup.waterMark, pOperator->operatorType);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
||||
|
@ -2208,6 +2210,7 @@ SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap
|
|||
int32_t* pIndex) {
|
||||
int32_t size = taosArrayGetSize(pWinInfos);
|
||||
if (size == 0) {
|
||||
*pIndex = 0;
|
||||
return addNewSessionWindow(pWinInfos, ts);
|
||||
}
|
||||
// find the first position which is smaller than the key
|
||||
|
@ -2234,8 +2237,8 @@ SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap
|
|||
*pIndex = taosArrayGetSize(pWinInfos);
|
||||
return addNewSessionWindow(pWinInfos, ts);
|
||||
}
|
||||
*pIndex = index;
|
||||
return insertNewSessionWindow(pWinInfos, ts, index);
|
||||
*pIndex = index + 1;
|
||||
return insertNewSessionWindow(pWinInfos, ts, index + 1);
|
||||
}
|
||||
|
||||
int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows,
|
||||
|
@ -2290,24 +2293,41 @@ static int32_t setWindowOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pRes
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doOneWindowAgg(SStreamSessionAggOperatorInfo* pInfo,
|
||||
static int32_t doOneWindowAggImpl(int32_t tsColId, SOptrBasicInfo* pBinfo,
|
||||
SStreamAggSupporter* pAggSup, SColumnInfoData* pTimeWindowData,
|
||||
SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult,
|
||||
int32_t startIndex, int32_t winRows, int32_t numOutput, SExecTaskInfo* pTaskInfo) {
|
||||
SColumnInfoData* pColDataInfo =
|
||||
taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
taosArrayGet(pSDataBlock->pDataBlock, tsColId);
|
||||
TSKEY* tsCols = (int64_t*)pColDataInfo->pData;
|
||||
int32_t code = setWindowOutputBuf(pCurWin, pResult, pInfo->binfo.pCtx, pSDataBlock->info.groupId,
|
||||
numOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->streamAggSup, pTaskInfo);
|
||||
int32_t code = setWindowOutputBuf(pCurWin, pResult, pBinfo->pCtx,
|
||||
pSDataBlock->info.groupId, numOutput, pBinfo->rowCellInfoOffset,
|
||||
pAggSup, pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || (*pResult) == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pCurWin->win, true);
|
||||
doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &pCurWin->win,
|
||||
&pInfo->twAggSup.timeWindowData, startIndex, winRows, tsCols, pSDataBlock->info.rows,
|
||||
numOutput, TSDB_ORDER_ASC);
|
||||
updateTimeWindowInfo(pTimeWindowData, &pCurWin->win, true);
|
||||
doApplyFunctions(pTaskInfo, pBinfo->pCtx, &pCurWin->win, pTimeWindowData, startIndex,
|
||||
winRows, tsCols, pSDataBlock->info.rows, numOutput, TSDB_ORDER_ASC);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doOneWindowAgg(SStreamSessionAggOperatorInfo* pInfo,
|
||||
SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult,
|
||||
int32_t startIndex, int32_t winRows, int32_t numOutput, SExecTaskInfo* pTaskInfo) {
|
||||
return doOneWindowAggImpl(pInfo->primaryTsIndex, &pInfo->binfo, &pInfo->streamAggSup,
|
||||
&pInfo->twAggSup.timeWindowData, pSDataBlock, pCurWin, pResult, startIndex,
|
||||
winRows, numOutput, pTaskInfo);
|
||||
}
|
||||
|
||||
static int32_t doOneStateWindowAgg(SStreamStateAggOperatorInfo* pInfo,
|
||||
SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult,
|
||||
int32_t startIndex, int32_t winRows, int32_t numOutput, SExecTaskInfo* pTaskInfo) {
|
||||
return doOneWindowAggImpl(pInfo->primaryTsIndex, &pInfo->binfo, &pInfo->streamAggSup,
|
||||
&pInfo->twAggSup.timeWindowData, pSDataBlock, pCurWin, pResult, startIndex,
|
||||
winRows, numOutput, pTaskInfo);
|
||||
}
|
||||
|
||||
int32_t copyWinInfoToDataBlock(SSDataBlock* pBlock, SStreamAggSupporter* pAggSup,
|
||||
int32_t start, int32_t num, int32_t numOfExprs, SOptrBasicInfo* pBinfo) {
|
||||
for (int32_t i = start; i < num; i += 1) {
|
||||
|
@ -2366,7 +2386,7 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
|
|||
}
|
||||
}
|
||||
|
||||
static void doStreamSessionWindowAggImpl(SOperatorInfo* pOperator,
|
||||
static void doStreamSessionAggImpl(SOperatorInfo* pOperator,
|
||||
SSDataBlock* pSDataBlock, SHashObj* pStUpdated, SHashObj* pStDeleted) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||
|
@ -2395,8 +2415,8 @@ static void doStreamSessionWindowAggImpl(SOperatorInfo* pOperator,
|
|||
int32_t winIndex = 0;
|
||||
SResultWindowInfo* pCurWin =
|
||||
getSessionTimeWindow(pAggSup->pResultRows, tsCols[i], gap, &winIndex);
|
||||
winRows =
|
||||
updateSessionWindowInfo(pCurWin, tsCols, pSDataBlock->info.rows, i, pInfo->gap, pStDeleted);
|
||||
winRows = updateSessionWindowInfo(pCurWin, tsCols, pSDataBlock->info.rows, i,
|
||||
pInfo->gap, pStDeleted);
|
||||
code = doOneWindowAgg(pInfo, pSDataBlock, pCurWin, &pResult, i, winRows, numOfOutput, pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -2512,12 +2532,21 @@ bool isFinalSession(SStreamSessionAggOperatorInfo* pInfo) {
|
|||
return pInfo->pChildren != NULL;
|
||||
}
|
||||
|
||||
typedef SResultWindowInfo* (*__get_win_info_)(void *);
|
||||
SResultWindowInfo* getSessionWinInfo(void* pData) {
|
||||
return (SResultWindowInfo*) pData;
|
||||
}
|
||||
SResultWindowInfo* getStateWinInfo(void* pData) {
|
||||
return &((SStateWindowInfo*) pData)->winInfo;
|
||||
}
|
||||
|
||||
int32_t closeSessionWindow(SArray *pWins, STimeWindowAggSupp *pTwSup, SArray *pClosed,
|
||||
int8_t calTrigger) {
|
||||
int8_t calTrigger, __get_win_info_ fn) {
|
||||
// Todo(liuyao) save window to tdb
|
||||
int32_t size = taosArrayGetSize(pWins);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SResultWindowInfo *pSeWin = taosArrayGet(pWins, i);
|
||||
void *pWin = taosArrayGet(pWins, i);
|
||||
SResultWindowInfo *pSeWin = fn(pWin);
|
||||
if (pSeWin->win.ekey < pTwSup->maxTs - pTwSup->waterMark) {
|
||||
if (!pSeWin->isClosed) {
|
||||
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
|
||||
|
@ -2543,7 +2572,7 @@ int32_t closeSessionWindow(SArray *pWins, STimeWindowAggSupp *pTwSup, SArray *pC
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SSDataBlock* doStreamSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||
static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2592,9 +2621,9 @@ static SSDataBlock* doStreamSessionWindowAgg(SOperatorInfo* pOperator) {
|
|||
if (isFinalSession(pInfo)) {
|
||||
int32_t childIndex = 0; //Todo(liuyao) get child id from SSDataBlock
|
||||
SOptrBasicInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
|
||||
doStreamSessionWindowAggImpl(pOperator, pBlock, NULL, NULL);
|
||||
doStreamSessionAggImpl(pOperator, pBlock, NULL, NULL);
|
||||
}
|
||||
doStreamSessionWindowAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted);
|
||||
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted);
|
||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||
}
|
||||
// restore the value
|
||||
|
@ -2602,7 +2631,7 @@ static SSDataBlock* doStreamSessionWindowAgg(SOperatorInfo* pOperator) {
|
|||
|
||||
SArray* pClosed = taosArrayInit(16, POINTER_BYTES);
|
||||
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pClosed,
|
||||
pInfo->twAggSup.calTrigger);
|
||||
pInfo->twAggSup.calTrigger, getSessionWinInfo);
|
||||
SArray* pUpdated = taosArrayInit(16, POINTER_BYTES);
|
||||
copyUpdateResult(pStUpdated, pUpdated, pBInfo->pRes->info.groupId);
|
||||
taosHashCleanup(pStUpdated);
|
||||
|
@ -2658,3 +2687,396 @@ _error:
|
|||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) {
|
||||
SStreamStateAggOperatorInfo* pInfo = (SStreamStateAggOperatorInfo *)param;
|
||||
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
||||
destroyStreamAggSupporter(&pInfo->streamAggSup);
|
||||
cleanupGroupResInfo(&pInfo->groupResInfo);
|
||||
if (pInfo->pChildren != NULL) {
|
||||
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SOperatorInfo *pChild = taosArrayGetP(pInfo->pChildren, i);
|
||||
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
||||
destroyStreamSessionAggOperatorInfo(pChInfo, numOfOutput);
|
||||
taosMemoryFreeClear(pChild);
|
||||
taosMemoryFreeClear(pChInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t getStateWinTsKey(void* data, int32_t index) {
|
||||
SStateWindowInfo* pStateWin = taosArrayGet(data, index);
|
||||
return pStateWin->winInfo.win.ekey;
|
||||
}
|
||||
|
||||
SStateWindowInfo* addNewStateWindow(SArray* pWinInfos, TSKEY ts, char* pKeyData,
|
||||
SColumn* pCol) {
|
||||
SStateWindowInfo win = {.stateKey.bytes = pCol->bytes,
|
||||
.stateKey.type = pCol->type,
|
||||
.stateKey.pData = taosMemoryCalloc(1, pCol->bytes),
|
||||
.winInfo.pos.offset = -1, .winInfo.pos.pageId = -1,
|
||||
.winInfo.win.skey = ts, .winInfo.win.ekey = ts,
|
||||
.winInfo.isOutput = false,
|
||||
.winInfo.isClosed = false,
|
||||
};
|
||||
if (IS_VAR_DATA_TYPE(win.stateKey.type)) {
|
||||
varDataCopy(win.stateKey.pData, pKeyData);
|
||||
} else {
|
||||
memcpy(win.stateKey.pData, pKeyData, win.stateKey.bytes);
|
||||
}
|
||||
return taosArrayPush(pWinInfos, &win);
|
||||
}
|
||||
|
||||
SStateWindowInfo* insertNewStateWindow(SArray* pWinInfos, TSKEY ts, char* pKeyData,
|
||||
int32_t index, SColumn* pCol) {
|
||||
SStateWindowInfo win = {.stateKey.bytes = pCol->bytes,
|
||||
.stateKey.type = pCol->type,
|
||||
.stateKey.pData = taosMemoryCalloc(1, pCol->bytes),
|
||||
.winInfo.pos.offset = -1, .winInfo.pos.pageId = -1,
|
||||
.winInfo.win.skey = ts, .winInfo.win.ekey = ts,
|
||||
.winInfo.isOutput = false,
|
||||
.winInfo.isClosed = false,
|
||||
};
|
||||
if (IS_VAR_DATA_TYPE(win.stateKey.type)) {
|
||||
varDataCopy(win.stateKey.pData, pKeyData);
|
||||
} else {
|
||||
memcpy(win.stateKey.pData, pKeyData, win.stateKey.bytes);
|
||||
}
|
||||
return taosArrayInsert(pWinInfos, index, &win);
|
||||
}
|
||||
|
||||
bool isTsInWindow(SStateWindowInfo* pWin, TSKEY ts) {
|
||||
if (pWin->winInfo.win.skey <= ts && ts <= pWin->winInfo.win.ekey) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isEqualStateKey(SStateWindowInfo* pWin, char* pKeyData) {
|
||||
return pKeyData && compareVal(pKeyData, &pWin->stateKey);
|
||||
}
|
||||
|
||||
SStateWindowInfo* getStateWindowByTs(SArray* pWinInfos, TSKEY ts, int32_t* pIndex) {
|
||||
int32_t size = taosArrayGetSize(pWinInfos);
|
||||
int32_t index = binarySearch(pWinInfos, size, ts, TSDB_ORDER_DESC, getStateWinTsKey);
|
||||
SStateWindowInfo* pWin = NULL;
|
||||
if (index >= 0) {
|
||||
pWin = taosArrayGet(pWinInfos, index);
|
||||
if (isTsInWindow(pWin, ts)) {
|
||||
*pIndex = index;
|
||||
return pWin;
|
||||
}
|
||||
}
|
||||
|
||||
if (index + 1 < size) {
|
||||
pWin = taosArrayGet(pWinInfos, index + 1);
|
||||
if (isTsInWindow(pWin, ts)) {
|
||||
*pIndex = index + 1;
|
||||
return pWin;
|
||||
}
|
||||
}
|
||||
*pIndex = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SStateWindowInfo* getStateWindow(SArray* pWinInfos, TSKEY ts, char* pKeyData,
|
||||
SColumn* pCol, int32_t* pIndex) {
|
||||
int32_t size = taosArrayGetSize(pWinInfos);
|
||||
if (size == 0) {
|
||||
*pIndex = 0;
|
||||
return addNewStateWindow(pWinInfos, ts, pKeyData, pCol);
|
||||
}
|
||||
int32_t index = binarySearch(pWinInfos, size, ts, TSDB_ORDER_DESC, getStateWinTsKey);
|
||||
SStateWindowInfo* pWin = NULL;
|
||||
if (index >= 0) {
|
||||
pWin = taosArrayGet(pWinInfos, index);
|
||||
if (isTsInWindow(pWin, ts)) {
|
||||
*pIndex = index;
|
||||
return pWin;
|
||||
}
|
||||
}
|
||||
|
||||
if (index + 1 < size) {
|
||||
pWin = taosArrayGet(pWinInfos, index + 1);
|
||||
if (isTsInWindow(pWin, ts) || isEqualStateKey(pWin, pKeyData)) {
|
||||
*pIndex = index + 1;
|
||||
return pWin;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
pWin = taosArrayGet(pWinInfos, index);
|
||||
if (isEqualStateKey(pWin, pKeyData)) {
|
||||
*pIndex = index;
|
||||
return pWin;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == size - 1) {
|
||||
*pIndex = taosArrayGetSize(pWinInfos);
|
||||
return addNewStateWindow(pWinInfos, ts, pKeyData, pCol);
|
||||
}
|
||||
*pIndex = index + 1;
|
||||
return insertNewStateWindow(pWinInfos, ts, pKeyData, index + 1, pCol);
|
||||
}
|
||||
|
||||
int32_t updateStateWindowInfo(SArray* pWinInfos, int32_t winIndex, TSKEY* pTs,
|
||||
SColumnInfoData* pKeyCol, int32_t rows, int32_t start, bool* allEqual,
|
||||
SHashObj* pSeDelete) {
|
||||
*allEqual = true;
|
||||
SStateWindowInfo* pWinInfo = taosArrayGet(pWinInfos, winIndex);
|
||||
for (int32_t i = start; i < rows; ++i) {
|
||||
char* pKeyData = colDataGetData(pKeyCol, i);
|
||||
if (!isTsInWindow(pWinInfo, pTs[i])) {
|
||||
if(isEqualStateKey(pWinInfo, pKeyData)) {
|
||||
int32_t size = taosArrayGetSize(pWinInfos);
|
||||
if (winIndex + 1 < size) {
|
||||
SStateWindowInfo* pNextWin = taosArrayGet(pWinInfos, winIndex + 1);
|
||||
// ts belongs to the next window
|
||||
if (pTs[i] >= pNextWin->winInfo.win.skey) {
|
||||
return i - start;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return i - start;
|
||||
}
|
||||
}
|
||||
if (pWinInfo->winInfo.win.skey > pTs[i]) {
|
||||
if (pSeDelete && pWinInfo->winInfo.isOutput) {
|
||||
taosHashPut(pSeDelete, &pWinInfo->winInfo.pos, sizeof(SResultRowPosition), &pWinInfo->winInfo.win.skey, sizeof(TSKEY));
|
||||
pWinInfo->winInfo.isOutput = false;
|
||||
}
|
||||
pWinInfo->winInfo.win.skey = pTs[i];
|
||||
}
|
||||
pWinInfo->winInfo.win.ekey = TMAX(pWinInfo->winInfo.win.ekey, pTs[i]);
|
||||
if (!isEqualStateKey(pWinInfo, pKeyData)) {
|
||||
*allEqual = false;
|
||||
}
|
||||
}
|
||||
return rows - start;
|
||||
}
|
||||
|
||||
void deleteWindow(SArray* pWinInfos, int32_t index) {
|
||||
ASSERT(index >=0 && index < taosArrayGetSize(pWinInfos));
|
||||
taosArrayRemove(pWinInfos, index);
|
||||
}
|
||||
|
||||
static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock,
|
||||
int32_t tsIndex, SColumn* pCol, int32_t keyIndex, SHashObj* pSeUpdated, SHashObj* pSeDeleted) {
|
||||
SColumnInfoData* pTsColInfo = taosArrayGet(pBlock->pDataBlock, tsIndex);
|
||||
SColumnInfoData* pKeyColInfo = taosArrayGet(pBlock->pDataBlock, keyIndex);
|
||||
TSKEY* tsCol = (TSKEY *)pTsColInfo->pData;
|
||||
bool allEqual = false;
|
||||
int32_t step = 1;
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
||||
int32_t winIndex = 0;
|
||||
SStateWindowInfo* pCurWin = getStateWindowByTs(pAggSup->pResultRows, tsCol[i], &winIndex);
|
||||
if (!pCurWin) {
|
||||
continue;
|
||||
}
|
||||
step = updateStateWindowInfo(pAggSup->pResultRows, winIndex, tsCol, pKeyColInfo,
|
||||
pBlock->info.rows, i, &allEqual, pSeDeleted);
|
||||
ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData));
|
||||
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
||||
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
||||
deleteWindow(pAggSup->pResultRows, winIndex);
|
||||
}
|
||||
}
|
||||
|
||||
static void doStreamStateAggImpl(SOperatorInfo* pOperator,
|
||||
SSDataBlock* pSDataBlock, SHashObj* pSeUpdated, SHashObj* pStDeleted) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
||||
bool masterScan = true;
|
||||
int32_t numOfOutput = pOperator->numOfExprs;
|
||||
int64_t groupId = pSDataBlock->info.groupId;
|
||||
int64_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t step = 1;
|
||||
bool ascScan = true;
|
||||
TSKEY* tsCols = NULL;
|
||||
SResultRow* pResult = NULL;
|
||||
int32_t winRows = 0;
|
||||
if (pSDataBlock->pDataBlock != NULL) {
|
||||
SColumnInfoData* pColDataInfo =
|
||||
taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
tsCols = (int64_t *)pColDataInfo->pData;
|
||||
} else {
|
||||
return ;
|
||||
}
|
||||
|
||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||
SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId);
|
||||
for(int32_t i = 0; i < pSDataBlock->info.rows; i += winRows) {
|
||||
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
||||
int32_t winIndex = 0;
|
||||
bool allEqual = true;
|
||||
SStateWindowInfo* pCurWin =
|
||||
getStateWindow(pAggSup->pResultRows, tsCols[i], pKeyData, &pInfo->stateCol, &winIndex);
|
||||
winRows = updateStateWindowInfo(pAggSup->pResultRows, winIndex, tsCols, pKeyColInfo,
|
||||
pSDataBlock->info.rows, i, &allEqual, pInfo->pSeDeleted);
|
||||
if (!allEqual) {
|
||||
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
||||
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
||||
deleteWindow(pAggSup->pResultRows, winIndex);
|
||||
continue;
|
||||
}
|
||||
code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows,
|
||||
numOfOutput, pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
pCurWin->winInfo.isClosed = false;
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||
code = taosHashPut(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition), &(pCurWin->winInfo.win.skey), sizeof(TSKEY));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
pCurWin->winInfo.isOutput = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||
doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||
if (pInfo->pDelRes->info.rows > 0) {
|
||||
return pInfo->pDelRes;
|
||||
}
|
||||
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo,
|
||||
pInfo->streamAggSup.pResultBuf);
|
||||
if (pBInfo->pRes->info.rows == 0 ||
|
||||
!hashRemainDataInGroupInfo(&pInfo->groupResInfo)) {
|
||||
doSetOperatorCompleted(pOperator);
|
||||
}
|
||||
return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes;
|
||||
}
|
||||
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
SHashObj* pSeUpdated = taosHashInit(64, hashFn, true, HASH_NO_LOCK);
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
}
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||
doClearStateWindows(&pInfo->streamAggSup, pBlock, pInfo->primaryTsIndex,
|
||||
&pInfo->stateCol, pInfo->stateCol.slotId, pSeUpdated, pInfo->pSeDeleted);
|
||||
continue;
|
||||
}
|
||||
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
|
||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||
}
|
||||
// restore the value
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
|
||||
SArray* pClosed = taosArrayInit(16, POINTER_BYTES);
|
||||
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pClosed,
|
||||
pInfo->twAggSup.calTrigger, getStateWinInfo);
|
||||
SArray* pUpdated = taosArrayInit(16, POINTER_BYTES);
|
||||
copyUpdateResult(pSeUpdated, pUpdated, pBInfo->pRes->info.groupId);
|
||||
taosHashCleanup(pSeUpdated);
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||
taosArrayAddAll(pUpdated, pClosed);
|
||||
}
|
||||
|
||||
finalizeUpdatedResult(pOperator->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated,
|
||||
pInfo->binfo.rowCellInfoOffset);
|
||||
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||
if (pInfo->pDelRes->info.rows > 0) {
|
||||
return pInfo->pDelRes;
|
||||
}
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo,
|
||||
pInfo->streamAggSup.pResultBuf);
|
||||
return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes;
|
||||
}
|
||||
|
||||
SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream,
|
||||
SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) {
|
||||
SStreamStateWinodwPhysiNode* pStateNode = (SStreamStateWinodwPhysiNode *)pPhyNode;
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
int32_t tsSlotId = ((SColumnNode *)pStateNode->window.pTspk)->slotId;
|
||||
SColumnNode* pColNode = (SColumnNode *)((STargetNode *)pStateNode->pStateKey)->pExpr;
|
||||
|
||||
SStreamStateAggOperatorInfo* pInfo =
|
||||
taosMemoryCalloc(1, sizeof(SStreamStateAggOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &numOfCols);
|
||||
|
||||
pInfo->stateCol = extractColumnFromColumnNode(pColNode);
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
||||
pInfo->twAggSup = (STimeWindowAggSupp) {.waterMark = pStateNode->window.watermark,
|
||||
.calTrigger = pStateNode->window.triggerType,
|
||||
.maxTs = INT64_MIN,
|
||||
.winMap = NULL,};
|
||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||
int32_t code = initStateAggSupporter(&pInfo->streamAggSup, "StreamStateAggOperatorInfo");
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
code = initBiasicInfo(&pInfo->binfo, pExprInfo, numOfCols, pResBlock,
|
||||
pInfo->streamAggSup.pResultBuf);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->streamAggSup.resultRowSize = getResultRowSize(pInfo->binfo.pCtx, numOfCols);
|
||||
pInfo->pDummyCtx = (SqlFunctionCtx*)taosMemoryCalloc(numOfCols, sizeof(SqlFunctionCtx));
|
||||
if (pInfo->pDummyCtx == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
initDummyFunction(pInfo->pDummyCtx, pInfo->binfo.pCtx, numOfCols);
|
||||
pInfo->primaryTsIndex = tsSlotId;
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
pInfo->pSeDeleted = taosHashInit(64, hashFn, true, HASH_NO_LOCK);
|
||||
pInfo->pDelIterator = NULL;
|
||||
pInfo->pDelRes = createOneDataBlock(pResBlock, false);
|
||||
blockDataEnsureCapacity(pInfo->pDelRes, 64);
|
||||
pInfo->pChildren = NULL;
|
||||
|
||||
pOperator->name = "StreamStateAggOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW;
|
||||
pOperator->blocking = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->numOfExprs = numOfCols;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL,
|
||||
NULL, destroyStreamStateOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
initDownStream(downstream, &pInfo->streamAggSup, 0, pInfo->twAggSup.waterMark,
|
||||
pOperator->operatorType);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
destroyStreamStateOperatorInfo(pInfo, numOfCols);
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -610,8 +610,7 @@ int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
|||
} else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
|
||||
pDBuf->dsum += pSBuf->dsum;
|
||||
}
|
||||
|
||||
SET_VAL(pDResInfo, *((int64_t*)pDBuf), 1);
|
||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1394,7 +1393,7 @@ int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3
|
|||
pDBuf->v = pSBuf->v;
|
||||
}
|
||||
}
|
||||
SET_VAL(pDResInfo, *((int64_t*)pDBuf), 1);
|
||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1639,6 +1638,7 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
|||
pDBuf->quadraticDSum += pSBuf->quadraticDSum;
|
||||
}
|
||||
pDBuf->count += pSBuf->count;
|
||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
|||
dataLen = 0;
|
||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
dataLen = varDataTLen(pData + CHAR_BYTES);
|
||||
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
} else if (*pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
dataLen = LONG_BYTES;
|
||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = CHAR_BYTES;
|
||||
|
@ -513,7 +513,6 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
|||
if (node->opType == OP_TYPE_JSON_GET_VALUE || node->opType == OP_TYPE_JSON_CONTAINS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SIFParam *params = NULL;
|
||||
|
||||
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||
|
@ -521,14 +520,12 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
|||
output->arg = ctx->arg;
|
||||
sif_func_t operFn = sifNullFunc;
|
||||
code = sifGetOperFn(node->opType, &operFn, &output->status);
|
||||
if (ctx->noExec) {
|
||||
SIF_RET(code);
|
||||
} else {
|
||||
return operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
||||
if (!ctx->noExec) {
|
||||
code = operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
||||
}
|
||||
_return:
|
||||
|
||||
taosMemoryFree(params);
|
||||
SIF_RET(code);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||
|
@ -538,7 +535,7 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou
|
|||
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||
}
|
||||
|
||||
int32_t code;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SIFParam *params = NULL;
|
||||
SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx));
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
|||
COPY_SCALAR_FIELD(tableType);
|
||||
COPY_SCALAR_FIELD(colId);
|
||||
COPY_SCALAR_FIELD(colType);
|
||||
COPY_SCALAR_FIELD(hasIndex);
|
||||
COPY_CHAR_ARRAY_FIELD(dbName);
|
||||
COPY_CHAR_ARRAY_FIELD(tableName);
|
||||
COPY_CHAR_ARRAY_FIELD(tableAlias);
|
||||
|
|
|
@ -178,6 +178,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "ShowQueriesStmt";
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
return "ShowVnodeStmt";
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return "DeleteStmt";
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return "LogicScan";
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
@ -242,6 +244,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "PhysiStreamSessionWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||
return "PhysiStateWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW:
|
||||
return "PhysiStreamStateWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return "PhysiPartition";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
|
@ -2742,6 +2746,28 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkStateWindowCol = "StateWindowCol";
|
||||
static const char* jkStateWindowExpr = "StateWindowExpr";
|
||||
|
||||
static int32_t stateWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SStateWindowNode* pNode = (const SStateWindowNode*)pObj;
|
||||
int32_t code = tjsonAddObject(pJson, jkStateWindowCol, nodeToJson, pNode->pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkStateWindowExpr, nodeToJson, pNode->pExpr);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToStateWindowNode(const SJson* pJson, void* pObj) {
|
||||
SStateWindowNode* pNode = (SStateWindowNode*)pObj;
|
||||
|
||||
int32_t code = jsonToNodeObject(pJson, jkStateWindowCol, (SNode**)&pNode->pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkStateWindowExpr, (SNode**)&pNode->pExpr);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkSessionWindowTsPrimaryKey = "TsPrimaryKey";
|
||||
static const char* jkSessionWindowGap = "Gap";
|
||||
|
||||
|
@ -3519,8 +3545,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
case QUERY_NODE_ORDER_BY_EXPR:
|
||||
return orderByExprNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LIMIT:
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
break;
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
return stateWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
return sessionWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
|
@ -3624,6 +3651,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW:
|
||||
return physiSessionWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW:
|
||||
return physiStateWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return physiPartitionNodeToJson(pObj, pJson);
|
||||
|
@ -3660,6 +3688,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_STATE_WINDOW:
|
||||
return jsonToStateWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
return jsonToSessionWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
|
@ -3743,6 +3773,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW:
|
||||
return jsonToPhysiSessionWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW:
|
||||
return jsonToPhysiStateWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return jsonToPhysiPartitionNode(pJson, pObj);
|
||||
|
|
|
@ -520,7 +520,8 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
|
|||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW:
|
||||
res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW: {
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW: {
|
||||
SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)pNode;
|
||||
res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
|
|
|
@ -208,6 +208,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_KILL_QUERY_STMT:
|
||||
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
||||
return makeNode(type, sizeof(SKillStmt));
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return makeNode(type, sizeof(SDeleteStmt));
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return makeNode(type, sizeof(SScanLogicNode));
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
@ -272,6 +274,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SStreamSessionWinodwPhysiNode));
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||
return makeNode(type, sizeof(SStateWinodwPhysiNode));
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW:
|
||||
return makeNode(type, sizeof(SStreamStateWinodwPhysiNode));
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return makeNode(type, sizeof(SPartitionPhysiNode));
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
|
@ -1305,7 +1309,7 @@ int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeT
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* getFillModeString(EFillMode mode) {
|
||||
char* nodesGetFillModeString(EFillMode mode) {
|
||||
switch (mode) {
|
||||
case FILL_MODE_NONE:
|
||||
return "none";
|
||||
|
@ -1353,7 +1357,7 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
|||
return num;
|
||||
}
|
||||
|
||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||
pVal->nType = pNode->node.resType.type;
|
||||
pVal->nLen = pNode->node.resType.bytes;
|
||||
switch (pNode->node.resType.type) {
|
||||
|
@ -1394,3 +1398,159 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) {
|
||||
if (NULL == *pSrc) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (1 == LIST_LENGTH(*pSrc)) {
|
||||
*pDst = nodesListGetNode(*pSrc, 0);
|
||||
nodesClearList(*pSrc);
|
||||
} else {
|
||||
SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
pLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
pLogicCond->pParameterList = *pSrc;
|
||||
*pDst = (SNode*)pLogicCond;
|
||||
}
|
||||
*pSrc = NULL;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
typedef struct SClassifyConditionCxt {
|
||||
bool hasPrimaryKey;
|
||||
bool hasTagIndexCol;
|
||||
bool hasOtherCol;
|
||||
} SClassifyConditionCxt;
|
||||
|
||||
static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
|
||||
SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext;
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) {
|
||||
pCxt->hasPrimaryKey = true;
|
||||
} else if (pCol->hasIndex) {
|
||||
pCxt->hasTagIndexCol = true;
|
||||
} else {
|
||||
pCxt->hasOtherCol = true;
|
||||
}
|
||||
return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
typedef enum EConditionType { COND_TYPE_PRIMARY_KEY = 1, COND_TYPE_TAG_INDEX, COND_TYPE_NORMAL } EConditionType;
|
||||
|
||||
static EConditionType classifyCondition(SNode* pNode) {
|
||||
SClassifyConditionCxt cxt = {.hasPrimaryKey = false, .hasTagIndexCol = false, .hasOtherCol = false};
|
||||
nodesWalkExpr(pNode, classifyConditionImpl, &cxt);
|
||||
return cxt.hasOtherCol ? COND_TYPE_NORMAL
|
||||
: (cxt.hasPrimaryKey && cxt.hasTagIndexCol
|
||||
? COND_TYPE_NORMAL
|
||||
: (cxt.hasPrimaryKey ? COND_TYPE_PRIMARY_KEY : COND_TYPE_TAG_INDEX));
|
||||
}
|
||||
|
||||
static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagCond, SNode** pOtherCond) {
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*pCondition);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SNodeList* pPrimaryKeyConds = NULL;
|
||||
SNodeList* pTagConds = NULL;
|
||||
SNodeList* pOtherConds = NULL;
|
||||
SNode* pCond = NULL;
|
||||
FOREACH(pCond, pLogicCond->pParameterList) {
|
||||
switch (classifyCondition(pCond)) {
|
||||
case COND_TYPE_PRIMARY_KEY:
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
code = nodesListMakeAppend(&pPrimaryKeyConds, nodesCloneNode(pCond));
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG_INDEX:
|
||||
if (NULL != pTagCond) {
|
||||
code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond));
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_NORMAL:
|
||||
default:
|
||||
if (NULL != pOtherCond) {
|
||||
code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SNode* pTempPrimaryKeyCond = NULL;
|
||||
SNode* pTempTagCond = NULL;
|
||||
SNode* pTempOtherCond = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMergeConds(&pTempPrimaryKeyCond, &pPrimaryKeyConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMergeConds(&pTempTagCond, &pTagConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMergeConds(&pTempOtherCond, &pOtherConds);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
*pPrimaryKeyCond = pTempPrimaryKeyCond;
|
||||
}
|
||||
if (NULL != pTagCond) {
|
||||
*pTagCond = pTempTagCond;
|
||||
}
|
||||
if (NULL != pOtherCond) {
|
||||
*pOtherCond = pTempOtherCond;
|
||||
}
|
||||
nodesDestroyNode(*pCondition);
|
||||
*pCondition = NULL;
|
||||
} else {
|
||||
nodesDestroyList(pPrimaryKeyConds);
|
||||
nodesDestroyList(pTagConds);
|
||||
nodesDestroyList(pOtherConds);
|
||||
nodesDestroyNode(pTempPrimaryKeyCond);
|
||||
nodesDestroyNode(pTempTagCond);
|
||||
nodesDestroyNode(pTempOtherCond);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagCond, SNode** pOtherCond) {
|
||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCondition) &&
|
||||
LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCondition)->condType) {
|
||||
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagCond, pOtherCond);
|
||||
}
|
||||
|
||||
switch (classifyCondition(*pCondition)) {
|
||||
case COND_TYPE_PRIMARY_KEY:
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
*pPrimaryKeyCond = *pCondition;
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG_INDEX:
|
||||
if (NULL != pTagCond) {
|
||||
*pTagCond = *pCondition;
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_NORMAL:
|
||||
default:
|
||||
if (NULL != pOtherCond) {
|
||||
*pOtherCond = *pCondition;
|
||||
}
|
||||
break;
|
||||
}
|
||||
*pCondition = NULL;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId);
|
|||
SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
||||
SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName);
|
||||
SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName);
|
||||
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -481,6 +481,9 @@ dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C).
|
|||
/************************************************ syncdb **************************************************************/
|
||||
cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); }
|
||||
|
||||
/************************************************ syncdb **************************************************************/
|
||||
cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B). { pCxt->pRootNode = createDeleteStmt(pCxt, A, B); }
|
||||
|
||||
/************************************************ select **************************************************************/
|
||||
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
|
||||
|
||||
|
|
|
@ -1488,3 +1488,12 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
|||
strncpy(pStmt->userName, pUserName->z, pUserName->n);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pFromTable = pTable;
|
||||
pStmt->pWhere = pWhere;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
|
|
@ -113,21 +113,26 @@ static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFu
|
|||
return reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, SRealTableNode* pRealTable,
|
||||
AUTH_TYPE authType) {
|
||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName,
|
||||
pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pRealTable->table.dbName, authType,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pCxt->pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static EDealRes collectMetaKeyFromRealTable(SCollectMetaKeyFromExprCxt* pCxt, SRealTableNode* pRealTable) {
|
||||
pCxt->errCode = reserveTableMetaInCache(pCxt->pComCxt->pParseCxt->acctId, pRealTable->table.dbName,
|
||||
pRealTable->table.tableName, pCxt->pComCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = reserveTableVgroupInCache(pCxt->pComCxt->pParseCxt->acctId, pRealTable->table.dbName,
|
||||
pRealTable->table.tableName, pCxt->pComCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = reserveUserAuthInCache(pCxt->pComCxt->pParseCxt->acctId, pCxt->pComCxt->pParseCxt->pUser,
|
||||
pRealTable->table.dbName, AUTH_TYPE_READ, pCxt->pComCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode =
|
||||
reserveDbVgInfoInCache(pCxt->pComCxt->pParseCxt->acctId, pRealTable->table.dbName, pCxt->pComCxt->pMetaCache);
|
||||
}
|
||||
pCxt->errCode = collectMetaKeyFromRealTableImpl(pCxt->pComCxt, pRealTable, AUTH_TYPE_READ);
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -199,6 +204,22 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableStmt* pStmt) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pStmt->pTables) {
|
||||
SDropTableClause* pClause = (SDropTableClause*)pNode;
|
||||
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) {
|
||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -331,6 +352,10 @@ static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SSho
|
|||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromDelete(SCollectMetaKeyCxt* pCxt, SDeleteStmt* pStmt) {
|
||||
return collectMetaKeyFromRealTableImpl(pCxt, (SRealTableNode*)pStmt->pFromTable, AUTH_TYPE_WRITE);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
|
@ -341,6 +366,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromCreateTable(pCxt, (SCreateTableStmt*)pStmt);
|
||||
case QUERY_NODE_CREATE_MULTI_TABLE_STMT:
|
||||
return collectMetaKeyFromCreateMultiTable(pCxt, (SCreateMultiTableStmt*)pStmt);
|
||||
case QUERY_NODE_DROP_TABLE_STMT:
|
||||
return collectMetaKeyFromDropTable(pCxt, (SDropTableStmt*)pStmt);
|
||||
case QUERY_NODE_ALTER_TABLE_STMT:
|
||||
return collectMetaKeyFromAlterTable(pCxt, (SAlterTableStmt*)pStmt);
|
||||
case QUERY_NODE_USE_DATABASE_STMT:
|
||||
|
@ -387,6 +414,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
return collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ static int32_t authDropUser(SAuthCxt* pCxt, SDropUserStmt* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t authDelete(SAuthCxt* pCxt, SDeleteStmt* pDelete) {
|
||||
return checkAuth(pCxt, ((SRealTableNode*)pDelete->pFromTable)->table.dbName, AUTH_TYPE_WRITE);
|
||||
}
|
||||
|
||||
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
|
@ -88,6 +92,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
return authSelect(pCxt, (SSelectStmt*)pStmt);
|
||||
case QUERY_NODE_DROP_USER_STMT:
|
||||
return authDropUser(pCxt, (SDropUserStmt*)pStmt);
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return authDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -135,11 +135,11 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t calcConstFromTable(SCalcConstContext* pCxt, SSelectStmt* pSelect) {
|
||||
return rewriteConditionForFromTable(pCxt, pSelect->pFromTable);
|
||||
static int32_t calcConstFromTable(SCalcConstContext* pCxt, SNode* pTable) {
|
||||
return rewriteConditionForFromTable(pCxt, pTable);
|
||||
}
|
||||
|
||||
static void rewriteConstCondition(SSelectStmt* pSelect, SNode** pCond) {
|
||||
static void rewriteConstCondition(SNode** pCond, bool* pAlwaysFalse) {
|
||||
if (QUERY_NODE_VALUE != nodeType(*pCond)) {
|
||||
return;
|
||||
}
|
||||
|
@ -147,11 +147,11 @@ static void rewriteConstCondition(SSelectStmt* pSelect, SNode** pCond) {
|
|||
nodesDestroyNode(*pCond);
|
||||
*pCond = NULL;
|
||||
} else {
|
||||
pSelect->isEmptyResult = true;
|
||||
*pAlwaysFalse = true;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t calcConstSelectCondition(SCalcConstContext* pCxt, SSelectStmt* pSelect, SNode** pCond) {
|
||||
static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bool* pAlwaysFalse) {
|
||||
if (NULL == *pCond) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ static int32_t calcConstSelectCondition(SCalcConstContext* pCxt, SSelectStmt* pS
|
|||
code = calcConstNode(pCond);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
rewriteConstCondition(pSelect, pCond);
|
||||
rewriteConstCondition(pCond, pAlwaysFalse);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -233,12 +233,12 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) {
|
|||
}
|
||||
|
||||
static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
||||
int32_t code = calcConstFromTable(pCxt, pSelect);
|
||||
int32_t code = calcConstFromTable(pCxt, pSelect->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstProjections(pCxt, pSelect, subquery);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstSelectCondition(pCxt, pSelect, &pSelect->pWhere);
|
||||
code = calcConstStmtCondition(pCxt, &pSelect->pWhere, &pSelect->isEmptyResult);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstList(pSelect->pPartitionByList);
|
||||
|
@ -250,7 +250,7 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
|
|||
code = calcConstGroupBy(pCxt, pSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstSelectCondition(pCxt, pSelect, &pSelect->pHaving);
|
||||
code = calcConstStmtCondition(pCxt, &pSelect->pHaving, &pSelect->isEmptyResult);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstList(pSelect->pOrderByList);
|
||||
|
@ -258,6 +258,14 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t calcConstDelete(SCalcConstContext* pCxt, SDeleteStmt* pDelete) {
|
||||
int32_t code = calcConstFromTable(pCxt, pDelete->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstStmtCondition(pCxt, &pDelete->pWhere, &pDelete->deleteZeroRows);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subquery) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pStmt)) {
|
||||
|
@ -275,6 +283,9 @@ static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subque
|
|||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
code = calcConstDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ static SKeyword keywordTable[] = {
|
|||
{"DATABASES", TK_DATABASES},
|
||||
{"DAYS", TK_DAYS},
|
||||
{"DBS", TK_DBS},
|
||||
{"DELETE", TK_DELETE},
|
||||
{"DESC", TK_DESC},
|
||||
{"DESCRIBE", TK_DESCRIBE},
|
||||
{"DISTINCT", TK_DISTINCT},
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct STranslateContext {
|
|||
SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode*
|
||||
int32_t currLevel;
|
||||
ESqlClause currClause;
|
||||
SSelectStmt* pCurrStmt;
|
||||
SSelectStmt* pCurrSelectStmt;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
SHashObj* pDbs;
|
||||
SHashObj* pTables;
|
||||
|
@ -335,7 +335,7 @@ static bool isIndefiniteRowsFunc(const SNode* pNode) {
|
|||
}
|
||||
|
||||
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
||||
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct);
|
||||
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrSelectStmt->isDistinct);
|
||||
}
|
||||
|
||||
static bool belongTable(const char* currentDb, const SColumnNode* pCol, const STableNode* pTable) {
|
||||
|
@ -360,7 +360,7 @@ static SNodeList* getProjectList(const SNode* pNode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, bool isTag,
|
||||
static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, int32_t tagFlag,
|
||||
SColumnNode* pCol) {
|
||||
strcpy(pCol->dbName, pTable->table.dbName);
|
||||
strcpy(pCol->tableAlias, pTable->table.tableAlias);
|
||||
|
@ -372,7 +372,8 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
|
|||
pCol->tableId = pTable->pMeta->uid;
|
||||
pCol->tableType = pTable->pMeta->tableType;
|
||||
pCol->colId = pColSchema->colId;
|
||||
pCol->colType = isTag ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN;
|
||||
pCol->colType = (tagFlag >= 0 ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN);
|
||||
pCol->hasIndex = (0 == tagFlag);
|
||||
pCol->node.resType.type = pColSchema->type;
|
||||
pCol->node.resType.bytes = pColSchema->bytes;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP == pCol->node.resType.type) {
|
||||
|
@ -414,7 +415,7 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
|
|||
if (NULL == pCol) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i >= pMeta->tableInfo.numOfColumns), pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i - pMeta->tableInfo.numOfColumns), pCol);
|
||||
nodesListAppend(pList, (SNode*)pCol);
|
||||
}
|
||||
} else {
|
||||
|
@ -472,14 +473,14 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
|
|||
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
||||
if (isInternalPrimaryKey(pCol)) {
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema, false, pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema, -1, pCol);
|
||||
*pFound = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
|
||||
for (int32_t i = 0; i < nums; ++i) {
|
||||
if (0 == strcmp(pCol->colName, pMeta->schema[i].name)) {
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i >= pMeta->tableInfo.numOfColumns), pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i - pMeta->tableInfo.numOfColumns), pCol);
|
||||
*pFound = true;
|
||||
break;
|
||||
}
|
||||
|
@ -551,7 +552,7 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod
|
|||
}
|
||||
if (!found) {
|
||||
if (isInternalPk) {
|
||||
if (NULL != pCxt->pCurrStmt->pWindow) {
|
||||
if (NULL != pCxt->pCurrSelectStmt && NULL != pCxt->pCurrSelectStmt->pWindow) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY);
|
||||
}
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_INTERNAL_PK);
|
||||
|
@ -563,7 +564,7 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod
|
|||
}
|
||||
|
||||
static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||
SNodeList* pProjectionList = pCxt->pCurrStmt->pProjectionList;
|
||||
SNodeList* pProjectionList = pCxt->pCurrSelectStmt->pProjectionList;
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pProjectionList) {
|
||||
SExprNode* pExpr = (SExprNode*)pNode;
|
||||
|
@ -621,7 +622,7 @@ static int32_t parseTimeFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
|
|||
}
|
||||
|
||||
static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SDataType targetDt) {
|
||||
uint8_t precision = (NULL != pCxt->pCurrStmt ? pCxt->pCurrStmt->precision : targetDt.precision);
|
||||
uint8_t precision = (NULL != pCxt->pCurrSelectStmt ? pCxt->pCurrSelectStmt->precision : targetDt.precision);
|
||||
pVal->node.resType.precision = precision;
|
||||
if (pVal->placeholderNo > 0) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
@ -830,7 +831,8 @@ static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNo
|
|||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
||||
}
|
||||
if (QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
||||
((!IS_STR_DATA_TYPE(((SExprNode*)(pOp->pRight))->resType.type)) && (((SExprNode*)(pOp->pRight))->resType.type != TSDB_DATA_TYPE_NULL))) {
|
||||
((!IS_STR_DATA_TYPE(((SExprNode*)(pOp->pRight))->resType.type)) &&
|
||||
(((SExprNode*)(pOp->pRight))->resType.type != TSDB_DATA_TYPE_NULL))) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +912,7 @@ static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount)
|
|||
STableNode* pTable = NULL;
|
||||
int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable);
|
||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, false, pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, -1, pCol);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -936,7 +938,7 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
|||
if (hasInvalidFuncNesting(pFunc->pParameterList)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
||||
}
|
||||
if (pCxt->pCurrStmt->hasIndefiniteRowsFunc) {
|
||||
if (pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
|
||||
|
@ -948,7 +950,7 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
|||
|
||||
static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
if (0 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrStmt->pFromTable)) {
|
||||
if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrSelectStmt->pFromTable)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME);
|
||||
}
|
||||
} else {
|
||||
|
@ -963,7 +965,8 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionN
|
|||
}
|
||||
|
||||
static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
if (SQL_CLAUSE_SELECT != pCxt->currClause || pCxt->pCurrStmt->hasIndefiniteRowsFunc || pCxt->pCurrStmt->hasAggFuncs) {
|
||||
if (SQL_CLAUSE_SELECT != pCxt->currClause || pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc ||
|
||||
pCxt->pCurrSelectStmt->hasAggFuncs) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
if (hasInvalidFuncNesting(pFunc->pParameterList)) {
|
||||
|
@ -973,10 +976,12 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod
|
|||
}
|
||||
|
||||
static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) {
|
||||
if (NULL != pSelect) {
|
||||
pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId);
|
||||
pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId);
|
||||
pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId);
|
||||
}
|
||||
}
|
||||
|
||||
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
SNode* pParam = NULL;
|
||||
|
@ -997,7 +1002,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
|
|||
pCxt->errCode = translateIndefiniteRowsFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
setFuncClassification(pCxt->pCurrStmt, pFunc);
|
||||
setFuncClassification(pCxt->pCurrSelectStmt, pFunc);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -1045,9 +1050,9 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) {
|
|||
|
||||
static SNodeList* getGroupByList(STranslateContext* pCxt) {
|
||||
if (isDistinctOrderBy(pCxt)) {
|
||||
return pCxt->pCurrStmt->pProjectionList;
|
||||
return pCxt->pCurrSelectStmt->pProjectionList;
|
||||
}
|
||||
return pCxt->pCurrStmt->pGroupByList;
|
||||
return pCxt->pCurrSelectStmt->pGroupByList;
|
||||
}
|
||||
|
||||
static SNode* getGroupByNode(SNode* pNode) {
|
||||
|
@ -1085,7 +1090,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
*pNode = (SNode*)pFunc;
|
||||
pCxt->pCurrStmt->hasSelectValFunc = true;
|
||||
pCxt->pCurrSelectStmt->hasSelectValFunc = true;
|
||||
} else {
|
||||
nodesDestroyNode(pFunc);
|
||||
}
|
||||
|
@ -1308,6 +1313,8 @@ static int32_t setTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTa
|
|||
static uint8_t getStmtPrecision(SNode* pStmt) {
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
|
||||
return ((SSelectStmt*)pStmt)->precision;
|
||||
} else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) {
|
||||
return ((SSetOperator*)pStmt)->precision;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1319,10 +1326,10 @@ static bool stmtIsSingleTable(SNode* pStmt) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static uint8_t getJoinTablePrecision(SJoinTableNode* pJoinTable) {
|
||||
uint8_t lp = ((STableNode*)pJoinTable->pLeft)->precision;
|
||||
uint8_t rp = ((STableNode*)pJoinTable->pRight)->precision;
|
||||
return (lp > rp ? rp : lp);
|
||||
static uint8_t calcPrecision(uint8_t lp, uint8_t rp) { return (lp > rp ? rp : lp); }
|
||||
|
||||
static uint8_t calcJoinTablePrecision(SJoinTableNode* pJoinTable) {
|
||||
return calcPrecision(((STableNode*)pJoinTable->pLeft)->precision, ((STableNode*)pJoinTable->pRight)->precision);
|
||||
}
|
||||
|
||||
static bool joinTableIsSingleTable(SJoinTableNode* pJoinTable) {
|
||||
|
@ -1378,7 +1385,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
code = translateTable(pCxt, pJoinTable->pRight);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pJoinTable->table.precision = getJoinTablePrecision(pJoinTable);
|
||||
pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable);
|
||||
pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable);
|
||||
code = translateExpr(pCxt, &pJoinTable->pOnCond);
|
||||
}
|
||||
|
@ -1678,71 +1685,40 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static EDealRes isPrimaryKeyCondImpl(SNode* pNode, void* pContext) {
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
*((bool*)pContext) = ((PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pNode)->colId) ? true : false);
|
||||
return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END;
|
||||
static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bool* pIsStrict) {
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = scalarCalculateConstants(*pPrimaryKeyCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPrimaryKeyCond = pNew;
|
||||
code = filterGetTimeRange(*pPrimaryKeyCond, pTimeRange, pIsStrict);
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static bool isPrimaryKeyCond(SNode* pNode) {
|
||||
bool isPrimaryKeyCond = false;
|
||||
nodesWalkExpr(pNode, isPrimaryKeyCondImpl, &isPrimaryKeyCond);
|
||||
return isPrimaryKeyCond;
|
||||
}
|
||||
|
||||
static int32_t getTimeRangeFromLogicCond(STranslateContext* pCxt, SLogicConditionNode* pLogicCond,
|
||||
STimeWindow* pTimeRange) {
|
||||
SNodeList* pPrimaryKeyConds = NULL;
|
||||
SNode* pCond = NULL;
|
||||
FOREACH(pCond, pLogicCond->pParameterList) {
|
||||
if (isPrimaryKeyCond(pCond)) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pPrimaryKeyConds, pCond)) {
|
||||
nodesClearList(pPrimaryKeyConds);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == pPrimaryKeyConds) {
|
||||
*pTimeRange = TSWINDOW_INITIALIZER;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SLogicConditionNode* pPrimaryKeyLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pPrimaryKeyLogicCond) {
|
||||
nodesClearList(pPrimaryKeyConds);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pPrimaryKeyLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
pPrimaryKeyLogicCond->pParameterList = pPrimaryKeyConds;
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange((SNode*)pPrimaryKeyLogicCond, pTimeRange, &isStrict);
|
||||
nodesClearList(pPrimaryKeyConds);
|
||||
pPrimaryKeyLogicCond->pParameterList = NULL;
|
||||
nodesDestroyNode(pPrimaryKeyLogicCond);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) {
|
||||
static int32_t getFillTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) {
|
||||
if (NULL == pWhere) {
|
||||
*pTimeRange = TSWINDOW_INITIALIZER;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pWhere) &&
|
||||
LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)pWhere)->condType) {
|
||||
return getTimeRangeFromLogicCond(pCxt, (SLogicConditionNode*)pWhere, pTimeRange);
|
||||
SNode* pCond = nodesCloneNode(pWhere);
|
||||
if (NULL == pCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (isPrimaryKeyCond(pWhere)) {
|
||||
SNode* pPrimaryKeyCond = NULL;
|
||||
nodesPartitionCond(&pCond, &pPrimaryKeyCond, NULL, NULL);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
bool isStrict = false;
|
||||
return filterGetTimeRange(pWhere, pTimeRange, &isStrict);
|
||||
code = getTimeRange(&pPrimaryKeyCond, pTimeRange, &isStrict);
|
||||
} else {
|
||||
*pTimeRange = TSWINDOW_INITIALIZER;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
nodesDestroyNode(pCond);
|
||||
nodesDestroyNode(pPrimaryKeyCond);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkFill(STranslateContext* pCxt, SIntervalWindowNode* pInterval) {
|
||||
|
@ -1778,7 +1754,7 @@ static int32_t translateFill(STranslateContext* pCxt, SNode* pWhere, SIntervalWi
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = getTimeRange(pCxt, pWhere, &(((SFillNode*)pInterval->pFill)->timeRange));
|
||||
int32_t code = getFillTimeRange(pCxt, pWhere, &(((SFillNode*)pInterval->pFill)->timeRange));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkFill(pCxt, pInterval);
|
||||
}
|
||||
|
@ -1924,13 +1900,9 @@ static int32_t translateWhere(STranslateContext* pCxt, SNode** pWhere) {
|
|||
return translateExpr(pCxt, pWhere);
|
||||
}
|
||||
|
||||
static int32_t translateFrom(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) {
|
||||
pCxt->currClause = SQL_CLAUSE_FROM;
|
||||
int32_t code = translateTable(pCxt, pSelect->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
|
||||
}
|
||||
return code;
|
||||
return translateTable(pCxt, pTable);
|
||||
}
|
||||
|
||||
static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
|
@ -1991,9 +1963,10 @@ static int32_t rewriteTimelineFunc(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
pCxt->pCurrStmt = pSelect;
|
||||
int32_t code = translateFrom(pCxt, pSelect);
|
||||
pCxt->pCurrSelectStmt = pSelect;
|
||||
int32_t code = translateFrom(pCxt, pSelect->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
|
||||
code = translateWhere(pCxt, &pSelect->pWhere);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2094,6 +2067,10 @@ static int32_t translateSetOperatorImpl(STranslateContext* pCxt, SSetOperator* p
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t calcSetOperatorPrecision(SSetOperator* pSetOperator) {
|
||||
return calcPrecision(getStmtPrecision(pSetOperator->pLeft), getStmtPrecision(pSetOperator->pRight));
|
||||
}
|
||||
|
||||
static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
||||
int32_t code = translateQuery(pCxt, pSetOperator->pLeft);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2103,11 +2080,55 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO
|
|||
code = translateQuery(pCxt, pSetOperator->pRight);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSetOperator->precision = calcSetOperatorPrecision(pSetOperator);
|
||||
code = translateSetOperatorImpl(pCxt, pSetOperator);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
||||
if (NULL == pDelete->pWhere) {
|
||||
pDelete->timeRange = TSWINDOW_INITIALIZER;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pPrimaryKeyCond = NULL;
|
||||
SNode* pOtherCond = NULL;
|
||||
int32_t code = nodesPartitionCond(&pDelete->pWhere, &pPrimaryKeyCond, &pDelete->pTagIndexCond, &pOtherCond);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pOtherCond) {
|
||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DELETE_WHERE);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
bool isStrict = false;
|
||||
code = getTimeRange(&pPrimaryKeyCond, &pDelete->timeRange, &isStrict);
|
||||
if (TSDB_CODE_SUCCESS == code && !isStrict) {
|
||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DELETE_WHERE);
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pPrimaryKeyCond);
|
||||
nodesDestroyNode(pOtherCond);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
||||
int32_t code = translateWhere(pCxt, &pDelete->pWhere);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = partitionDeleteWhere(pCxt, pDelete);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateDelete(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
||||
int32_t code = translateFrom(pCxt, pDelete->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateDeleteWhere(pCxt, pDelete);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateExpr(pCxt, &pDelete->pCountFunc);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int64_t getUnitPerMinute(uint8_t precision) {
|
||||
switch (precision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
|
@ -2923,25 +2944,9 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
|
|||
|
||||
static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) {
|
||||
SDropTableClause* pClause = nodesListGetNode(pStmt->pTables, 0);
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SName tableName;
|
||||
int32_t code = getTableMetaImpl(
|
||||
pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta);
|
||||
if ((TSDB_CODE_PAR_TABLE_NOT_EXIST == code || TSDB_CODE_VND_TB_NOT_EXIST == code) && pClause->ignoreNotExists) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (TSDB_SUPER_TABLE == pTableMeta->tableType) {
|
||||
code = doTranslateDropSuperTable(pCxt, &tableName, pClause->ignoreNotExists);
|
||||
} else {
|
||||
// todo : drop normal table or child table
|
||||
code = TSDB_CODE_FAILED;
|
||||
}
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
}
|
||||
|
||||
return code;
|
||||
return doTranslateDropSuperTable(
|
||||
pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists);
|
||||
}
|
||||
|
||||
static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableStmt* pStmt) {
|
||||
|
@ -3449,7 +3454,6 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
|||
SName name;
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName));
|
||||
tNameGetFullDbName(&name, pReq->name);
|
||||
// tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pStmt->streamName, &name), pReq->name);
|
||||
|
||||
if ('\0' != pStmt->targetTabName[0]) {
|
||||
strcpy(name.dbname, pStmt->targetDbName);
|
||||
|
@ -3602,6 +3606,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_SET_OPERATOR:
|
||||
code = translateSetOperator(pCxt, (SSetOperator*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
code = translateDelete(pCxt, (SDeleteStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_DATABASE_STMT:
|
||||
code = translateCreateDatabase(pCxt, (SCreateDatabaseStmt*)pNode);
|
||||
break;
|
||||
|
@ -3721,11 +3728,11 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
|
||||
++(pCxt->currLevel);
|
||||
ESqlClause currClause = pCxt->currClause;
|
||||
SSelectStmt* pCurrStmt = pCxt->pCurrStmt;
|
||||
SSelectStmt* pCurrStmt = pCxt->pCurrSelectStmt;
|
||||
int32_t code = translateQuery(pCxt, pNode);
|
||||
--(pCxt->currLevel);
|
||||
pCxt->currClause = currClause;
|
||||
pCxt->pCurrStmt = pCurrStmt;
|
||||
pCxt->pCurrSelectStmt = pCurrStmt;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -4428,7 +4435,6 @@ static SArray* serializeVgroupsCreateTableBatch(int32_t acctId, SHashObj* pVgrou
|
|||
}
|
||||
|
||||
static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
|
||||
SCreateMultiTableStmt* pStmt = (SCreateMultiTableStmt*)pQuery->pRoot;
|
||||
|
||||
SHashObj* pVgroupHashmap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
|
|
|
@ -178,6 +178,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "Only tag can be json type";
|
||||
case TSDB_CODE_PAR_VALUE_TOO_LONG:
|
||||
return "Value too long for column/tag: %s";
|
||||
case TSDB_CODE_PAR_INVALID_DELETE_WHERE:
|
||||
return "The DELETE statement must have a definite time window range";
|
||||
case TSDB_CODE_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
|
@ -371,7 +373,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
|
|||
}
|
||||
STagVal val = {0};
|
||||
val.pKey = jsonKey;
|
||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen, CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||
|
||||
if (item->type == cJSON_String) { // add json value format: type|data
|
||||
char* jsonValue = item->valuestring;
|
||||
|
@ -382,8 +385,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
|
|||
goto end;
|
||||
}
|
||||
val.type = TSDB_DATA_TYPE_NCHAR;
|
||||
if (valLen > 0 && !taosMbsToUcs4(jsonValue, valLen, (TdUcs4*)tmp,
|
||||
(int32_t)(valLen * TSDB_NCHAR_SIZE), &valLen)) {
|
||||
if (valLen > 0 && !taosMbsToUcs4(jsonValue, valLen, (TdUcs4*)tmp, (int32_t)(valLen * TSDB_NCHAR_SIZE), &valLen)) {
|
||||
uError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue,
|
||||
strerror(errno));
|
||||
retCode = buildSyntaxErrMsg(pMsgBuf, "charset convert json error", jsonValue);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,10 +21,24 @@ namespace ParserTest {
|
|||
|
||||
class ParserInitialDTest : public ParserDdlTest {};
|
||||
|
||||
// todo delete
|
||||
// DELETE FROM tb_name [WHERE condition]
|
||||
TEST_F(ParserInitialDTest, delete) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("DELETE FROM t1");
|
||||
|
||||
run("DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, deleteSemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("DELETE FROM t1 WHERE c1 > 10", TSDB_CODE_PAR_INVALID_DELETE_WHERE, PARSER_STAGE_TRANSLATE);
|
||||
}
|
||||
|
||||
// todo desc
|
||||
// todo describe
|
||||
// todo drop account
|
||||
// todo DROP account
|
||||
|
||||
TEST_F(ParserInitialDTest, dropBnode) {
|
||||
useDb("root", "test");
|
||||
|
@ -62,51 +76,61 @@ TEST_F(ParserInitialDTest, dropCGroup) {
|
|||
run("DROP CONSUMER GROUP IF EXISTS cg1 ON tp1");
|
||||
}
|
||||
|
||||
// todo drop database
|
||||
// todo drop dnode
|
||||
// todo drop function
|
||||
// todo DROP database
|
||||
// todo DROP dnode
|
||||
// todo DROP function
|
||||
|
||||
TEST_F(ParserInitialDTest, dropIndex) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop index index1 on t1");
|
||||
run("DROP index index1 on t1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropMnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop mnode on dnode 1");
|
||||
run("DROP mnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropQnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop qnode on dnode 1");
|
||||
run("DROP qnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropSnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop snode on dnode 1");
|
||||
run("DROP snode on dnode 1");
|
||||
}
|
||||
|
||||
// todo drop stable
|
||||
// todo drop stream
|
||||
// todo drop table
|
||||
TEST_F(ParserInitialDTest, dropSTable) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("DROP STABLE st1");
|
||||
}
|
||||
|
||||
// todo DROP stream
|
||||
|
||||
TEST_F(ParserInitialDTest, dropTable) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("DROP TABLE t1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropTopic) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop topic tp1");
|
||||
run("DROP topic tp1");
|
||||
|
||||
run("drop topic if exists tp1");
|
||||
run("DROP topic if exists tp1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropUser) {
|
||||
login("root");
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop user wxy");
|
||||
run("DROP user wxy");
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
||||
|
|
|
@ -229,14 +229,14 @@ TEST_F(ParserSelectTest, subquery) {
|
|||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, subquerySemanticError) {
|
||||
TEST_F(ParserSelectTest, subquerySemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)", TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, semanticError) {
|
||||
TEST_F(ParserSelectTest, semanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
// TSDB_CODE_PAR_INVALID_COLUMN
|
||||
|
|
|
@ -21,8 +21,10 @@ typedef struct SLogicPlanContext {
|
|||
SPlanContext* pPlanCxt;
|
||||
} SLogicPlanContext;
|
||||
|
||||
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**);
|
||||
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**);
|
||||
typedef int32_t (*FCreateSelectLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**);
|
||||
typedef int32_t (*FCreateSetOpLogicNode)(SLogicPlanContext*, SSetOperator*, SLogicNode**);
|
||||
typedef int32_t (*FCreateDeleteLogicNode)(SLogicPlanContext*, SDeleteStmt*, SLogicNode**);
|
||||
|
||||
static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable,
|
||||
SLogicNode** pLogicNode);
|
||||
|
@ -119,12 +121,12 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func,
|
||||
static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t precision, FCreateLogicNode func,
|
||||
SLogicNode** pRoot) {
|
||||
SLogicNode* pNode = NULL;
|
||||
int32_t code = func(pCxt, pSelect, &pNode);
|
||||
int32_t code = func(pCxt, pStmt, &pNode);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||
pNode->precision = pSelect->precision;
|
||||
pNode->precision = precision;
|
||||
code = pushLogicNode(pCxt, pRoot, pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -133,56 +135,10 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
|
|||
return code;
|
||||
}
|
||||
|
||||
// typedef struct SCreateColumnCxt {
|
||||
// int32_t errCode;
|
||||
// SNodeList* pList;
|
||||
// } SCreateColumnCxt;
|
||||
|
||||
// static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
||||
// SCreateColumnCxt* pCxt = (SCreateColumnCxt*)pContext;
|
||||
// switch (nodeType(pNode)) {
|
||||
// case QUERY_NODE_COLUMN: {
|
||||
// SNode* pCol = nodesCloneNode(pNode);
|
||||
// if (NULL == pCol) {
|
||||
// return DEAL_RES_ERROR;
|
||||
// }
|
||||
// return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||
// }
|
||||
// case QUERY_NODE_OPERATOR:
|
||||
// case QUERY_NODE_LOGIC_CONDITION:
|
||||
// case QUERY_NODE_FUNCTION: {
|
||||
// SExprNode* pExpr = (SExprNode*)pNode;
|
||||
// SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
// if (NULL == pCol) {
|
||||
// return DEAL_RES_ERROR;
|
||||
// }
|
||||
// pCol->node.resType = pExpr->resType;
|
||||
// strcpy(pCol->colName, pExpr->aliasName);
|
||||
// return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||
// }
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// return DEAL_RES_CONTINUE;
|
||||
// }
|
||||
|
||||
// static int32_t createColumnByRewriteExps(SNodeList* pExprs, SNodeList** pList) {
|
||||
// SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList)};
|
||||
// if (NULL == cxt.pList) {
|
||||
// return TSDB_CODE_OUT_OF_MEMORY;
|
||||
// }
|
||||
|
||||
// nodesWalkExprs(pExprs, doCreateColumn, &cxt);
|
||||
// if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||
// nodesDestroyList(cxt.pList);
|
||||
// return cxt.errCode;
|
||||
// }
|
||||
// if (NULL == *pList) {
|
||||
// *pList = cxt.pList;
|
||||
// }
|
||||
// return cxt.errCode;
|
||||
// }
|
||||
static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateSelectLogicNode func,
|
||||
SLogicNode** pRoot) {
|
||||
return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot);
|
||||
}
|
||||
|
||||
static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols,
|
||||
STableMeta* pMeta) {
|
||||
|
@ -783,25 +739,25 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
|||
SLogicNode* pRoot = NULL;
|
||||
int32_t code = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable, &pRoot);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createPartitionLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createPartitionLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createWindowLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createWindowLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createFillLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createFillLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createAggLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createAggLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createDistinctLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createDistinctLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createSortLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createSortLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createChildLogicNode(pCxt, pSelect, createProjectLogicNode, &pRoot);
|
||||
code = createSelectRootLogicNode(pCxt, pSelect, createProjectLogicNode, &pRoot);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -813,17 +769,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t createSetOpChildLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||
FCreateSetOpLogicNode func, SLogicNode** pRoot) {
|
||||
SLogicNode* pNode = NULL;
|
||||
int32_t code = func(pCxt, pSetOperator, &pNode);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||
code = pushLogicNode(pCxt, pRoot, pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pNode);
|
||||
}
|
||||
return code;
|
||||
static int32_t createSetOpRootLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, FCreateSetOpLogicNode func,
|
||||
SLogicNode** pRoot) {
|
||||
return createRootLogicNode(pCxt, pSetOperator, pSetOperator->precision, (FCreateLogicNode)func, pRoot);
|
||||
}
|
||||
|
||||
static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
||||
|
@ -970,7 +918,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator*
|
|||
SLogicNode* pRoot = NULL;
|
||||
int32_t code = createSetOpLogicNode(pCxt, pSetOperator, &pRoot);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createSetOpChildLogicNode(pCxt, pSetOperator, createSetOpSortLogicNode, &pRoot);
|
||||
code = createSetOpRootLogicNode(pCxt, pSetOperator, createSetOpSortLogicNode, &pRoot);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -1008,6 +956,43 @@ static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpS
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, FCreateDeleteLogicNode func,
|
||||
SLogicNode** pRoot) {
|
||||
return createRootLogicNode(pCxt, pDelete, pDelete->precision, (FCreateLogicNode)func, pRoot);
|
||||
}
|
||||
|
||||
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t createDeleteModifyTableLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
||||
SLogicNode** pLogicNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
SLogicNode* pRoot = NULL;
|
||||
int32_t code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteScanLogicNode, &pRoot);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteAggLogicNode, &pRoot);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteModifyTableLogicNode, &pRoot);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = pRoot;
|
||||
} else {
|
||||
nodesDestroyNode(pRoot);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -1018,6 +1003,8 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi
|
|||
return createQueryLogicNode(pCxt, ((SExplainStmt*)pStmt)->pQuery, pLogicNode);
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return createSetOperatorLogicNode(pCxt, (SSetOperator*)pStmt, pLogicNode);
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return createDeleteLogicNode(pCxt, (SDeleteStmt*)pStmt, pLogicNode);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,8 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
|
|||
return false;
|
||||
}
|
||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent)) {
|
||||
return (WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType);
|
||||
return true;
|
||||
// return (WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType);
|
||||
}
|
||||
return !osdHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys);
|
||||
}
|
||||
|
@ -217,8 +218,7 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
|||
}
|
||||
|
||||
static void setScanWindowInfo(SScanLogicNode* pScan) {
|
||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pScan->node.pParent) &&
|
||||
WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pScan->node.pParent)->winType) {
|
||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pScan->node.pParent)) {
|
||||
pScan->interval = ((SWindowLogicNode*)pScan->node.pParent)->interval;
|
||||
pScan->offset = ((SWindowLogicNode*)pScan->node.pParent)->offset;
|
||||
pScan->sliding = ((SWindowLogicNode*)pScan->node.pParent)->sliding;
|
||||
|
@ -268,30 +268,6 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t cpdMergeConds(SNode** pDst, SNodeList** pSrc) {
|
||||
if (NULL == *pSrc) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (1 == LIST_LENGTH(*pSrc)) {
|
||||
*pDst = nodesListGetNode(*pSrc, 0);
|
||||
nodesClearList(*pSrc);
|
||||
} else {
|
||||
SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
pLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
pLogicCond->pParameterList = *pSrc;
|
||||
*pDst = (SNode*)pLogicCond;
|
||||
}
|
||||
*pSrc = NULL;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) {
|
||||
if (NULL == *pCond) {
|
||||
TSWAP(*pCond, *pAdditionalCond);
|
||||
|
@ -310,119 +286,6 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static EDealRes cpdIsPrimaryKeyCondImpl(SNode* pNode, void* pContext) {
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
*((bool*)pContext) = ((PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pNode)->colId) ? true : false);
|
||||
return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static bool cpdIsPrimaryKeyCond(SNode* pNode) {
|
||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pNode)) {
|
||||
return false;
|
||||
}
|
||||
bool isPrimaryKeyCond = false;
|
||||
nodesWalkExpr(pNode, cpdIsPrimaryKeyCondImpl, &isPrimaryKeyCond);
|
||||
return isPrimaryKeyCond;
|
||||
}
|
||||
|
||||
static EDealRes cpdIsTagCondImpl(SNode* pNode, void* pContext) {
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
*((bool*)pContext) = ((COLUMN_TYPE_TAG == ((SColumnNode*)pNode)->colType) ? true : false);
|
||||
return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static bool cpdIsTagCond(SNode* pNode) {
|
||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pNode)) {
|
||||
return false;
|
||||
}
|
||||
bool isTagCond = false;
|
||||
nodesWalkExpr(pNode, cpdIsTagCondImpl, &isTagCond);
|
||||
return isTagCond;
|
||||
}
|
||||
|
||||
static int32_t cpdPartitionScanLogicCond(SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pTagCond,
|
||||
SNode** pOtherCond) {
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pScan->node.pConditions;
|
||||
|
||||
if (LOGIC_COND_TYPE_AND != pLogicCond->condType) {
|
||||
*pPrimaryKeyCond = NULL;
|
||||
*pOtherCond = pScan->node.pConditions;
|
||||
pScan->node.pConditions = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SNodeList* pPrimaryKeyConds = NULL;
|
||||
SNodeList* pTagConds = NULL;
|
||||
SNodeList* pOtherConds = NULL;
|
||||
SNode* pCond = NULL;
|
||||
FOREACH(pCond, pLogicCond->pParameterList) {
|
||||
if (cpdIsPrimaryKeyCond(pCond)) {
|
||||
code = nodesListMakeAppend(&pPrimaryKeyConds, nodesCloneNode(pCond));
|
||||
} else if (cpdIsTagCond(pScan->node.pConditions)) {
|
||||
code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond));
|
||||
} else {
|
||||
code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond));
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SNode* pTempPrimaryKeyCond = NULL;
|
||||
SNode* pTempTagCond = NULL;
|
||||
SNode* pTempOtherCond = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempPrimaryKeyCond, &pPrimaryKeyConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempTagCond, &pTagConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempOtherCond, &pOtherConds);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPrimaryKeyCond = pTempPrimaryKeyCond;
|
||||
*pTagCond = pTempTagCond;
|
||||
*pOtherCond = pTempOtherCond;
|
||||
nodesDestroyNode(pScan->node.pConditions);
|
||||
pScan->node.pConditions = NULL;
|
||||
} else {
|
||||
nodesDestroyList(pPrimaryKeyConds);
|
||||
nodesDestroyList(pTagConds);
|
||||
nodesDestroyList(pOtherConds);
|
||||
nodesDestroyNode(pTempPrimaryKeyCond);
|
||||
nodesDestroyNode(pTempTagCond);
|
||||
nodesDestroyNode(pTempOtherCond);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t cpdPartitionScanCond(SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pTagCond,
|
||||
SNode** pOtherCond) {
|
||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pScan->node.pConditions)) {
|
||||
return cpdPartitionScanLogicCond(pScan, pPrimaryKeyCond, pTagCond, pOtherCond);
|
||||
}
|
||||
|
||||
if (cpdIsPrimaryKeyCond(pScan->node.pConditions)) {
|
||||
*pPrimaryKeyCond = pScan->node.pConditions;
|
||||
} else if (cpdIsTagCond(pScan->node.pConditions)) {
|
||||
*pTagCond = pScan->node.pConditions;
|
||||
} else {
|
||||
*pOtherCond = pScan->node.pConditions;
|
||||
}
|
||||
pScan->node.pConditions = NULL;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdCalcTimeRange(SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pOtherCond) {
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict);
|
||||
|
@ -472,7 +335,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode*
|
|||
SNode* pPrimaryKeyCond = NULL;
|
||||
SNode* pTagCond = NULL;
|
||||
SNode* pOtherCond = NULL;
|
||||
int32_t code = cpdPartitionScanCond(pScan, &pPrimaryKeyCond, &pTagCond, &pOtherCond);
|
||||
int32_t code = nodesPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pTagCond, &pOtherCond);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pPrimaryKeyCond) {
|
||||
code = cpdCalcTimeRange(pScan, &pPrimaryKeyCond, &pOtherCond);
|
||||
}
|
||||
|
@ -565,16 +428,16 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo
|
|||
SNode* pTempRightChildCond = NULL;
|
||||
SNode* pTempRemainCond = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempOnCond, &pOnConds);
|
||||
code = nodesMergeConds(&pTempOnCond, &pOnConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempLeftChildCond, &pLeftChildConds);
|
||||
code = nodesMergeConds(&pTempLeftChildCond, &pLeftChildConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempRightChildCond, &pRightChildConds);
|
||||
code = nodesMergeConds(&pTempRightChildCond, &pRightChildConds);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = cpdMergeConds(&pTempRemainCond, &pRemainConds);
|
||||
code = nodesMergeConds(&pTempRemainCond, &pRemainConds);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -980,7 +980,9 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
|||
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||
SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(
|
||||
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW);
|
||||
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode,
|
||||
(pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW:
|
||||
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW));
|
||||
if (NULL == pState) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
|
|||
return !stbSplHasGatherExecFunc(pWindow->pFuncs) && stbSplHasMultiTbScan(streamQuery, pNode);
|
||||
}
|
||||
// case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||
// return stbSplHasMultiTbScan(pNode);
|
||||
// return stbSplHasMultiTbScan(streamQuery, pNode);
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode);
|
||||
default:
|
||||
|
@ -295,7 +295,8 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, SLogicNode* pPartChild) {
|
||||
static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, SNodeList* pMergeKeys,
|
||||
SLogicNode* pPartChild) {
|
||||
SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
if (NULL == pMerge) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -304,25 +305,28 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, S
|
|||
pMerge->srcGroupId = pCxt->groupId;
|
||||
pMerge->node.pParent = pParent;
|
||||
pMerge->node.precision = pPartChild->precision;
|
||||
int32_t code = nodesListMakeStrictAppend(&pMerge->pMergeKeys, nodesCloneNode(((SWindowLogicNode*)pParent)->pTspk));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pMerge->pMergeKeys = pMergeKeys;
|
||||
pMerge->node.pTargets = nodesCloneList(pPartChild->pTargets);
|
||||
if (NULL == pMerge->node.pTargets) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pParent->pChildren, pMerge);
|
||||
nodesDestroyNode(pMerge);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return code;
|
||||
return nodesListMakeAppend(&pParent->pChildren, pMerge);
|
||||
}
|
||||
|
||||
static int32_t stbSplSplitWindowNodeForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||
SLogicNode* pPartWindow = NULL;
|
||||
int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplCreateMergeNode(pCxt, pInfo->pSplitNode, pPartWindow);
|
||||
SNodeList* pMergeKeys = NULL;
|
||||
code = nodesListMakeStrictAppend(&pMergeKeys, nodesCloneNode(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplCreateMergeNode(pCxt, pInfo->pSplitNode, pMergeKeys, pPartWindow);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pMergeKeys);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
|
@ -425,6 +429,64 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplCreatePartSortNode(SSortLogicNode* pMergeSort, SLogicNode** pOutput) {
|
||||
SNodeList* pSortKeys = pMergeSort->pSortKeys;
|
||||
pMergeSort->pSortKeys = NULL;
|
||||
SNodeList* pTargets = pMergeSort->node.pTargets;
|
||||
pMergeSort->node.pTargets = NULL;
|
||||
SNodeList* pChildren = pMergeSort->node.pChildren;
|
||||
pMergeSort->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SSortLogicNode* pPartSort = nodesCloneNode(pMergeSort);
|
||||
if (NULL == pPartSort) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pMergeSort->node.pTargets = pTargets;
|
||||
pPartSort->node.pChildren = pChildren;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pPartSort->pSortKeys = pSortKeys;
|
||||
code = createColumnByRewriteExps(pPartSort->pSortKeys, &pPartSort->node.pTargets);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pMergeSort->pSortKeys = nodesCloneList(pPartSort->node.pTargets);
|
||||
if (NULL == pMergeSort->pSortKeys) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = (SLogicNode*)pPartSort;
|
||||
} else {
|
||||
nodesDestroyNode(pPartSort);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||
SLogicNode* pPartSort = NULL;
|
||||
int32_t code = stbSplCreatePartSortNode((SSortLogicNode*)pInfo->pSplitNode, &pPartSort);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNodeList* pMergeKeys = nodesCloneList(((SSortLogicNode*)pInfo->pSplitNode)->pSortKeys);
|
||||
if (NULL != pMergeKeys) {
|
||||
code = stbSplCreateMergeNode(pCxt, pInfo->pSplitNode, pMergeKeys, pPartSort);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pMergeKeys);
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pInfo->pSplitNode, SUBPLAN_TYPE_MERGE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -452,6 +514,9 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
|||
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||
code = stbSplSplitWindowNode(pCxt, &info);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||
code = stbSplSplitSortNode(pCxt, &info);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
code = stbSplSplitScanNode(pCxt, &info);
|
||||
break;
|
||||
|
|
|
@ -36,6 +36,10 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
|
|||
useDb("root", "test");
|
||||
|
||||
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4");
|
||||
|
||||
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 or tag1 < 2");
|
||||
|
||||
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'");
|
||||
}
|
||||
|
||||
TEST_F(PlanOptimizeTest, orderByPrimaryKey) {
|
||||
|
|
|
@ -23,20 +23,27 @@ class PlanOrderByTest : public PlannerTestBase {};
|
|||
TEST_F(PlanOrderByTest, basic) {
|
||||
useDb("root", "test");
|
||||
|
||||
// order by key is in the projection list
|
||||
run("select c1 from t1 order by c1");
|
||||
// order by key is not in the projection list
|
||||
run("select c1 from t1 order by c2");
|
||||
// ORDER BY key is in the projection list
|
||||
run("SELECT c1 FROM t1 ORDER BY c1");
|
||||
// ORDER BY key is not in the projection list
|
||||
run("SELECT c1 FROM t1 ORDER BY c2");
|
||||
}
|
||||
|
||||
TEST_F(PlanOrderByTest, expr) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select * from t1 order by c1 + 10, c2");
|
||||
run("SELECT * FROM t1 ORDER BY c1 + 10, c2");
|
||||
}
|
||||
|
||||
TEST_F(PlanOrderByTest, nullsOrder) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select * from t1 order by c1 desc nulls first");
|
||||
run("SELECT * FROM t1 ORDER BY c1 DESC NULLS FIRST");
|
||||
}
|
||||
|
||||
TEST_F(PlanOrderByTest, stable) {
|
||||
useDb("root", "test");
|
||||
|
||||
// ORDER BY key is in the projection list
|
||||
run("SELECT c1 FROM st1 ORDER BY c1");
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
#define QW_DEFAULT_TASK_NUMBER 10000
|
||||
#define QW_DEFAULT_SCH_TASK_NUMBER 10000
|
||||
#define QW_DEFAULT_SHORT_RUN_TIMES 2
|
||||
#define QW_DEFAULT_HEARTBEAT_MSEC 3000
|
||||
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
|
||||
|
||||
enum {
|
||||
QW_PHASE_PRE_QUERY = 1,
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include "qwInt.h"
|
||||
#include "dataSinkMgt.h"
|
||||
|
||||
int32_t qwPrerocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain);
|
||||
int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||
int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||
|
|
|
@ -36,7 +36,8 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus,
|
|||
|
||||
break;
|
||||
case JOB_TASK_STATUS_NOT_START:
|
||||
if (newStatus != JOB_TASK_STATUS_CANCELLED) {
|
||||
if (newStatus != JOB_TASK_STATUS_DROPPING && newStatus != JOB_TASK_STATUS_EXECUTING
|
||||
&& newStatus != JOB_TASK_STATUS_FAILED) {
|
||||
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
@ -248,6 +248,41 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo *
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||
if (NULL == qWorkerMgmt || NULL == pMsg) {
|
||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
SSubQueryMsg *msg = pMsg->pCont;
|
||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
||||
|
||||
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
|
||||
QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
|
||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
msg->sId = be64toh(msg->sId);
|
||||
msg->queryId = be64toh(msg->queryId);
|
||||
msg->taskId = be64toh(msg->taskId);
|
||||
msg->refId = be64toh(msg->refId);
|
||||
msg->phyLen = ntohl(msg->phyLen);
|
||||
msg->sqlLen = ntohl(msg->sqlLen);
|
||||
|
||||
uint64_t sId = msg->sId;
|
||||
uint64_t qId = msg->queryId;
|
||||
uint64_t tId = msg->taskId;
|
||||
int64_t rId = msg->refId;
|
||||
|
||||
SQWMsg qwMsg = {.msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
||||
|
||||
QW_SCH_TASK_DLOG("prerocessQuery start, handle:%p", pMsg->info.handle);
|
||||
QW_ERR_RET(qwPrerocessQuery(QW_FPARAMS(), &qwMsg));
|
||||
QW_SCH_TASK_DLOG("prerocessQuery end, handle:%p", pMsg->info.handle);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) {
|
||||
if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
|
||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
|
@ -265,12 +300,12 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
|||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
msg->sId = be64toh(msg->sId);
|
||||
msg->queryId = be64toh(msg->queryId);
|
||||
msg->taskId = be64toh(msg->taskId);
|
||||
msg->refId = be64toh(msg->refId);
|
||||
msg->phyLen = ntohl(msg->phyLen);
|
||||
msg->sqlLen = ntohl(msg->sqlLen);
|
||||
msg->sId = msg->sId;
|
||||
msg->queryId = msg->queryId;
|
||||
msg->taskId = msg->taskId;
|
||||
msg->refId = msg->refId;
|
||||
msg->phyLen = msg->phyLen;
|
||||
msg->sqlLen = msg->sqlLen;
|
||||
|
||||
uint64_t sId = msg->sId;
|
||||
uint64_t qId = msg->queryId;
|
||||
|
|
|
@ -248,11 +248,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
|||
|
||||
QW_TASK_DLOG("start to handle event at phase %s", qwPhaseStr(phase));
|
||||
|
||||
if (QW_PHASE_PRE_QUERY == phase) {
|
||||
QW_ERR_JRET(qwAddAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||
} else {
|
||||
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||
}
|
||||
|
||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||
|
||||
|
@ -285,7 +281,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
|||
break;
|
||||
}
|
||||
|
||||
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_EXECUTING));
|
||||
QW_ERR_JRET(qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_EXECUTING));
|
||||
break;
|
||||
}
|
||||
case QW_PHASE_PRE_FETCH: {
|
||||
|
@ -437,7 +433,7 @@ _return:
|
|||
QW_RET(code);
|
||||
}
|
||||
|
||||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain) {
|
||||
int32_t qwPrerocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||
int32_t code = 0;
|
||||
bool queryRsped = false;
|
||||
SSubplan *plan = NULL;
|
||||
|
@ -448,6 +444,32 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex
|
|||
|
||||
QW_ERR_JRET(qwRegisterQueryBrokenLinkArg(QW_FPARAMS(), &qwMsg->connInfo));
|
||||
|
||||
QW_ERR_JRET(qwAddAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||
|
||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
||||
|
||||
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_NOT_START));
|
||||
|
||||
_return:
|
||||
|
||||
if (ctx) {
|
||||
QW_UPDATE_RSP_CODE(ctx, code);
|
||||
qwReleaseTaskCtx(mgmt, ctx);
|
||||
}
|
||||
|
||||
QW_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain) {
|
||||
int32_t code = 0;
|
||||
bool queryRsped = false;
|
||||
SSubplan *plan = NULL;
|
||||
SQWPhaseInput input = {0};
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
DataSinkHandle sinkHandle = NULL;
|
||||
SQWTaskCtx *ctx = NULL;
|
||||
|
||||
QW_ERR_JRET(qwHandlePrePhaseEvents(QW_FPARAMS(), QW_PHASE_PRE_QUERY, &input, NULL));
|
||||
|
||||
QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx));
|
||||
|
@ -455,8 +477,6 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex
|
|||
atomic_store_8(&ctx->taskType, taskType);
|
||||
atomic_store_8(&ctx->explain, explain);
|
||||
|
||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
||||
|
||||
/*QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);*/
|
||||
|
||||
code = qStringToSubplan(qwMsg->msg, &plan);
|
||||
|
@ -663,7 +683,7 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
|||
|
||||
// TODO : TASK ALREADY REMOVED AND A NEW DROP MSG RECEIVED
|
||||
|
||||
QW_ERR_JRET(qwAddAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||
|
||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ extern "C" {
|
|||
#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000
|
||||
#define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 200 // unit is TSDB_TABLE_NUM_UNIT
|
||||
|
||||
#define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000
|
||||
#define SCH_MAX_TASK_TIMEOUT_USEC 60000000
|
||||
|
||||
#define SCH_TASK_MAX_EXEC_TIMES 5
|
||||
#define SCH_MAX_CANDIDATE_EP_NUM TSDB_MAX_REPLICA
|
||||
|
||||
enum {
|
||||
|
@ -51,6 +55,7 @@ typedef struct SSchTrans {
|
|||
|
||||
typedef struct SSchHbTrans {
|
||||
SRWLatch lock;
|
||||
int64_t taskNum;
|
||||
SRpcCtx rpcCtx;
|
||||
SSchTrans trans;
|
||||
} SSchHbTrans;
|
||||
|
@ -114,7 +119,8 @@ typedef struct SSchTaskCallbackParam {
|
|||
uint64_t queryId;
|
||||
int64_t refId;
|
||||
uint64_t taskId;
|
||||
void *transport;
|
||||
int32_t execIdx;
|
||||
void *pTrans;
|
||||
} SSchTaskCallbackParam;
|
||||
|
||||
typedef struct SSchHbCallbackParam {
|
||||
|
@ -148,25 +154,36 @@ typedef struct SSchLevel {
|
|||
SArray *subTasks; // Element is SQueryTask
|
||||
} SSchLevel;
|
||||
|
||||
typedef struct SSchTaskProfile {
|
||||
int64_t startTs;
|
||||
int64_t execUseTime[SCH_TASK_MAX_EXEC_TIMES];
|
||||
int64_t waitTime;
|
||||
int64_t endTs;
|
||||
} SSchTaskProfile;
|
||||
|
||||
typedef struct SSchTask {
|
||||
uint64_t taskId; // task id
|
||||
SRWLatch lock; // task lock
|
||||
int32_t maxExecTimes; // task may exec times
|
||||
int32_t execIdx; // task current execute try index
|
||||
SSchLevel *level; // level
|
||||
SRWLatch planLock; // task update plan lock
|
||||
SSubplan *plan; // subplan
|
||||
char *msg; // operator tree
|
||||
int32_t msgLen; // msg length
|
||||
int8_t status; // task status
|
||||
int32_t lastMsgType; // last sent msg type
|
||||
int32_t tryTimes; // task already tried times
|
||||
int64_t timeoutUsec; // taks timeout useconds before reschedule
|
||||
SQueryNodeAddr succeedAddr; // task executed success node address
|
||||
int8_t candidateIdx; // current try condidation index
|
||||
SArray *candidateAddrs; // condidate node addresses, element is SQueryNodeAddr
|
||||
SArray *execNodes; // all tried node for current task, element is SSchNodeInfo
|
||||
SQueryProfileSummary summary; // task execution summary
|
||||
SHashObj *execNodes; // all tried node for current task, element is SSchNodeInfo
|
||||
SSchTaskProfile profile; // task execution profile
|
||||
int32_t childReady; // child task ready number
|
||||
SArray *children; // the datasource tasks,from which to fetch the result, element is SQueryTask*
|
||||
SArray *parents; // the data destination tasks, get data from current task, element is SQueryTask*
|
||||
void* handle; // task send handle
|
||||
bool registerdHb; // registered in hb
|
||||
} SSchTask;
|
||||
|
||||
typedef struct SSchJobAttr {
|
||||
|
@ -215,8 +232,39 @@ typedef struct SSchJob {
|
|||
|
||||
extern SSchedulerMgmt schMgmt;
|
||||
|
||||
#define SCH_LOG_TASK_START_TS(_task) \
|
||||
do { \
|
||||
int64_t us = taosGetTimestampUs(); \
|
||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
||||
(_task)->profile.execUseTime[idx] = us; \
|
||||
if (0 == (_task)->execIdx) { \
|
||||
(_task)->profile.startTs = us; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SCH_LOG_TASK_WAIT_TS(_task) \
|
||||
do { \
|
||||
int64_t us = taosGetTimestampUs(); \
|
||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
||||
(_task)->profile.waitTime += us - (_task)->profile.execUseTime[idx]; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define SCH_LOG_TASK_END_TS(_task) \
|
||||
do { \
|
||||
int64_t us = taosGetTimestampUs(); \
|
||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
||||
(_task)->profile.execUseTime[idx] = us - (_task)->profile.execUseTime[idx]; \
|
||||
(_task)->profile.endTs = us; \
|
||||
} while (0)
|
||||
|
||||
#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec)
|
||||
|
||||
#define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children))
|
||||
|
||||
#define SCH_LOCK_TASK(_task) SCH_LOCK(SCH_WRITE, &(_task)->lock)
|
||||
#define SCH_UNLOCK_TASK(_task) SCH_UNLOCK(SCH_WRITE, &(_task)->lock)
|
||||
|
||||
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
|
||||
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
|
||||
#define SCH_GET_TASK_LASTMSG_TYPE(_task) ((_task) ? atomic_load_32(&(_task)->lastMsgType) : -1)
|
||||
|
@ -284,7 +332,7 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask);
|
|||
int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask);
|
||||
int32_t schFetchFromRemote(SSchJob *pJob);
|
||||
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode);
|
||||
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId);
|
||||
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray* taskAction);
|
||||
int32_t schCloneSMsgSendInfo(void *src, void **dst);
|
||||
int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob);
|
||||
void schFreeJobImpl(void *job);
|
||||
|
@ -301,10 +349,9 @@ int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp);
|
|||
int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp);
|
||||
void schProcessOnDataFetched(SSchJob *job);
|
||||
int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask);
|
||||
int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCode);
|
||||
void schFreeRpcCtxVal(const void *arg);
|
||||
int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb);
|
||||
int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, void *handle);
|
||||
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx);
|
||||
int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql,
|
||||
SSchResInfo *pRes, bool sync);
|
||||
int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql,
|
||||
|
@ -318,7 +365,8 @@ int32_t schExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *p
|
|||
int32_t schAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, int64_t startTs, SSchResInfo *pRes);
|
||||
int32_t schFetchRows(SSchJob *pJob);
|
||||
int32_t schAsyncFetchRows(SSchJob *pJob);
|
||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, int32_t msgType, void *handle, int32_t rspCode);
|
||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx);
|
||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -28,11 +28,14 @@ FORCE_INLINE int32_t schReleaseJob(int64_t refId) { qDebug("release jobId:0x%"PR
|
|||
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) {
|
||||
pTask->plan = pPlan;
|
||||
pTask->level = pLevel;
|
||||
pTask->execIdx = -1;
|
||||
pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES;
|
||||
pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||
pTask->taskId = schGenTaskId();
|
||||
pTask->execNodes = taosArrayInit(SCH_MAX_CANDIDATE_EP_NUM, sizeof(SSchNodeInfo));
|
||||
pTask->execNodes = taosHashInit(SCH_MAX_CANDIDATE_EP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
if (NULL == pTask->execNodes) {
|
||||
SCH_TASK_ELOG("taosArrayInit %d execNodes failed", SCH_MAX_CANDIDATE_EP_NUM);
|
||||
SCH_TASK_ELOG("taosHashInit %d execNodes failed", SCH_MAX_CANDIDATE_EP_NUM);
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -123,7 +126,34 @@ _return:
|
|||
SCH_RET(code);
|
||||
}
|
||||
|
||||
void schFreeTask(SSchTask *pTask) {
|
||||
void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask) {
|
||||
if (!pTask->registerdHb) {
|
||||
return;
|
||||
}
|
||||
|
||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||
SQueryNodeEpId epId = {0};
|
||||
|
||||
epId.nodeId = addr->nodeId;
|
||||
|
||||
SEp* pEp = SCH_GET_CUR_EP(addr);
|
||||
strcpy(epId.ep.fqdn, pEp->fqdn);
|
||||
epId.ep.port = pEp->port;
|
||||
|
||||
SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, &epId, sizeof(SQueryNodeEpId));
|
||||
if (NULL == hb) {
|
||||
SCH_TASK_ELOG("nodeId %d fqdn %s port %d not in hb connections", epId.nodeId, epId.ep.fqdn, epId.ep.port);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_sub_fetch_64(&hb->taskNum, 1);
|
||||
|
||||
pTask->registerdHb = false;
|
||||
}
|
||||
|
||||
void schFreeTask(SSchJob *pJob, SSchTask *pTask) {
|
||||
schDeregisterTaskHb(pJob, pTask);
|
||||
|
||||
if (pTask->candidateAddrs) {
|
||||
taosArrayDestroy(pTask->candidateAddrs);
|
||||
}
|
||||
|
@ -139,7 +169,7 @@ void schFreeTask(SSchTask *pTask) {
|
|||
}
|
||||
|
||||
if (pTask->execNodes) {
|
||||
taosArrayDestroy(pTask->execNodes);
|
||||
taosHashCleanup(pTask->execNodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,44 +359,51 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, void *handle) {
|
||||
SSchNodeInfo nodeInfo = {.addr = *addr, .handle = handle};
|
||||
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx) {
|
||||
SSchNodeInfo nodeInfo = {.addr = *addr, .handle = NULL};
|
||||
|
||||
if (NULL == taosArrayPush(pTask->execNodes, &nodeInfo)) {
|
||||
SCH_TASK_ELOG("taosArrayPush nodeInfo to execNodes list failed, errno:%d", errno);
|
||||
if (taosHashPut(pTask->execNodes, &execIdx, sizeof(execIdx), &nodeInfo, sizeof(nodeInfo))) {
|
||||
SCH_TASK_ELOG("taosHashPut nodeInfo to execNodes failed, errno:%d", errno);
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SCH_TASK_DLOG("task execNode recorded, handle:%p", handle);
|
||||
SCH_TASK_DLOG("task execNode added, execIdx:%d", execIdx);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle) {
|
||||
int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execIdx) {
|
||||
if (NULL == pTask->execNodes) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t num = taosArrayGetSize(pTask->execNodes);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SSchNodeInfo* pNode = taosArrayGet(pTask->execNodes, i);
|
||||
if (pNode->handle == handle) {
|
||||
taosArrayRemove(pTask->execNodes, i);
|
||||
break;
|
||||
}
|
||||
taosHashRemove(pTask->execNodes, &execIdx, sizeof(execIdx));
|
||||
if (execIdx != pTask->execIdx) { // ignore it
|
||||
SCH_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, int32_t msgType, void *handle, int32_t rspCode) {
|
||||
int32_t schUpdateTaskExecNode(SSchTask *pTask, void *handle, int32_t execIdx) {
|
||||
if (taosHashGetSize(pTask->execNodes) <= 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execIdx, sizeof(execIdx));
|
||||
nodeInfo->handle = handle;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx) {
|
||||
if (dropExecNode) {
|
||||
SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execIdx));
|
||||
}
|
||||
|
||||
SCH_SET_TASK_HANDLE(pTask, handle);
|
||||
|
||||
schUpdateTaskExecNodeHandle(pTask, handle, rspCode);
|
||||
|
||||
if (msgType == TDMT_SCH_LINK_BROKEN) {
|
||||
schDropTaskExecNode(pJob, pTask, handle);
|
||||
}
|
||||
schUpdateTaskExecNode(pTask, handle, execIdx);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -672,7 +709,6 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
|||
|
||||
int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) {
|
||||
int8_t status = 0;
|
||||
++pTask->tryTimes;
|
||||
|
||||
if (schJobNeedToStop(pJob, &status)) {
|
||||
*needRetry = false;
|
||||
|
@ -680,9 +716,19 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pTask->tryTimes >= REQUEST_MAX_TRY_TIMES) {
|
||||
if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) {
|
||||
pTask->maxExecTimes++;
|
||||
if (pTask->timeoutUsec < SCH_MAX_TASK_TIMEOUT_USEC) {
|
||||
pTask->timeoutUsec *= 2;
|
||||
if (pTask->timeoutUsec > SCH_MAX_TASK_TIMEOUT_USEC) {
|
||||
pTask->timeoutUsec = SCH_MAX_TASK_TIMEOUT_USEC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((pTask->execIdx + 1) >= pTask->maxExecTimes) {
|
||||
*needRetry = false;
|
||||
SCH_TASK_DLOG("task no more retry since reach max try times, tryTimes:%d", pTask->tryTimes);
|
||||
SCH_TASK_DLOG("task no more retry since reach max try times, execIdx:%d", pTask->execIdx);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -694,16 +740,16 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
|||
|
||||
// TODO CHECK epList/condidateList
|
||||
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||
if (pTask->tryTimes >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||
if ((pTask->execIdx + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||
*needRetry = false;
|
||||
SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes,
|
||||
SCH_TASK_DLOG("task no more retry since all ep tried, execIdx:%d, epNum:%d", pTask->execIdx,
|
||||
SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
||||
|
||||
if ((pTask->candidateIdx + 1) >= candidateNum) {
|
||||
if ((pTask->candidateIdx + 1) >= candidateNum && (TSDB_CODE_SCH_TIMEOUT_ERROR != errCode)) {
|
||||
*needRetry = false;
|
||||
SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d",
|
||||
pTask->candidateIdx, candidateNum);
|
||||
|
@ -712,7 +758,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
|||
}
|
||||
|
||||
*needRetry = true;
|
||||
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->tryTimes, errCode, tstrerror(errCode));
|
||||
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execIdx + 1, errCode, tstrerror(errCode));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -728,10 +774,15 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
||||
}
|
||||
|
||||
schDeregisterTaskHb(pJob, pTask);
|
||||
|
||||
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||
SCH_SWITCH_EPSET(&pTask->plan->execNode);
|
||||
} else {
|
||||
++pTask->candidateIdx;
|
||||
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
||||
if (++pTask->candidateIdx >= candidateNum) {
|
||||
pTask->candidateIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SCH_ERR_RET(schLaunchTask(pJob, pTask));
|
||||
|
@ -906,6 +957,12 @@ void schProcessOnDataFetched(SSchJob *job) {
|
|||
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) {
|
||||
int8_t status = 0;
|
||||
|
||||
if (errCode == TSDB_CODE_SCH_TIMEOUT_ERROR) {
|
||||
SCH_LOG_TASK_WAIT_TS(pTask);
|
||||
} else {
|
||||
SCH_LOG_TASK_END_TS(pTask);
|
||||
}
|
||||
|
||||
if (schJobNeedToStop(pJob, &status)) {
|
||||
SCH_TASK_DLOG("task failed not processed cause of job status, job status:%s", jobTaskStatusStr(status));
|
||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||
|
@ -989,6 +1046,8 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
|||
|
||||
SCH_TASK_DLOG("taskOnSuccess, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||
|
||||
SCH_LOG_TASK_END_TS(pTask);
|
||||
|
||||
SCH_ERR_JRET(schMoveTaskToSuccList(pJob, pTask, &moved));
|
||||
|
||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_PARTIAL_SUCCEED);
|
||||
|
@ -1105,6 +1164,92 @@ int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRs
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) {
|
||||
if (NULL == pTask->execNodes) {
|
||||
SCH_TASK_DLOG("no exec address, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t size = (int32_t)taosHashGetSize(pTask->execNodes);
|
||||
|
||||
if (size <= 0) {
|
||||
SCH_TASK_DLOG("task has no execNodes, no need to drop it, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||
return;
|
||||
}
|
||||
|
||||
SSchNodeInfo *nodeInfo = taosHashIterate(pTask->execNodes, NULL);
|
||||
while (nodeInfo) {
|
||||
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
||||
|
||||
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_VND_DROP_TASK);
|
||||
|
||||
nodeInfo = taosHashIterate(pTask->execNodes, nodeInfo);
|
||||
}
|
||||
|
||||
SCH_TASK_DLOG("task has %d exec address", size);
|
||||
}
|
||||
|
||||
|
||||
int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) {
|
||||
if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCH_LOCK_TASK(pTask);
|
||||
if (JOB_TASK_STATUS_EXECUTING == pTask->status && pJob->fetchTask != pTask) {
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
taosHashClear(pTask->execNodes);
|
||||
schProcessOnTaskFailure(pJob, pTask, TSDB_CODE_SCH_TIMEOUT_ERROR);
|
||||
}
|
||||
SCH_UNLOCK_TASK(pTask);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) {
|
||||
int32_t taskNum = (int32_t)taosArrayGetSize(pStatusList);
|
||||
SSchTask *pTask = NULL;
|
||||
|
||||
qDebug("%d task status in hb rsp from nodeId:%d, fqdn:%s, port:%d", taskNum, pEpId->nodeId, pEpId->ep.fqdn, pEpId->ep.port);
|
||||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
STaskStatus *taskStatus = taosArrayGet(pStatusList, i);
|
||||
|
||||
SSchJob *pJob = schAcquireJob(taskStatus->refId);
|
||||
if (NULL == pJob) {
|
||||
qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId,
|
||||
taskStatus->queryId, taskStatus->taskId);
|
||||
// TODO DROP TASK FROM SERVER!!!!
|
||||
continue;
|
||||
}
|
||||
|
||||
SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, jobTaskStatusStr(taskStatus->status));
|
||||
|
||||
pTask = NULL;
|
||||
schGetTaskInJob(pJob, taskStatus->taskId, &pTask);
|
||||
if (NULL == pTask) {
|
||||
// TODO DROP TASK FROM SERVER!!!!
|
||||
schReleaseJob(taskStatus->refId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (taskStatus->status == JOB_TASK_STATUS_FAILED) {
|
||||
// RECORD AND HANDLE ERROR!!!!
|
||||
schReleaseJob(taskStatus->refId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (taskStatus->status == JOB_TASK_STATUS_NOT_START && SCH_TASK_TIMEOUT(pTask)) {
|
||||
schRescheduleTask(pJob, pTask);
|
||||
}
|
||||
|
||||
schReleaseJob(taskStatus->refId);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) {
|
||||
if (rsp->tbFName[0]) {
|
||||
if (NULL == pJob->execRes.res) {
|
||||
|
@ -1156,25 +1301,16 @@ int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCode) {
|
||||
if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 ||
|
||||
taosArrayGetSize(pTask->execNodes) <= 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSchNodeInfo *nodeInfo = taosArrayGet(pTask->execNodes, 0);
|
||||
nodeInfo->handle = handle;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
||||
int8_t status = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||
|
||||
pTask->execIdx++;
|
||||
|
||||
SCH_LOG_TASK_START_TS(pTask);
|
||||
|
||||
if (schJobNeedToStop(pJob, &status)) {
|
||||
SCH_TASK_DLOG("no need to launch task cause of job status, job status:%s", jobTaskStatusStr(status));
|
||||
|
||||
|
@ -1257,29 +1393,6 @@ int32_t schLaunchJob(SSchJob *pJob) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) {
|
||||
if (NULL == pTask->execNodes) {
|
||||
SCH_TASK_DLOG("no exec address, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t size = (int32_t)taosArrayGetSize(pTask->execNodes);
|
||||
|
||||
if (size <= 0) {
|
||||
SCH_TASK_DLOG("task has no execNodes, no need to drop it, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||
return;
|
||||
}
|
||||
|
||||
SSchNodeInfo *nodeInfo = NULL;
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
nodeInfo = (SSchNodeInfo *)taosArrayGet(pTask->execNodes, i);
|
||||
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
||||
|
||||
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_VND_DROP_TASK);
|
||||
}
|
||||
|
||||
SCH_TASK_DLOG("task has %d exec address", size);
|
||||
}
|
||||
|
||||
void schDropTaskInHashList(SSchJob *pJob, SHashObj *list) {
|
||||
if (!SCH_IS_NEED_DROP_JOB(pJob)) {
|
||||
|
@ -1332,7 +1445,7 @@ void schFreeJobImpl(void *job) {
|
|||
int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks);
|
||||
for (int32_t j = 0; j < numOfTasks; ++j) {
|
||||
SSchTask *pTask = taosArrayGet(pLevel->subTasks, j);
|
||||
schFreeTask(pTask);
|
||||
schFreeTask(pJob, pTask);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pLevel->subTasks);
|
||||
|
|
|
@ -92,8 +92,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
|||
int8_t status = 0;
|
||||
|
||||
if (schJobNeedToStop(pJob, &status)) {
|
||||
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status),
|
||||
rspCode);
|
||||
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode);
|
||||
taosMemoryFreeClear(msg);
|
||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||
}
|
||||
|
@ -364,14 +363,26 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in
|
|||
|
||||
SCH_ERR_JRET(schGetTaskInJob(pJob, pParam->taskId, &pTask));
|
||||
|
||||
SCH_LOCK_TASK(pTask);
|
||||
|
||||
SCH_TASK_DLOG("rsp msg received, type:%s, handle:%p, code:%s", TMSG_INFO(msgType), pMsg->handle, tstrerror(rspCode));
|
||||
|
||||
SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, msgType, pMsg->handle, rspCode));
|
||||
if (pParam->execIdx != pTask->execIdx) {
|
||||
SCH_TASK_DLOG("execIdx %d mis-match current execIdx %d", pParam->execIdx, pTask->execIdx);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || rspCode == TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, pParam->execIdx));
|
||||
|
||||
SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode));
|
||||
|
||||
_return:
|
||||
|
||||
if (pTask) {
|
||||
SCH_UNLOCK_TASK(pTask);
|
||||
}
|
||||
|
||||
if (pJob) {
|
||||
schReleaseJob(pParam->refId);
|
||||
}
|
||||
|
@ -426,7 +437,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c
|
|||
SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL};
|
||||
SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans));
|
||||
|
||||
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId));
|
||||
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId, NULL));
|
||||
} else {
|
||||
SCH_ERR_RET(schHandleCallback(param, pMsg, TDMT_SCH_LINK_BROKEN, code));
|
||||
}
|
||||
|
@ -454,7 +465,8 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, int32_t msgType,
|
|||
param->queryId = pJob->queryId;
|
||||
param->refId = pJob->refId;
|
||||
param->taskId = SCH_TASK_ID(pTask);
|
||||
param->transport = pJob->pTrans;
|
||||
param->pTrans = pJob->pTrans;
|
||||
param->execIdx = pTask->execIdx;
|
||||
|
||||
msgSendInfo->param = param;
|
||||
msgSendInfo->fp = fp;
|
||||
|
@ -661,7 +673,7 @@ int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *
|
|||
}
|
||||
|
||||
|
||||
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
|
||||
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray* taskAction) {
|
||||
SSchedulerHbReq req = {0};
|
||||
int32_t code = 0;
|
||||
SRpcCtx rpcCtx = {0};
|
||||
|
@ -717,7 +729,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
|
|||
__async_send_cb_fn_t fp = NULL;
|
||||
SCH_ERR_JRET(schGetCallbackFp(msgType, &fp));
|
||||
|
||||
param->transport = trans.pTrans;
|
||||
param->pTrans = trans.pTrans;
|
||||
|
||||
pMsgSendInfo->param = param;
|
||||
pMsgSendInfo->msgInfo.pData = msg;
|
||||
|
@ -763,15 +775,26 @@ int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask) {
|
|||
strcpy(epId.ep.fqdn, pEp->fqdn);
|
||||
epId.ep.port = pEp->port;
|
||||
|
||||
SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, &epId, sizeof(SQueryNodeEpId));
|
||||
SSchHbTrans *hb = NULL;
|
||||
while (true) {
|
||||
hb = taosHashGet(schMgmt.hbConnections, &epId, sizeof(SQueryNodeEpId));
|
||||
if (NULL == hb) {
|
||||
bool exist = false;
|
||||
SCH_ERR_RET(schRegisterHbConnection(pJob, pTask, &epId, &exist));
|
||||
if (!exist) {
|
||||
SCH_ERR_RET(schBuildAndSendHbMsg(&epId));
|
||||
SCH_ERR_RET(schBuildAndSendHbMsg(&epId, NULL));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
atomic_add_fetch_64(&hb->taskNum, 1);
|
||||
|
||||
pTask->registerdHb = true;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -810,33 +833,12 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
SSchTrans trans = {0};
|
||||
trans.pTrans = pParam->transport;
|
||||
trans.pTrans = pParam->pTrans;
|
||||
trans.pHandle = pMsg->handle;
|
||||
|
||||
SCH_ERR_JRET(schUpdateHbConnection(&rsp.epId, &trans));
|
||||
|
||||
int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus);
|
||||
qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn,
|
||||
rsp.epId.ep.port);
|
||||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
STaskStatus *taskStatus = taosArrayGet(rsp.taskStatus, i);
|
||||
|
||||
SSchJob *pJob = schAcquireJob(taskStatus->refId);
|
||||
if (NULL == pJob) {
|
||||
qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId,
|
||||
taskStatus->queryId, taskStatus->taskId);
|
||||
// TODO DROP TASK FROM SERVER!!!!
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId,
|
||||
jobTaskStatusStr(taskStatus->status));
|
||||
|
||||
schReleaseJob(taskStatus->refId);
|
||||
}
|
||||
SCH_ERR_JRET(schProcessOnTaskStatusRsp(&rsp.epId, rsp.taskStatus));
|
||||
|
||||
_return:
|
||||
|
||||
|
@ -856,7 +858,8 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) {
|
|||
param->queryId = pJob->queryId;
|
||||
param->refId = pJob->refId;
|
||||
param->taskId = SCH_TASK_ID(pTask);
|
||||
param->transport = pJob->pTrans;
|
||||
param->pTrans = pJob->pTrans;
|
||||
param->taskId = pTask->taskId;
|
||||
|
||||
*pParam = param;
|
||||
|
||||
|
@ -1158,7 +1161,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
(rpcCtx.args ? &rpcCtx : NULL)));
|
||||
|
||||
if (msgType == TDMT_VND_QUERY) {
|
||||
SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.pHandle));
|
||||
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execIdx));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -200,7 +200,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SSyncRaftEntry* pRollBackEntry = ths->pLogStore->getEntry(ths->pLogStore, index);
|
||||
assert(pRollBackEntry != NULL);
|
||||
|
||||
// if (pRollBackEntry->msgType != TDMT_VND_SYNC_NOOP) {
|
||||
// if (pRollBackEntry->msgType != TDMT_SYNC_NOOP) {
|
||||
if (syncUtilUserRollback(pRollBackEntry->msgType)) {
|
||||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pRollBackEntry, &rpcMsg);
|
||||
|
@ -229,7 +229,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pAppendEntry, &rpcMsg);
|
||||
if (ths->pFsm != NULL) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_VND_SYNC_NOOP) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) {
|
||||
SFsmCbMeta cbMeta;
|
||||
cbMeta.index = pAppendEntry->index;
|
||||
|
@ -261,7 +261,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pAppendEntry, &rpcMsg);
|
||||
if (ths->pFsm != NULL) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_VND_SYNC_NOOP) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) {
|
||||
SFsmCbMeta cbMeta;
|
||||
cbMeta.index = pAppendEntry->index;
|
||||
|
@ -346,7 +346,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
}
|
||||
|
||||
// config change
|
||||
if (pEntry->originalRpcType == TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE) {
|
||||
SSyncCfg oldSyncCfg = ths->pRaftCfg->cfg;
|
||||
|
||||
SSyncCfg newSyncCfg;
|
||||
|
|
|
@ -124,7 +124,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
|
|||
}
|
||||
|
||||
// config change
|
||||
if (pEntry->originalRpcType == TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE) {
|
||||
SSyncCfg oldSyncCfg = pSyncNode->pRaftCfg->cfg;
|
||||
|
||||
SSyncCfg newSyncCfg;
|
||||
|
|
|
@ -256,7 +256,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncRpcMsgLog2((char *)"==syncIOConsumerFunc==", pRpcMsg);
|
||||
|
||||
// use switch case instead of if else
|
||||
if (pRpcMsg->msgType == TDMT_VND_SYNC_PING) {
|
||||
if (pRpcMsg->msgType == TDMT_SYNC_PING) {
|
||||
if (io->FpOnSyncPing != NULL) {
|
||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -264,7 +264,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncPingDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||
if (io->FpOnSyncPingReply != NULL) {
|
||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -272,7 +272,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncPingReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||
if (io->FpOnSyncClientRequest != NULL) {
|
||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -280,7 +280,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncClientRequestDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||
if (io->FpOnSyncRequestVote != NULL) {
|
||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -288,7 +288,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncRequestVoteDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||
if (io->FpOnSyncRequestVoteReply != NULL) {
|
||||
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -296,7 +296,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||
if (io->FpOnSyncAppendEntries != NULL) {
|
||||
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -304,7 +304,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncAppendEntriesDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
if (io->FpOnSyncAppendEntriesReply != NULL) {
|
||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -312,7 +312,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_TIMEOUT) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
if (io->FpOnSyncTimeout != NULL) {
|
||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
|
||||
assert(pSyncMsg != NULL);
|
||||
|
@ -365,7 +365,7 @@ static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
if (pMsg->msgType == TDMT_VND_SYNC_COMMON_RESPONSE) {
|
||||
if (pMsg->msgType == TDMT_SYNC_COMMON_RESPONSE) {
|
||||
sTrace("==syncIOProcessReply==");
|
||||
} else {
|
||||
syncRpcMsgLog2((char *)"==syncIOProcessReply==", pMsg);
|
||||
|
|
|
@ -174,7 +174,7 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) {
|
|||
sInfo("==syncReconfig== newconfig:%s", configChange);
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.msgType = TDMT_VND_SYNC_CONFIG_CHANGE;
|
||||
rpcMsg.msgType = TDMT_SYNC_CONFIG_CHANGE;
|
||||
rpcMsg.info.noResp = 1;
|
||||
rpcMsg.contLen = strlen(configChange) + 1;
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
|
@ -1399,7 +1399,7 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
|
|||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (ths->pFsm != NULL) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_VND_SYNC_NOOP) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) {
|
||||
SFsmCbMeta cbMeta;
|
||||
cbMeta.index = pEntry->index;
|
||||
|
@ -1421,7 +1421,7 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
|
|||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (ths->pFsm != NULL) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_VND_SYNC_NOOP) {
|
||||
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) {
|
||||
SFsmCbMeta cbMeta;
|
||||
cbMeta.index = pEntry->index;
|
||||
|
|
|
@ -22,50 +22,50 @@ cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg) {
|
|||
cJSON* pRoot;
|
||||
|
||||
// in compiler optimization, switch case = if else constants
|
||||
if (pRpcMsg->msgType == TDMT_VND_SYNC_TIMEOUT) {
|
||||
if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
SyncTimeout* pSyncMsg = syncTimeoutDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncTimeout2Json(pSyncMsg);
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING) {
|
||||
SyncPing* pSyncMsg = syncPingDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncPing2Json(pSyncMsg);
|
||||
syncPingDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||
SyncPingReply* pSyncMsg = syncPingReplyDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncPingReply2Json(pSyncMsg);
|
||||
syncPingReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||
SyncClientRequest* pSyncMsg = syncClientRequestDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncClientRequest2Json(pSyncMsg);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST_REPLY) {
|
||||
pRoot = syncRpcUnknownMsg2Json();
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||
SyncRequestVote* pSyncMsg = syncRequestVoteDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncRequestVote2Json(pSyncMsg);
|
||||
syncRequestVoteDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||
SyncRequestVoteReply* pSyncMsg = syncRequestVoteReplyDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncRequestVoteReply2Json(pSyncMsg);
|
||||
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||
SyncAppendEntries* pSyncMsg = syncAppendEntriesDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncAppendEntries2Json(pSyncMsg);
|
||||
syncAppendEntriesDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
SyncAppendEntriesReply* pSyncMsg = syncAppendEntriesReplyDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||
pRoot = syncAppendEntriesReply2Json(pSyncMsg);
|
||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_COMMON_RESPONSE) {
|
||||
} else if (pRpcMsg->msgType == TDMT_SYNC_COMMON_RESPONSE) {
|
||||
pRoot = cJSON_CreateObject();
|
||||
char* s;
|
||||
s = syncUtilprintBin((char*)(pRpcMsg->pCont), pRpcMsg->contLen);
|
||||
|
@ -98,7 +98,7 @@ cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg) {
|
|||
|
||||
cJSON* syncRpcUnknownMsg2Json() {
|
||||
cJSON* pRoot = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(pRoot, "msgType", TDMT_VND_SYNC_UNKNOWN);
|
||||
cJSON_AddNumberToObject(pRoot, "msgType", TDMT_SYNC_UNKNOWN);
|
||||
cJSON_AddStringToObject(pRoot, "data", "unknown message");
|
||||
|
||||
cJSON* pJson = cJSON_CreateObject();
|
||||
|
@ -146,7 +146,7 @@ SyncTimeout* syncTimeoutBuild() {
|
|||
SyncTimeout* pMsg = taosMemoryMalloc(bytes);
|
||||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->msgType = TDMT_VND_SYNC_TIMEOUT;
|
||||
pMsg->msgType = TDMT_SYNC_TIMEOUT;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ SyncPing* syncPingBuild(uint32_t dataLen) {
|
|||
SyncPing* pMsg = taosMemoryMalloc(bytes);
|
||||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->msgType = TDMT_VND_SYNC_PING;
|
||||
pMsg->msgType = TDMT_SYNC_PING;
|
||||
pMsg->dataLen = dataLen;
|
||||
return pMsg;
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ SyncPingReply* syncPingReplyBuild(uint32_t dataLen) {
|
|||
SyncPingReply* pMsg = taosMemoryMalloc(bytes);
|
||||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->msgType = TDMT_VND_SYNC_PING_REPLY;
|
||||
pMsg->msgType = TDMT_SYNC_PING_REPLY;
|
||||
pMsg->dataLen = dataLen;
|
||||
return pMsg;
|
||||
}
|
||||
|
@ -795,7 +795,7 @@ SyncClientRequest* syncClientRequestBuild(uint32_t dataLen) {
|
|||
SyncClientRequest* pMsg = taosMemoryMalloc(bytes);
|
||||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->msgType = TDMT_VND_SYNC_CLIENT_REQUEST;
|
||||
pMsg->msgType = TDMT_SYNC_CLIENT_REQUEST;
|
||||
pMsg->seqNum = 0;
|
||||
pMsg->isWeak = false;
|
||||
pMsg->dataLen = dataLen;
|
||||
|
@ -937,7 +937,7 @@ SyncRequestVote* syncRequestVoteBuild(int32_t vgId) {
|
|||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->vgId = vgId;
|
||||
pMsg->msgType = TDMT_VND_SYNC_REQUEST_VOTE;
|
||||
pMsg->msgType = TDMT_SYNC_REQUEST_VOTE;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
|
@ -1086,7 +1086,7 @@ SyncRequestVoteReply* syncRequestVoteReplyBuild(int32_t vgId) {
|
|||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->vgId = vgId;
|
||||
pMsg->msgType = TDMT_VND_SYNC_REQUEST_VOTE_REPLY;
|
||||
pMsg->msgType = TDMT_SYNC_REQUEST_VOTE_REPLY;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ SyncAppendEntries* syncAppendEntriesBuild(uint32_t dataLen, int32_t vgId) {
|
|||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->vgId = vgId;
|
||||
pMsg->msgType = TDMT_VND_SYNC_APPEND_ENTRIES;
|
||||
pMsg->msgType = TDMT_SYNC_APPEND_ENTRIES;
|
||||
pMsg->dataLen = dataLen;
|
||||
return pMsg;
|
||||
}
|
||||
|
@ -1398,7 +1398,7 @@ SyncAppendEntriesReply* syncAppendEntriesReplyBuild(int32_t vgId) {
|
|||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->vgId = vgId;
|
||||
pMsg->msgType = TDMT_VND_SYNC_APPEND_ENTRIES_REPLY;
|
||||
pMsg->msgType = TDMT_SYNC_APPEND_ENTRIES_REPLY;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ SyncApplyMsg* syncApplyMsgBuild(uint32_t dataLen) {
|
|||
SyncApplyMsg* pMsg = taosMemoryMalloc(bytes);
|
||||
memset(pMsg, 0, bytes);
|
||||
pMsg->bytes = bytes;
|
||||
pMsg->msgType = TDMT_VND_SYNC_APPLY_MSG;
|
||||
pMsg->msgType = TDMT_SYNC_APPLY_MSG;
|
||||
pMsg->dataLen = dataLen;
|
||||
return pMsg;
|
||||
}
|
||||
|
|
|
@ -59,14 +59,14 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId)
|
|||
memset(&rpcMsg, 0, sizeof(SRpcMsg));
|
||||
rpcMsg.contLen = head.contLen;
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
rpcMsg.msgType = TDMT_VND_SYNC_NOOP;
|
||||
rpcMsg.msgType = TDMT_SYNC_NOOP;
|
||||
memcpy(rpcMsg.pCont, &head, sizeof(head));
|
||||
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(rpcMsg.contLen);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
pEntry->msgType = TDMT_VND_SYNC_CLIENT_REQUEST;
|
||||
pEntry->originalRpcType = TDMT_VND_SYNC_NOOP;
|
||||
pEntry->msgType = TDMT_SYNC_CLIENT_REQUEST;
|
||||
pEntry->originalRpcType = TDMT_SYNC_NOOP;
|
||||
pEntry->seqNum = 0;
|
||||
pEntry->isWeak = 0;
|
||||
pEntry->term = term;
|
||||
|
|
|
@ -104,7 +104,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
SSyncRaftEntry* pEntry = syncEntryBuild(pWalHandle->pHead->head.bodyLen);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
pEntry->msgType = TDMT_VND_SYNC_CLIENT_REQUEST;
|
||||
pEntry->msgType = TDMT_SYNC_CLIENT_REQUEST;
|
||||
pEntry->originalRpcType = pWalHandle->pHead->head.msgType;
|
||||
pEntry->seqNum = pWalHandle->pHead->head.syncMeta.seqNum;
|
||||
pEntry->isWeak = pWalHandle->pHead->head.syncMeta.isWeek;
|
||||
|
|
|
@ -215,28 +215,28 @@ void syncUtilMsgNtoH(void* msg) {
|
|||
}
|
||||
|
||||
bool syncUtilIsData(tmsg_t msgType) {
|
||||
if (msgType == TDMT_VND_SYNC_NOOP || msgType == TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (msgType == TDMT_SYNC_NOOP || msgType == TDMT_SYNC_CONFIG_CHANGE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool syncUtilUserPreCommit(tmsg_t msgType) {
|
||||
if (msgType != TDMT_VND_SYNC_NOOP && msgType != TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool syncUtilUserCommit(tmsg_t msgType) {
|
||||
if (msgType != TDMT_VND_SYNC_NOOP && msgType != TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool syncUtilUserRollback(tmsg_t msgType) {
|
||||
if (msgType != TDMT_VND_SYNC_NOOP && msgType != TDMT_VND_SYNC_CONFIG_CHANGE) {
|
||||
if (msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_CONFIG_CHANGE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -227,6 +227,33 @@ int32_t compareJsonContainsKey(const void* pLeft, const void* pRight) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// string > number > bool > null
|
||||
// ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison
|
||||
int32_t compareJsonVal(const void *pLeft, const void *pRight) {
|
||||
char leftType = *(char*)pLeft;
|
||||
char rightType = *(char*)pRight;
|
||||
if(leftType != rightType){
|
||||
return leftType > rightType ? 1 : -1;
|
||||
}
|
||||
|
||||
char* realDataLeft = POINTER_SHIFT(pLeft, CHAR_BYTES);
|
||||
char* realDataRight = POINTER_SHIFT(pRight, CHAR_BYTES);
|
||||
if(leftType == TSDB_DATA_TYPE_BOOL) {
|
||||
DEFAULT_COMP(GET_INT8_VAL(realDataLeft), GET_INT8_VAL(realDataRight));
|
||||
}else if(leftType == TSDB_DATA_TYPE_DOUBLE){
|
||||
DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(realDataLeft), GET_DOUBLE_VAL(realDataRight));
|
||||
}else if(leftType == TSDB_DATA_TYPE_NCHAR){
|
||||
return compareLenPrefixedWStr(realDataLeft, realDataRight);
|
||||
}else if(leftType == TSDB_DATA_TYPE_NULL) {
|
||||
return 0;
|
||||
}else{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t compareJsonValDesc(const void *pLeft, const void *pRight) {
|
||||
return compareJsonVal(pRight, pLeft);
|
||||
}
|
||||
/*
|
||||
* Compare two strings
|
||||
* TSDB_MATCH: Match
|
||||
|
@ -601,6 +628,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) {
|
|||
return (order == TSDB_ORDER_ASC) ? compareLenPrefixedStr : compareLenPrefixedStrDesc;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
return (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
return (order == TSDB_ORDER_ASC) ? compareJsonVal : compareJsonValDesc;
|
||||
default:
|
||||
return (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc;
|
||||
}
|
||||
|
|
|
@ -444,6 +444,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_CTG_VG_META_MISMATCH, "table meta and vgroup
|
|||
//scheduler
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_STATUS_ERROR, "scheduler status error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_TIMEOUT_ERROR, "Task timeout")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QW_MSG_ERROR, "Invalid msg order")
|
||||
|
||||
// parser
|
||||
|
|
|
@ -89,7 +89,7 @@ endi
|
|||
if $data4_db != 3 then # replica
|
||||
return -1
|
||||
endi
|
||||
if $data5_db != nostrict then # strict
|
||||
if $data5_db != no_strict then # strict
|
||||
return -1
|
||||
endi
|
||||
if $data6_db != 345600 then # days
|
||||
|
|
|
@ -110,7 +110,7 @@ if $data4_db != 1 then # replica
|
|||
print expect 1, actual: $data4_db
|
||||
return -1
|
||||
endi
|
||||
if $data5_db != nostrict then # strict
|
||||
if $data5_db != no_strict then # strict
|
||||
return -1
|
||||
endi
|
||||
if $data6_db != 14400 then # days
|
||||
|
|
|
@ -70,42 +70,42 @@ endi
|
|||
# row 1
|
||||
|
||||
if $data11 != 3 then
|
||||
print ======$data01
|
||||
print ======$data11
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 10 then
|
||||
print ======$data02
|
||||
print ======$data12
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 10 then
|
||||
print ======$data03
|
||||
print ======$data13
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != 1.100000000 then
|
||||
print ======$data04
|
||||
print ======$data14
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 0.000000000 then
|
||||
print ======$data05
|
||||
print ======$data15
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data16 != 10 then
|
||||
print ======$data05
|
||||
print ======$data15
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data17 != 1.100000000 then
|
||||
print ======$data05
|
||||
print ======$data17
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data18 != 5 then
|
||||
print ======$data05
|
||||
print ======$data18
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -145,17 +145,17 @@ if $data05 != 0.816496581 then
|
|||
endi
|
||||
|
||||
if $data06 != 3 then
|
||||
print ======$data05
|
||||
print ======$data06
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data07 != 1.100000000 then
|
||||
print ======$data05
|
||||
print ======$data07
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data08 != 13 then
|
||||
print ======$data05
|
||||
print ======$data08
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -187,4 +187,14 @@ if $data34 != 19 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791000000,1,1,1,1.1,23);
|
||||
sleep 300
|
||||
sql select * from streamt order by s desc;
|
||||
|
||||
# row 0
|
||||
if $data01 != 1 then
|
||||
print ======$data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -0,0 +1,477 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 50
|
||||
sql connect
|
||||
|
||||
print =============== create database
|
||||
sql create database test vgroups 1
|
||||
sql show databases
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data00 $data01 $data02
|
||||
|
||||
sql use test
|
||||
|
||||
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
|
||||
sql create stream streams1 trigger at_once into streamt1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
|
||||
|
||||
sql insert into t1 values(1648791213000,1,2,3,1.0,1);
|
||||
sql insert into t1 values(1648791213000,1,2,3,1.0,2);
|
||||
sql select * from streamt1 order by c desc;
|
||||
sleep 300
|
||||
|
||||
if $rows != 1 then
|
||||
print ======$rows
|
||||
return -1;
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791214000,1,2,3,1.0,3);
|
||||
sql select * from streamt1 order by c desc;
|
||||
sleep 300
|
||||
|
||||
if $rows != 1 then
|
||||
print ======$rows
|
||||
return -1;
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791213010,2,2,3,1.0,4);
|
||||
sql insert into t1 values(1648791213000,1,2,3,1.0,5);
|
||||
sql insert into t1 values(1648791214000,1,2,3,1.0,6);
|
||||
$loop_count = 0
|
||||
loop1:
|
||||
sql select * from streamt1 where c >=4 order by `_wstartts`;
|
||||
sleep 300
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != 3 then
|
||||
print ======$rows
|
||||
goto loop1
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 0
|
||||
if $data01 != 1 then
|
||||
print ======$data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 1 then
|
||||
print ======$data02
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 1 then
|
||||
print ======$data03
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != 1 then
|
||||
print ======$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data05 != 3 then
|
||||
print ======$data05
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data06 != 5 then
|
||||
print ======$data06
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 1
|
||||
if $data11 != 1 then
|
||||
print ======$data11
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
print ======$data12
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 2 then
|
||||
print ======$data13
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != 2 then
|
||||
print ======$data14
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 3 then
|
||||
print ======$data15
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data16 != 4 then
|
||||
print ======$data16
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 2
|
||||
if $data21 != 1 then
|
||||
print ======$data21
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
print ======$data22
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data23 != 1 then
|
||||
print ======$data23
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data24 != 1 then
|
||||
print ======$data24
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data25 != 3 then
|
||||
print ======$data25
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data26 != 6 then
|
||||
print ======$data26
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791213011,1,2,3,1.0,7);
|
||||
|
||||
loop2:
|
||||
$loop_count = 0
|
||||
sql select * from streamt1 where c in (5,4,7) order by `_wstartts`;
|
||||
sleep 300
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 2
|
||||
if $data21 != 2 then
|
||||
print ======$data21
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 2 then
|
||||
print ======$data22
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data23 != 2 then
|
||||
print ======$data23
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data24 != 1 then
|
||||
print ======$data24
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data25 != 3 then
|
||||
print ======$data25
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data26 != 7 then
|
||||
print ======$data26
|
||||
goto loop2
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791213011,1,2,3,1.0,8);
|
||||
|
||||
loop21:
|
||||
$loop_count = 0
|
||||
sql select * from streamt1 where c in (5,4,8) order by `_wstartts`;
|
||||
sleep 300
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data26 != 8 then
|
||||
print ======$data26
|
||||
goto loop21
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql insert into t1 values(1648791213020,1,2,3,1.0,9);
|
||||
sql insert into t1 values(1648791213020,3,2,3,1.0,10);
|
||||
sql insert into t1 values(1648791214000,1,2,3,1.0,11);
|
||||
sql insert into t1 values(1648791213011,10,20,10,10.0,12);
|
||||
|
||||
loop3:
|
||||
$loop_count = 0
|
||||
sql select * from streamt1 where c in (5,4,10,11,12) order by `_wstartts`;
|
||||
sleep 300
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 2
|
||||
if $data21 != 1 then
|
||||
print ======$data21
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
print ======$data22
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data23 != 10 then
|
||||
print ======$data23
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data24 != 10 then
|
||||
print ======$data24
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data25 != 10 then
|
||||
print ======$data25
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data26 != 12 then
|
||||
print ======$data26
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 3
|
||||
if $data31 != 1 then
|
||||
print ======$data31
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data32 != 1 then
|
||||
print ======$data32
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data33 != 3 then
|
||||
print ======$data33
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data34 != 3 then
|
||||
print ======$data34
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data35 != 3 then
|
||||
print ======$data35
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data36 != 10 then
|
||||
print ======$data36
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 4
|
||||
if $data41 != 1 then
|
||||
print ======$data41
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data42 != 1 then
|
||||
print ======$data42
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data43 != 1 then
|
||||
print ======$data43
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data44 != 1 then
|
||||
print ======$data44
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data45 != 3 then
|
||||
print ======$data45
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data46 != 11 then
|
||||
print ======$data46
|
||||
goto loop3
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql insert into t1 values(1648791213030,3,12,12,12.0,13);
|
||||
sql insert into t1 values(1648791214040,1,13,13,13.0,14);
|
||||
sql insert into t1 values(1648791213030,3,14,14,14.0,15) (1648791214020,15,15,15,15.0,16);
|
||||
|
||||
loop4:
|
||||
$loop_count = 0
|
||||
sql select * from streamt1 where c in (14,15,16) order by `_wstartts`;
|
||||
sleep 300
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != 3 then
|
||||
print ======$rows
|
||||
goto loop4
|
||||
return -1;
|
||||
endi
|
||||
|
||||
# row 0
|
||||
if $data01 != 2 then
|
||||
print ======$data01
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 2 then
|
||||
print ======$data02
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 6 then
|
||||
print ======$data03
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != 3 then
|
||||
print ======$data04
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data05 != 3 then
|
||||
print ======$data05
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data06 != 15 then
|
||||
print ======$data06
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 1
|
||||
if $data11 != 1 then
|
||||
print ======$data11
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
print ======$data12
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 15 then
|
||||
print ======$data13
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != 15 then
|
||||
print ======$data14
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 15 then
|
||||
print ======$data15
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data16 != 16 then
|
||||
print ======$data16
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
# row 2
|
||||
if $data21 != 1 then
|
||||
print ======$data21
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
print ======$data22
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data23 != 1 then
|
||||
print ======$data23
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data24 != 1 then
|
||||
print ======$data24
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data25 != 13 then
|
||||
print ======$data25
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data26 != 14 then
|
||||
print ======$data26
|
||||
goto loop4
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -102,4 +102,4 @@ if $data21 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,45 +1,45 @@
|
|||
run tsim/user/pass_alter.sim
|
||||
run tsim/user/basic1.sim
|
||||
run tsim/user/privilege2.sim
|
||||
run tsim/user/user_len.sim
|
||||
run tsim/user/privilege1.sim
|
||||
run tsim/user/pass_len.sim
|
||||
run tsim/table/basic1.sim
|
||||
run tsim/trans/lossdata1.sim
|
||||
run tsim/trans/create_db.sim
|
||||
run tsim/stable/alter_metrics.sim
|
||||
run tsim/stable/tag_modify.sim
|
||||
run tsim/stable/alter_comment.sim
|
||||
run tsim/stable/column_drop.sim
|
||||
run tsim/stable/column_modify.sim
|
||||
run tsim/stable/tag_rename.sim
|
||||
run tsim/stable/vnode3.sim
|
||||
run tsim/stable/metrics.sim
|
||||
run tsim/stable/alter_insert2.sim
|
||||
run tsim/stable/show.sim
|
||||
run tsim/stable/alter_import.sim
|
||||
run tsim/stable/tag_add.sim
|
||||
run tsim/stable/tag_drop.sim
|
||||
run tsim/stable/column_add.sim
|
||||
run tsim/stable/alter_count.sim
|
||||
run tsim/stable/values.sim
|
||||
run tsim/stable/dnode3.sim
|
||||
run tsim/stable/alter_insert1.sim
|
||||
run tsim/stable/refcount.sim
|
||||
run tsim/stable/disk.sim
|
||||
run tsim/db/basic1.sim
|
||||
run tsim/db/basic3.sim
|
||||
run tsim/db/basic7.sim
|
||||
run tsim/db/basic6.sim
|
||||
run tsim/db/create_all_options.sim
|
||||
run tsim/db/basic2.sim
|
||||
run tsim/db/error1.sim
|
||||
run tsim/db/taosdlog.sim
|
||||
run tsim/db/alter_option.sim
|
||||
run tsim/mnode/basic1.sim
|
||||
run tsim/mnode/basic3.sim
|
||||
run tsim/mnode/basic2.sim
|
||||
run tsim/parser/fourArithmetic-basic.sim
|
||||
#run tsim/user/pass_alter.sim
|
||||
#run tsim/user/basic1.sim
|
||||
#run tsim/user/privilege2.sim
|
||||
#run tsim/user/user_len.sim
|
||||
#run tsim/user/privilege1.sim
|
||||
##run tsim/user/pass_len.sim
|
||||
##run tsim/table/basic1.sim
|
||||
#run tsim/trans/lossdata1.sim
|
||||
#run tsim/trans/create_db.sim
|
||||
##run tsim/stable/alter_metrics.sim
|
||||
##run tsim/stable/tag_modify.sim
|
||||
##run tsim/stable/alter_comment.sim
|
||||
##run tsim/stable/column_drop.sim
|
||||
##run tsim/stable/column_modify.sim
|
||||
##run tsim/stable/tag_rename.sim
|
||||
##run tsim/stable/vnode3.sim
|
||||
##run tsim/stable/metrics.sim
|
||||
##run tsim/stable/alter_insert2.sim
|
||||
##run tsim/stable/show.sim
|
||||
##run tsim/stable/alter_import.sim
|
||||
##run tsim/stable/tag_add.sim
|
||||
##run tsim/stable/tag_drop.sim
|
||||
##run tsim/stable/column_add.sim
|
||||
##run tsim/stable/alter_count.sim
|
||||
##run tsim/stable/values.sim
|
||||
##run tsim/stable/dnode3.sim
|
||||
##run tsim/stable/alter_insert1.sim
|
||||
##run tsim/stable/refcount.sim
|
||||
##run tsim/stable/disk.sim
|
||||
#run tsim/db/basic1.sim
|
||||
#run tsim/db/basic3.sim
|
||||
##run tsim/db/basic7.sim
|
||||
#run tsim/db/basic6.sim
|
||||
#run tsim/db/create_all_options.sim
|
||||
#run tsim/db/basic2.sim
|
||||
#run tsim/db/error1.sim
|
||||
#run tsim/db/taosdlog.sim
|
||||
#run tsim/db/alter_option.sim
|
||||
#run tsim/mnode/basic1.sim
|
||||
#run tsim/mnode/basic3.sim
|
||||
#run tsim/mnode/basic2.sim
|
||||
#run tsim/parser/fourArithmetic-basic.sim
|
||||
run tsim/parser/groupby-basic.sim
|
||||
run tsim/snode/basic1.sim
|
||||
run tsim/query/time_process.sim
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import string
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def get_long_name(self, length, mode="mixed"):
|
||||
"""
|
||||
generate long name
|
||||
mode could be numbers/letters/letters_mixed/mixed
|
||||
"""
|
||||
if mode == "numbers":
|
||||
population = string.digits
|
||||
elif mode == "letters":
|
||||
population = string.ascii_letters.lower()
|
||||
elif mode == "letters_mixed":
|
||||
population = string.ascii_letters.upper() + string.ascii_letters.lower()
|
||||
else:
|
||||
population = string.ascii_letters.lower() + string.digits
|
||||
return "".join(random.choices(population, k=length))
|
||||
def alter_stable_column_check(self,dbname,stbname,tbname):
|
||||
tdSql.execute(f'create database if not exists {dbname}')
|
||||
tdSql.execute(f'use {dbname}')
|
||||
tdSql.execute(
|
||||
f'create stable {stbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \
|
||||
c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) ')
|
||||
tdSql.execute(f'create table {tbname} using {stbname} tags(1)')
|
||||
tdSql.execute(f'insert into {tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")')
|
||||
tdSql.execute(f'alter stable {stbname} add column c14 int')
|
||||
tdSql.query(f'select c14 from {stbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'alter stable {stbname} add column `c15` int')
|
||||
tdSql.query(f'select c15 from {stbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(17)
|
||||
tdSql.execute(f'alter stable {stbname} drop column c14')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(16)
|
||||
tdSql.execute(f'alter stable {stbname} drop column `c15`')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(15)
|
||||
tdSql.execute(f'alter stable {stbname} modify column c12 binary(30)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(12,2,30)
|
||||
tdSql.execute(f'alter stable {stbname} modify column `c12` binary(35)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(12,2,35)
|
||||
tdSql.error(f'alter stable {stbname} modify column `c12` binary(34)')
|
||||
tdSql.execute(f'alter stable {stbname} modify column c13 nchar(30)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(13,2,30)
|
||||
tdSql.error(f'alter stable {stbname} modify column c13 nchar(29)')
|
||||
tdSql.error(f'alter stable {stbname} rename column c1 c21')
|
||||
tdSql.error(f'alter stable {stbname} modify column c1 int')
|
||||
tdSql.error(f'alter stable {stbname} modify column c4 int')
|
||||
tdSql.error(f'alter stable {stbname} modify column c8 int')
|
||||
tdSql.error(f'alter stable {stbname} modify column c1 unsigned int')
|
||||
tdSql.error(f'alter stable {stbname} modify column c9 double')
|
||||
tdSql.error(f'alter stable {stbname} modify column c10 float')
|
||||
tdSql.error(f'alter stable {stbname} modify column c11 int')
|
||||
tdSql.execute(f'drop database {dbname}')
|
||||
|
||||
def alter_stable_tag_check(self,dbname,stbname,tbname):
|
||||
tdSql.execute(f'create database if not exists {dbname}')
|
||||
tdSql.execute(f'use {dbname}')
|
||||
tdSql.execute(
|
||||
f'create stable {stbname} (ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int, \
|
||||
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) ')
|
||||
tdSql.execute(f'create table {tbname} using {stbname} tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")')
|
||||
tdSql.execute(f'insert into {tbname} values(now,1)')
|
||||
|
||||
tdSql.execute(f'alter stable {stbname} add tag t14 int')
|
||||
tdSql.query(f'select t14 from {stbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'alter stable {stbname} add tag `t15` int')
|
||||
tdSql.query(f'select t14 from {stbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(18)
|
||||
tdSql.execute(f'alter stable {stbname} drop tag t14')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(17)
|
||||
tdSql.execute(f'alter stable {stbname} drop tag `t15`')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkRows(16)
|
||||
tdSql.execute(f'alter stable {stbname} modify tag t12 binary(30)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(14,2,30)
|
||||
tdSql.execute(f'alter stable {stbname} modify tag `t12` binary(35)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(14,2,35)
|
||||
tdSql.error(f'alter stable {stbname} modify tag `t12` binary(34)')
|
||||
tdSql.execute(f'alter stable {stbname} modify tag t13 nchar(30)')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(15,2,30)
|
||||
tdSql.error(f'alter stable {stbname} modify tag t13 nchar(29)')
|
||||
tdSql.execute(f'alter table {stbname} rename tag t1 t21')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(3,0,'t21')
|
||||
tdSql.execute(f'alter table {stbname} rename tag `t21` t1')
|
||||
tdSql.query(f'describe {stbname}')
|
||||
tdSql.checkData(3,0,'t1')
|
||||
|
||||
for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']:
|
||||
for j in [1,2,3]:
|
||||
tdSql.error(f'alter table {stbname} modify tag t{j} {i}')
|
||||
for i in ['int','unsigned int','float','binary(10)','nchar(10)']:
|
||||
tdSql.error(f'alter table {stbname} modify tag t8 {i}')
|
||||
tdSql.error(f'alter table {stbname} modify tag t4 int')
|
||||
tdSql.execute(f'drop database {dbname}')
|
||||
|
||||
def run(self):
|
||||
|
||||
dbname = self.get_long_name(length=10, mode="letters")
|
||||
stbname = self.get_long_name(length=5, mode="letters")
|
||||
tbname = self.get_long_name(length=5, mode="letters")
|
||||
self.alter_stable_column_check(dbname,stbname,tbname)
|
||||
self.alter_stable_tag_check(dbname,stbname,tbname)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,170 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import string
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def get_long_name(self, length, mode="mixed"):
|
||||
"""
|
||||
generate long name
|
||||
mode could be numbers/letters/letters_mixed/mixed
|
||||
"""
|
||||
if mode == "numbers":
|
||||
population = string.digits
|
||||
elif mode == "letters":
|
||||
population = string.ascii_letters.lower()
|
||||
elif mode == "letters_mixed":
|
||||
population = string.ascii_letters.upper() + string.ascii_letters.lower()
|
||||
else:
|
||||
population = string.ascii_letters.lower() + string.digits
|
||||
return "".join(random.choices(population, k=length))
|
||||
|
||||
def alter_tb_tag_check(self):
|
||||
tag_tinyint = random.randint(-127,129)
|
||||
tag_int = random.randint(-2147483648,2147483647)
|
||||
tag_smallint = random.randint(-32768,32768)
|
||||
tag_bigint = random.randint(-2147483648,2147483647)
|
||||
tag_untinyint = random.randint(0,256)
|
||||
tag_unsmallint = random.randint(0,65536)
|
||||
tag_unint = random.randint(0,4294967296)
|
||||
tag_unbigint = random.randint(0,2147483647)
|
||||
tag_binary = self.get_long_name(length=10, mode="letters")
|
||||
tag_nchar = self.get_long_name(length=10, mode="letters")
|
||||
dbname = self.get_long_name(length=10, mode="letters")
|
||||
tdSql.execute(f'create database if not exists {dbname}')
|
||||
stbname = self.get_long_name(length=3, mode="letters")
|
||||
tbname = self.get_long_name(length=3, mode="letters")
|
||||
tdLog.info('--------------------------child table tag check--------------------------------------')
|
||||
tdLog.info(f'-----------------create stable {stbname} and child table {tbname}-------------------')
|
||||
tdSql.execute(f'create stable if not exists {dbname}.{stbname} (col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int, \
|
||||
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))')
|
||||
tdSql.execute(f'create table if not exists {dbname}.{tbname} using {dbname}.{stbname} tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")')
|
||||
tdSql.execute(f'insert into {dbname}.{tbname} values(now, 1)')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag tag_ts = 1640966400000')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag `t1` = 11')
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.checkData(0,3,11)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t1 = {tag_tinyint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t2 = {tag_smallint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t3 = {tag_int}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t4 = {tag_bigint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t5 = {tag_untinyint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t6 = {tag_unsmallint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t7 = {tag_unint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t8 = {tag_unbigint}')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t11 = false')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"')
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
# bug TD-15899
|
||||
tdSql.checkData(0,2,'2022-01-01 00:00:00.000')
|
||||
tdSql.checkData(0,3,tag_tinyint)
|
||||
tdSql.checkData(0,4,tag_smallint)
|
||||
tdSql.checkData(0,5,tag_int)
|
||||
tdSql.checkData(0,6,tag_bigint)
|
||||
tdSql.checkData(0,7,tag_untinyint)
|
||||
tdSql.checkData(0,8,tag_unsmallint)
|
||||
tdSql.checkData(0,9,tag_unint)
|
||||
tdSql.checkData(0,10,tag_unbigint)
|
||||
|
||||
tdSql.checkData(0,13,False)
|
||||
tdSql.checkData(0,14,tag_binary)
|
||||
tdSql.checkData(0,15,tag_nchar)
|
||||
|
||||
# bug TD-16211 insert length more than setting binary and nchar
|
||||
# tag_binary = self.get_long_name(length=21, mode="letters")
|
||||
# tag_nchar = self.get_long_name(length=21, mode="letters")
|
||||
# tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"')
|
||||
# tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"')
|
||||
|
||||
# bug TD-16210 modify binary to nchar
|
||||
# tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)')
|
||||
tdSql.execute(f"drop database {dbname}")
|
||||
def alter_ntb_column_check(self):
|
||||
'''
|
||||
alter ntb column check
|
||||
'''
|
||||
dbname = self.get_long_name(length=10, mode="letters")
|
||||
tdSql.execute(f'create database if not exists {dbname}')
|
||||
tbname = self.get_long_name(length=3, mode="letters")
|
||||
tdLog.info('------------------normal table column check---------------------')
|
||||
tdLog.info(f'-----------------create normal table {tbname}-------------------')
|
||||
tdSql.execute(f'create table if not exists {dbname}.{tbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \
|
||||
c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20))')
|
||||
tdSql.execute(f'insert into {dbname}.{tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")')
|
||||
# bug TD-15757
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} add column c14 int')
|
||||
tdSql.query(f'select c14 from {dbname}.{tbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} add column `c15` int')
|
||||
tdSql.query(f'select c15 from {dbname}.{tbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkRows(16)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} drop column c14')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkRows(15)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} drop column `c15`')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkRows(14)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} modify column c12 binary(30)')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(12,2,30)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} modify column `c12` binary(35)')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(12,2,35)
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c12 binary(34)')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c12 nchar(10)')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c12 int')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} modify column c13 nchar(30)')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(13,2,30)
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} modify column `c13` nchar(35)')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(13,2,35)
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c13 nchar(34)')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c13 binary(10)')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} rename column c1 c21')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(1,0,'c21')
|
||||
tdSql.execute(f'alter table {dbname}.{tbname} rename column `c21` c1')
|
||||
tdSql.query(f'describe {dbname}.{tbname}')
|
||||
tdSql.checkData(1,0,'c1')
|
||||
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bigint')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 double')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c4 int')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column `c1` double')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c9 double')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c10 float')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool')
|
||||
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)')
|
||||
tdSql.execute(f'drop database {dbname}')
|
||||
def run(self):
|
||||
self.alter_tb_tag_check()
|
||||
self.alter_ntb_column_check()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -48,8 +48,8 @@ class TDTestCase:
|
|||
|
||||
# test duplicate key using the first one. elimate empty key
|
||||
tdSql.execute("CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90, \"\":32}')")
|
||||
#tdSql.query("select jtag from jsons1_8")
|
||||
#tdSql.checkData(0, 0, '{"tag1":null,"1tag$":2," ":90}')
|
||||
tdSql.query("select jtag from jsons1_8")
|
||||
tdSql.checkData(0, 0, '{" ":90,"1tag$":2,"tag1":null}')
|
||||
|
||||
# test empty json string, save as jtag is NULL
|
||||
tdSql.execute("insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '你就会', '2sdw')")
|
||||
|
@ -95,8 +95,8 @@ class TDTestCase:
|
|||
tdSql.error("ALTER TABLE jsons1 MODIFY TAG jtag nchar(128)")
|
||||
#
|
||||
tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'")
|
||||
# tdSql.query("select jtag from jsons1_1")
|
||||
# tdSql.checkData(0, 0, '{"tag1":"femail","tag2":35,"tag3":true}')
|
||||
tdSql.query("select jtag from jsons1_1")
|
||||
tdSql.checkData(0, 0, '{"tag1":"femail","tag2":35,"tag3":true}')
|
||||
tdSql.execute("ALTER TABLE jsons1 rename TAG jtag jtag_new")
|
||||
tdSql.execute("ALTER TABLE jsons1 rename TAG jtag_new jtag")
|
||||
|
||||
|
@ -106,69 +106,69 @@ class TDTestCase:
|
|||
#
|
||||
# print("============== STEP 3 ===== query table")
|
||||
# # test error syntax
|
||||
# tdSql.error("select * from jsons1 where jtag->tag1='beijing'")
|
||||
tdSql.error("select * from jsons1 where jtag->tag1='beijing'")
|
||||
#tdSql.error("select * from jsons1 where jtag->'location'")
|
||||
#tdSql.error("select * from jsons1 where jtag->''")
|
||||
#tdSql.error("select * from jsons1 where jtag->''=9")
|
||||
# tdSql.error("select -> from jsons1")
|
||||
# tdSql.error("select * from jsons1 where contains")
|
||||
# tdSql.error("select * from jsons1 where jtag->")
|
||||
# tdSql.error("select jtag->location from jsons1")
|
||||
# tdSql.error("select jtag contains location from jsons1")
|
||||
# tdSql.error("select * from jsons1 where jtag contains location")
|
||||
# tdSql.error("select * from jsons1 where jtag contains''")
|
||||
# tdSql.error("select * from jsons1 where jtag contains 'location'='beijing'")
|
||||
tdSql.error("select -> from jsons1")
|
||||
tdSql.error("select * from jsons1 where contains")
|
||||
tdSql.error("select * from jsons1 where jtag->")
|
||||
tdSql.error("select jtag->location from jsons1")
|
||||
tdSql.error("select jtag contains location from jsons1")
|
||||
tdSql.error("select * from jsons1 where jtag contains location")
|
||||
tdSql.error("select * from jsons1 where jtag contains''")
|
||||
tdSql.error("select * from jsons1 where jtag contains 'location'='beijing'")
|
||||
#
|
||||
# # test function error
|
||||
# tdSql.error("select avg(jtag->'tag1') from jsons1")
|
||||
# tdSql.error("select avg(jtag) from jsons1")
|
||||
# tdSql.error("select min(jtag->'tag1') from jsons1")
|
||||
# tdSql.error("select min(jtag) from jsons1")
|
||||
# tdSql.error("select ceil(jtag->'tag1') from jsons1")
|
||||
# tdSql.error("select ceil(jtag) from jsons1")
|
||||
tdSql.error("select avg(jtag->'tag1') from jsons1")
|
||||
tdSql.error("select avg(jtag) from jsons1")
|
||||
tdSql.error("select min(jtag->'tag1') from jsons1")
|
||||
tdSql.error("select min(jtag) from jsons1")
|
||||
tdSql.error("select ceil(jtag->'tag1') from jsons1")
|
||||
tdSql.error("select ceil(jtag) from jsons1")
|
||||
#
|
||||
# # test select normal column
|
||||
# tdSql.query("select dataint from jsons1")
|
||||
# tdSql.checkRows(9)
|
||||
# tdSql.checkData(1, 0, 1)
|
||||
tdSql.query("select dataint from jsons1")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
|
||||
# test select json tag
|
||||
# tdSql.query("select * from jsons1")
|
||||
# tdSql.checkRows(8)
|
||||
# tdSql.query("select jtag from jsons1")
|
||||
# tdSql.checkRows(7)
|
||||
tdSql.query("select * from jsons1")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag from jsons1")
|
||||
tdSql.checkRows(13)
|
||||
# tdSql.query("select jtag from jsons1 where jtag is null")
|
||||
# tdSql.checkRows(5)
|
||||
# tdSql.query("select jtag from jsons1 where jtag is not null")
|
||||
# tdSql.checkRows(8)
|
||||
|
||||
# test jtag is NULL
|
||||
#tdSql.query("select jtag from jsons1_9")
|
||||
#tdSql.checkData(0, 0, None)
|
||||
tdSql.query("select jtag from jsons1_9")
|
||||
tdSql.checkData(0, 0, None)
|
||||
|
||||
# # test select json tag->'key', value is string
|
||||
# tdSql.query("select jtag->'tag1' from jsons1_1")
|
||||
# tdSql.checkData(0, 0, '"femail"')
|
||||
# tdSql.query("select jtag->'tag2' from jsons1_6")
|
||||
# tdSql.checkData(0, 0, '""')
|
||||
# # test select json tag->'key', value is int
|
||||
# tdSql.query("select jtag->'tag2' from jsons1_1")
|
||||
# tdSql.checkData(0, 0, 35)
|
||||
# # test select json tag->'key', value is bool
|
||||
# tdSql.query("select jtag->'tag3' from jsons1_1")
|
||||
# tdSql.checkData(0, 0, "true")
|
||||
# # test select json tag->'key', value is null
|
||||
# tdSql.query("select jtag->'tag1' from jsons1_4")
|
||||
# tdSql.checkData(0, 0, "null")
|
||||
# # test select json tag->'key', value is double
|
||||
# tdSql.query("select jtag->'tag1' from jsons1_5")
|
||||
# tdSql.checkData(0, 0, "1.232000000")
|
||||
# # test select json tag->'key', key is not exist
|
||||
# tdSql.query("select jtag->'tag10' from jsons1_4")
|
||||
# tdSql.checkData(0, 0, None)
|
||||
tdSql.query("select jtag->'tag1' from jsons1_1")
|
||||
tdSql.checkData(0, 0, '"femail"')
|
||||
tdSql.query("select jtag->'tag2' from jsons1_6")
|
||||
tdSql.checkData(0, 0, '""')
|
||||
# test select json tag->'key', value is int
|
||||
tdSql.query("select jtag->'tag2' from jsons1_1")
|
||||
tdSql.checkData(0, 0, "35.000000000")
|
||||
# test select json tag->'key', value is bool
|
||||
tdSql.query("select jtag->'tag3' from jsons1_1")
|
||||
tdSql.checkData(0, 0, "true")
|
||||
# test select json tag->'key', value is null
|
||||
tdSql.query("select jtag->'tag1' from jsons1_4")
|
||||
tdSql.checkData(0, 0, "null")
|
||||
# test select json tag->'key', value is double
|
||||
tdSql.query("select jtag->'tag1' from jsons1_5")
|
||||
tdSql.checkData(0, 0, "1.232000000")
|
||||
# test select json tag->'key', key is not exist
|
||||
tdSql.query("select jtag->'tag10' from jsons1_4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
#
|
||||
# tdSql.query("select jtag->'tag1' from jsons1")
|
||||
# tdSql.checkRows(13)
|
||||
tdSql.query("select jtag->'tag1' from jsons1")
|
||||
tdSql.checkRows(13)
|
||||
# test header name
|
||||
res = tdSql.getColNameList("select jtag->'tag1' from jsons1")
|
||||
cname_list = []
|
||||
|
@ -176,7 +176,6 @@ class TDTestCase:
|
|||
tdSql.checkColNameList(res, cname_list)
|
||||
|
||||
|
||||
|
||||
# # test where with json tag
|
||||
# tdSql.error("select * from jsons1_1 where jtag is not null")
|
||||
# tdSql.error("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'")
|
||||
|
@ -313,8 +312,8 @@ class TDTestCase:
|
|||
# tdSql.checkRows(2)
|
||||
#
|
||||
# # test with tbname/normal column
|
||||
# tdSql.query("select * from jsons1 where tbname = 'jsons1_1'")
|
||||
# tdSql.checkRows(2)
|
||||
tdSql.query("select * from jsons1 where tbname = 'jsons1_1'")
|
||||
tdSql.checkRows(2)
|
||||
# tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'")
|
||||
# tdSql.checkRows(2)
|
||||
# tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3")
|
||||
|
@ -345,14 +344,14 @@ class TDTestCase:
|
|||
# tdSql.checkRows(1)
|
||||
#
|
||||
# # test distinct
|
||||
# tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')")
|
||||
# tdSql.query("select distinct jtag->'tag1' from jsons1")
|
||||
# tdSql.checkRows(8)
|
||||
# tdSql.query("select distinct jtag from jsons1")
|
||||
# tdSql.checkRows(9)
|
||||
tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')")
|
||||
tdSql.query("select distinct jtag->'tag1' from jsons1")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.query("select distinct jtag from jsons1")
|
||||
tdSql.checkRows(9)
|
||||
#
|
||||
# #test dumplicate key with normal colomn
|
||||
# tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")")
|
||||
tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")")
|
||||
# tdSql.query("select *,tbname,jtag from jsons1 where jtag->'datastr' match '是' and datastr match 'js'")
|
||||
# tdSql.checkRows(1)
|
||||
# tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'")
|
||||
|
@ -377,67 +376,71 @@ class TDTestCase:
|
|||
# cname_list.append("a.jtag->'tag3'")
|
||||
# tdSql.checkColNameList(res, cname_list)
|
||||
#
|
||||
# # test group by & order by json tag
|
||||
# tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'")
|
||||
# tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag")
|
||||
# tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
|
||||
# tdSql.checkRows(8)
|
||||
# tdSql.checkData(1, 0, 2)
|
||||
# tdSql.checkData(1, 1, '"femail"')
|
||||
# tdSql.checkData(2, 0, 1)
|
||||
# tdSql.checkData(2, 1, 11)
|
||||
# tdSql.checkData(5, 0, 1)
|
||||
# tdSql.checkData(5, 1, "false")
|
||||
# test group by & order by json tag
|
||||
tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'")
|
||||
tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag")
|
||||
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkData(0, 0, 2)
|
||||
tdSql.checkData(0, 1, '"femail"')
|
||||
tdSql.checkData(1, 0, 2)
|
||||
tdSql.checkData(1, 1, '"收到货"')
|
||||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(2, 1, "11.000000000")
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(5, 1, "false")
|
||||
# tdSql.checkData(6, 0, 1)
|
||||
# tdSql.checkData(6, 1, "null")
|
||||
# tdSql.checkData(7, 0, 2)
|
||||
# tdSql.checkData(7, 1, None)
|
||||
tdSql.checkData(7, 0, 2)
|
||||
tdSql.checkData(7, 1, None)
|
||||
|
||||
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkData(0, 0, 2)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(2, 1, "false")
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(5, 1, "11.000000000")
|
||||
tdSql.checkData(7, 0, 2)
|
||||
tdSql.checkData(7, 1, '"femail"')
|
||||
#
|
||||
# tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc")
|
||||
# tdSql.checkRows(8)
|
||||
# tdSql.checkData(0, 0, 2)
|
||||
# test stddev with group by json tag
|
||||
tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkData(0, 0, 10)
|
||||
# tdSql.checkData(0, 1, None)
|
||||
# tdSql.checkData(2, 0, 1)
|
||||
# tdSql.checkData(2, 1, "false")
|
||||
# tdSql.checkData(5, 0, 1)
|
||||
# tdSql.checkData(5, 1, 11)
|
||||
# tdSql.checkData(6, 0, 2)
|
||||
# tdSql.checkData(6, 1, '"femail"')
|
||||
#
|
||||
# # test stddev with group by json tag
|
||||
# tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1'")
|
||||
# tdSql.checkData(0, 0, 10)
|
||||
# tdSql.checkData(0, 1, None)
|
||||
# tdSql.checkData(1, 0, 0)
|
||||
# tdSql.checkData(1, 1, "null")
|
||||
# tdSql.checkData(6, 0, 11)
|
||||
# tdSql.checkData(6, 1, '"femail"')
|
||||
#
|
||||
# res = tdSql.getColNameList("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'")
|
||||
# cname_list = []
|
||||
# cname_list.append("stddev(dataint)")
|
||||
# cname_list.append("jsons1.jtag->'tag1'")
|
||||
# tdSql.checkColNameList(res, cname_list)
|
||||
#
|
||||
# # test top/bottom with group by json tag
|
||||
# tdSql.query("select top(dataint,100) from jsons1 group by jtag->'tag1'")
|
||||
# tdSql.checkRows(11)
|
||||
# tdSql.checkData(0, 1, 4)
|
||||
# tdSql.checkData(1, 1, 24)
|
||||
# tdSql.checkData(1, 2, None)
|
||||
# tdSql.checkData(8, 1, 1)
|
||||
# tdSql.checkData(8, 2, '"femail"')
|
||||
#
|
||||
# # test having
|
||||
tdSql.checkData(4, 0, 0)
|
||||
tdSql.checkData(4, 1, "5.000000000")
|
||||
tdSql.checkData(7, 0, 11)
|
||||
tdSql.checkData(7, 1, '"femail"')
|
||||
|
||||
res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'")
|
||||
cname_list = []
|
||||
cname_list.append("stddev(dataint)")
|
||||
cname_list.append("jsons1.jtag->'tag1'")
|
||||
tdSql.checkColNameList(res, cname_list)
|
||||
|
||||
# test top/bottom with group by json tag
|
||||
tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(3, 0, 3)
|
||||
tdSql.checkData(3, 1, "false")
|
||||
# tdSql.checkData(3, 0, 24)
|
||||
# tdSql.checkData(3, 1, None)
|
||||
tdSql.checkData(10, 0, 23)
|
||||
tdSql.checkData(10, 1, '"femail"')
|
||||
|
||||
# test having
|
||||
# tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0")
|
||||
# tdSql.checkRows(2)
|
||||
#
|
||||
# # subquery with json tag
|
||||
# tdSql.query("select * from (select jtag, dataint from jsons1)")
|
||||
# tdSql.checkRows(11)
|
||||
# tdSql.checkData(1, 1, 1)
|
||||
# tdSql.checkData(2, 0, '{"tag1":5,"tag2":"beijing"}')
|
||||
#
|
||||
|
||||
# subquery with json tag
|
||||
tdSql.query("select * from (select jtag, dataint from jsons1)")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(1, 1, 1)
|
||||
tdSql.checkData(2, 0, '{"tag1":5,"tag2":"beijing"}')
|
||||
|
||||
# tdSql.query("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)")
|
||||
# tdSql.checkRows(11)
|
||||
# tdSql.checkData(1, 0, '"femail"')
|
||||
|
@ -514,17 +517,17 @@ class TDTestCase:
|
|||
# tdSql.checkRows(3)
|
||||
#
|
||||
# #test TD-12077
|
||||
# tdSql.execute("insert into jsons1_16 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":-2.111}') values(1591062628000, 2, NULL, '你就会', 'dws')")
|
||||
# tdSql.query("select jtag->'tag3' from jsons1_16")
|
||||
# tdSql.checkData(0, 0, '-2.111000000')
|
||||
#
|
||||
tdSql.execute("insert into jsons1_16 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":-2.111}') values(1591062628000, 2, NULL, '你就会', 'dws')")
|
||||
tdSql.query("select jtag->'tag3' from jsons1_16")
|
||||
tdSql.checkData(0, 0, '-2.111000000')
|
||||
|
||||
# # test TD-12452
|
||||
# tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag=NULL")
|
||||
# tdSql.query("select jtag from jsons1_1")
|
||||
# tdSql.checkData(0, 0, None)
|
||||
# tdSql.execute("CREATE TABLE if not exists jsons1_20 using jsons1 tags(NULL)")
|
||||
# tdSql.query("select jtag from jsons1_20")
|
||||
# tdSql.checkData(0, 0, None)
|
||||
tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag=NULL")
|
||||
tdSql.query("select jtag from jsons1_1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.execute("CREATE TABLE if not exists jsons1_20 using jsons1 tags(NULL)")
|
||||
tdSql.query("select jtag from jsons1_20")
|
||||
tdSql.checkData(0, 0, None)
|
||||
# tdSql.execute("insert into jsons1_21 using jsons1 tags(NULL) values(1591061628000, 11, false, '你就会','')")
|
||||
# tdSql.query("select jtag from jsons1_21")
|
||||
# tdSql.checkData(0, 0, None)
|
||||
|
@ -536,24 +539,24 @@ class TDTestCase:
|
|||
tdSql.checkData(5, 2, 4095)
|
||||
#
|
||||
# #test TD-13918
|
||||
# tdSql.execute("drop table if exists jsons_13918_1")
|
||||
# tdSql.execute("drop table if exists jsons_13918_2")
|
||||
# tdSql.execute("drop table if exists jsons_13918_3")
|
||||
# tdSql.execute("drop table if exists jsons_13918_4")
|
||||
# tdSql.execute("drop table if exists jsons_stb")
|
||||
# tdSql.execute("create table jsons_stb (ts timestamp, dataInt int) tags (jtag json)")
|
||||
# tdSql.error("create table jsons_13918_1 using jsons_stb tags ('nullx')")
|
||||
# tdSql.error("create table jsons_13918_2 using jsons_stb tags (nullx)")
|
||||
# tdSql.error("insert into jsons_13918_3 using jsons_stb tags('NULLx') values(1591061628001, 11)")
|
||||
# tdSql.error("insert into jsons_13918_4 using jsons_stb tags(NULLx) values(1591061628002, 11)")
|
||||
# tdSql.execute("create table jsons_13918_1 using jsons_stb tags ('null')")
|
||||
# tdSql.execute("create table jsons_13918_2 using jsons_stb tags (null)")
|
||||
# tdSql.execute("insert into jsons_13918_1 values(1591061628003, 11)")
|
||||
# tdSql.execute("insert into jsons_13918_2 values(1591061628004, 11)")
|
||||
# tdSql.execute("insert into jsons_13918_3 using jsons_stb tags('NULL') values(1591061628005, 11)")
|
||||
# tdSql.execute("insert into jsons_13918_4 using jsons_stb tags(\"NULL\") values(1591061628006, 11)")
|
||||
# tdSql.query("select * from jsons_stb")
|
||||
# tdSql.checkRows(4)
|
||||
tdSql.execute("drop table if exists jsons_13918_1")
|
||||
tdSql.execute("drop table if exists jsons_13918_2")
|
||||
tdSql.execute("drop table if exists jsons_13918_3")
|
||||
tdSql.execute("drop table if exists jsons_13918_4")
|
||||
tdSql.execute("drop table if exists jsons_stb")
|
||||
tdSql.execute("create table jsons_stb (ts timestamp, dataInt int) tags (jtag json)")
|
||||
tdSql.error("create table jsons_13918_1 using jsons_stb tags ('nullx')")
|
||||
tdSql.error("create table jsons_13918_2 using jsons_stb tags (nullx)")
|
||||
tdSql.error("insert into jsons_13918_3 using jsons_stb tags('NULLx') values(1591061628001, 11)")
|
||||
tdSql.error("insert into jsons_13918_4 using jsons_stb tags(NULLx) values(1591061628002, 11)")
|
||||
tdSql.execute("create table jsons_13918_1 using jsons_stb tags ('null')")
|
||||
tdSql.execute("create table jsons_13918_2 using jsons_stb tags (null)")
|
||||
tdSql.execute("insert into jsons_13918_1 values(1591061628003, 11)")
|
||||
tdSql.execute("insert into jsons_13918_2 values(1591061628004, 11)")
|
||||
tdSql.execute("insert into jsons_13918_3 using jsons_stb tags('NULL') values(1591061628005, 11)")
|
||||
tdSql.execute("insert into jsons_13918_4 using jsons_stb tags(\"NULL\") values(1591061628006, 11)")
|
||||
tdSql.query("select * from jsons_stb")
|
||||
tdSql.checkRows(4)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -19,7 +19,8 @@ python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
|
|||
python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
|
||||
python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
|
||||
#python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py
|
||||
|
||||
python3 ./test.py -f 1-insert/alter_stable.py
|
||||
python3 ./test.py -f 1-insert/alter_table.py
|
||||
python3 ./test.py -f 2-query/between.py
|
||||
python3 ./test.py -f 2-query/distinct.py
|
||||
python3 ./test.py -f 2-query/varchar.py
|
||||
|
@ -79,6 +80,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
|||
# TD-15983 subquery output duplicate name column.
|
||||
# Please Xiangyang Guo modify the following script
|
||||
# python3 ./test.py -f 2-query/nestedQuery_str.py
|
||||
|
||||
python3 ./test.py -f 2-query/avg.py
|
||||
python3 ./test.py -f 2-query/elapsed.py
|
||||
python3 ./test.py -f 2-query/csum.py
|
||||
|
|
Loading…
Reference in New Issue