Merge branch '3.0' into enh/cast_function
This commit is contained in:
commit
b1f16fca4e
105
Jenkinsfile2
105
Jenkinsfile2
|
@ -43,10 +43,8 @@ def pre_test(){
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WK}
|
cd ${WK}
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
|
@ -82,6 +80,7 @@ def pre_test(){
|
||||||
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
|
git remote prune origin
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log -5
|
git log -5
|
||||||
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
|
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
|
||||||
|
@ -107,6 +106,7 @@ def pre_test(){
|
||||||
git log -5
|
git log -5
|
||||||
echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log
|
echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
|
git remote prune origin
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log -5
|
git log -5
|
||||||
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
|
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
|
@ -137,53 +137,51 @@ def pre_test_win(){
|
||||||
set
|
set
|
||||||
date /t
|
date /t
|
||||||
time /t
|
time /t
|
||||||
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug || exit 0
|
rd /s /Q %WIN_INTERNAL_ROOT%\\debug || exit 0
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git checkout master
|
git checkout master
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git checkout master
|
git checkout master
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '2.0') {
|
} else if(env.CHANGE_TARGET == '2.0') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '3.0') {
|
} else if(env.CHANGE_TARGET == '3.0') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git checkout develop
|
git checkout develop
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git checkout develop
|
git checkout develop
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
@ -191,36 +189,38 @@ def pre_test_win(){
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git pull
|
git pull
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
|
git remote prune origin
|
||||||
git pull
|
git pull
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
'''
|
'''
|
||||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git pull
|
git pull
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
|
git remote prune origin
|
||||||
git pull
|
git pull
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,27 +230,27 @@ def pre_test_win(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
git branch
|
git branch
|
||||||
git log -5
|
git log -5
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git branch
|
git branch
|
||||||
git log -5
|
git log -5
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd %WIN_COMMUNITY_ROOT%
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
cd %WIN_CONNECTOR_ROOT%
|
||||||
git branch
|
git branch
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git pull
|
git pull
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
cd %WIN_CONNECTOR_ROOT%
|
||||||
git log -5
|
git log -5
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ def pre_test_build_win() {
|
||||||
bat '''
|
bat '''
|
||||||
echo "building ..."
|
echo "building ..."
|
||||||
time /t
|
time /t
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd %WIN_INTERNAL_ROOT%
|
||||||
mkdir debug
|
mkdir debug
|
||||||
cd debug
|
cd debug
|
||||||
time /t
|
time /t
|
||||||
|
@ -273,9 +273,9 @@ def pre_test_build_win() {
|
||||||
time /t
|
time /t
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
cd %WIN_CONNECTOR_ROOT%
|
||||||
python -m pip install .
|
python -m pip install .
|
||||||
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
||||||
'''
|
'''
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ def run_win_ctest() {
|
||||||
bat '''
|
bat '''
|
||||||
echo "windows ctest ..."
|
echo "windows ctest ..."
|
||||||
time /t
|
time /t
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
cd %WIN_INTERNAL_ROOT%\\debug
|
||||||
ctest -j 1 || exit 7
|
ctest -j 1 || exit 7
|
||||||
time /t
|
time /t
|
||||||
'''
|
'''
|
||||||
|
@ -292,12 +292,12 @@ def run_win_test() {
|
||||||
echo "LINUX NODE: ${linux_node_ip} - ${linux_node_pass}"
|
echo "LINUX NODE: ${linux_node_ip} - ${linux_node_pass}"
|
||||||
bat '''
|
bat '''
|
||||||
echo "windows test ..."
|
echo "windows test ..."
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
|
cd %WIN_CONNECTOR_ROOT%
|
||||||
python -m pip install .
|
python -m pip install .
|
||||||
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
|
||||||
ls -l C:\\Windows\\System32\\taos.dll
|
ls -l C:\\Windows\\System32\\taos.dll
|
||||||
time /t
|
time /t
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community\\tests\\system-test
|
cd %WIN_SYSTEM_TEST_ROOT%
|
||||||
echo "node: ''' + linux_node_ip + ''':''' + linux_node_pass + '''"
|
echo "node: ''' + linux_node_ip + ''':''' + linux_node_pass + '''"
|
||||||
echo "testing ..."
|
echo "testing ..."
|
||||||
test-all.bat "{\\\"host\\\":\\\"''' + linux_node_ip + '''\\\",\\\"port\\\":22,\\\"user\\\":\\\"root\\\",\\\"password\\\":\\\"''' + linux_node_pass + '''\\\",\\\"path\\\":\\\"/var/lib/jenkins/workspace/TDinternal\\\"}"
|
test-all.bat "{\\\"host\\\":\\\"''' + linux_node_ip + '''\\\",\\\"port\\\":22,\\\"user\\\":\\\"root\\\",\\\"password\\\":\\\"''' + linux_node_pass + '''\\\",\\\"path\\\":\\\"/var/lib/jenkins/workspace/TDinternal\\\"}"
|
||||||
|
@ -319,6 +319,12 @@ pipeline {
|
||||||
parallel {
|
parallel {
|
||||||
stage('windows test') {
|
stage('windows test') {
|
||||||
agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "}
|
agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "}
|
||||||
|
environment{
|
||||||
|
WIN_INTERNAL_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal"
|
||||||
|
WIN_COMMUNITY_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community"
|
||||||
|
WIN_SYSTEM_TEST_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community\\tests\\system-test"
|
||||||
|
WIN_CONNECTOR_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\taos-connector-python"
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
timeout(time: 55, unit: 'MINUTES'){
|
timeout(time: 55, unit: 'MINUTES'){
|
||||||
|
@ -357,7 +363,7 @@ pipeline {
|
||||||
echo "${linux_node_ip}:${linux_node_pass}"
|
echo "${linux_node_ip}:${linux_node_pass}"
|
||||||
}
|
}
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
timeout(time: 40, unit: 'MINUTES'){
|
timeout(time: 120, unit: 'MINUTES'){
|
||||||
pre_test()
|
pre_test()
|
||||||
script {
|
script {
|
||||||
sh '''
|
sh '''
|
||||||
|
@ -368,11 +374,36 @@ pipeline {
|
||||||
rm -f /tmp/cases.task
|
rm -f /tmp/cases.task
|
||||||
./collect_cases.sh -e
|
./collect_cases.sh -e
|
||||||
'''
|
'''
|
||||||
|
def extra_param = ""
|
||||||
|
def log_server_file = "/home/log_server.json"
|
||||||
|
def timeout_cmd = ""
|
||||||
|
if (fileExists(log_server_file)) {
|
||||||
|
def log_server_enabled = sh (
|
||||||
|
script: 'jq .enabled ' + log_server_file,
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
def timeout_param = sh (
|
||||||
|
script: 'jq .timeout ' + log_server_file,
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
if (timeout_param != "null" && timeout_param != "0") {
|
||||||
|
timeout_cmd = "timeout " + timeout_param
|
||||||
|
}
|
||||||
|
if (log_server_enabled == "1") {
|
||||||
|
def log_server = sh (
|
||||||
|
script: 'jq .server ' + log_server_file + ' | sed "s/\\\"//g"',
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
if (log_server != "null" && log_server != "") {
|
||||||
|
extra_param = "-w " + log_server
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}/tests/parallel_test
|
cd ${WKC}/tests/parallel_test
|
||||||
export DEFAULT_RETRY_TIME=2
|
export DEFAULT_RETRY_TIME=2
|
||||||
date
|
date
|
||||||
timeout 2100 time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480
|
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + '''
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ int32_t init_env() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -68,6 +68,14 @@ int32_t init_env() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists tu3 using st1 tags(3)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table tu3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +98,9 @@ int32_t create_stream() {
|
||||||
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
||||||
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||||
pRes = taos_query(
|
pRes = taos_query(pConn,
|
||||||
pConn,
|
"create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 "
|
||||||
"create stream stream1 trigger window_close watermark 10s into outstb as select _wstartts, sum(k) from st1 "
|
"partition by tbname interval(10s) ");
|
||||||
"interval(10s) ");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -128,7 +128,6 @@ typedef struct setConfRet {
|
||||||
|
|
||||||
DLL_EXPORT void taos_cleanup(void);
|
DLL_EXPORT void taos_cleanup(void);
|
||||||
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
|
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
|
||||||
DLL_EXPORT setConfRet taos_set_config(const char *config);
|
|
||||||
DLL_EXPORT int taos_init(void);
|
DLL_EXPORT int taos_init(void);
|
||||||
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
||||||
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
||||||
|
|
|
@ -50,8 +50,10 @@ typedef enum EStreamType {
|
||||||
} EStreamType;
|
} EStreamType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
SArray* pGroupList;
|
||||||
SArray* pTableList;
|
SArray* pTableList;
|
||||||
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
||||||
|
bool needSortTableByGroupId;
|
||||||
void* pTagCond;
|
void* pTagCond;
|
||||||
void* pTagIndexCond;
|
void* pTagIndexCond;
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
|
|
|
@ -151,6 +151,7 @@ void taosCfgDynamicOptions(const char *option, const char *value);
|
||||||
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary);
|
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary);
|
||||||
|
|
||||||
struct SConfig *taosGetCfg();
|
struct SConfig *taosGetCfg();
|
||||||
|
int32_t taosSetCfg(SConfig *pCfg, char* name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,8 @@ typedef struct {
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
int8_t connType;
|
int8_t connType;
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
char sVersion[128];
|
char sVer[TSDB_VERSION_LEN];
|
||||||
|
char sDetailVer[128];
|
||||||
} SConnectRsp;
|
} SConnectRsp;
|
||||||
|
|
||||||
int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
|
int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
|
||||||
|
@ -836,6 +837,20 @@ typedef struct {
|
||||||
int32_t tSerializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
|
int32_t tSerializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
|
||||||
int32_t tDeserializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
|
int32_t tDeserializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t useless; // useless
|
||||||
|
} SServerVerReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
|
||||||
|
int32_t tDeserializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char ver[TSDB_VERSION_LEN];
|
||||||
|
} SServerVerRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
|
||||||
|
int32_t tDeserializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
|
||||||
|
|
||||||
|
|
||||||
typedef struct SQueryNodeAddr {
|
typedef struct SQueryNodeAddr {
|
||||||
int32_t nodeId; // vgId or qnodeId
|
int32_t nodeId; // vgId or qnodeId
|
||||||
|
@ -1229,6 +1244,21 @@ typedef struct {
|
||||||
int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
|
int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
|
||||||
int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
|
int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_CONFIG_OPTION_LEN + 1];
|
||||||
|
char value[TSDB_CONFIG_VALUE_LEN + 1];
|
||||||
|
} SVariablesInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SArray *variables; //SArray<SVariablesInfo>
|
||||||
|
} SShowVariablesRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
|
||||||
|
int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
|
||||||
|
|
||||||
|
void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sql: show tables like '%a_%'
|
* sql: show tables like '%a_%'
|
||||||
* payload is the query condition, e.g., '%a_%'
|
* payload is the query condition, e.g., '%a_%'
|
||||||
|
@ -2463,6 +2493,8 @@ typedef struct {
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
|
int64_t maxDelay;
|
||||||
|
int64_t watermark;
|
||||||
int32_t exprLen; // strlen + 1
|
int32_t exprLen; // strlen + 1
|
||||||
int32_t tagsFilterLen; // strlen + 1
|
int32_t tagsFilterLen; // strlen + 1
|
||||||
int32_t sqlLen; // strlen + 1
|
int32_t sqlLen; // strlen + 1
|
||||||
|
|
|
@ -163,6 +163,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_REDISTRIBUTE_VGROUP, "redistribute-vgroup", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_REDISTRIBUTE_VGROUP, "redistribute-vgroup", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_SPLIT_VGROUP, "split-vgroup", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_SPLIT_VGROUP, "split-vgroup", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_SERVER_VERSION, "server-version", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||||
|
|
|
@ -57,6 +57,8 @@ void tNameAssign(SName* dst, const SName* src);
|
||||||
|
|
||||||
int32_t tNameSetDbName(SName* dst, int32_t acctId, const char* dbName, size_t nameLen);
|
int32_t tNameSetDbName(SName* dst, int32_t acctId, const char* dbName, size_t nameLen);
|
||||||
|
|
||||||
|
int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen);
|
||||||
|
|
||||||
int32_t tNameFromString(SName* dst, const char* str, uint32_t type);
|
int32_t tNameFromString(SName* dst, const char* str, uint32_t type);
|
||||||
|
|
||||||
int32_t tNameSetAcctId(SName* dst, int32_t acctId);
|
int32_t tNameSetAcctId(SName* dst, int32_t acctId);
|
||||||
|
|
|
@ -158,107 +158,109 @@
|
||||||
#define TK_CLUSTER 140
|
#define TK_CLUSTER 140
|
||||||
#define TK_TRANSACTIONS 141
|
#define TK_TRANSACTIONS 141
|
||||||
#define TK_DISTRIBUTED 142
|
#define TK_DISTRIBUTED 142
|
||||||
#define TK_LIKE 143
|
#define TK_CONSUMERS 143
|
||||||
#define TK_INDEX 144
|
#define TK_SUBSCRIPTIONS 144
|
||||||
#define TK_FUNCTION 145
|
#define TK_LIKE 145
|
||||||
#define TK_INTERVAL 146
|
#define TK_INDEX 146
|
||||||
#define TK_TOPIC 147
|
#define TK_FUNCTION 147
|
||||||
#define TK_AS 148
|
#define TK_INTERVAL 148
|
||||||
#define TK_WITH 149
|
#define TK_TOPIC 149
|
||||||
#define TK_META 150
|
#define TK_AS 150
|
||||||
#define TK_CONSUMER 151
|
#define TK_WITH 151
|
||||||
#define TK_GROUP 152
|
#define TK_META 152
|
||||||
#define TK_DESC 153
|
#define TK_CONSUMER 153
|
||||||
#define TK_DESCRIBE 154
|
#define TK_GROUP 154
|
||||||
#define TK_RESET 155
|
#define TK_DESC 155
|
||||||
#define TK_QUERY 156
|
#define TK_DESCRIBE 156
|
||||||
#define TK_CACHE 157
|
#define TK_RESET 157
|
||||||
#define TK_EXPLAIN 158
|
#define TK_QUERY 158
|
||||||
#define TK_ANALYZE 159
|
#define TK_CACHE 159
|
||||||
#define TK_VERBOSE 160
|
#define TK_EXPLAIN 160
|
||||||
#define TK_NK_BOOL 161
|
#define TK_ANALYZE 161
|
||||||
#define TK_RATIO 162
|
#define TK_VERBOSE 162
|
||||||
#define TK_NK_FLOAT 163
|
#define TK_NK_BOOL 163
|
||||||
#define TK_COMPACT 164
|
#define TK_RATIO 164
|
||||||
#define TK_VNODES 165
|
#define TK_NK_FLOAT 165
|
||||||
#define TK_IN 166
|
#define TK_COMPACT 166
|
||||||
#define TK_OUTPUTTYPE 167
|
#define TK_VNODES 167
|
||||||
#define TK_AGGREGATE 168
|
#define TK_IN 168
|
||||||
#define TK_BUFSIZE 169
|
#define TK_OUTPUTTYPE 169
|
||||||
#define TK_STREAM 170
|
#define TK_AGGREGATE 170
|
||||||
#define TK_INTO 171
|
#define TK_BUFSIZE 171
|
||||||
#define TK_TRIGGER 172
|
#define TK_STREAM 172
|
||||||
#define TK_AT_ONCE 173
|
#define TK_INTO 173
|
||||||
#define TK_WINDOW_CLOSE 174
|
#define TK_TRIGGER 174
|
||||||
#define TK_KILL 175
|
#define TK_AT_ONCE 175
|
||||||
#define TK_CONNECTION 176
|
#define TK_WINDOW_CLOSE 176
|
||||||
#define TK_TRANSACTION 177
|
#define TK_KILL 177
|
||||||
#define TK_BALANCE 178
|
#define TK_CONNECTION 178
|
||||||
#define TK_VGROUP 179
|
#define TK_TRANSACTION 179
|
||||||
#define TK_MERGE 180
|
#define TK_BALANCE 180
|
||||||
#define TK_REDISTRIBUTE 181
|
#define TK_VGROUP 181
|
||||||
#define TK_SPLIT 182
|
#define TK_MERGE 182
|
||||||
#define TK_SYNCDB 183
|
#define TK_REDISTRIBUTE 183
|
||||||
#define TK_DELETE 184
|
#define TK_SPLIT 184
|
||||||
#define TK_NULL 185
|
#define TK_SYNCDB 185
|
||||||
#define TK_NK_QUESTION 186
|
#define TK_DELETE 186
|
||||||
#define TK_NK_ARROW 187
|
#define TK_NULL 187
|
||||||
#define TK_ROWTS 188
|
#define TK_NK_QUESTION 188
|
||||||
#define TK_TBNAME 189
|
#define TK_NK_ARROW 189
|
||||||
#define TK_QSTARTTS 190
|
#define TK_ROWTS 190
|
||||||
#define TK_QENDTS 191
|
#define TK_TBNAME 191
|
||||||
#define TK_WSTARTTS 192
|
#define TK_QSTARTTS 192
|
||||||
#define TK_WENDTS 193
|
#define TK_QENDTS 193
|
||||||
#define TK_WDURATION 194
|
#define TK_WSTARTTS 194
|
||||||
#define TK_CAST 195
|
#define TK_WENDTS 195
|
||||||
#define TK_NOW 196
|
#define TK_WDURATION 196
|
||||||
#define TK_TODAY 197
|
#define TK_CAST 197
|
||||||
#define TK_TIMEZONE 198
|
#define TK_NOW 198
|
||||||
#define TK_COUNT 199
|
#define TK_TODAY 199
|
||||||
#define TK_LAST_ROW 200
|
#define TK_TIMEZONE 200
|
||||||
#define TK_BETWEEN 201
|
#define TK_COUNT 201
|
||||||
#define TK_IS 202
|
#define TK_LAST_ROW 202
|
||||||
#define TK_NK_LT 203
|
#define TK_BETWEEN 203
|
||||||
#define TK_NK_GT 204
|
#define TK_IS 204
|
||||||
#define TK_NK_LE 205
|
#define TK_NK_LT 205
|
||||||
#define TK_NK_GE 206
|
#define TK_NK_GT 206
|
||||||
#define TK_NK_NE 207
|
#define TK_NK_LE 207
|
||||||
#define TK_MATCH 208
|
#define TK_NK_GE 208
|
||||||
#define TK_NMATCH 209
|
#define TK_NK_NE 209
|
||||||
#define TK_CONTAINS 210
|
#define TK_MATCH 210
|
||||||
#define TK_JOIN 211
|
#define TK_NMATCH 211
|
||||||
#define TK_INNER 212
|
#define TK_CONTAINS 212
|
||||||
#define TK_SELECT 213
|
#define TK_JOIN 213
|
||||||
#define TK_DISTINCT 214
|
#define TK_INNER 214
|
||||||
#define TK_WHERE 215
|
#define TK_SELECT 215
|
||||||
#define TK_PARTITION 216
|
#define TK_DISTINCT 216
|
||||||
#define TK_BY 217
|
#define TK_WHERE 217
|
||||||
#define TK_SESSION 218
|
#define TK_PARTITION 218
|
||||||
#define TK_STATE_WINDOW 219
|
#define TK_BY 219
|
||||||
#define TK_SLIDING 220
|
#define TK_SESSION 220
|
||||||
#define TK_FILL 221
|
#define TK_STATE_WINDOW 221
|
||||||
#define TK_VALUE 222
|
#define TK_SLIDING 222
|
||||||
#define TK_NONE 223
|
#define TK_FILL 223
|
||||||
#define TK_PREV 224
|
#define TK_VALUE 224
|
||||||
#define TK_LINEAR 225
|
#define TK_NONE 225
|
||||||
#define TK_NEXT 226
|
#define TK_PREV 226
|
||||||
#define TK_HAVING 227
|
#define TK_LINEAR 227
|
||||||
#define TK_RANGE 228
|
#define TK_NEXT 228
|
||||||
#define TK_EVERY 229
|
#define TK_HAVING 229
|
||||||
#define TK_ORDER 230
|
#define TK_RANGE 230
|
||||||
#define TK_SLIMIT 231
|
#define TK_EVERY 231
|
||||||
#define TK_SOFFSET 232
|
#define TK_ORDER 232
|
||||||
#define TK_LIMIT 233
|
#define TK_SLIMIT 233
|
||||||
#define TK_OFFSET 234
|
#define TK_SOFFSET 234
|
||||||
#define TK_ASC 235
|
#define TK_LIMIT 235
|
||||||
#define TK_NULLS 236
|
#define TK_OFFSET 236
|
||||||
#define TK_ID 237
|
#define TK_ASC 237
|
||||||
#define TK_NK_BITNOT 238
|
#define TK_NULLS 238
|
||||||
#define TK_INSERT 239
|
#define TK_ID 239
|
||||||
#define TK_VALUES 240
|
#define TK_NK_BITNOT 240
|
||||||
#define TK_IMPORT 241
|
#define TK_INSERT 241
|
||||||
#define TK_NK_SEMI 242
|
#define TK_VALUES 242
|
||||||
#define TK_FILE 243
|
#define TK_IMPORT 243
|
||||||
|
#define TK_NK_SEMI 244
|
||||||
|
#define TK_FILE 245
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -71,6 +71,7 @@ typedef struct SCatalogReq {
|
||||||
SArray* pTableCfg; // element is SNAME
|
SArray* pTableCfg; // element is SNAME
|
||||||
bool qNodeRequired; // valid qnode
|
bool qNodeRequired; // valid qnode
|
||||||
bool dNodeRequired; // valid dnode
|
bool dNodeRequired; // valid dnode
|
||||||
|
bool svrVerRequired;
|
||||||
bool forceUpdate;
|
bool forceUpdate;
|
||||||
} SCatalogReq;
|
} SCatalogReq;
|
||||||
|
|
||||||
|
@ -80,18 +81,19 @@ typedef struct SMetaRes {
|
||||||
} SMetaRes;
|
} SMetaRes;
|
||||||
|
|
||||||
typedef struct SMetaData {
|
typedef struct SMetaData {
|
||||||
SArray* pDbVgroup; // pRes = SArray<SVgroupInfo>*
|
SArray* pDbVgroup; // pRes = SArray<SVgroupInfo>*
|
||||||
SArray* pDbCfg; // pRes = SDbCfgInfo*
|
SArray* pDbCfg; // pRes = SDbCfgInfo*
|
||||||
SArray* pDbInfo; // pRes = SDbInfo*
|
SArray* pDbInfo; // pRes = SDbInfo*
|
||||||
SArray* pTableMeta; // pRes = STableMeta*
|
SArray* pTableMeta; // pRes = STableMeta*
|
||||||
SArray* pTableHash; // pRes = SVgroupInfo*
|
SArray* pTableHash; // pRes = SVgroupInfo*
|
||||||
SArray* pTableIndex; // pRes = SArray<STableIndexInfo>*
|
SArray* pTableIndex; // pRes = SArray<STableIndexInfo>*
|
||||||
SArray* pUdfList; // pRes = SFuncInfo*
|
SArray* pUdfList; // pRes = SFuncInfo*
|
||||||
SArray* pIndex; // pRes = SIndexInfo*
|
SArray* pIndex; // pRes = SIndexInfo*
|
||||||
SArray* pUser; // pRes = bool*
|
SArray* pUser; // pRes = bool*
|
||||||
SArray* pQnodeList; // pRes = SArray<SQueryNodeLoad>*
|
SArray* pQnodeList; // pRes = SArray<SQueryNodeLoad>*
|
||||||
SArray* pTableCfg; // pRes = STableCfg*
|
SArray* pTableCfg; // pRes = STableCfg*
|
||||||
SArray* pDnodeList; // pRes = SArray<SEpSet>*
|
SArray* pDnodeList; // pRes = SArray<SEpSet>*
|
||||||
|
SMetaRes* pSvrVer; // pRes = char*
|
||||||
} SMetaData;
|
} SMetaData;
|
||||||
|
|
||||||
typedef struct SCatalogCfg {
|
typedef struct SCatalogCfg {
|
||||||
|
@ -268,7 +270,7 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, c
|
||||||
*/
|
*/
|
||||||
int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp);
|
int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp);
|
||||||
|
|
||||||
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId);
|
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId);
|
||||||
|
|
||||||
int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList);
|
int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList);
|
||||||
|
|
||||||
|
@ -298,6 +300,8 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||||
|
|
||||||
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet);
|
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet);
|
||||||
|
|
||||||
|
int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion);
|
||||||
|
|
||||||
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate);
|
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate);
|
||||||
|
|
||||||
int32_t catalogClearCache(void);
|
int32_t catalogClearCache(void);
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SReadHandle {
|
||||||
void* vnode;
|
void* vnode;
|
||||||
void* mnd;
|
void* mnd;
|
||||||
SMsgCb* pMsgCb;
|
SMsgCb* pMsgCb;
|
||||||
int8_t initTsdbReader;
|
// int8_t initTsdbReader;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -123,6 +123,8 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_SELECT_VALUE,
|
FUNCTION_TYPE_SELECT_VALUE,
|
||||||
FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function
|
FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function
|
||||||
FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function
|
FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function
|
||||||
|
FUNCTION_TYPE_TO_COLUMN,
|
||||||
|
FUNCTION_TYPE_GROUP_KEY,
|
||||||
|
|
||||||
// distributed splitting functions
|
// distributed splitting functions
|
||||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||||
|
|
|
@ -28,19 +28,18 @@ extern "C" {
|
||||||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||||
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
#define SHOW_CREATE_DB_RESULT_COLS 2
|
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||||
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||||
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
#define SHOW_CREATE_TB_RESULT_COLS 2
|
#define SHOW_CREATE_TB_RESULT_COLS 2
|
||||||
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||||
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
|
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
|
|
||||||
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||||
|
|
||||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||||
|
@ -234,10 +233,10 @@ typedef struct SShowCreateDatabaseStmt {
|
||||||
} SShowCreateDatabaseStmt;
|
} SShowCreateDatabaseStmt;
|
||||||
|
|
||||||
typedef struct SShowCreateTableStmt {
|
typedef struct SShowCreateTableStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
void* pCfg; // STableCfg
|
void* pCfg; // STableCfg
|
||||||
} SShowCreateTableStmt;
|
} SShowCreateTableStmt;
|
||||||
|
|
||||||
typedef struct SShowTableDistributedStmt {
|
typedef struct SShowTableDistributedStmt {
|
||||||
|
@ -259,6 +258,7 @@ typedef struct SIndexOptions {
|
||||||
SNode* pInterval;
|
SNode* pInterval;
|
||||||
SNode* pOffset;
|
SNode* pOffset;
|
||||||
SNode* pSliding;
|
SNode* pSliding;
|
||||||
|
SNode* pStreamOptions;
|
||||||
} SIndexOptions;
|
} SIndexOptions;
|
||||||
|
|
||||||
typedef struct SCreateIndexStmt {
|
typedef struct SCreateIndexStmt {
|
||||||
|
|
|
@ -188,6 +188,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||||
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||||
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
||||||
|
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||||
QUERY_NODE_KILL_QUERY_STMT,
|
QUERY_NODE_KILL_QUERY_STMT,
|
||||||
QUERY_NODE_KILL_TRANSACTION_STMT,
|
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||||
|
@ -284,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||||
|
SListCell* nodesListGetCell(SNodeList* pList, int32_t index);
|
||||||
void nodesDestroyList(SNodeList* pList);
|
void nodesDestroyList(SNodeList* pList);
|
||||||
// Only clear the linked list structure, without releasing the elements inside
|
// Only clear the linked list structure, without releasing the elements inside
|
||||||
void nodesClearList(SNodeList* pList);
|
void nodesClearList(SNodeList* pList);
|
||||||
|
|
|
@ -32,6 +32,8 @@ typedef struct SLogicNode {
|
||||||
struct SLogicNode* pParent;
|
struct SLogicNode* pParent;
|
||||||
int32_t optimizedFlag;
|
int32_t optimizedFlag;
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
|
SNode* pLimit;
|
||||||
|
SNode* pSlimit;
|
||||||
} SLogicNode;
|
} SLogicNode;
|
||||||
|
|
||||||
typedef enum EScanType {
|
typedef enum EScanType {
|
||||||
|
@ -92,10 +94,6 @@ typedef struct SProjectLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
int64_t limit;
|
|
||||||
int64_t offset;
|
|
||||||
int64_t slimit;
|
|
||||||
int64_t soffset;
|
|
||||||
} SProjectLogicNode;
|
} SProjectLogicNode;
|
||||||
|
|
||||||
typedef struct SIndefRowsFuncLogicNode {
|
typedef struct SIndefRowsFuncLogicNode {
|
||||||
|
@ -248,6 +246,8 @@ typedef struct SPhysiNode {
|
||||||
SNode* pConditions;
|
SNode* pConditions;
|
||||||
SNodeList* pChildren;
|
SNodeList* pChildren;
|
||||||
struct SPhysiNode* pParent;
|
struct SPhysiNode* pParent;
|
||||||
|
SNode* pLimit;
|
||||||
|
SNode* pSlimit;
|
||||||
} SPhysiNode;
|
} SPhysiNode;
|
||||||
|
|
||||||
typedef struct SScanPhysiNode {
|
typedef struct SScanPhysiNode {
|
||||||
|
@ -297,10 +297,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
|
||||||
typedef struct SProjectPhysiNode {
|
typedef struct SProjectPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
int64_t limit;
|
|
||||||
int64_t offset;
|
|
||||||
int64_t slimit;
|
|
||||||
int64_t soffset;
|
|
||||||
} SProjectPhysiNode;
|
} SProjectPhysiNode;
|
||||||
|
|
||||||
typedef struct SIndefRowsFuncPhysiNode {
|
typedef struct SIndefRowsFuncPhysiNode {
|
||||||
|
@ -378,7 +374,7 @@ typedef struct SIntervalPhysiNode {
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
} SIntervalPhysiNode;
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
|
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
|
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
|
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
|
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
|
||||||
|
@ -462,6 +458,7 @@ typedef struct SSubplan {
|
||||||
int32_t msgType; // message type for subplan, used to denote the send message type to vnode.
|
int32_t msgType; // message type for subplan, used to denote the send message type to vnode.
|
||||||
int32_t level; // the execution level of current subplan, starting from 0 in a top-down manner.
|
int32_t level; // the execution level of current subplan, starting from 0 in a top-down manner.
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
char user[TSDB_USER_LEN];
|
||||||
SQueryNodeAddr execNode; // for the scan/modify subplan, the optional execution node
|
SQueryNodeAddr execNode; // for the scan/modify subplan, the optional execution node
|
||||||
SQueryNodeStat execNodeStat; // only for scan subplan
|
SQueryNodeStat execNodeStat; // only for scan subplan
|
||||||
SNodeList* pChildren; // the datasource subplan,from which to fetch the result
|
SNodeList* pChildren; // the datasource subplan,from which to fetch the result
|
||||||
|
|
|
@ -51,6 +51,8 @@ typedef struct SParseContext {
|
||||||
bool isSuperUser;
|
bool isSuperUser;
|
||||||
bool async;
|
bool async;
|
||||||
int8_t schemalessType;
|
int8_t schemalessType;
|
||||||
|
const char* svrVer;
|
||||||
|
bool nodeOffline;
|
||||||
} SParseContext;
|
} SParseContext;
|
||||||
|
|
||||||
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
||||||
|
|
|
@ -24,18 +24,19 @@ extern "C" {
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
typedef struct SPlanContext {
|
typedef struct SPlanContext {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
SEpSet mgmtEpSet;
|
SEpSet mgmtEpSet;
|
||||||
SNode* pAstRoot;
|
SNode* pAstRoot;
|
||||||
bool topicQuery;
|
bool topicQuery;
|
||||||
bool streamQuery;
|
bool streamQuery;
|
||||||
bool rSmaQuery;
|
bool rSmaQuery;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
|
const char* pUser;
|
||||||
} SPlanContext;
|
} SPlanContext;
|
||||||
|
|
||||||
// Create the physical plan for the query, according to the AST.
|
// Create the physical plan for the query, according to the AST.
|
||||||
|
|
|
@ -266,19 +266,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
#define qDebug(...) \
|
#define qDebug(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qTrace(...) \
|
#define qTrace(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_TRACE) { \
|
if (qDebugFlag & DEBUG_TRACE) { \
|
||||||
taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qDebugL(...) \
|
#define qDebugL(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ const char* syncGetMyRoleStr(int64_t rid);
|
||||||
SyncTerm syncGetMyTerm(int64_t rid);
|
SyncTerm syncGetMyTerm(int64_t rid);
|
||||||
SyncGroupId syncGetVgId(int64_t rid);
|
SyncGroupId syncGetVgId(int64_t rid);
|
||||||
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
|
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||||
bool syncEnvIsStart();
|
bool syncEnvIsStart();
|
||||||
const char* syncStr(ESyncState state);
|
const char* syncStr(ESyncState state);
|
||||||
|
|
|
@ -33,7 +33,8 @@ typedef enum {
|
||||||
CFG_STYPE_ENV_CMD,
|
CFG_STYPE_ENV_CMD,
|
||||||
CFG_STYPE_APOLLO_URL,
|
CFG_STYPE_APOLLO_URL,
|
||||||
CFG_STYPE_ARG_LIST,
|
CFG_STYPE_ARG_LIST,
|
||||||
CFG_STYPE_TAOS_OPTIONS
|
CFG_STYPE_TAOS_OPTIONS,
|
||||||
|
CFG_STYPE_ALTER_CMD,
|
||||||
} ECfgSrcType;
|
} ECfgSrcType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -54,6 +54,11 @@ enum {
|
||||||
RES_TYPE__TMQ_META,
|
RES_TYPE__TMQ_META,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SHOW_VARIABLES_RESULT_COLS 2
|
||||||
|
#define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
#define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
|
|
||||||
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
||||||
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
||||||
#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META)
|
#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META)
|
||||||
|
@ -104,6 +109,8 @@ typedef struct SHeartBeatInfo {
|
||||||
struct SAppInstInfo {
|
struct SAppInstInfo {
|
||||||
int64_t numOfConns;
|
int64_t numOfConns;
|
||||||
SCorEpSet mgmtEp;
|
SCorEpSet mgmtEp;
|
||||||
|
int32_t totalDnodes;
|
||||||
|
int32_t onlineDnodes;
|
||||||
TdThreadMutex qnodeMutex;
|
TdThreadMutex qnodeMutex;
|
||||||
SArray* pQnodeList;
|
SArray* pQnodeList;
|
||||||
SAppClusterSummary summary;
|
SAppClusterSummary summary;
|
||||||
|
@ -127,7 +134,8 @@ typedef struct STscObj {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_PASSWORD_LEN];
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
char ver[128];
|
char sVer[TSDB_VERSION_LEN];
|
||||||
|
char sDetailVer[128];
|
||||||
int8_t connType;
|
int8_t connType;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
uint32_t connId;
|
uint32_t connId;
|
||||||
|
@ -215,6 +223,7 @@ typedef struct SRequestObj {
|
||||||
SQueryExecMetric metric;
|
SQueryExecMetric metric;
|
||||||
SRequestSendRecvBody body;
|
SRequestSendRecvBody body;
|
||||||
bool stableQuery;
|
bool stableQuery;
|
||||||
|
bool validateOnly;
|
||||||
|
|
||||||
bool killed;
|
bool killed;
|
||||||
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
|
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
|
||||||
|
@ -235,7 +244,12 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveT
|
||||||
bool freeAfterUse);
|
bool freeAfterUse);
|
||||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||||
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
|
||||||
|
void syncCatalogFn(SMetaData* pResult, void* param, int32_t code);
|
||||||
|
|
||||||
|
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly);
|
||||||
|
TAOS_RES *taosQueryImpl(TAOS *taos, const char *sql, bool validateOnly);
|
||||||
|
void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, bool validateOnly);
|
||||||
|
|
||||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||||
SMqRspObj* msg = (SMqRspObj*)res;
|
SMqRspObj* msg = (SMqRspObj*)res;
|
||||||
|
@ -301,7 +315,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||||
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType);
|
uint16_t port, int connType);
|
||||||
|
|
||||||
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly);
|
||||||
|
|
||||||
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,9 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
|
|
||||||
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet);
|
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pTscObj->pAppInfo->totalDnodes = pRsp->query->totalDnodes;
|
||||||
|
pTscObj->pAppInfo->onlineDnodes = pRsp->query->onlineDnodes;
|
||||||
pTscObj->connId = pRsp->query->connId;
|
pTscObj->connId = pRsp->query->connId;
|
||||||
|
|
||||||
if (pRsp->query->killRid) {
|
if (pRsp->query->killRid) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ static STscObj* taosConnectImpl(const char* user, const char* auth, const char*
|
||||||
SAppInstInfo* pAppInfo, int connType);
|
SAppInstInfo* pAppInfo, int connType);
|
||||||
|
|
||||||
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType) {
|
uint16_t port, int connType) {
|
||||||
if (taos_init() != TSDB_CODE_SUCCESS) {
|
if (taos_init() != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,9 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
||||||
.pStmtCb = pStmtCb,
|
.pStmtCb = pStmtCb,
|
||||||
.pUser = pTscObj->user,
|
.pUser = pTscObj->user,
|
||||||
.schemalessType = pTscObj->schemalessType,
|
.schemalessType = pTscObj->schemalessType,
|
||||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER))};
|
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||||
|
.svrVer = pTscObj->sVer,
|
||||||
|
.nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes)};
|
||||||
|
|
||||||
cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||||
int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog);
|
int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog);
|
||||||
|
@ -237,6 +239,10 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscOb
|
||||||
|
|
||||||
void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SRetrieveTableRsp* pRsp = NULL;
|
SRetrieveTableRsp* pRsp = NULL;
|
||||||
|
if (pRequest->validateOnly) {
|
||||||
|
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||||
|
@ -261,6 +267,11 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
|
if (pRequest->validateOnly) {
|
||||||
|
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// drop table if exists not_exists_table
|
// drop table if exists not_exists_table
|
||||||
if (NULL == pQuery->pCmdMsg) {
|
if (NULL == pQuery->pCmdMsg) {
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||||
|
@ -276,8 +287,11 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg);
|
int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg);
|
||||||
return TSDB_CODE_SUCCESS;
|
if (code) {
|
||||||
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int compareQueryNodeLoad(const void* elem1, const void* elem2) {
|
int compareQueryNodeLoad(const void* elem1, const void* elem2) {
|
||||||
|
@ -313,7 +327,7 @@ bool qnodeRequired(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SAppInstInfo* pInfo = pRequest->pTscObj->pAppInfo;
|
SAppInstInfo* pInfo = pRequest->pTscObj->pAppInfo;
|
||||||
bool required = false;
|
bool required = false;
|
||||||
|
|
||||||
taosThreadMutexLock(&pInfo->qnodeMutex);
|
taosThreadMutexLock(&pInfo->qnodeMutex);
|
||||||
required = (NULL == pInfo->pQnodeList);
|
required = (NULL == pInfo->pQnodeList);
|
||||||
|
@ -362,7 +376,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
||||||
.pAstRoot = pQuery->pRoot,
|
.pAstRoot = pQuery->pRoot,
|
||||||
.showRewrite = pQuery->showRewrite,
|
.showRewrite = pQuery->showRewrite,
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE};
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
|
.pUser = pRequest->pTscObj->user};
|
||||||
|
|
||||||
return qCreateQueryPlan(&cxt, pPlan, pNodeList);
|
return qCreateQueryPlan(&cxt, pPlan, pNodeList);
|
||||||
}
|
}
|
||||||
|
@ -419,7 +434,7 @@ int32_t buildVnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < vgNum; ++j) {
|
for (int32_t j = 0; j < vgNum; ++j) {
|
||||||
SVgroupInfo* pInfo = taosArrayGet(pVg, j);
|
SVgroupInfo* pInfo = taosArrayGet(pVg, j);
|
||||||
SQueryNodeLoad load = {0};
|
SQueryNodeLoad load = {0};
|
||||||
load.addr.nodeId = pInfo->vgId;
|
load.addr.nodeId = pInfo->vgId;
|
||||||
load.addr.epSet = pInfo->epSet;
|
load.addr.epSet = pInfo->epSet;
|
||||||
|
@ -481,8 +496,7 @@ _return:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList, SMetaData* pResultMeta) {
|
||||||
int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList, SMetaData *pResultMeta) {
|
|
||||||
SArray* pDbVgList = NULL;
|
SArray* pDbVgList = NULL;
|
||||||
SArray* pQnodeList = NULL;
|
SArray* pQnodeList = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -547,7 +561,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
|
||||||
case QUERY_POLICY_VNODE: {
|
case QUERY_POLICY_VNODE: {
|
||||||
int32_t dbNum = taosArrayGetSize(pRequest->dbList);
|
int32_t dbNum = taosArrayGetSize(pRequest->dbList);
|
||||||
if (dbNum > 0) {
|
if (dbNum > 0) {
|
||||||
SCatalog* pCtg = NULL;
|
SCatalog* pCtg = NULL;
|
||||||
SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo;
|
SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo;
|
||||||
code = catalogGetHandle(pInst->clusterId, &pCtg);
|
code = catalogGetHandle(pInst->clusterId, &pCtg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -557,7 +571,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
|
||||||
pDbVgList = taosArrayInit(dbNum, POINTER_BYTES);
|
pDbVgList = taosArrayInit(dbNum, POINTER_BYTES);
|
||||||
SArray* pVgList = NULL;
|
SArray* pVgList = NULL;
|
||||||
for (int32_t i = 0; i < dbNum; ++i) {
|
for (int32_t i = 0; i < dbNum; ++i) {
|
||||||
char* dbFName = taosArrayGet(pRequest->dbList, i);
|
char* dbFName = taosArrayGet(pRequest->dbList, i);
|
||||||
SRequestConnInfo conn = {.pTrans = pInst->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pInst->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
|
@ -595,7 +609,6 @@ _return:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||||
tsem_init(&schdRspSem, 0, 0);
|
tsem_init(&schdRspSem, 0, 0);
|
||||||
|
|
||||||
|
@ -819,8 +832,8 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code,
|
||||||
pRequest->self, code, tstrerror(code), pRequest->requestId);
|
tstrerror(code), pRequest->requestId);
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||||
|
@ -851,15 +864,19 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
||||||
|
|
||||||
switch (pQuery->execMode) {
|
switch (pQuery->execMode) {
|
||||||
case QUERY_EXEC_MODE_LOCAL:
|
case QUERY_EXEC_MODE_LOCAL:
|
||||||
code = execLocalCmd(pRequest, pQuery);
|
if (!pRequest->validateOnly) {
|
||||||
|
code = execLocalCmd(pRequest, pQuery);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QUERY_EXEC_MODE_RPC:
|
case QUERY_EXEC_MODE_RPC:
|
||||||
code = execDdlQuery(pRequest, pQuery);
|
if (!pRequest->validateOnly) {
|
||||||
|
code = execDdlQuery(pRequest, pQuery);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QUERY_EXEC_MODE_SCHEDULE: {
|
case QUERY_EXEC_MODE_SCHEDULE: {
|
||||||
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
||||||
code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pMnodeList);
|
code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pMnodeList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||||
SArray* pNodeList = NULL;
|
SArray* pNodeList = NULL;
|
||||||
buildSyncExecNodeList(pRequest, &pNodeList, pMnodeList);
|
buildSyncExecNodeList(pRequest, &pNodeList, pMnodeList);
|
||||||
|
|
||||||
|
@ -894,7 +911,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) {
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
SQuery* pQuery = NULL;
|
SQuery* pQuery = NULL;
|
||||||
|
|
||||||
|
@ -904,6 +921,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pRequest->validateOnly = validateOnly;
|
||||||
|
|
||||||
code = parseSql(pRequest, false, &pQuery, NULL);
|
code = parseSql(pRequest, false, &pQuery, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
@ -915,7 +934,7 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
||||||
return launchQueryImpl(pRequest, pQuery, false, NULL);
|
return launchQueryImpl(pRequest, pQuery, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultMeta) {
|
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
switch (pQuery->execMode) {
|
switch (pQuery->execMode) {
|
||||||
|
@ -936,7 +955,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
|
||||||
.pAstRoot = pQuery->pRoot,
|
.pAstRoot = pQuery->pRoot,
|
||||||
.showRewrite = pQuery->showRewrite,
|
.showRewrite = pQuery->showRewrite,
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE};
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
|
.pUser = pRequest->pTscObj->user};
|
||||||
|
|
||||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||||
code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pMnodeList);
|
code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pMnodeList);
|
||||||
|
@ -945,7 +965,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||||
SArray* pNodeList = NULL;
|
SArray* pNodeList = NULL;
|
||||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||||
|
|
||||||
|
@ -962,7 +982,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
|
||||||
code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||||
taosArrayDestroy(pNodeList);
|
taosArrayDestroy(pNodeList);
|
||||||
} else {
|
} else {
|
||||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
tscDebug("0x%" PRIx64 " plan not executed, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
}
|
}
|
||||||
|
@ -1045,14 +1065,14 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) {
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
int32_t retryNum = 0;
|
int32_t retryNum = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
pRequest = launchQuery(pTscObj, sql, sqlLen);
|
pRequest = launchQuery(pTscObj, sql, sqlLen, validateOnly);
|
||||||
if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) {
|
if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1480,10 +1500,10 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows){
|
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
|
|
||||||
int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t));
|
int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t));
|
||||||
int32_t* colLength = (int32_t*)(p + len);
|
int32_t* colLength = (int32_t*)(p + len);
|
||||||
len += sizeof(int32_t) * numOfCols;
|
len += sizeof(int32_t) * numOfCols;
|
||||||
|
|
||||||
|
@ -1493,7 +1513,7 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
|
||||||
|
|
||||||
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
||||||
int32_t* offset = (int32_t*)pStart;
|
int32_t* offset = (int32_t*)pStart;
|
||||||
int32_t lenTmp = numOfRows * sizeof(int32_t);
|
int32_t lenTmp = numOfRows * sizeof(int32_t);
|
||||||
len += lenTmp;
|
len += lenTmp;
|
||||||
pStart += lenTmp;
|
pStart += lenTmp;
|
||||||
|
|
||||||
|
@ -1518,7 +1538,6 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||||
int32_t lenTmp = numOfRows * sizeof(int32_t);
|
int32_t lenTmp = numOfRows * sizeof(int32_t);
|
||||||
|
@ -1542,13 +1561,13 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!needConvert) return TSDB_CODE_SUCCESS;
|
if (!needConvert) return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
||||||
|
|
||||||
pResultInfo->convertJson = taosMemoryCalloc(1, dataLen);
|
pResultInfo->convertJson = taosMemoryCalloc(1, dataLen);
|
||||||
if(pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
char* p1 = pResultInfo->convertJson;
|
char* p1 = pResultInfo->convertJson;
|
||||||
|
|
||||||
int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t));
|
int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t));
|
||||||
|
@ -1617,7 +1636,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset1[j]= len;
|
offset1[j] = len;
|
||||||
memcpy(pStart1 + len, dst, varDataTLen(dst));
|
memcpy(pStart1 + len, dst, varDataTLen(dst));
|
||||||
len += varDataTLen(dst);
|
len += varDataTLen(dst);
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1654,6 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
pStart += len;
|
pStart += len;
|
||||||
pStart1 += len;
|
pStart1 += len;
|
||||||
memcpy(pStart1, pStart, colLen);
|
memcpy(pStart1, pStart, colLen);
|
||||||
|
|
||||||
}
|
}
|
||||||
pStart += colLen;
|
pStart += colLen;
|
||||||
pStart1 += colLen1;
|
pStart1 += colLen1;
|
||||||
|
@ -1703,7 +1721,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
pStart += colLength[i];
|
pStart += colLength[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(convertUcs4){
|
if (convertUcs4) {
|
||||||
code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength);
|
code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1819,3 +1837,246 @@ _OVER:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str,
|
||||||
|
int32_t acctId, char* db) {
|
||||||
|
SName name;
|
||||||
|
|
||||||
|
if (len1 <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* dbName = db;
|
||||||
|
const char* tbName = NULL;
|
||||||
|
int32_t dbLen = 0;
|
||||||
|
int32_t tbLen = 0;
|
||||||
|
if (len2 > 0) {
|
||||||
|
dbName = str + pos1;
|
||||||
|
dbLen = len1;
|
||||||
|
tbName = str + pos2;
|
||||||
|
tbLen = len2;
|
||||||
|
} else {
|
||||||
|
dbLen = strlen(db);
|
||||||
|
tbName = str + pos1;
|
||||||
|
tbLen = len1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tNameSetDbName(&name, acctId, dbName, dbLen)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tNameAddTbName(&name, tbName, tbLen)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pList, &name);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq) {
|
||||||
|
*pReq = taosArrayInit(10, sizeof(SName));
|
||||||
|
if (NULL == *pReq) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inEscape = false;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
int32_t vIdx = 0;
|
||||||
|
int32_t vPos[2];
|
||||||
|
int32_t vLen[2];
|
||||||
|
|
||||||
|
memset(vPos, -1, sizeof(vPos));
|
||||||
|
memset(vLen, 0, sizeof(vLen));
|
||||||
|
|
||||||
|
for (int32_t i = 0;; ++i) {
|
||||||
|
if (0 == *(tbList + i)) {
|
||||||
|
if (vPos[vIdx] >= 0 && vLen[vIdx] <= 0) {
|
||||||
|
vLen[vIdx] = i - vPos[vIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||||
|
if (code) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('`' == *(tbList + i)) {
|
||||||
|
inEscape = !inEscape;
|
||||||
|
if (!inEscape) {
|
||||||
|
if (vPos[vIdx] >= 0) {
|
||||||
|
vLen[vIdx] = i - vPos[vIdx];
|
||||||
|
} else {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inEscape) {
|
||||||
|
if (vPos[vIdx] < 0) {
|
||||||
|
vPos[vIdx] = i;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('.' == *(tbList + i)) {
|
||||||
|
if (vPos[vIdx] < 0) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
if (vLen[vIdx] <= 0) {
|
||||||
|
vLen[vIdx] = i - vPos[vIdx];
|
||||||
|
}
|
||||||
|
vIdx++;
|
||||||
|
if (vIdx >= 2) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (',' == *(tbList + i)) {
|
||||||
|
if (vPos[vIdx] < 0) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
if (vLen[vIdx] <= 0) {
|
||||||
|
vLen[vIdx] = i - vPos[vIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||||
|
if (code) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(vPos, -1, sizeof(vPos));
|
||||||
|
memset(vLen, 0, sizeof(vLen));
|
||||||
|
vIdx = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (' ' == *(tbList + i) || '\r' == *(tbList + i) || '\t' == *(tbList + i) || '\n' == *(tbList + i)) {
|
||||||
|
if (vPos[vIdx] >= 0 && vLen[vIdx] <= 0) {
|
||||||
|
vLen[vIdx] = i - vPos[vIdx];
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (('a' <= *(tbList + i) && 'z' >= *(tbList + i)) || ('A' <= *(tbList + i) && 'Z' >= *(tbList + i)) ||
|
||||||
|
('0' <= *(tbList + i) && '9' >= *(tbList + i))) {
|
||||||
|
if (vLen[vIdx] > 0) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
if (vPos[vIdx] < 0) {
|
||||||
|
vPos[vIdx] = i;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
|
||||||
|
taosArrayDestroy(*pReq);
|
||||||
|
*pReq = NULL;
|
||||||
|
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncCatalogFn(SMetaData* pResult, void* param, int32_t code) {
|
||||||
|
SSyncQueryParam* pParam = param;
|
||||||
|
pParam->pRequest->code = code;
|
||||||
|
|
||||||
|
tsem_post(&pParam->sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncQueryFn(void* param, void* res, int32_t code) {
|
||||||
|
SSyncQueryParam* pParam = param;
|
||||||
|
pParam->pRequest = res;
|
||||||
|
pParam->pRequest->code = code;
|
||||||
|
|
||||||
|
tsem_post(&pParam->sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) {
|
||||||
|
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
||||||
|
if (pTscObj == NULL || sql == NULL || NULL == fp) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
if (pTscObj) {
|
||||||
|
releaseTscObj(*(int64_t*)taos);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
}
|
||||||
|
fp(param, NULL, terrno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t sqlLen = strlen(sql);
|
||||||
|
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
||||||
|
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
||||||
|
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
||||||
|
|
||||||
|
fp(param, NULL, terrno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRequestObj* pRequest = NULL;
|
||||||
|
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = code;
|
||||||
|
fp(param, NULL, terrno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRequest->validateOnly = validateOnly;
|
||||||
|
pRequest->body.queryFp = fp;
|
||||||
|
pRequest->body.param = param;
|
||||||
|
doAsyncQuery(pRequest, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
|
||||||
|
if (NULL == taos) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
||||||
|
if (pTscObj == NULL || sql == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SYNC_ON_TOP_OF_ASYNC
|
||||||
|
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||||
|
tsem_init(¶m->sem, 0, 0);
|
||||||
|
|
||||||
|
taosAsyncQueryImpl(taos, sql, syncQueryFn, param, validateOnly);
|
||||||
|
tsem_wait(¶m->sem);
|
||||||
|
|
||||||
|
releaseTscObj(*(int64_t*)taos);
|
||||||
|
|
||||||
|
return param->pRequest;
|
||||||
|
#else
|
||||||
|
size_t sqlLen = strlen(sql);
|
||||||
|
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
||||||
|
releaseTscObj(*(int64_t*)taos);
|
||||||
|
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
||||||
|
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen, validateOnly);
|
||||||
|
|
||||||
|
releaseTscObj(*(int64_t*)taos);
|
||||||
|
|
||||||
|
return pRes;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -81,12 +81,6 @@ void taos_cleanup(void) {
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfRet taos_set_config(const char *config) {
|
|
||||||
// TODO
|
|
||||||
setConfRet ret = {SET_CONF_RET_SUCC, {0}};
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
|
@ -205,51 +199,9 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||||
return pResInfo->userFields;
|
return pResInfo->userFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void syncQueryFn(void *param, void *res, int32_t code) {
|
|
||||||
SSyncQueryParam *pParam = param;
|
|
||||||
pParam->pRequest = res;
|
|
||||||
pParam->pRequest->code = code;
|
|
||||||
|
|
||||||
tsem_post(&pParam->sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
if (NULL == taos) {
|
return taosQueryImpl(taos, sql, false);
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
|
||||||
if (pTscObj == NULL || sql == NULL) {
|
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SYNC_ON_TOP_OF_ASYNC
|
|
||||||
SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
|
||||||
tsem_init(¶m->sem, 0, 0);
|
|
||||||
|
|
||||||
taos_query_a(taos, sql, syncQueryFn, param);
|
|
||||||
tsem_wait(¶m->sem);
|
|
||||||
|
|
||||||
releaseTscObj(*(int64_t *)taos);
|
|
||||||
|
|
||||||
return param->pRequest;
|
|
||||||
#else
|
|
||||||
size_t sqlLen = strlen(sql);
|
|
||||||
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
|
||||||
releaseTscObj(*(int64_t *)taos);
|
|
||||||
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
|
||||||
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen);
|
|
||||||
|
|
||||||
releaseTscObj(*(int64_t *)taos);
|
|
||||||
|
|
||||||
return pRes;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
|
@ -641,7 +593,14 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||||
return pResInfo->pCol[columnIndex].offset;
|
return pResInfo->pCol[columnIndex].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
|
TAOS_RES* pObj = taosQueryImpl(taos, sql, true);
|
||||||
|
|
||||||
|
int code = taos_errno(pObj);
|
||||||
|
|
||||||
|
taos_free_result(pObj);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
void taos_reset_current_db(TAOS *taos) {
|
void taos_reset_current_db(TAOS *taos) {
|
||||||
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
|
@ -664,7 +623,7 @@ const char *taos_get_server_info(TAOS *taos) {
|
||||||
|
|
||||||
releaseTscObj(*(int64_t *)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
return pTscObj->ver;
|
return pTscObj->sDetailVer;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SqlParseWrapper {
|
typedef struct SqlParseWrapper {
|
||||||
|
@ -731,38 +690,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
||||||
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
taosAsyncQueryImpl(taos, sql, fp, param, false);
|
||||||
if (pTscObj == NULL || sql == NULL || NULL == fp) {
|
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
|
||||||
if (pTscObj) {
|
|
||||||
releaseTscObj(*(int64_t *)taos);
|
|
||||||
} else {
|
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
|
||||||
}
|
|
||||||
fp(param, NULL, terrno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t sqlLen = strlen(sql);
|
|
||||||
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
|
||||||
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
|
||||||
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
|
||||||
|
|
||||||
fp(param, NULL, terrno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRequestObj *pRequest = NULL;
|
|
||||||
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
terrno = code;
|
|
||||||
fp(param, NULL, terrno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRequest->body.queryFp = fp;
|
|
||||||
pRequest->body.param = param;
|
|
||||||
doAsyncQuery(pRequest, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
||||||
|
@ -838,7 +766,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
||||||
.requestObjRefId = pCxt->requestRid,
|
.requestObjRefId = pCxt->requestRid,
|
||||||
.mgmtEps = pCxt->mgmtEpSet};
|
.mgmtEps = pCxt->mgmtEpSet};
|
||||||
|
|
||||||
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, &catalogReq, retrieveMetaCallback, pWrapper,
|
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, &catalogReq, retrieveMetaCallback, pWrapper,
|
||||||
&pRequest->body.queryJob);
|
&pRequest->body.queryJob);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
|
@ -955,10 +883,75 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
// TODO
|
const int32_t MAX_TABLE_NAME_LENGTH = 12 * 1024 * 1024; // 12MB list
|
||||||
return -1;
|
int32_t code = 0;
|
||||||
|
SRequestObj *pRequest = NULL;
|
||||||
|
SCatalogReq catalogReq = {0};
|
||||||
|
|
||||||
|
if (NULL == tableNameList) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t length = (int32_t)strlen(tableNameList);
|
||||||
|
if (0 == length) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (length > MAX_TABLE_NAME_LENGTH) {
|
||||||
|
tscError("tableNameList too long, length:%d, maximum allowed:%d", length, MAX_TABLE_NAME_LENGTH);
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
|
if (pTscObj == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = transferTableNameList(tableNameList, pTscObj->acctId, pTscObj->db, &catalogReq.pTableMeta);
|
||||||
|
if (code) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCatalog* pCtg = NULL;
|
||||||
|
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* sql = "taos_load_table_info";
|
||||||
|
code = buildRequest(pTscObj, sql, strlen(sql), &pRequest);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = code;
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncQueryParam param = {0};
|
||||||
|
tsem_init(¶m.sem, 0, 0);
|
||||||
|
param.pRequest = pRequest;
|
||||||
|
|
||||||
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
|
.requestId = pRequest->requestId,
|
||||||
|
.requestObjRefId = pRequest->self};
|
||||||
|
|
||||||
|
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
||||||
|
code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, ¶m, NULL);
|
||||||
|
if (code) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsem_wait(¶m.sem);
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
taosArrayDestroy(catalogReq.pTableMeta);
|
||||||
|
destroyRequest(pRequest);
|
||||||
|
|
||||||
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
||||||
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
|
|
|
@ -82,7 +82,8 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
pTscObj->connId = connectRsp.connId;
|
pTscObj->connId = connectRsp.connId;
|
||||||
pTscObj->acctId = connectRsp.acctId;
|
pTscObj->acctId = connectRsp.acctId;
|
||||||
tstrncpy(pTscObj->ver, connectRsp.sVersion, tListLen(pTscObj->ver));
|
tstrncpy(pTscObj->sVer, connectRsp.sVer, tListLen(pTscObj->sVer));
|
||||||
|
tstrncpy(pTscObj->sDetailVer, connectRsp.sDetailVer, tListLen(pTscObj->sDetailVer));
|
||||||
|
|
||||||
// update the appInstInfo
|
// update the appInstInfo
|
||||||
pTscObj->pAppInfo->clusterId = connectRsp.clusterId;
|
pTscObj->pAppInfo->clusterId = connectRsp.clusterId;
|
||||||
|
@ -287,6 +288,103 @@ int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
||||||
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
pBlock->info.hasVarCol = true;
|
||||||
|
|
||||||
|
pBlock->pDataBlock = taosArrayInit(SHOW_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
SColumnInfoData infoData = {0};
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD1_LEN;
|
||||||
|
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD2_LEN;
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
|
int32_t numOfCfg = taosArrayGetSize(pVars);
|
||||||
|
blockDataEnsureCapacity(pBlock, numOfCfg);
|
||||||
|
|
||||||
|
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||||
|
SVariablesInfo *pInfo = taosArrayGet(pVars, i);
|
||||||
|
|
||||||
|
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
|
colDataAppend(pColInfo, i, name, false);
|
||||||
|
|
||||||
|
char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
|
colDataAppend(pColInfo, i, value, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->info.rows = numOfCfg;
|
||||||
|
|
||||||
|
*block = pBlock;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
|
SSDataBlock* pBlock = NULL;
|
||||||
|
int32_t code = buildShowVariablesBlock(pVars, &pBlock);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||||
|
*pRsp = taosMemoryCalloc(1, rspSize);
|
||||||
|
if (NULL == *pRsp) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pRsp)->useconds = 0;
|
||||||
|
(*pRsp)->completed = 1;
|
||||||
|
(*pRsp)->precision = 0;
|
||||||
|
(*pRsp)->compressed = 0;
|
||||||
|
(*pRsp)->compLen = 0;
|
||||||
|
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
||||||
|
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_VARIABLES_RESULT_COLS, false);
|
||||||
|
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||||
|
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t processShowVariablesRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
|
SRequestObj* pRequest = param;
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
setErrno(pRequest, code);
|
||||||
|
} else {
|
||||||
|
SShowVariablesRsp rsp = {0};
|
||||||
|
SRetrieveTableRsp* pRes = NULL;
|
||||||
|
code = tDeserializeSShowVariablesRsp(pMsg->pData, pMsg->len, &rsp);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = buildShowVariablesRsp(rsp.variables, &pRes);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRequest->body.queryFp != NULL) {
|
||||||
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
|
} else {
|
||||||
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
__async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
__async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_MND_CONNECT:
|
case TDMT_MND_CONNECT:
|
||||||
|
@ -301,6 +399,8 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
||||||
return processDropDbRsp;
|
return processDropDbRsp;
|
||||||
case TDMT_MND_ALTER_STB:
|
case TDMT_MND_ALTER_STB:
|
||||||
return processAlterStbRsp;
|
return processAlterStbRsp;
|
||||||
|
case TDMT_MND_SHOW_VARIABLES:
|
||||||
|
return processShowVariablesRsp;
|
||||||
default:
|
default:
|
||||||
return genericRspCallback;
|
return genericRspCallback;
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,6 +636,377 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t taosSetCfg(SConfig *pCfg, char* name) {
|
||||||
|
int32_t len = strlen(name);
|
||||||
|
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
|
||||||
|
strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len));
|
||||||
|
|
||||||
|
switch (lowcaseName[0]) {
|
||||||
|
case 'a': {
|
||||||
|
if (strcasecmp("asyncLog", name) == 0) {
|
||||||
|
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'b': {
|
||||||
|
if (strcasecmp("bnodeShmSize", name) == 0) {
|
||||||
|
tsBnodeShmSize = cfgGetItem(pCfg, "bnodeShmSize")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'c': {
|
||||||
|
if (strcasecmp("charset", name) == 0) {
|
||||||
|
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
||||||
|
const char *charset = cfgGetItem(pCfg, "charset")->str;
|
||||||
|
taosSetSystemLocale(locale, charset);
|
||||||
|
osSetSystemLocale(locale, charset);
|
||||||
|
} else if (strcasecmp("compressMsgSize", name) == 0) {
|
||||||
|
tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32;
|
||||||
|
} else if (strcasecmp("compressColData", name) == 0) {
|
||||||
|
tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32;
|
||||||
|
} else if (strcasecmp("countAlwaysReturnValue", name) == 0) {
|
||||||
|
tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32;
|
||||||
|
} else if (strcasecmp("cDebugFlag", name) == 0) {
|
||||||
|
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'd': {
|
||||||
|
if (strcasecmp("deadLockKillQuery", name) == 0) {
|
||||||
|
tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32;
|
||||||
|
} else if (strcasecmp("dDebugFlag", name) == 0) {
|
||||||
|
dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'e': {
|
||||||
|
if (strcasecmp("enableCoreFile", name) == 0) {
|
||||||
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
|
taosSetConsoleEcho(enableCore);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'f': {
|
||||||
|
if (strcasecmp("fqdn", name) == 0) {
|
||||||
|
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN);
|
||||||
|
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
|
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
|
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp");
|
||||||
|
SEp firstEp = {0};
|
||||||
|
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp);
|
||||||
|
snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port);
|
||||||
|
cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype);
|
||||||
|
} else if (strcasecmp("firstEp", name) == 0) {
|
||||||
|
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN);
|
||||||
|
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
|
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
|
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp");
|
||||||
|
SEp firstEp = {0};
|
||||||
|
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp);
|
||||||
|
snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port);
|
||||||
|
cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype);
|
||||||
|
} else if (strcasecmp("fsDebugFlag", name) == 0) {
|
||||||
|
fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32;
|
||||||
|
} else if (strcasecmp("fnDebugFlag", name) == 0) {
|
||||||
|
fnDebugFlag = cfgGetItem(pCfg, "fnDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'i': {
|
||||||
|
if (strcasecmp("idxDebugFlag", name) == 0) {
|
||||||
|
idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'j': {
|
||||||
|
if (strcasecmp("jniDebugFlag", name) == 0) {
|
||||||
|
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'k': {
|
||||||
|
if (strcasecmp("keepColumnName", name) == 0) {
|
||||||
|
tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'l': {
|
||||||
|
if (strcasecmp("locale", name) == 0) {
|
||||||
|
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
||||||
|
const char *charset = cfgGetItem(pCfg, "charset")->str;
|
||||||
|
taosSetSystemLocale(locale, charset);
|
||||||
|
osSetSystemLocale(locale, charset);
|
||||||
|
} else if (strcasecmp("logDir", name) == 0) {
|
||||||
|
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
|
||||||
|
taosExpandDir(tsLogDir, tsLogDir, PATH_MAX);
|
||||||
|
} else if (strcasecmp("logKeepDays", name) == 0) {
|
||||||
|
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'm': {
|
||||||
|
switch (lowcaseName[1]) {
|
||||||
|
case 'a': {
|
||||||
|
if (strcasecmp("maxShellConns", name) == 0) {
|
||||||
|
tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
|
||||||
|
} else if (strcasecmp("maxNumOfDistinctRes", name) == 0) {
|
||||||
|
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
|
||||||
|
} else if (strcasecmp("maxStreamCompDelay", name) == 0) {
|
||||||
|
tsMaxStreamComputDelay = cfgGetItem(pCfg, "maxStreamCompDelay")->i32;
|
||||||
|
} else if (strcasecmp("maxFirstStreamCompDelay", name) == 0) {
|
||||||
|
tsStreamCompStartDelay = cfgGetItem(pCfg, "maxFirstStreamCompDelay")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'd': {
|
||||||
|
if (strcasecmp("mDebugFlag", name) == 0) {
|
||||||
|
mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'i': {
|
||||||
|
if (strcasecmp("minimalTempDirGB", name) == 0) {
|
||||||
|
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval;
|
||||||
|
} else if (strcasecmp("minimalDataDirGB", name) == 0) {
|
||||||
|
tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
|
||||||
|
} else if (strcasecmp("minSlidingTime", name) == 0) {
|
||||||
|
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
|
||||||
|
} else if (strcasecmp("minIntervalTime", name) == 0) {
|
||||||
|
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
|
||||||
|
} else if (strcasecmp("minimalLogDirGB", name) == 0) {
|
||||||
|
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'n': {
|
||||||
|
if (strcasecmp("mnodeShmSize", name) == 0) {
|
||||||
|
tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'o': {
|
||||||
|
if (strcasecmp("monitor", name) == 0) {
|
||||||
|
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
||||||
|
} else if (strcasecmp("monitorInterval", name) == 0) {
|
||||||
|
tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32;
|
||||||
|
} else if (strcasecmp("monitorFqdn", name) == 0) {
|
||||||
|
tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN);
|
||||||
|
} else if (strcasecmp("monitorPort", name) == 0) {
|
||||||
|
tsMonitorPort = (uint16_t)cfgGetItem(pCfg, "monitorPort")->i32;
|
||||||
|
} else if (strcasecmp("monitorMaxLogs", name) == 0) {
|
||||||
|
tsMonitorMaxLogs = cfgGetItem(pCfg, "monitorMaxLogs")->i32;
|
||||||
|
} else if (strcasecmp("monitorComp", name) == 0) {
|
||||||
|
tsMonitorComp = cfgGetItem(pCfg, "monitorComp")->bval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'q': {
|
||||||
|
if (strcasecmp("mqRebalanceInterval", name) == 0) {
|
||||||
|
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'u': {
|
||||||
|
if (strcasecmp("multiProcess", name) == 0) {
|
||||||
|
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
terrno = TSDB_CODE_CFG_NOT_FOUND;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'n': {
|
||||||
|
if (strcasecmp("numOfTaskQueueThreads", name) == 0) {
|
||||||
|
tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfRpcThreads", name) == 0) {
|
||||||
|
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfCommitThreads", name) == 0) {
|
||||||
|
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfMnodeQueryThreads", name) == 0) {
|
||||||
|
tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfMnodeReadThreads", name) == 0) {
|
||||||
|
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) {
|
||||||
|
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfVnodeFetchThreads", name) == 0) {
|
||||||
|
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfVnodeWriteThreads", name) == 0) {
|
||||||
|
tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfVnodeSyncThreads", name) == 0) {
|
||||||
|
tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfVnodeMergeThreads", name) == 0) {
|
||||||
|
tsNumOfVnodeMergeThreads = cfgGetItem(pCfg, "numOfVnodeMergeThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfQnodeQueryThreads", name) == 0) {
|
||||||
|
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) {
|
||||||
|
tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfSnodeSharedThreads", name) == 0) {
|
||||||
|
tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfSnodeUniqueThreads", name) == 0) {
|
||||||
|
tsNumOfSnodeUniqueThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32;
|
||||||
|
} else if (strcasecmp("numOfLogLines", name) == 0) {
|
||||||
|
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'p': {
|
||||||
|
if (strcasecmp("printAuth", name) == 0) {
|
||||||
|
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'q': {
|
||||||
|
if (strcasecmp("queryPolicy", name) == 0) {
|
||||||
|
tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32;
|
||||||
|
} else if (strcasecmp("querySmaOptimize", name) == 0) {
|
||||||
|
tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32;
|
||||||
|
} else if (strcasecmp("queryBufferSize", name) == 0) {
|
||||||
|
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||||
|
if (tsQueryBufferSize >= 0) {
|
||||||
|
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||||
|
}
|
||||||
|
} else if (strcasecmp("qnodeShmSize", name) == 0) {
|
||||||
|
tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
|
||||||
|
} else if (strcasecmp("qDebugFlag", name) == 0) {
|
||||||
|
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'r': {
|
||||||
|
if (strcasecmp("retryStreamCompDelay", name) == 0) {
|
||||||
|
tsRetryStreamCompDelay = cfgGetItem(pCfg, "retryStreamCompDelay")->i32;
|
||||||
|
} else if (strcasecmp("retrieveBlockingModel", name) == 0) {
|
||||||
|
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
|
||||||
|
} else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) {
|
||||||
|
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
|
||||||
|
} else if (strcasecmp("rpcDebugFlag", name) == 0) {
|
||||||
|
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 's': {
|
||||||
|
if (strcasecmp("secondEp", name) == 0) {
|
||||||
|
SConfigItem *pSecondpItem = cfgGetItem(pCfg, "secondEp");
|
||||||
|
SEp secondEp = {0};
|
||||||
|
taosGetFqdnPortFromEp(strlen(pSecondpItem->str) == 0 ? tsFirst : pSecondpItem->str, &secondEp);
|
||||||
|
snprintf(tsSecond, sizeof(tsSecond), "%s:%u", secondEp.fqdn, secondEp.port);
|
||||||
|
cfgSetItem(pCfg, "secondEp", tsSecond, pSecondpItem->stype);
|
||||||
|
} else if (strcasecmp("smlChildTableName", name) == 0) {
|
||||||
|
tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN);
|
||||||
|
} else if (strcasecmp("smlTagName", name) == 0) {
|
||||||
|
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
|
||||||
|
} else if (strcasecmp("smlDataFormat", name) == 0) {
|
||||||
|
tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
|
||||||
|
} else if (strcasecmp("shellActivityTimer", name) == 0) {
|
||||||
|
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||||
|
} else if (strcasecmp("supportVnodes", name) == 0) {
|
||||||
|
tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
||||||
|
} else if (strcasecmp("statusInterval", name) == 0) {
|
||||||
|
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
|
||||||
|
} else if (strcasecmp("streamCompDelayRatio", name) == 0) {
|
||||||
|
tsStreamComputDelayRatio = cfgGetItem(pCfg, "streamCompDelayRatio")->fval;
|
||||||
|
} else if (strcasecmp("slaveQuery", name) == 0) {
|
||||||
|
tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval;
|
||||||
|
} else if (strcasecmp("snodeShmSize", name) == 0) {
|
||||||
|
tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32;
|
||||||
|
} else if (strcasecmp("serverPort", name) == 0) {
|
||||||
|
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN);
|
||||||
|
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
|
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
|
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
|
SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp");
|
||||||
|
SEp firstEp = {0};
|
||||||
|
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp);
|
||||||
|
snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port);
|
||||||
|
cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype);
|
||||||
|
} else if (strcasecmp("sDebugFlag", name) == 0) {
|
||||||
|
sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32;
|
||||||
|
} else if (strcasecmp("smaDebugFlag", name) == 0) {
|
||||||
|
smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 't': {
|
||||||
|
if (strcasecmp("timezone", name) == 0) {
|
||||||
|
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
|
||||||
|
osSetTimezone(pItem->str);
|
||||||
|
uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr);
|
||||||
|
cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype);
|
||||||
|
} else if (strcasecmp("tempDir", name) == 0) {
|
||||||
|
tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
|
||||||
|
taosExpandDir(tsTempDir, tsTempDir, PATH_MAX);
|
||||||
|
if (taosMulMkDir(tsTempDir) != 0) {
|
||||||
|
uError("failed to create tempDir:%s since %s", tsTempDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (strcasecmp("telemetryReporting", name) == 0) {
|
||||||
|
tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval;
|
||||||
|
} else if (strcasecmp("telemetryInterval", name) == 0) {
|
||||||
|
tsTelemInterval = cfgGetItem(pCfg, "telemetryInterval")->i32;
|
||||||
|
} else if (strcasecmp("telemetryServer", name) == 0) {
|
||||||
|
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||||
|
} else if (strcasecmp("telemetryPort", name) == 0) {
|
||||||
|
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
||||||
|
} else if (strcasecmp("transPullupInterval", name) == 0) {
|
||||||
|
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||||
|
} else if (strcasecmp("ttlUnit", name) == 0) {
|
||||||
|
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||||
|
} else if (strcasecmp("ttlPushInterval", name) == 0) {
|
||||||
|
tsTtlPushInterval = cfgGetItem(pCfg, "ttlPushInterval")->i32;
|
||||||
|
} else if (strcasecmp("tmrDebugFlag", name) == 0) {
|
||||||
|
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
||||||
|
} else if (strcasecmp("tsdbDebugFlag", name) == 0) {
|
||||||
|
tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32;
|
||||||
|
} else if (strcasecmp("tqDebugFlag", name) == 0) {
|
||||||
|
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'u': {
|
||||||
|
if (strcasecmp("udf", name) == 0) {
|
||||||
|
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||||
|
} else if (strcasecmp("uDebugFlag", name) == 0) {
|
||||||
|
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'v': {
|
||||||
|
if (strcasecmp("vnodeShmSize", name) == 0) {
|
||||||
|
tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
|
||||||
|
} else if (strcasecmp("vDebugFlag", name) == 0) {
|
||||||
|
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'w': {
|
||||||
|
if (strcasecmp("wDebugFlag", name) == 0) {
|
||||||
|
wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
terrno = TSDB_CODE_CFG_NOT_FOUND;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
|
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
|
||||||
if (tsCfg == NULL) osDefaultInit();
|
if (tsCfg == NULL) osDefaultInit();
|
||||||
|
|
|
@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (NULL == pReq->pFuncs) return -1;
|
if (NULL == pReq->pFuncs) return -1;
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
||||||
char* pFunc = NULL;
|
char *pFunc = NULL;
|
||||||
if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1;
|
if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1;
|
||||||
if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) {
|
if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
|
||||||
if (tEncodeI64(&encoder, pReq->interval) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->interval) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->offset) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->offset) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1;
|
||||||
|
@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
|
||||||
if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1;
|
||||||
|
@ -1945,7 +1949,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1;
|
||||||
if (tDecodeBinaryAlloc(&decoder, (void**)&pRsp->pTags, NULL) < 0) return -1;
|
if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
@ -2246,6 +2250,56 @@ int32_t tDeserializeSDnodeListReq(void *buf, int32_t bufLen, SDnodeListReq *pReq
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSServerVerReq(void *buf, int32_t bufLen, SServerVerReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->useless) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSServerVerReq(void *buf, int32_t bufLen, SServerVerReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->useless) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSServerVerRsp(void *buf, int32_t bufLen, SServerVerRsp *pRsp) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->ver) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSServerVerRsp(void *buf, int32_t bufLen, SServerVerRsp *pRsp) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->ver) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) {
|
int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
|
@ -2855,6 +2909,67 @@ int32_t tDeserializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesR
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSVariablesInfo(SEncoder* pEncoder, SVariablesInfo* pInfo) {
|
||||||
|
if (tEncodeCStr(pEncoder, pInfo->name) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pEncoder, pInfo->value) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeSVariablesInfo(SDecoder* pDecoder, SVariablesInfo* pInfo) {
|
||||||
|
if (tDecodeCStrTo(pDecoder, pInfo->name) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(pDecoder, pInfo->value) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
int32_t varNum = taosArrayGetSize(pRsp->variables);
|
||||||
|
if (tEncodeI32(&encoder, varNum) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < varNum; ++i) {
|
||||||
|
SVariablesInfo* pInfo = taosArrayGet(pRsp->variables, i);
|
||||||
|
if (tEncodeSVariablesInfo(&encoder, pInfo) < 0) return -1;
|
||||||
|
}
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
int32_t varNum = 0;
|
||||||
|
if (tDecodeI32(&decoder, &varNum) < 0) return -1;
|
||||||
|
if (varNum > 0) {
|
||||||
|
pRsp->variables = taosArrayInit(varNum, sizeof(SVariablesInfo));
|
||||||
|
if (NULL == pRsp->variables) return -1;
|
||||||
|
for (int32_t i = 0; i < varNum; ++i) {
|
||||||
|
SVariablesInfo info = {0};
|
||||||
|
if (tDecodeSVariablesInfo(&decoder, &info) < 0) return -1;
|
||||||
|
if (NULL == taosArrayPush(pRsp->variables, &info)) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp) {
|
||||||
|
if (NULL == pRsp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pRsp->variables);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -3396,7 +3511,8 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
||||||
if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1;
|
if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1;
|
if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1;
|
||||||
if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1;
|
if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pRsp->sVersion) < 0) return -1;
|
if (tEncodeCStr(&encoder, pRsp->sVer) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->sDetailVer) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -3416,7 +3532,8 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
||||||
if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1;
|
if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1;
|
||||||
if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1;
|
if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pRsp->sVersion) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pRsp->sVer) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->sDetailVer) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
|
@ -214,6 +214,20 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) {
|
||||||
|
assert(dst != NULL && tbName != NULL && nameLen > 0);
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (nameLen >= tListLen(dst->tname) || nameLen <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst->type = TSDB_TABLE_NAME_T;
|
||||||
|
tstrncpy(dst->tname, tbName, nameLen + 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t tNameSetAcctId(SName* dst, int32_t acctId) {
|
int32_t tNameSetAcctId(SName* dst, int32_t acctId) {
|
||||||
assert(dst != NULL);
|
assert(dst != NULL);
|
||||||
dst->acctId = acctId;
|
dst->acctId = acctId;
|
||||||
|
|
|
@ -206,6 +206,8 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -133,10 +133,10 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
|
||||||
ret = taosLockFile(pFile);
|
ret = taosLockFile(pFile);
|
||||||
if (ret == 0) break;
|
if (ret == 0) break;
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
taosMsleep(100);
|
taosMsleep(1000);
|
||||||
retryTimes++;
|
retryTimes++;
|
||||||
dError("failed to lock file:%s since %s, retryTimes:%d", filepath, terrstr(), retryTimes);
|
dError("failed to lock file:%s since %s, retryTimes:%d", filepath, terrstr(), retryTimes);
|
||||||
} while (retryTimes < 120);
|
} while (retryTimes < 12);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
|
@ -23,13 +23,15 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MND_OPER_CREATE_USER = 1,
|
MND_OPER_CONNECT = 1,
|
||||||
|
MND_OPER_CREATE_USER,
|
||||||
MND_OPER_DROP_USER,
|
MND_OPER_DROP_USER,
|
||||||
MND_OPER_ALTER_USER,
|
MND_OPER_ALTER_USER,
|
||||||
MND_OPER_CREATE_BNODE,
|
MND_OPER_CREATE_BNODE,
|
||||||
MND_OPER_DROP_BNODE,
|
MND_OPER_DROP_BNODE,
|
||||||
MND_OPER_CREATE_DNODE,
|
MND_OPER_CREATE_DNODE,
|
||||||
MND_OPER_DROP_DNODE,
|
MND_OPER_DROP_DNODE,
|
||||||
|
MND_OPER_CONFIG_DNODE,
|
||||||
MND_OPER_CREATE_MNODE,
|
MND_OPER_CREATE_MNODE,
|
||||||
MND_OPER_DROP_MNODE,
|
MND_OPER_DROP_MNODE,
|
||||||
MND_OPER_CREATE_QNODE,
|
MND_OPER_CREATE_QNODE,
|
||||||
|
@ -37,6 +39,7 @@ typedef enum {
|
||||||
MND_OPER_CREATE_SNODE,
|
MND_OPER_CREATE_SNODE,
|
||||||
MND_OPER_DROP_SNODE,
|
MND_OPER_DROP_SNODE,
|
||||||
MND_OPER_REDISTRIBUTE_VGROUP,
|
MND_OPER_REDISTRIBUTE_VGROUP,
|
||||||
|
MND_OPER_MERGE_VGROUP,
|
||||||
MND_OPER_SPLIT_VGROUP,
|
MND_OPER_SPLIT_VGROUP,
|
||||||
MND_OPER_BALANCE_VGROUP,
|
MND_OPER_BALANCE_VGROUP,
|
||||||
MND_OPER_CREATE_FUNC,
|
MND_OPER_CREATE_FUNC,
|
||||||
|
|
|
@ -27,12 +27,10 @@ void mndCleanupScheduler(SMnode* pMnode);
|
||||||
|
|
||||||
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream);
|
|
||||||
|
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark);
|
int64_t watermark);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream);
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,13 @@ int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
switch (operType) {
|
||||||
code = -1;
|
case MND_OPER_CONNECT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
code = -1;
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
@ -102,7 +107,13 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
||||||
|
if (pUser->superUser && pAlter->alterType != TSDB_ALTER_USER_PASSWD) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (pOperUser->superUser) return 0;
|
if (pOperUser->superUser) return 0;
|
||||||
|
|
||||||
if (!pOperUser->enable) {
|
if (!pOperUser->enable) {
|
||||||
terrno = TSDB_CODE_MND_USER_DISABLED;
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -277,6 +277,9 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("bnode:%d, start to create", createReq.dnodeId);
|
mDebug("bnode:%d, start to create", createReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_BNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pObj = mndAcquireBnode(pMnode, createReq.dnodeId);
|
pObj = mndAcquireBnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
|
@ -292,10 +295,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_BNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateBnode(pMnode, pReq, pDnode, &createReq);
|
code = mndCreateBnode(pMnode, pReq, pDnode, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -383,6 +382,9 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("bnode:%d, start to drop", dropReq.dnodeId);
|
mDebug("bnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_BNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropReq.dnodeId <= 0) {
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -394,10 +396,6 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_BNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndDropBnode(pMnode, pReq, pObj);
|
code = mndDropBnode(pMnode, pReq, pObj);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode);
|
||||||
static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode);
|
static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode);
|
||||||
static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew);
|
static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew);
|
||||||
static int32_t mndProcessDnodeListReq(SRpcMsg *pReq);
|
static int32_t mndProcessDnodeListReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq);
|
||||||
|
@ -78,6 +79,7 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
||||||
|
@ -554,6 +556,59 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
||||||
|
SShowVariablesRsp rsp = {0};
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
rsp.variables = taosArrayInit(4, sizeof(SVariablesInfo));
|
||||||
|
if (NULL == rsp.variables) {
|
||||||
|
mError("failed to alloc SVariablesInfo array while process show variables req");
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SVariablesInfo info = {0};
|
||||||
|
|
||||||
|
strcpy(info.name, "statusInterval");
|
||||||
|
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||||
|
taosArrayPush(rsp.variables, &info);
|
||||||
|
|
||||||
|
strcpy(info.name, "timezone");
|
||||||
|
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
|
||||||
|
taosArrayPush(rsp.variables, &info);
|
||||||
|
|
||||||
|
strcpy(info.name, "locale");
|
||||||
|
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
|
||||||
|
taosArrayPush(rsp.variables, &info);
|
||||||
|
|
||||||
|
strcpy(info.name, "charset");
|
||||||
|
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
|
||||||
|
taosArrayPush(rsp.variables, &info);
|
||||||
|
|
||||||
|
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
|
||||||
|
void *pRsp = rpcMallocCont(rspLen);
|
||||||
|
if (pRsp == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp);
|
||||||
|
|
||||||
|
pReq->info.rspLen = rspLen;
|
||||||
|
pReq->info.rsp = pRsp;
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to get show variables info since %s", terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -566,6 +621,9 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("dnode:%s:%d, start to create", createReq.fqdn, createReq.port);
|
mInfo("dnode:%s:%d, start to create", createReq.fqdn, createReq.port);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) {
|
if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
|
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
|
||||||
|
@ -579,10 +637,6 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateDnode(pMnode, pReq, &createReq);
|
code = mndCreateDnode(pMnode, pReq, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -661,6 +715,9 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("dnode:%d, start to drop, ep:%s:%d", dropReq.dnodeId, dropReq.fqdn, dropReq.port);
|
mInfo("dnode:%d, start to drop, ep:%s:%d", dropReq.dnodeId, dropReq.fqdn, dropReq.port);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
|
@ -697,10 +754,6 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes);
|
code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -726,6 +779,10 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
|
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, cfgReq.dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, cfgReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("dnode:%d, failed to config since %s ", cfgReq.dnodeId, terrstr());
|
mError("dnode:%d, failed to config since %s ", cfgReq.dnodeId, terrstr());
|
||||||
|
|
|
@ -283,6 +283,9 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("func:%s, start to create", createReq.name);
|
mDebug("func:%s, start to create", createReq.name);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pFunc = mndAcquireFunc(pMnode, createReq.name);
|
pFunc = mndAcquireFunc(pMnode, createReq.name);
|
||||||
if (pFunc != NULL) {
|
if (pFunc != NULL) {
|
||||||
|
@ -318,10 +321,6 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateFunc(pMnode, pReq, &createReq);
|
code = mndCreateFunc(pMnode, pReq, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -347,6 +346,9 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("func:%s, start to drop", dropReq.name);
|
mDebug("func:%s, start to drop", dropReq.name);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropReq.name[0] == 0) {
|
if (dropReq.name[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
terrno = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
||||||
|
@ -365,10 +367,6 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndDropFunc(pMnode, pReq, pFunc);
|
code = mndDropFunc(pMnode, pReq, pFunc);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ static void *mndThreadFp(void *param) {
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
if (mndGetStop(pMnode)) break;
|
if (mndGetStop(pMnode)) break;
|
||||||
|
|
||||||
if (lastTime % (tsTransPullupInterval * 10) == 1) {
|
if (lastTime % (tsTtlPushInterval * 10) == 1) {
|
||||||
mndTtlTimer(pMnode);
|
mndTtlTimer(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,24 +529,33 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
if (!IsReq(pMsg)) return 0;
|
if (!IsReq(pMsg)) return 0;
|
||||||
if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0;
|
if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0;
|
||||||
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
||||||
pMsg->msgType == TDMT_MND_TRANS_TIMER || TDMT_MND_TTL_TIMER) {
|
pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
|
||||||
mError("msg:%p, failed to check mnode state since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType));
|
|
||||||
|
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
mndGetMnodeEpSet(pMsg->info.node, &epSet);
|
mndGetMnodeEpSet(pMsg->info.node, &epSet);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
pMsg->info.rsp = rpcMallocCont(contLen);
|
mError("msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d", pMsg, terrstr(),
|
||||||
if (pMsg->info.rsp != NULL) {
|
TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse);
|
||||||
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
|
||||||
pMsg->info.rspLen = contLen;
|
if (epSet.numOfEps > 0) {
|
||||||
terrno = TSDB_CODE_RPC_REDIRECT;
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
|
mInfo("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||||
|
pMsg->info.rsp = rpcMallocCont(contLen);
|
||||||
|
if (pMsg->info.rsp != NULL) {
|
||||||
|
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
||||||
|
pMsg->info.rspLen = contLen;
|
||||||
|
terrno = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -558,7 +567,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen,
|
mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen,
|
||||||
pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -723,7 +732,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb);
|
pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
SMonStbDesc desc = {0};
|
SMonStbDesc desc = {0};
|
||||||
|
|
||||||
SName name1 = {0};
|
SName name1 = {0};
|
||||||
tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
|
@ -389,6 +389,9 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("mnode:%d, start to create", createReq.dnodeId);
|
mDebug("mnode:%d, start to create", createReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_MNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pObj = mndAcquireMnode(pMnode, createReq.dnodeId);
|
pObj = mndAcquireMnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
|
@ -414,10 +417,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_MNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateMnode(pMnode, pReq, pDnode, &createReq);
|
code = mndCreateMnode(pMnode, pReq, pDnode, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -495,7 +494,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
{
|
{
|
||||||
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead);
|
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSSetStandbyReq((char*)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
||||||
SMsgHead *pHead = pReq;
|
SMsgHead *pHead = pReq;
|
||||||
pHead->contLen = htonl(contLen);
|
pHead->contLen = htonl(contLen);
|
||||||
pHead->vgId = htonl(MNODE_HANDLE);
|
pHead->vgId = htonl(MNODE_HANDLE);
|
||||||
|
@ -595,6 +594,9 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("mnode:%d, start to drop", dropReq.dnodeId);
|
mDebug("mnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropReq.dnodeId <= 0) {
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -621,10 +623,6 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndDropMnode(pMnode, pReq, pObj);
|
code = mndDropMnode(pMnode, pReq, pObj);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndProfile.h"
|
#include "mndProfile.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
|
@ -70,6 +71,7 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
||||||
static void mndFreeApp(SAppObj *pApp);
|
static void mndFreeApp(SAppObj *pApp);
|
||||||
static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextApp(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextApp(SMnode *pMnode, void *pIter);
|
||||||
|
static int32_t mndProcessSvrVerReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
int32_t mndInitProfile(SMnode *pMnode) {
|
int32_t mndInitProfile(SMnode *pMnode) {
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
@ -94,6 +96,7 @@ int32_t mndInitProfile(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CONNECT, mndProcessConnectReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CONNECT, mndProcessConnectReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_SERVER_VERSION, mndProcessSvrVerReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn);
|
||||||
|
@ -215,36 +218,42 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
SConnObj *pConn = NULL;
|
SConnObj *pConn = NULL;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SConnectReq connReq = {0};
|
SConnectReq connReq = {0};
|
||||||
char ip[30] = {0};
|
char ip[24] = {0};
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
|
|
||||||
if (tDeserializeSConnectReq(pReq->pCont, pReq->contLen, &connReq) != 0) {
|
if (tDeserializeSConnectReq(pReq->pCont, pReq->contLen, &connReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CONN_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosIp2String(pReq->info.conn.clientIp, ip);
|
taosIp2String(pReq->info.conn.clientIp, ip);
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
mGError("user:%s, failed to login while acquire user since %s", pReq->info.conn.user, terrstr());
|
mGError("user:%s, failed to login from %s while acquire user since %s", pReq->info.conn.user, ip, terrstr());
|
||||||
goto CONN_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) {
|
|
||||||
mGError("user:%s, failed to auth while acquire user, input:%s", pReq->info.conn.user, connReq.passwd);
|
if (strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1) != 0) {
|
||||||
|
mGError("user:%s, failed to login from %s since invalid pass, input:%s", pReq->info.conn.user, ip, connReq.passwd);
|
||||||
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
||||||
goto CONN_OVER;
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CONNECT) != 0) {
|
||||||
|
mGError("user:%s, failed to login from %s since %s", pReq->info.conn.user, ip, terrstr());
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connReq.db[0]) {
|
if (connReq.db[0]) {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
snprintf(db, TSDB_DB_FNAME_LEN, "%d%s%s", pUser->acctId, TS_PATH_DELIMITER, connReq.db);
|
snprintf(db, TSDB_DB_FNAME_LEN, "%d%s%s", pUser->acctId, TS_PATH_DELIMITER, connReq.db);
|
||||||
pDb = mndAcquireDb(pMnode, db);
|
pDb = mndAcquireDb(pMnode, db);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_DB;
|
terrno = TSDB_CODE_MND_INVALID_DB;
|
||||||
mGError("user:%s, failed to login from %s while use db:%s since %s", pReq->info.conn.user, ip, connReq.db,
|
mGError("user:%s, failed to login from %s while use db:%s since %s", pReq->info.conn.user, ip, connReq.db,
|
||||||
terrstr());
|
terrstr());
|
||||||
goto CONN_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +261,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
pReq->info.conn.clientPort, connReq.pid, connReq.app, connReq.startTime);
|
pReq->info.conn.clientPort, connReq.pid, connReq.app, connReq.startTime);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
mGError("user:%s, failed to login from %s while create connection since %s", pReq->info.conn.user, ip, terrstr());
|
mGError("user:%s, failed to login from %s while create connection since %s", pReq->info.conn.user, ip, terrstr());
|
||||||
goto CONN_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConnectRsp connectRsp = {0};
|
SConnectRsp connectRsp = {0};
|
||||||
|
@ -263,14 +272,15 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
connectRsp.connType = connReq.connType;
|
connectRsp.connType = connReq.connType;
|
||||||
connectRsp.dnodeNum = mndGetDnodeSize(pMnode);
|
connectRsp.dnodeNum = mndGetDnodeSize(pMnode);
|
||||||
|
|
||||||
snprintf(connectRsp.sVersion, sizeof(connectRsp.sVersion), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo,
|
strcpy(connectRsp.sVer, version);
|
||||||
|
snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo,
|
||||||
gitinfo);
|
gitinfo);
|
||||||
mndGetMnodeEpSet(pMnode, &connectRsp.epSet);
|
mndGetMnodeEpSet(pMnode, &connectRsp.epSet);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSConnectRsp(NULL, 0, &connectRsp);
|
int32_t contLen = tSerializeSConnectRsp(NULL, 0, &connectRsp);
|
||||||
if (contLen < 0) goto CONN_OVER;
|
if (contLen < 0) goto _OVER;
|
||||||
void *pRsp = rpcMallocCont(contLen);
|
void *pRsp = rpcMallocCont(contLen);
|
||||||
if (pRsp == NULL) goto CONN_OVER;
|
if (pRsp == NULL) goto _OVER;
|
||||||
tSerializeSConnectRsp(pRsp, contLen, &connectRsp);
|
tSerializeSConnectRsp(pRsp, contLen, &connectRsp);
|
||||||
|
|
||||||
pReq->info.rspLen = contLen;
|
pReq->info.rspLen = contLen;
|
||||||
|
@ -280,7 +290,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
CONN_OVER:
|
_OVER:
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
@ -460,6 +470,27 @@ static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnIn
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndGetOnlineDnodeNum(SMnode *pMnode, int32_t *num) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
void *pIter = NULL;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||||
|
if (online) {
|
||||||
|
(*num)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pDnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq,
|
static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq,
|
||||||
SClientHbBatchRsp *pBatchRsp) {
|
SClientHbBatchRsp *pBatchRsp) {
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
@ -503,7 +534,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
||||||
|
|
||||||
rspBasic->connId = pConn->id;
|
rspBasic->connId = pConn->id;
|
||||||
rspBasic->totalDnodes = mndGetDnodeSize(pMnode);
|
rspBasic->totalDnodes = mndGetDnodeSize(pMnode);
|
||||||
rspBasic->onlineDnodes = 1; // TODO
|
mndGetOnlineDnodeNum(pMnode, &rspBasic->onlineDnodes);
|
||||||
mndGetMnodeEpSet(pMnode, &rspBasic->epSet);
|
mndGetMnodeEpSet(pMnode, &rspBasic->epSet);
|
||||||
|
|
||||||
mndCreateQnodeList(pMnode, &rspBasic->pQnodeList, -1);
|
mndCreateQnodeList(pMnode, &rspBasic->pQnodeList, -1);
|
||||||
|
@ -694,6 +725,28 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) {
|
||||||
|
int32_t code = -1;
|
||||||
|
SServerVerRsp rsp = {0};
|
||||||
|
strcpy(rsp.ver, version);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp);
|
||||||
|
if (contLen < 0) goto _over;
|
||||||
|
void *pRsp = rpcMallocCont(contLen);
|
||||||
|
if (pRsp == NULL) goto _over;
|
||||||
|
tSerializeSServerVerRsp(pRsp, contLen, &rsp);
|
||||||
|
|
||||||
|
pReq->info.rspLen = contLen;
|
||||||
|
pReq->info.rsp = pRsp;
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_over:
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
@ -279,6 +279,9 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("qnode:%d, start to create", createReq.dnodeId);
|
mDebug("qnode:%d, start to create", createReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_QNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pObj = mndAcquireQnode(pMnode, createReq.dnodeId);
|
pObj = mndAcquireQnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
|
@ -294,10 +297,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_QNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateQnode(pMnode, pReq, pDnode, &createReq);
|
code = mndCreateQnode(pMnode, pReq, pDnode, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -391,6 +390,9 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("qnode:%d, start to drop", dropReq.dnodeId);
|
mDebug("qnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_QNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropReq.dnodeId <= 0) {
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -402,10 +404,6 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_QNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndDropQnode(pMnode, pReq, pObj);
|
code = mndDropQnode(pMnode, pReq, pObj);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -418,13 +416,13 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit) {
|
int32_t mndCreateQnodeList(SMnode *pMnode, SArray **pList, int32_t limit) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SQnodeObj *pObj = NULL;
|
SQnodeObj *pObj = NULL;
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
SArray* qnodeList = taosArrayInit(5, sizeof(SQueryNodeLoad));
|
SArray *qnodeList = taosArrayInit(5, sizeof(SQueryNodeLoad));
|
||||||
if (NULL == qnodeList) {
|
if (NULL == qnodeList) {
|
||||||
mError("failed to alloc epSet while process qnode list req");
|
mError("failed to alloc epSet while process qnode list req");
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -457,7 +455,6 @@ int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t mndProcessQnodeListReq(SRpcMsg *pReq) {
|
static int32_t mndProcessQnodeListReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
|
|
@ -97,37 +97,7 @@ END:
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet* pEpSet, tmsg_t type, int32_t nodeId) {
|
int32_t mndAddSinkToTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask) {
|
||||||
SEncoder encoder;
|
|
||||||
tEncoderInit(&encoder, NULL, 0);
|
|
||||||
tEncodeSStreamTask(&encoder, pTask);
|
|
||||||
int32_t size = encoder.pos;
|
|
||||||
int32_t tlen = sizeof(SMsgHead) + size;
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
void* buf = taosMemoryCalloc(1, tlen);
|
|
||||||
if (buf == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
((SMsgHead*)buf)->vgId = htonl(nodeId);
|
|
||||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
|
||||||
tEncoderInit(&encoder, abuf, size);
|
|
||||||
tEncodeSStreamTask(&encoder, pTask);
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
|
|
||||||
STransAction action = {0};
|
|
||||||
memcpy(&action.epSet, pEpSet, sizeof(SEpSet));
|
|
||||||
action.pCont = buf;
|
|
||||||
action.contLen = tlen;
|
|
||||||
action.msgType = type;
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(buf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) {
|
|
||||||
pTask->dispatchType = TASK_DISPATCH__NONE;
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
// sink
|
// sink
|
||||||
if (pStream->smaId != 0) {
|
if (pStream->smaId != 0) {
|
||||||
|
@ -142,7 +112,7 @@ int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SS
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) {
|
int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask) {
|
||||||
pTask->sinkType = TASK_SINK__NONE;
|
pTask->sinkType = TASK_SINK__NONE;
|
||||||
if (pStream->fixedSinkVgId == 0) {
|
if (pStream->fixedSinkVgId == 0) {
|
||||||
pTask->dispatchType = TASK_DISPATCH__SHUFFLE;
|
pTask->dispatchType = TASK_DISPATCH__SHUFFLE;
|
||||||
|
@ -187,7 +157,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj*
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SSubplan* plan, const SVgObj* pVgroup) {
|
int32_t mndAssignTaskToVg(SMnode* pMnode, SStreamTask* pTask, SSubplan* plan, const SVgObj* pVgroup) {
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
pTask->nodeId = pVgroup->vgId;
|
pTask->nodeId = pVgroup->vgId;
|
||||||
pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
@ -196,11 +166,11 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS
|
||||||
plan->execNode.epSet = pTask->epSet;
|
plan->execNode.epSet = pTask->epSet;
|
||||||
|
|
||||||
if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) {
|
if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE || pTask->sinkType != TASK_SINK__NONE);
|
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE || pTask->sinkType != TASK_SINK__NONE);
|
||||||
mndPersistTaskDeployReq(pTrans, pTask, &plan->execNode.epSet, TDMT_STREAM_TASK_DEPLOY, pVgroup->vgId);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +182,7 @@ SSnodeObj* mndSchedFetchOneSnode(SMnode* pMnode) {
|
||||||
return pObj;
|
return pObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SSubplan* plan,
|
int32_t mndAssignTaskToSnode(SMnode* pMnode, SStreamTask* pTask, SSubplan* plan, const SSnodeObj* pSnode) {
|
||||||
const SSnodeObj* pSnode) {
|
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
|
|
||||||
pTask->nodeId = SNODE_HANDLE;
|
pTask->nodeId = SNODE_HANDLE;
|
||||||
|
@ -223,10 +192,10 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
|
||||||
plan->execNode.epSet = pTask->epSet;
|
plan->execNode.epSet = pTask->epSet;
|
||||||
|
|
||||||
if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) {
|
if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mndPersistTaskDeployReq(pTrans, pTask, &plan->execNode.epSet, TDMT_STREAM_TASK_DEPLOY, SNODE_HANDLE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +214,7 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, int64_t dbUid) {
|
||||||
return pVgroup;
|
return pVgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
SSdb* pSdb = pMnode->pSdb;
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
||||||
|
@ -262,6 +231,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb
|
||||||
}
|
}
|
||||||
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -290,13 +260,11 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
pTask->dispatchType = TASK_DISPATCH__NONE;
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
|
|
||||||
mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_STREAM_TASK_DEPLOY, pVgroup->vgId);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
ASSERT(pStream->fixedSinkVgId != 0);
|
ASSERT(pStream->fixedSinkVgId != 0);
|
||||||
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
||||||
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
|
@ -337,13 +305,10 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj*
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
pTask->dispatchType = TASK_DISPATCH__NONE;
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
|
|
||||||
mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_STREAM_TASK_DEPLOY, pStream->fixedSinkVg.vgId);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
SSdb* pSdb = pMnode->pSdb;
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
||||||
if (pPlan == NULL) {
|
if (pPlan == NULL) {
|
||||||
|
@ -368,9 +333,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
// add extra sink
|
// add extra sink
|
||||||
hasExtraSink = true;
|
hasExtraSink = true;
|
||||||
if (pStream->fixedSinkVgId == 0) {
|
if (pStream->fixedSinkVgId == 0) {
|
||||||
mndAddShuffleSinkTasksToStream(pMnode, pTrans, pStream);
|
if (mndAddShuffleSinkTasksToStream(pMnode, pStream) < 0) {
|
||||||
|
// TODO free
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mndAddFixedSinkTaskToStream(pMnode, pTrans, pStream);
|
if (mndAddFixedSinkTaskToStream(pMnode, pStream) < 0) {
|
||||||
|
// TODO free
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,6 +357,11 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE);
|
ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE);
|
||||||
|
|
||||||
pInnerTask = tNewSStreamTask(pStream->uid);
|
pInnerTask = tNewSStreamTask(pStream->uid);
|
||||||
|
if (pInnerTask == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
qDestroyQueryPlan(pPlan);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
mndAddTaskToTaskSet(taskInnerLevel, pInnerTask);
|
mndAddTaskToTaskSet(taskInnerLevel, pInnerTask);
|
||||||
|
|
||||||
pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*));
|
pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*));
|
||||||
|
@ -397,7 +373,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
pInnerTask->triggerParam = pStream->triggerParam;
|
pInnerTask->triggerParam = pStream->triggerParam;
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
if (mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pInnerTask) < 0) {
|
if (mndAddDispatcherToInnerTask(pMnode, pStream, pInnerTask) < 0) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -409,14 +385,13 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid);
|
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid);
|
||||||
if (mndAssignTaskToVg(pMnode, pTrans, pInnerTask, plan, pVgroup) < 0) {
|
if (mndAssignTaskToVg(pMnode, pInnerTask, plan, pVgroup) < 0) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mndAssignTaskToSnode(pMnode, pTrans, pInnerTask, plan, pSnode) < 0) {
|
if (mndAssignTaskToSnode(pMnode, pInnerTask, plan, pSnode) < 0) {
|
||||||
ASSERT(0);
|
|
||||||
sdbRelease(pSdb, pSnode);
|
sdbRelease(pSdb, pSnode);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -424,7 +399,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid);
|
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid);
|
||||||
if (mndAssignTaskToVg(pMnode, pTrans, pInnerTask, plan, pVgroup) < 0) {
|
if (mndAssignTaskToVg(pMnode, pInnerTask, plan, pVgroup) < 0) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -450,6 +425,12 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
|
if (pInnerTask == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
qDestroyQueryPlan(pPlan);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
mndAddTaskToTaskSet(taskSourceLevel, pTask);
|
mndAddTaskToTaskSet(taskSourceLevel, pTask);
|
||||||
|
|
||||||
// source
|
// source
|
||||||
|
@ -466,7 +447,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
pTask->execType = TASK_EXEC__PIPE;
|
pTask->execType = TASK_EXEC__PIPE;
|
||||||
if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) {
|
if (mndAssignTaskToVg(pMnode, pTask, plan, pVgroup) < 0) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -507,6 +488,11 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
|
if (pTask == NULL) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
qDestroyQueryPlan(pPlan);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
mndAddTaskToTaskSet(taskOneLevel, pTask);
|
mndAddTaskToTaskSet(taskOneLevel, pTask);
|
||||||
|
|
||||||
// source
|
// source
|
||||||
|
@ -517,14 +503,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
|
|
||||||
// sink or dispatch
|
// sink or dispatch
|
||||||
if (hasExtraSink) {
|
if (hasExtraSink) {
|
||||||
mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pTask);
|
mndAddDispatcherToInnerTask(pMnode, pStream, pTask);
|
||||||
} else {
|
} else {
|
||||||
mndAddSinkToTask(pMnode, pTrans, pStream, pTask);
|
mndAddSinkToTask(pMnode, pStream, pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
pTask->execType = TASK_EXEC__PIPE;
|
pTask->execType = TASK_EXEC__PIPE;
|
||||||
if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) {
|
if (mndAssignTaskToVg(pMnode, pTask, plan, pVgroup) < 0) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -533,7 +533,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
#if 0
|
#if 0
|
||||||
smaObj.timezone = pCreate->timezone;
|
smaObj.timezone = pCreate->timezone;
|
||||||
#endif
|
#endif
|
||||||
smaObj.timezone = tsTimezone; // use timezone of server
|
smaObj.timezone = tsTimezone; // use timezone of server
|
||||||
smaObj.interval = pCreate->interval;
|
smaObj.interval = pCreate->interval;
|
||||||
smaObj.offset = pCreate->offset;
|
smaObj.offset = pCreate->offset;
|
||||||
smaObj.sliding = pCreate->sliding;
|
smaObj.sliding = pCreate->sliding;
|
||||||
|
@ -623,7 +623,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndScheduleStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
if (mndScheduleStream(pMnode, &streamObj) != 0) goto _OVER;
|
||||||
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,9 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("snode:%d, start to create", createReq.dnodeId);
|
mDebug("snode:%d, start to create", createReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_SNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pObj = mndAcquireSnode(pMnode, createReq.dnodeId);
|
pObj = mndAcquireSnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
|
@ -300,10 +303,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_SNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateSnode(pMnode, pReq, pDnode, &createReq);
|
code = mndCreateSnode(pMnode, pReq, pDnode, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -398,6 +397,9 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("snode:%d, start to drop", dropReq.dnodeId);
|
mDebug("snode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_SNODE) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropReq.dnodeId <= 0) {
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -409,10 +411,6 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_SNODE) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check deletable
|
// check deletable
|
||||||
code = mndDropSnode(pMnode, pReq, pObj);
|
code = mndDropSnode(pMnode, pReq, pObj);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
|
@ -320,11 +320,62 @@ FAIL:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndPersistTaskDeployReq(STrans *pTrans, const SStreamTask *pTask) {
|
||||||
|
ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1);
|
||||||
|
if (pTask->isDataScan == 0 && pTask->sinkType == TASK_SINK__NONE) {
|
||||||
|
ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0);
|
||||||
|
}
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, NULL, 0);
|
||||||
|
tEncodeSStreamTask(&encoder, pTask);
|
||||||
|
int32_t size = encoder.pos;
|
||||||
|
int32_t tlen = sizeof(SMsgHead) + size;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
void *buf = taosMemoryCalloc(1, tlen);
|
||||||
|
if (buf == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
((SMsgHead *)buf)->vgId = htonl(pTask->nodeId);
|
||||||
|
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
|
tEncoderInit(&encoder, abuf, size);
|
||||||
|
tEncodeSStreamTask(&encoder, pTask);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
STransAction action = {0};
|
||||||
|
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
||||||
|
action.pCont = buf;
|
||||||
|
action.contLen = tlen;
|
||||||
|
action.msgType = TDMT_STREAM_TASK_DEPLOY;
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndPersistStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
int32_t level = taosArrayGetSize(pStream->tasks);
|
||||||
|
for (int32_t i = 0; i < level; i++) {
|
||||||
|
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
||||||
|
int32_t sz = taosArrayGetSize(pLevel);
|
||||||
|
for (int32_t j = 0; j < sz; j++) {
|
||||||
|
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
||||||
|
if (mndPersistTaskDeployReq(pTrans, pTask) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
if (mndPersistStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
||||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||||
|
@ -342,51 +393,6 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) {
|
|
||||||
SNode *pAst = NULL;
|
|
||||||
|
|
||||||
if (nodesStringToNode(ast, &pAst) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qExtractResultSchema(pAst, (int32_t *)&pStream->outputSchema.nCols, &pStream->outputSchema.pSchema) != 0) {
|
|
||||||
nodesDestroyNode(pAst);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// free
|
|
||||||
nodesDestroyNode(pAst);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("|");
|
|
||||||
for (int i = 0; i < pStream->outputSchema.nCols; i++) {
|
|
||||||
printf(" %15s |", (char *)pStream->outputSchema.pSchema[i].name);
|
|
||||||
}
|
|
||||||
printf("\n=======================================================\n");
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != mndStreamGetPlanString(ast, pStream->trigger, pStream->watermark, &pStream->physicalPlan)) {
|
|
||||||
mError("topic:%s, failed to get plan since %s", pStream->name, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndScheduleStream(pMnode, pTrans, pStream) < 0) {
|
|
||||||
mError("stream:%ld, schedule stream since %s", pStream->uid, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
mDebug("trans:%d, used to create stream:%s", pTrans->id, pStream->name);
|
|
||||||
|
|
||||||
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
|
||||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
|
||||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
@ -503,64 +509,6 @@ static int32_t mndDropStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pS
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq *pCreate, SDbObj *pDb) {
|
|
||||||
mDebug("stream:%s to create", pCreate->name);
|
|
||||||
SStreamObj streamObj = {0};
|
|
||||||
tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN);
|
|
||||||
tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN);
|
|
||||||
tstrncpy(streamObj.targetSTbName, pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
|
||||||
streamObj.createTime = taosGetTimestampMs();
|
|
||||||
streamObj.updateTime = streamObj.createTime;
|
|
||||||
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
|
||||||
streamObj.targetStbUid = mndGenerateUid(pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
|
||||||
streamObj.sourceDbUid = pDb->uid;
|
|
||||||
streamObj.version = 1;
|
|
||||||
streamObj.sql = pCreate->sql;
|
|
||||||
// TODO
|
|
||||||
streamObj.fixedSinkVgId = 0;
|
|
||||||
streamObj.smaId = 0;
|
|
||||||
streamObj.trigger = pCreate->triggerType;
|
|
||||||
streamObj.watermark = pCreate->watermark;
|
|
||||||
streamObj.triggerParam = pCreate->maxDelay;
|
|
||||||
|
|
||||||
if (streamObj.targetSTbName[0]) {
|
|
||||||
pDb = mndAcquireDbByStb(pMnode, streamObj.targetSTbName);
|
|
||||||
if (pDb == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
tstrncpy(streamObj.targetDb, pDb->name, TSDB_DB_FNAME_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
|
||||||
if (pTrans == NULL) {
|
|
||||||
mError("stream:%s, failed to create since %s", pCreate->name, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
mDebug("trans:%d, used to create stream:%s", pTrans->id, pCreate->name);
|
|
||||||
|
|
||||||
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pTrans) != 0) {
|
|
||||||
mError("trans:%d, failed to add stream since %s", pTrans->id, terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (streamObj.targetSTbName[0] && mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
|
||||||
mError("trans:%d, failed to create stb for stream since %s", pTrans->id, terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -631,7 +579,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// schedule stream task for stream obj
|
// schedule stream task for stream obj
|
||||||
if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) {
|
if (mndScheduleStream(pMnode, &streamObj) < 0) {
|
||||||
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -653,8 +601,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
/*code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);*/
|
|
||||||
/*if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;*/
|
|
||||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -198,6 +198,10 @@ int32_t mndInitSync(SMnode *pMnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// decrease election timer
|
||||||
|
setElectTimerMS(pMgmt->sync, 600);
|
||||||
|
setHeartbeatTimerMS(pMgmt->sync, 300);
|
||||||
|
|
||||||
mDebug("mnode-sync is opened, id:%" PRId64, pMgmt->sync);
|
mDebug("mnode-sync is opened, id:%" PRId64, pMgmt->sync);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +265,8 @@ bool mndIsMaster(SMnode *pMnode) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
|
|
||||||
if (!syncIsReady(pMgmt->sync)) {
|
if (!syncIsReady(pMgmt->sync)) {
|
||||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
// get terrno from syncIsReady
|
||||||
|
// terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
userObj.createdTime = taosGetTimestampMs();
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
userObj.superUser = pCreate->superUser;
|
userObj.superUser = 0;//pCreate->superUser;
|
||||||
userObj.sysInfo = pCreate->sysInfo;
|
userObj.sysInfo = pCreate->sysInfo;
|
||||||
userObj.enable = pCreate->enable;
|
userObj.enable = pCreate->enable;
|
||||||
|
|
||||||
|
|
|
@ -1212,8 +1212,9 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("vgId:%d, start to redistribute vgroup to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
mInfo("vgId:%d, start to redistribute vgroup to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) {
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) goto _OVER;
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
||||||
if (pVgroup == NULL) goto _OVER;
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
@ -1506,6 +1507,9 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
|
||||||
mDebug("vgId:%d, start to split", vgId);
|
mDebug("vgId:%d, start to split", vgId);
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_SPLIT_VGROUP) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, vgId);
|
pVgroup = mndAcquireVgroup(pMnode, vgId);
|
||||||
if (pVgroup == NULL) goto _OVER;
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
@ -1513,8 +1517,6 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
||||||
if (pDb == NULL) goto _OVER;
|
if (pDb == NULL) goto _OVER;
|
||||||
|
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_SPLIT_VGROUP) != 0) goto _OVER;
|
|
||||||
|
|
||||||
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
@ -1655,8 +1657,9 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("start to balance vgroup");
|
mInfo("start to balance vgroup");
|
||||||
|
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_BALANCE_VGROUP) != 0) {
|
||||||
if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_BALANCE_VGROUP) != 0) goto _OVER;
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME dbTest
|
||||||
NAME dbTest
|
COMMAND dbTest
|
||||||
COMMAND dbTest
|
)
|
||||||
)
|
|
||||||
endif(NOT TD_WINDOWS)
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
# if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME funcTest
|
||||||
NAME funcTest
|
COMMAND funcTest
|
||||||
COMMAND funcTest
|
)
|
||||||
)
|
|
||||||
# endif(NOT TD_WINDOWS)
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
# if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME profileTest
|
||||||
NAME profileTest
|
COMMAND profileTest
|
||||||
COMMAND profileTest
|
)
|
||||||
)
|
|
||||||
# endif(NOT TD_WINDOWS)
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
# if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME showTest
|
||||||
NAME showTest
|
COMMAND showTest
|
||||||
COMMAND showTest
|
)
|
||||||
)
|
|
||||||
# endif(NOT TD_WINDOWS)
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME smaTest
|
||||||
NAME smaTest
|
COMMAND smaTest
|
||||||
COMMAND smaTest
|
)
|
||||||
)
|
|
||||||
endif(NOT TD_WINDOWS)
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME stbTest
|
||||||
NAME stbTest
|
COMMAND stbTest
|
||||||
COMMAND stbTest
|
)
|
||||||
)
|
|
||||||
endif(NOT TD_WINDOWS)
|
|
|
@ -5,9 +5,7 @@ target_link_libraries(
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT TD_WINDOWS)
|
add_test(
|
||||||
add_test(
|
NAME userTest
|
||||||
NAME userTest
|
COMMAND userTest
|
||||||
COMMAND userTest
|
)
|
||||||
)
|
|
||||||
endif(NOT TD_WINDOWS)
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ TEST_F(MndTestUser, 01_Show_User) {
|
||||||
TEST_F(MndTestUser, 02_Create_User) {
|
TEST_F(MndTestUser, 02_Create_User) {
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "");
|
strcpy(createReq.user, "");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
|
@ -47,6 +49,8 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "");
|
strcpy(createReq.pass, "");
|
||||||
|
|
||||||
|
@ -61,6 +65,8 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "root");
|
strcpy(createReq.user, "root");
|
||||||
strcpy(createReq.pass, "1");
|
strcpy(createReq.pass, "1");
|
||||||
|
|
||||||
|
@ -75,6 +81,8 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
|
@ -108,9 +116,11 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u2");
|
strcpy(createReq.user, "u2");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
createReq.superUser = 1;
|
createReq.superUser = 0;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -144,9 +154,11 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
TEST_F(MndTestUser, 03_Alter_User) {
|
TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u3");
|
strcpy(createReq.user, "u3");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
createReq.superUser = 1;
|
createReq.superUser = 0;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -225,7 +237,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
alterReq.alterType = TSDB_ALTER_USER_SUPERUSER;
|
alterReq.alterType = TSDB_ALTER_USER_SUPERUSER;
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
alterReq.superUser = 1;
|
alterReq.superUser = 0;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -361,7 +373,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
SGetUserAuthRsp authRsp = {0};
|
SGetUserAuthRsp authRsp = {0};
|
||||||
tDeserializeSGetUserAuthRsp(pRsp->pCont, pRsp->contLen, &authRsp);
|
tDeserializeSGetUserAuthRsp(pRsp->pCont, pRsp->contLen, &authRsp);
|
||||||
EXPECT_STREQ(authRsp.user, "u3");
|
EXPECT_STREQ(authRsp.user, "u3");
|
||||||
EXPECT_EQ(authRsp.superAuth, 1);
|
EXPECT_EQ(authRsp.superAuth, 0);
|
||||||
int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs);
|
int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs);
|
||||||
int32_t numOfWriteDbs = taosHashGetSize(authRsp.writeDbs);
|
int32_t numOfWriteDbs = taosHashGetSize(authRsp.writeDbs);
|
||||||
EXPECT_EQ(numOfReadDbs, 1);
|
EXPECT_EQ(numOfReadDbs, 1);
|
||||||
|
@ -436,6 +448,8 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
|
@ -468,6 +482,8 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
|
@ -482,6 +498,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
createReq.enable = 1;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
strcpy(createReq.user, "u2");
|
strcpy(createReq.user, "u2");
|
||||||
strcpy(createReq.pass, "p2");
|
strcpy(createReq.pass, "p2");
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,8 @@ typedef void *tsdbReaderT;
|
||||||
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
||||||
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
||||||
|
|
||||||
tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *tableInfoGroup, uint64_t qId,
|
int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList);
|
||||||
|
tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableList, uint64_t qId,
|
||||||
uint64_t taskId);
|
uint64_t taskId);
|
||||||
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *groupList, uint64_t qId,
|
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *groupList, uint64_t qId,
|
||||||
void *pMemRef);
|
void *pMemRef);
|
||||||
|
@ -195,7 +196,6 @@ struct SVnodeCfg {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TSKEY lastKey;
|
TSKEY lastKey;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
uint64_t groupId;
|
|
||||||
} STableKeyInfo;
|
} STableKeyInfo;
|
||||||
|
|
||||||
struct SMetaEntry {
|
struct SMetaEntry {
|
||||||
|
|
|
@ -121,7 +121,7 @@ int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSub
|
||||||
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
||||||
SSubmitBlkRsp* pRsp);
|
SSubmitBlkRsp* pRsp);
|
||||||
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||||
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId,
|
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId,
|
||||||
uint64_t taskId);
|
uint64_t taskId);
|
||||||
tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId,
|
tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId,
|
||||||
void* pMemRef);
|
void* pMemRef);
|
||||||
|
|
|
@ -381,6 +381,7 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
|
||||||
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
||||||
tb_uid_t *uid = (tb_uid_t *)taosArrayGet(tbUids, i);
|
tb_uid_t *uid = (tb_uid_t *)taosArrayGet(tbUids, i);
|
||||||
metaDropTableByUid(pMeta, *uid, NULL);
|
metaDropTableByUid(pMeta, *uid, NULL);
|
||||||
|
metaDebug("ttl drop table:%"PRId64, *uid);
|
||||||
}
|
}
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -443,7 +444,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
// drop schema.db (todo)
|
// drop schema.db (todo)
|
||||||
}
|
}
|
||||||
|
|
||||||
metaError("ttl drop table:%s", e.name);
|
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
||||||
|
@ -976,7 +976,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
|
||||||
// get super table
|
// get super table
|
||||||
tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData);
|
if(tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData) != 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
tbDbKey.uid = pCtbEntry->ctbEntry.suid;
|
tbDbKey.uid = pCtbEntry->ctbEntry.suid;
|
||||||
tbDbKey.version = *(int64_t *)pData;
|
tbDbKey.version = *(int64_t *)pData;
|
||||||
tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData);
|
tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData);
|
||||||
|
|
|
@ -403,7 +403,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
.reader = pHandle->execHandle.pExecReader[i],
|
.reader = pHandle->execHandle.pExecReader[i],
|
||||||
.meta = pTq->pVnode->pMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
.vnode = pTq->pVnode,
|
.vnode = pTq->pVnode,
|
||||||
.initTsdbReader = 1,
|
// .initTsdbReader = 1,
|
||||||
};
|
};
|
||||||
pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
|
pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
|
||||||
ASSERT(pHandle->execHandle.execCol.task[i]);
|
ASSERT(pHandle->execHandle.execCol.task[i]);
|
||||||
|
@ -455,6 +455,9 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1);
|
ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1);
|
||||||
|
if (pTask->isDataScan == 0 && pTask->sinkType == TASK_SINK__NONE) {
|
||||||
|
ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
||||||
|
|
||||||
|
@ -476,7 +479,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
.reader = pStreamReader,
|
.reader = pStreamReader,
|
||||||
.meta = pTq->pVnode->pMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
.vnode = pTq->pVnode,
|
.vnode = pTq->pVnode,
|
||||||
.initTsdbReader = 1,
|
// .initTsdbReader = 1,
|
||||||
};
|
};
|
||||||
/*pTask->exec.inputHandle = pStreamReader;*/
|
/*pTask->exec.inputHandle = pStreamReader;*/
|
||||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||||
|
|
|
@ -146,8 +146,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
|
||||||
int32_t* pNumOfRows) {
|
int32_t* pNumOfRows) {
|
||||||
*pUid = 0;
|
*pUid = 0;
|
||||||
|
|
||||||
// TODO set to real sversion
|
// TODO: cache multiple schema
|
||||||
/*int32_t sversion = 1;*/
|
|
||||||
int32_t sversion = htonl(pHandle->pBlock->sversion);
|
int32_t sversion = htonl(pHandle->pBlock->sversion);
|
||||||
if (pHandle->cachedSchemaSuid == 0 || pHandle->cachedSchemaVer != sversion ||
|
if (pHandle->cachedSchemaSuid == 0 || pHandle->cachedSchemaVer != sversion ||
|
||||||
pHandle->cachedSchemaSuid != pHandle->msgIter.suid) {
|
pHandle->cachedSchemaSuid != pHandle->msgIter.suid) {
|
||||||
|
@ -161,7 +160,6 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this interface use suid instead of uid
|
|
||||||
if (pHandle->pSchemaWrapper) tDeleteSSchemaWrapper(pHandle->pSchemaWrapper);
|
if (pHandle->pSchemaWrapper) tDeleteSSchemaWrapper(pHandle->pSchemaWrapper);
|
||||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion, true);
|
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion, true);
|
||||||
if (pHandle->pSchemaWrapper == NULL) {
|
if (pHandle->pSchemaWrapper == NULL) {
|
||||||
|
@ -245,7 +243,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
|
||||||
if (!tdSTSRowIterNext(&iter, pColData->info.colId, pColData->info.type, &sVal)) {
|
if (!tdSTSRowIterNext(&iter, pColData->info.colId, pColData->info.type, &sVal)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {
|
if (colDataAppend(pColData, curRow, sVal.val, sVal.valType != TD_VTYPE_NORM) < 0) {
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,9 +223,8 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, STableListInfo* pTableList) {
|
static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) {
|
||||||
size_t tableSize = taosArrayGetSize(pTableList->pTableList);
|
size_t tableSize = taosArrayGetSize(pTableList);
|
||||||
assert(tableSize >= 1);
|
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
SArray* pTableCheckInfo = taosArrayInit(tableSize, sizeof(STableCheckInfo));
|
SArray* pTableCheckInfo = taosArrayInit(tableSize, sizeof(STableCheckInfo));
|
||||||
|
@ -235,7 +234,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
|
||||||
|
|
||||||
// todo apply the lastkey of table check to avoid to load header file
|
// todo apply the lastkey of table check to avoid to load header file
|
||||||
for (int32_t j = 0; j < tableSize; ++j) {
|
for (int32_t j = 0; j < tableSize; ++j) {
|
||||||
STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(pTableList->pTableList, j);
|
STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(pTableList, j);
|
||||||
|
|
||||||
STableCheckInfo info = {.lastKey = pKeyInfo->lastKey, .tableId = pKeyInfo->uid};
|
STableCheckInfo info = {.lastKey = pKeyInfo->lastKey, .tableId = pKeyInfo->uid};
|
||||||
info.suid = pTsdbReadHandle->suid;
|
info.suid = pTsdbReadHandle->suid;
|
||||||
|
@ -254,8 +253,6 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
|
||||||
pTsdbReadHandle->idStr);
|
pTsdbReadHandle->idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO group table according to the tag value.
|
|
||||||
taosArraySort(pTableCheckInfo, tsdbCheckInfoCompar);
|
|
||||||
return pTableCheckInfo;
|
return pTableCheckInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +494,21 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId,
|
int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){
|
||||||
|
STsdbReadHandle* pTsdbReadHandle = reader;
|
||||||
|
if(pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo);
|
||||||
|
pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, tableList);
|
||||||
|
if (pTsdbReadHandle->pTableCheckInfo == NULL) {
|
||||||
|
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return TDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId,
|
||||||
uint64_t taskId) {
|
uint64_t taskId) {
|
||||||
|
if(taosArrayGetSize(tableList) == 0){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId);
|
||||||
if (pTsdbReadHandle == NULL) {
|
if (pTsdbReadHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -543,7 +553,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLis
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle,
|
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle,
|
||||||
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList->pTableList),
|
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList),
|
||||||
pTsdbReadHandle->idStr);
|
pTsdbReadHandle->idStr);
|
||||||
|
|
||||||
return (tsdbReaderT)pTsdbReadHandle;
|
return (tsdbReaderT)pTsdbReadHandle;
|
||||||
|
@ -639,7 +649,7 @@ tsdbReaderT tsdbQueryLastRow(SVnode* pVnode, SQueryTableDataCond* pCond, STableL
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbReaderOpen(pVnode, pCond, pList, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbReaderOpen(pVnode, pCond, pList->pTableList, qId, taskId);
|
||||||
if (pTsdbReadHandle == NULL) {
|
if (pTsdbReadHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2842,7 +2852,7 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id, .groupId = 0};
|
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id};
|
||||||
taosArrayPush(list, &info);
|
taosArrayPush(list, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3644,17 +3654,6 @@ SArray* tsdbRetrieveDataBlock(tsdbReaderT* pTsdbReadHandle, SArray* pIdList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbCheckInfoCompar(const void* key1, const void* key2) {
|
|
||||||
if (((STableCheckInfo*)key1)->tableId < ((STableCheckInfo*)key2)->tableId) {
|
|
||||||
return -1;
|
|
||||||
} else if (((STableCheckInfo*)key1)->tableId > ((STableCheckInfo*)key2)->tableId) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
ASSERT(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* doFreeColumnInfoData(SArray* pColumnInfoData) {
|
static void* doFreeColumnInfoData(SArray* pColumnInfoData) {
|
||||||
if (pColumnInfoData == NULL) {
|
if (pColumnInfoData == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -144,11 +144,15 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
||||||
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
SEpSet newEpSet = {0};
|
SEpSet newEpSet = {0};
|
||||||
|
syncGetRetryEpSet(pVnode->sync, &newEpSet);
|
||||||
|
|
||||||
|
/*
|
||||||
syncGetEpSet(pVnode->sync, &newEpSet);
|
syncGetEpSet(pVnode->sync, &newEpSet);
|
||||||
SEp *pEp = &newEpSet.eps[newEpSet.inUse];
|
SEp *pEp = &newEpSet.eps[newEpSet.inUse];
|
||||||
if (pEp->port == tsServerPort && strcmp(pEp->fqdn, tsLocalFqdn) == 0) {
|
if (pEp->port == tsServerPort && strcmp(pEp->fqdn, tsLocalFqdn) == 0) {
|
||||||
newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps;
|
newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
vGTrace("vgId:%d, msg:%p is redirect since not leader, numOfEps:%d inUse:%d", vgId, pMsg, newEpSet.numOfEps,
|
vGTrace("vgId:%d, msg:%p is redirect since not leader, numOfEps:%d inUse:%d", vgId, pMsg, newEpSet.numOfEps,
|
||||||
newEpSet.inUse);
|
newEpSet.inUse);
|
||||||
|
|
|
@ -76,6 +76,7 @@ typedef enum {
|
||||||
CTG_TASK_GET_INDEX,
|
CTG_TASK_GET_INDEX,
|
||||||
CTG_TASK_GET_UDF,
|
CTG_TASK_GET_UDF,
|
||||||
CTG_TASK_GET_USER,
|
CTG_TASK_GET_USER,
|
||||||
|
CTG_TASK_GET_SVR_VER,
|
||||||
} CTG_TASK_TYPE;
|
} CTG_TASK_TYPE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -224,6 +225,7 @@ typedef struct SCtgJob {
|
||||||
int32_t dbInfoNum;
|
int32_t dbInfoNum;
|
||||||
int32_t tbIndexNum;
|
int32_t tbIndexNum;
|
||||||
int32_t tbCfgNum;
|
int32_t tbCfgNum;
|
||||||
|
int32_t svrVerNum;
|
||||||
} SCtgJob;
|
} SCtgJob;
|
||||||
|
|
||||||
typedef struct SCtgMsgCtx {
|
typedef struct SCtgMsgCtx {
|
||||||
|
@ -578,8 +580,9 @@ int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
||||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask);
|
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask);
|
||||||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
||||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
|
||||||
|
|
||||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum);
|
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum);
|
||||||
int32_t ctgLaunchJob(SCtgJob *pJob);
|
int32_t ctgLaunchJob(SCtgJob *pJob);
|
||||||
int32_t ctgMakeAsyncRes(SCtgJob *pJob);
|
int32_t ctgMakeAsyncRes(SCtgJob *pJob);
|
||||||
int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param);
|
int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param);
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId) {
|
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pConn || NULL == pReq || NULL == fp || NULL == param) {
|
if (NULL == pCtg || NULL == pConn || NULL == pReq || NULL == fp || NULL == param) {
|
||||||
|
@ -1060,7 +1060,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, uint64_t
|
||||||
|
|
||||||
int32_t code = 0, taskNum = 0;
|
int32_t code = 0, taskNum = 0;
|
||||||
SCtgJob *pJob = NULL;
|
SCtgJob *pJob = NULL;
|
||||||
CTG_ERR_JRET(ctgInitJob(pCtg, pConn, &pJob, reqId, pReq, fp, param, &taskNum));
|
CTG_ERR_JRET(ctgInitJob(pCtg, pConn, &pJob, pReq, fp, param, &taskNum));
|
||||||
if (taskNum <= 0) {
|
if (taskNum <= 0) {
|
||||||
SMetaData* pMetaData = taosMemoryCalloc(1, sizeof(SMetaData));
|
SMetaData* pMetaData = taosMemoryCalloc(1, sizeof(SMetaData));
|
||||||
fp(pMetaData, param, TSDB_CODE_SUCCESS);
|
fp(pMetaData, param, TSDB_CODE_SUCCESS);
|
||||||
|
@ -1247,6 +1247,22 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
if (NULL == pCtg || NULL == pConn || NULL == pVersion) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
CTG_ERR_JRET(ctgGetSvrVerFromMnode(pCtg, pConn, pVersion, NULL));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) {
|
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,20 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgInitGetSvrVerTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
|
SCtgTask task = {0};
|
||||||
|
|
||||||
|
task.type = CTG_TASK_GET_SVR_VER;
|
||||||
|
task.taskId = taskIdx;
|
||||||
|
task.pJob = pJob;
|
||||||
|
|
||||||
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
|
qDebug("QID:0x%" PRIx64 " [%dth] task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
SName *name = (SName*)param;
|
SName *name = (SName*)param;
|
||||||
SCtgTask task = {0};
|
SCtgTask task = {0};
|
||||||
|
@ -413,7 +427,7 @@ int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *tas
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum) {
|
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t tbMetaNum = (int32_t)taosArrayGetSize(pReq->pTableMeta);
|
int32_t tbMetaNum = (int32_t)taosArrayGetSize(pReq->pTableMeta);
|
||||||
int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup);
|
int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup);
|
||||||
|
@ -421,6 +435,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6
|
||||||
int32_t udfNum = (int32_t)taosArrayGetSize(pReq->pUdf);
|
int32_t udfNum = (int32_t)taosArrayGetSize(pReq->pUdf);
|
||||||
int32_t qnodeNum = pReq->qNodeRequired ? 1 : 0;
|
int32_t qnodeNum = pReq->qNodeRequired ? 1 : 0;
|
||||||
int32_t dnodeNum = pReq->dNodeRequired ? 1 : 0;
|
int32_t dnodeNum = pReq->dNodeRequired ? 1 : 0;
|
||||||
|
int32_t svrVerNum = pReq->svrVerRequired ? 1 : 0;
|
||||||
int32_t dbCfgNum = (int32_t)taosArrayGetSize(pReq->pDbCfg);
|
int32_t dbCfgNum = (int32_t)taosArrayGetSize(pReq->pDbCfg);
|
||||||
int32_t indexNum = (int32_t)taosArrayGetSize(pReq->pIndex);
|
int32_t indexNum = (int32_t)taosArrayGetSize(pReq->pIndex);
|
||||||
int32_t userNum = (int32_t)taosArrayGetSize(pReq->pUser);
|
int32_t userNum = (int32_t)taosArrayGetSize(pReq->pUser);
|
||||||
|
@ -428,21 +443,21 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6
|
||||||
int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex);
|
int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex);
|
||||||
int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg);
|
int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg);
|
||||||
|
|
||||||
*taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum;
|
*taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum;
|
||||||
if (*taskNum <= 0) {
|
if (*taskNum <= 0) {
|
||||||
ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, reqId);
|
ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, pConn->requestId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
*job = taosMemoryCalloc(1, sizeof(SCtgJob));
|
*job = taosMemoryCalloc(1, sizeof(SCtgJob));
|
||||||
if (NULL == *job) {
|
if (NULL == *job) {
|
||||||
ctgError("failed to calloc, size:%d, reqId:0x%" PRIx64, (int32_t)sizeof(SCtgJob), reqId);
|
ctgError("failed to calloc, size:%d, reqId:0x%" PRIx64, (int32_t)sizeof(SCtgJob), pConn->requestId);
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCtgJob *pJob = *job;
|
SCtgJob *pJob = *job;
|
||||||
|
|
||||||
pJob->queryId = reqId;
|
pJob->queryId = pConn->requestId;
|
||||||
pJob->userFp = fp;
|
pJob->userFp = fp;
|
||||||
pJob->pCtg = pCtg;
|
pJob->pCtg = pCtg;
|
||||||
pJob->conn = *pConn;
|
pJob->conn = *pConn;
|
||||||
|
@ -460,6 +475,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6
|
||||||
pJob->dbInfoNum = dbInfoNum;
|
pJob->dbInfoNum = dbInfoNum;
|
||||||
pJob->tbIndexNum = tbIndexNum;
|
pJob->tbIndexNum = tbIndexNum;
|
||||||
pJob->tbCfgNum = tbCfgNum;
|
pJob->tbCfgNum = tbCfgNum;
|
||||||
|
pJob->svrVerNum = svrVerNum;
|
||||||
|
|
||||||
pJob->pTasks = taosArrayInit(*taskNum, sizeof(SCtgTask));
|
pJob->pTasks = taosArrayInit(*taskNum, sizeof(SCtgTask));
|
||||||
|
|
||||||
|
@ -530,6 +546,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6
|
||||||
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DNODE, NULL, NULL));
|
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DNODE, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (svrVerNum) {
|
||||||
|
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_SVR_VER, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
pJob->refId = taosAddRef(gCtgMgmt.jobPool, pJob);
|
pJob->refId = taosAddRef(gCtgMgmt.jobPool, pJob);
|
||||||
if (pJob->refId < 0) {
|
if (pJob->refId < 0) {
|
||||||
ctgError("add job to ref failed, error: %s", tstrerror(terrno));
|
ctgError("add job to ref failed, error: %s", tstrerror(terrno));
|
||||||
|
@ -728,6 +748,21 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgDumpSvrVer(SCtgTask* pTask) {
|
||||||
|
SCtgJob* pJob = pTask->pJob;
|
||||||
|
if (NULL == pJob->jobRes.pSvrVer) {
|
||||||
|
pJob->jobRes.pSvrVer = taosMemoryCalloc(1, sizeof(SMetaRes));
|
||||||
|
if (NULL == pJob->jobRes.pSvrVer) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pJob->jobRes.pSvrVer->code = pTask->code;
|
||||||
|
pJob->jobRes.pSvrVer->pRes = pTask->res;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgInvokeSubCb(SCtgTask *pTask) {
|
int32_t ctgInvokeSubCb(SCtgTask *pTask) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1156,6 +1191,20 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgHandleGetSvrVerRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
|
||||||
|
|
||||||
|
TSWAP(pTask->res, pTask->msgCtx.out);
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
ctgHandleTaskEnd(pTask, code);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
|
int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
|
||||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||||
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||||
|
@ -1459,6 +1508,15 @@ int32_t ctgLaunchGetUserTask(SCtgTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgLaunchGetSvrVerTask(SCtgTask *pTask) {
|
||||||
|
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||||
|
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgGetSvrVerFromMnode(pCtg, pConn, NULL, pTask));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) {
|
int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) {
|
||||||
ctgResetTbMetaTask(pTask);
|
ctgResetTbMetaTask(pTask);
|
||||||
|
|
||||||
|
@ -1532,6 +1590,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
|
||||||
{ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL},
|
{ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL},
|
||||||
{ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL},
|
{ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL},
|
||||||
{ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL},
|
{ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL},
|
||||||
|
{ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t ctgMakeAsyncRes(SCtgJob *pJob) {
|
int32_t ctgMakeAsyncRes(SCtgJob *pJob) {
|
||||||
|
@ -1633,7 +1692,7 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
|
||||||
for (int32_t i = 0; i < taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, i);
|
SCtgTask *pTask = taosArrayGet(pJob->pTasks, i);
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " ctg start to launch task %d", pJob->queryId, pTask->taskId);
|
qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId);
|
||||||
CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask));
|
CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask));
|
||||||
pTask->status = CTG_TASK_LAUNCHED;
|
pTask->status = CTG_TASK_LAUNCHED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re
|
||||||
|
|
||||||
int64_t jobId = 0;
|
int64_t jobId = 0;
|
||||||
|
|
||||||
CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pConn, reqId, &req, ctgdUserCallback, param, &jobId));
|
CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pConn, &req, ctgdUserCallback, param, &jobId));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,21 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
||||||
qDebug("Got stb cfg from mnode, tbFName:%s", target);
|
qDebug("Got stb cfg from mnode, tbFName:%s", target);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case TDMT_MND_SERVER_VERSION: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for svr ver from mnode, error:%s", tstrerror(rspCode));
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process svr ver rsp failed, error:%s", tstrerror(code));
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got svr ver from mnode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
qError("invalid req type %s", TMSG_INFO(reqType));
|
qError("invalid req type %s", TMSG_INFO(reqType));
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
@ -811,4 +826,38 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_SERVER_VERSION;
|
||||||
|
void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||||
|
|
||||||
|
qDebug("try to get svr ver from mnode");
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](NULL, &msg, 0, &msgLen, mallocFp);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build get svr ver msg failed, code:%s", tstrerror(code));
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pConn->pTrans, &pConn->mgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, NULL));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
||||||
return "[get udf]";
|
return "[get udf]";
|
||||||
case CTG_TASK_GET_USER:
|
case CTG_TASK_GET_USER:
|
||||||
return "[get user]";
|
return "[get user]";
|
||||||
|
case CTG_TASK_GET_SVR_VER:
|
||||||
|
return "[get svr ver]";
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -103,8 +105,13 @@ void ctgFreeSMetaData(SMetaData* pData) {
|
||||||
taosArrayDestroy(pData->pQnodeList);
|
taosArrayDestroy(pData->pQnodeList);
|
||||||
pData->pQnodeList = NULL;
|
pData->pQnodeList = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pDnodeList);
|
||||||
|
pData->pDnodeList = NULL;
|
||||||
|
|
||||||
taosArrayDestroy(pData->pTableCfg);
|
taosArrayDestroy(pData->pTableCfg);
|
||||||
pData->pTableCfg = NULL;
|
pData->pTableCfg = NULL;
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pData->pSvrVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) {
|
void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) {
|
||||||
|
@ -346,20 +353,8 @@ void ctgResetTbMetaTask(SCtgTask* pTask) {
|
||||||
|
|
||||||
void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CTG_TASK_GET_QNODE: {
|
case CTG_TASK_GET_QNODE:
|
||||||
taosArrayDestroy((SArray*)*pRes);
|
case CTG_TASK_GET_DNODE:
|
||||||
*pRes = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DNODE: {
|
|
||||||
taosArrayDestroy((SArray*)*pRes);
|
|
||||||
*pRes = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_META: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DB_VGROUP: {
|
case CTG_TASK_GET_DB_VGROUP: {
|
||||||
taosArrayDestroy((SArray*)*pRes);
|
taosArrayDestroy((SArray*)*pRes);
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
|
@ -373,14 +368,6 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_DB_INFO: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_HASH: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_INDEX: {
|
case CTG_TASK_GET_TB_INDEX: {
|
||||||
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
|
@ -394,15 +381,13 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_INDEX: {
|
case CTG_TASK_GET_TB_HASH:
|
||||||
taosMemoryFreeClear(*pRes);
|
case CTG_TASK_GET_DB_INFO:
|
||||||
break;
|
case CTG_TASK_GET_INDEX:
|
||||||
}
|
case CTG_TASK_GET_UDF:
|
||||||
case CTG_TASK_GET_UDF: {
|
case CTG_TASK_GET_USER:
|
||||||
taosMemoryFreeClear(*pRes);
|
case CTG_TASK_GET_SVR_VER:
|
||||||
break;
|
case CTG_TASK_GET_TB_META: {
|
||||||
}
|
|
||||||
case CTG_TASK_GET_USER: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
taosMemoryFreeClear(*pRes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -415,20 +400,12 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
|
|
||||||
void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CTG_TASK_GET_QNODE: {
|
case CTG_TASK_GET_QNODE:
|
||||||
taosArrayDestroy((SArray*)*pRes);
|
|
||||||
*pRes = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DNODE: {
|
case CTG_TASK_GET_DNODE: {
|
||||||
taosArrayDestroy((SArray*)*pRes);
|
taosArrayDestroy((SArray*)*pRes);
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_TB_META: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DB_VGROUP: {
|
case CTG_TASK_GET_DB_VGROUP: {
|
||||||
if (*pRes) {
|
if (*pRes) {
|
||||||
SDBVgInfo* pInfo = (SDBVgInfo*)*pRes;
|
SDBVgInfo* pInfo = (SDBVgInfo*)*pRes;
|
||||||
|
@ -445,14 +422,6 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_DB_INFO: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_HASH: {
|
|
||||||
taosMemoryFreeClear(*pRes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_INDEX: {
|
case CTG_TASK_GET_TB_INDEX: {
|
||||||
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
|
@ -466,14 +435,12 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_INDEX: {
|
case CTG_TASK_GET_TB_META:
|
||||||
taosMemoryFreeClear(*pRes);
|
case CTG_TASK_GET_DB_INFO:
|
||||||
break;
|
case CTG_TASK_GET_TB_HASH:
|
||||||
}
|
case CTG_TASK_GET_INDEX:
|
||||||
case CTG_TASK_GET_UDF: {
|
case CTG_TASK_GET_UDF:
|
||||||
taosMemoryFreeClear(*pRes);
|
case CTG_TASK_GET_SVR_VER:
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_USER: {
|
case CTG_TASK_GET_USER: {
|
||||||
taosMemoryFreeClear(*pRes);
|
taosMemoryFreeClear(*pRes);
|
||||||
break;
|
break;
|
||||||
|
@ -497,10 +464,6 @@ void ctgClearSubTaskRes(SCtgSubRes *pRes) {
|
||||||
|
|
||||||
void ctgFreeTaskCtx(SCtgTask* pTask) {
|
void ctgFreeTaskCtx(SCtgTask* pTask) {
|
||||||
switch (pTask->type) {
|
switch (pTask->type) {
|
||||||
case CTG_TASK_GET_QNODE: {
|
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_META: {
|
case CTG_TASK_GET_TB_META: {
|
||||||
SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
taosMemoryFreeClear(taskCtx->pName);
|
taosMemoryFreeClear(taskCtx->pName);
|
||||||
|
@ -511,18 +474,6 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_DB_VGROUP: {
|
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DB_CFG: {
|
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_DB_INFO: {
|
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_TB_HASH: {
|
case CTG_TASK_GET_TB_HASH: {
|
||||||
SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx;
|
SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx;
|
||||||
taosMemoryFreeClear(taskCtx->pName);
|
taosMemoryFreeClear(taskCtx->pName);
|
||||||
|
@ -542,14 +493,12 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTG_TASK_GET_INDEX: {
|
case CTG_TASK_GET_DB_VGROUP:
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
case CTG_TASK_GET_DB_CFG:
|
||||||
break;
|
case CTG_TASK_GET_DB_INFO:
|
||||||
}
|
case CTG_TASK_GET_INDEX:
|
||||||
case CTG_TASK_GET_UDF: {
|
case CTG_TASK_GET_UDF:
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
case CTG_TASK_GET_QNODE:
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTG_TASK_GET_USER: {
|
case CTG_TASK_GET_USER: {
|
||||||
taosMemoryFreeClear(pTask->taskCtx);
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -520,7 +520,17 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR
|
||||||
return execShowCreateTable(pStmt, pRsp);
|
return execShowCreateTable(pStmt, pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { return TSDB_CODE_FAILED; }
|
static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
|
||||||
|
if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosSetCfg(tsCfg, pStmt->config)) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildLocalVariablesResultDataBlock() {
|
static SSDataBlock* buildLocalVariablesResultDataBlock() {
|
||||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
|
|
@ -273,6 +273,10 @@ typedef struct STableScanInfo {
|
||||||
|
|
||||||
SSampleExecInfo sample; // sample execution info
|
SSampleExecInfo sample; // sample execution info
|
||||||
int32_t curTWinIdx;
|
int32_t curTWinIdx;
|
||||||
|
|
||||||
|
int32_t currentGroupId;
|
||||||
|
uint64_t queryId;
|
||||||
|
uint64_t taskId;
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
|
||||||
typedef struct STagScanInfo {
|
typedef struct STagScanInfo {
|
||||||
|
@ -706,7 +710,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo, uint64_t queryId, uint64_t taskId);
|
||||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
|
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
|
||||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
|
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
@ -749,8 +753,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* readHandle, uint64_t uid, SBlockDistScanPhysiNode* pBlockScanNode,
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* readHandle, uint64_t uid, SBlockDistScanPhysiNode* pBlockScanNode,
|
||||||
SExecTaskInfo* pTaskInfo);
|
SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle,
|
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle,
|
||||||
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup);
|
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup, uint64_t queryId, uint64_t taskId);
|
||||||
|
|
||||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, bool multigroupResult,
|
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, bool multigroupResult,
|
||||||
SExecTaskInfo* pTaskInfo);
|
SExecTaskInfo* pTaskInfo);
|
||||||
|
@ -845,7 +849,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
|
|
||||||
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
||||||
|
|
||||||
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey);
|
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){
|
||||||
int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo) {
|
int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
pListInfo->pTableList = taosArrayInit(8, sizeof(STableKeyInfo));
|
pListInfo->pTableList = taosArrayInit(8, sizeof(STableKeyInfo));
|
||||||
|
if(pListInfo->pTableList == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
uint64_t tableUid = pScanNode->uid;
|
uint64_t tableUid = pScanNode->uid;
|
||||||
|
|
||||||
|
@ -314,7 +315,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(res); i++) {
|
for (int i = 0; i < taosArrayGetSize(res); i++) {
|
||||||
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0};
|
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)};
|
||||||
taosArrayPush(pListInfo->pTableList, &info);
|
taosArrayPush(pListInfo->pTableList, &info);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(res);
|
taosArrayDestroy(res);
|
||||||
|
@ -335,9 +336,14 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else { // Create one table group.
|
}else { // Create one table group.
|
||||||
STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0};
|
STableKeyInfo info = {.lastKey = 0, .uid = tableUid};
|
||||||
taosArrayPush(pListInfo->pTableList, &info);
|
taosArrayPush(pListInfo->pTableList, &info);
|
||||||
}
|
}
|
||||||
|
pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
if(pListInfo->pGroupList == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
//put into list as default group, remove it if grouping sorting is required later
|
||||||
|
taosArrayPush(pListInfo->pGroupList, &pListInfo->pTableList);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,15 +40,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
SStreamBlockScanInfo* pInfo = pOperator->info;
|
SStreamBlockScanInfo* pInfo = pOperator->info;
|
||||||
pInfo->assignBlockUid = assignUid;
|
pInfo->assignBlockUid = assignUid;
|
||||||
|
|
||||||
// no need to check
|
// TODO: if a block was set but not consumed,
|
||||||
#if 0
|
// prevent setting a different type of block
|
||||||
if (pInfo->blockType == 0) {
|
|
||||||
pInfo->blockType = type;
|
|
||||||
} else if (pInfo->blockType != type) {
|
|
||||||
ASSERT(0);
|
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
pInfo->blockType = type;
|
pInfo->blockType = type;
|
||||||
|
|
||||||
if (type == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
if (type == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
||||||
|
@ -152,10 +145,10 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(mr.me.type == TSDB_CHILD_TABLE);
|
if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != pScanInfo->tableUid) {
|
||||||
if (mr.me.ctbEntry.suid != pScanInfo->tableUid) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// TODO handle ntb case
|
||||||
|
|
||||||
taosArrayPush(qa, id);
|
taosArrayPush(qa, id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||||
// todo move to the initialization function
|
// todo move to the initialization function
|
||||||
int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0);
|
int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0);
|
||||||
|
|
||||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
SFilterColumnParam param1 = {.numOfCols = numOfCols, .pDataBlock = pBlock->pDataBlock};
|
SFilterColumnParam param1 = {.numOfCols = numOfCols, .pDataBlock = pBlock->pDataBlock};
|
||||||
code = filterSetDataFromSlotId(filter, ¶m1);
|
code = filterSetDataFromSlotId(filter, ¶m1);
|
||||||
|
|
||||||
|
@ -2048,7 +2048,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLo
|
||||||
SArray* pColList) {
|
SArray* pColList) {
|
||||||
if (pColList == NULL) { // data from other sources
|
if (pColList == NULL) { // data from other sources
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pRes);
|
||||||
// blockDataEnsureCapacity(pRes, numOfRows);
|
// blockDataEnsureCapacity(pRes, numOfRows);
|
||||||
blockCompressDecode(pRes, numOfOutput, numOfRows, pData);
|
blockCompressDecode(pRes, numOfOutput, numOfRows, pData);
|
||||||
} else { // extract data according to pColList
|
} else { // extract data according to pColList
|
||||||
ASSERT(numOfOutput == taosArrayGetSize(pColList));
|
ASSERT(numOfOutput == taosArrayGetSize(pColList));
|
||||||
|
@ -2402,14 +2402,14 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
||||||
|
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
||||||
pInfo->seqLoadData = false;
|
pInfo->seqLoadData = false;
|
||||||
pInfo->pTransporter = pTransporter;
|
pInfo->pTransporter = pTransporter;
|
||||||
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
||||||
pOperator->name = "ExchangeOperator";
|
pOperator->name = "ExchangeOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pResult->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pResult->pDataBlock);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
@ -3581,6 +3581,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t getLimit(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
||||||
|
|
||||||
|
static int64_t getOffset(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
||||||
|
|
||||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
|
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SExecTaskInfo* pTaskInfo) {
|
||||||
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
||||||
|
@ -3593,8 +3597,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc);
|
||||||
SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset};
|
SLimit limit = {.limit = getLimit(pProjPhyNode->node.pLimit), .offset = getOffset(pProjPhyNode->node.pLimit)};
|
||||||
SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset};
|
SLimit slimit = {.limit = getLimit(pProjPhyNode->node.pSlimit), .offset = getOffset(pProjPhyNode->node.pSlimit)};
|
||||||
|
|
||||||
pInfo->limit = limit;
|
pInfo->limit = limit;
|
||||||
pInfo->slimit = slimit;
|
pInfo->slimit = slimit;
|
||||||
|
@ -3858,9 +3862,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
||||||
return pTaskInfo;
|
return pTaskInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
|
||||||
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId);
|
|
||||||
|
|
||||||
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
|
|
||||||
int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) {
|
int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) {
|
||||||
|
@ -3891,8 +3892,67 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey) {
|
static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum){
|
||||||
if (groupKey == NULL) {
|
taosArrayClear(pTableListInfo->pGroupList);
|
||||||
|
SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t));
|
||||||
|
if(sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) {
|
||||||
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t));
|
||||||
|
|
||||||
|
int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ);
|
||||||
|
if (index == -1){
|
||||||
|
void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT);
|
||||||
|
SArray *tGroup = taosArrayInit(8, sizeof(STableKeyInfo));
|
||||||
|
if(tGroup == NULL) {
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
if(taosArrayPush(tGroup, info) == NULL){
|
||||||
|
qError("taos push info array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
if(p == NULL){
|
||||||
|
if(taosArrayPush(sortSupport, groupId) != NULL){
|
||||||
|
qError("taos push support array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
if(taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL){
|
||||||
|
qError("taos push group array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int32_t pos = TARRAY_ELEM_IDX(sortSupport, p);
|
||||||
|
if(taosArrayInsert(sortSupport, pos, groupId) == NULL){
|
||||||
|
qError("taos insert support array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
if(taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL){
|
||||||
|
qError("taos insert group array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index);
|
||||||
|
if(taosArrayPush(tGroup, info) == NULL){
|
||||||
|
qError("taos push uid array error");
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
taosArrayDestroy(sortSupport);
|
||||||
|
return TDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group) {
|
||||||
|
if (group == NULL) {
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3902,13 +3962,14 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
}
|
}
|
||||||
int32_t keyLen = 0;
|
int32_t keyLen = 0;
|
||||||
void* keyBuf = NULL;
|
void* keyBuf = NULL;
|
||||||
int32_t numOfGroupCols = taosArrayGetSize(groupKey);
|
|
||||||
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
SNode* node;
|
||||||
SColumn* pCol = taosArrayGet(groupKey, j);
|
FOREACH(node, group) {
|
||||||
keyLen += pCol->bytes; // actual data + null_flag
|
SExprNode *pExpr = (SExprNode *)node;
|
||||||
|
keyLen += pExpr->resType.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols;
|
int32_t nullFlagSize = sizeof(int8_t) * LIST_LENGTH(group);
|
||||||
keyLen += nullFlagSize;
|
keyLen += nullFlagSize;
|
||||||
|
|
||||||
keyBuf = taosMemoryCalloc(1, keyLen);
|
keyBuf = taosMemoryCalloc(1, keyLen);
|
||||||
|
@ -3916,59 +3977,68 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t groupNum = 0;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, pHandle->meta, 0);
|
metaReaderInit(&mr, pHandle->meta, 0);
|
||||||
metaGetTableEntryByUid(&mr, info->uid);
|
metaGetTableEntryByUid(&mr, info->uid);
|
||||||
|
|
||||||
char* isNull = (char*)keyBuf;
|
SNodeList *groupNew = nodesCloneList(group);
|
||||||
char* pStart = (char*)keyBuf + sizeof(int8_t) * numOfGroupCols;
|
|
||||||
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
|
||||||
SColumn* pCol = taosArrayGet(groupKey, j);
|
|
||||||
|
|
||||||
if (strcmp(pCol->name, "tbname") == 0) {
|
nodesRewriteExprsPostOrder(groupNew, doTranslateTagExpr, &mr);
|
||||||
isNull[i] = 0;
|
char* isNull = (char*)keyBuf;
|
||||||
memcpy(pStart, mr.me.name, strlen(mr.me.name));
|
char* pStart = (char*)keyBuf + nullFlagSize;
|
||||||
pStart += strlen(mr.me.name);
|
|
||||||
|
SNode* pNode;
|
||||||
|
int32_t index = 0;
|
||||||
|
FOREACH(pNode, groupNew){
|
||||||
|
SNode* pNew = NULL;
|
||||||
|
int32_t code = scalarCalculateConstants(pNode, &pNew);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
REPLACE_NODE(pNew);
|
||||||
} else {
|
} else {
|
||||||
STagVal tagVal = {0};
|
taosMemoryFree(keyBuf);
|
||||||
tagVal.cid = pCol->colId;
|
nodesClearList(groupNew);
|
||||||
const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal);
|
return code;
|
||||||
if (p == NULL) {
|
}
|
||||||
isNull[j] = 1;
|
|
||||||
continue;
|
ASSERT(nodeType(pNew) == QUERY_NODE_VALUE);
|
||||||
}
|
SValueNode *pValue = (SValueNode *)pNew;
|
||||||
isNull[i] = 0;
|
|
||||||
if (pCol->type == TSDB_DATA_TYPE_JSON) {
|
if (pValue->node.resType.type == TSDB_DATA_TYPE_NULL) {
|
||||||
// int32_t dataLen = getJsonValueLen(pkey->pData);
|
isNull[index++] = 1;
|
||||||
// memcpy(pStart, (pkey->pData), dataLen);
|
continue;
|
||||||
// pStart += dataLen;
|
} else {
|
||||||
} else if (IS_VAR_DATA_TYPE(pCol->type)) {
|
isNull[index++] = 0;
|
||||||
memcpy(pStart, tagVal.pData, tagVal.nData);
|
char* data = nodesGetValueFromNode(pValue);
|
||||||
pStart += tagVal.nData;
|
if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON){
|
||||||
ASSERT(tagVal.nData <= pCol->bytes);
|
int32_t len = getJsonValueLen(data);
|
||||||
|
memcpy(pStart, data, len);
|
||||||
|
pStart += len;
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) {
|
||||||
|
memcpy(pStart, data, varDataTLen(data));
|
||||||
|
pStart += varDataTLen(data);
|
||||||
} else {
|
} else {
|
||||||
memcpy(pStart, &(tagVal.i64), pCol->bytes);
|
memcpy(pStart, data, pValue->node.resType.bytes);
|
||||||
pStart += pCol->bytes;
|
pStart += pValue->node.resType.bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
||||||
|
uint64_t groupId = calcGroupId(keyBuf, len);
|
||||||
uint64_t* pGroupId = taosHashGet(pTableListInfo->map, keyBuf, len);
|
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &groupId, sizeof(uint64_t));
|
||||||
|
groupNum++;
|
||||||
if (!pGroupId) {
|
|
||||||
uint64_t tmpId = calcGroupId(keyBuf, len);
|
|
||||||
info->groupId = tmpId;
|
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t));
|
|
||||||
} else {
|
|
||||||
info->groupId = *pGroupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
nodesClearList(groupNew);
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
}
|
}
|
||||||
taosMemoryFree(keyBuf);
|
taosMemoryFree(keyBuf);
|
||||||
|
|
||||||
|
if(pTableListInfo->needSortTableByGroupId){
|
||||||
|
return sortTableGroup(pTableListInfo, groupNum);
|
||||||
|
}
|
||||||
|
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3980,39 +4050,36 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableListInfo, (uint64_t)queryId, taskId);
|
int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId);
|
||||||
if (pDataReader == NULL && terrno != 0) {
|
if(code){
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
int32_t code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = terrno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId);
|
||||||
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
|
||||||
taosArrayDestroy(groupKeys);
|
|
||||||
if (code) {
|
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
|
||||||
pTaskInfo->code = terrno;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
||||||
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
||||||
createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId);
|
int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId);
|
||||||
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
if(code){
|
||||||
SOperatorInfo* pOperator =
|
return NULL;
|
||||||
createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo, queryId, taskId);
|
}
|
||||||
|
code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
|
if (code) {
|
||||||
|
pTaskInfo->code = terrno;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo, queryId, taskId);
|
||||||
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -4021,46 +4088,17 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
|
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
STimeWindowAggSupp twSup = {
|
STimeWindowAggSupp twSup = {
|
||||||
.waterMark = pTableScanNode->watermark,
|
.waterMark = pTableScanNode->watermark,
|
||||||
.calTrigger = pTableScanNode->triggerType,
|
.calTrigger = pTableScanNode->triggerType,
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
tsdbReaderT pDataReader = NULL;
|
|
||||||
|
|
||||||
if (pHandle) {
|
if (pHandle) {
|
||||||
if (pHandle->initTsdbReader) {
|
createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId);
|
||||||
// for stream
|
|
||||||
ASSERT(pHandle->vnode);
|
|
||||||
pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableListInfo, (uint64_t)queryId, taskId);
|
|
||||||
} else {
|
|
||||||
// for tq
|
|
||||||
ASSERT(pHandle->meta);
|
|
||||||
getTableList(pHandle->meta, pScanPhyNode, pTableListInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTaskInfo, &twSup, queryId, taskId);
|
||||||
if (pDataReader == NULL && terrno != 0) {
|
|
||||||
qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo));
|
|
||||||
// return NULL;
|
|
||||||
} else {
|
|
||||||
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
|
||||||
int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
|
||||||
taosArrayDestroy(groupKeys);
|
|
||||||
if (code) {
|
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup);
|
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||||
|
@ -4089,7 +4127,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else { // Create one table group.
|
} else { // Create one table group.
|
||||||
STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid, .groupId = 0};
|
STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid};
|
||||||
taosArrayPush(pTableListInfo->pTableList, &info);
|
taosArrayPush(pTableListInfo->pTableList, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4114,7 +4152,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
cond.suid = pBlockNode->suid;
|
cond.suid = pBlockNode->suid;
|
||||||
cond.type = BLOCK_LOAD_OFFSET_SEQ_ORDER;
|
cond.type = BLOCK_LOAD_OFFSET_SEQ_ORDER;
|
||||||
}
|
}
|
||||||
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo, queryId, taskId);
|
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, queryId, taskId);
|
||||||
cleanupQueryTableDataCond(&cond);
|
cleanupQueryTableDataCond(&cond);
|
||||||
|
|
||||||
return createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
return createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
||||||
|
@ -4351,7 +4389,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo, queryId, taskId);
|
tsdbReaderT pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, queryId, taskId);
|
||||||
cleanupQueryTableDataCond(&cond);
|
cleanupQueryTableDataCond(&cond);
|
||||||
|
|
||||||
return pReader;
|
return pReader;
|
||||||
|
@ -4361,6 +4399,72 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanInfo** ppInfo) {
|
||||||
|
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
|
if (pOperator->numOfDownstream == 0) {
|
||||||
|
qError("failed to find stream scan operator");
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pOperator->numOfDownstream > 1) {
|
||||||
|
qError("join not supported for stream block scan");
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo);
|
||||||
|
} else {
|
||||||
|
SStreamBlockScanInfo* pInfo = pOperator->info;
|
||||||
|
ASSERT(pInfo->pSnapshotReadOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
||||||
|
*ppInfo = pInfo->pSnapshotReadOp->info;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
|
||||||
|
if (pNode->pChildren == NULL || LIST_LENGTH(pNode->pChildren) == 0) {
|
||||||
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == pNode->type) {
|
||||||
|
*ppNode = (STableScanPhysiNode*)pNode;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
terrno = TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (LIST_LENGTH(pNode->pChildren) != 1) {
|
||||||
|
ASSERT(0);
|
||||||
|
terrno = TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pNode->pChildren, 0);
|
||||||
|
return extractTableScanNode(pChildNode, ppNode);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle, int64_t uid, int64_t ts) {
|
||||||
|
STableScanInfo* pTableScanInfo = NULL;
|
||||||
|
if (extractTbscanInStreamOpTree(pOperator, &pTableScanInfo) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
STableScanPhysiNode* pNode = NULL;
|
||||||
|
if (extractTableScanNode(plan->pNode, &pNode) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbCleanupReadHandle(pTableScanInfo->dataReader);
|
||||||
|
|
||||||
|
STableListInfo info = {0};
|
||||||
|
pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, 0, 0);
|
||||||
|
if (pTableScanInfo->dataReader == NULL) {
|
||||||
|
ASSERT(0);
|
||||||
|
qError("failed to create data reader");
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
// TODO: set uid and ts to data reader
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
|
int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
|
||||||
int32_t code = TDB_CODE_SUCCESS;
|
int32_t code = TDB_CODE_SUCCESS;
|
||||||
char* pCurrent = NULL;
|
char* pCurrent = NULL;
|
||||||
|
@ -4514,6 +4618,13 @@ _complete:
|
||||||
static void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
static void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
||||||
taosArrayDestroy(pTableqinfoList->pTableList);
|
taosArrayDestroy(pTableqinfoList->pTableList);
|
||||||
taosHashCleanup(pTableqinfoList->map);
|
taosHashCleanup(pTableqinfoList->map);
|
||||||
|
if(pTableqinfoList->needSortTableByGroupId){
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++){
|
||||||
|
SArray* tmp = taosArrayGetP(pTableqinfoList->pGroupList, i);
|
||||||
|
taosArrayDestroy(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pTableqinfoList->pGroupList);
|
||||||
|
|
||||||
pTableqinfoList->pTableList = NULL;
|
pTableqinfoList->pTableList = NULL;
|
||||||
pTableqinfoList->map = NULL;
|
pTableqinfoList->map = NULL;
|
||||||
|
|
|
@ -418,7 +418,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
@ -500,6 +500,48 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
|
STableScanInfo* pInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
if(pInfo->currentGroupId == -1){
|
||||||
|
pInfo->currentGroupId++;
|
||||||
|
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
||||||
|
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId);
|
||||||
|
tsdbCleanupReadHandle(pInfo->dataReader);
|
||||||
|
tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId);
|
||||||
|
pInfo->dataReader = pReader;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* result = doTableScanGroup(pOperator);
|
||||||
|
if(result){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->currentGroupId++;
|
||||||
|
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
||||||
|
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId);
|
||||||
|
tsdbSetTableList(pInfo->dataReader, tableList);
|
||||||
|
|
||||||
|
tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0);
|
||||||
|
pInfo->curTWinIdx = 0;
|
||||||
|
pInfo->scanTimes = 0;
|
||||||
|
|
||||||
|
result = doTableScanGroup(pOperator);
|
||||||
|
if(result){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -525,8 +567,8 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader,
|
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle,
|
||||||
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) {
|
SExecTaskInfo* pTaskInfo, uint64_t queryId, uint64_t taskId) {
|
||||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
@ -561,10 +603,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||||
pInfo->pResBlock = createResDataBlock(pDescNode);
|
pInfo->pResBlock = createResDataBlock(pDescNode);
|
||||||
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
||||||
pInfo->dataReader = pDataReader;
|
|
||||||
pInfo->scanFlag = MAIN_SCAN;
|
pInfo->scanFlag = MAIN_SCAN;
|
||||||
pInfo->pColMatchInfo = pColList;
|
pInfo->pColMatchInfo = pColList;
|
||||||
pInfo->curTWinIdx = 0;
|
pInfo->curTWinIdx = 0;
|
||||||
|
pInfo->queryId = queryId;
|
||||||
|
pInfo->taskId = taskId;
|
||||||
|
pInfo->currentGroupId = -1;
|
||||||
|
|
||||||
pOperator->name = "TableScanOperator"; // for debug purpose
|
pOperator->name = "TableScanOperator"; // for debug purpose
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||||
|
@ -778,8 +822,9 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
|
||||||
STableScanInfo* pTableScanInfo = pInfo->pSnapshotReadOp->info;
|
STableScanInfo* pTableScanInfo = pInfo->pSnapshotReadOp->info;
|
||||||
pTableScanInfo->cond.twindows[0] = win;
|
pTableScanInfo->cond.twindows[0] = win;
|
||||||
pTableScanInfo->curTWinIdx = 0;
|
pTableScanInfo->curTWinIdx = 0;
|
||||||
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
|
// tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
|
||||||
pTableScanInfo->scanTimes = 0;
|
pTableScanInfo->scanTimes = 0;
|
||||||
|
pTableScanInfo->currentGroupId = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1087,9 +1132,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
|
||||||
return tableIdList;
|
return tableIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle,
|
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle,
|
||||||
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo,
|
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo,
|
||||||
STimeWindowAggSupp* pTwSup) {
|
STimeWindowAggSupp* pTwSup, uint64_t queryId, uint64_t taskId) {
|
||||||
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
|
@ -1129,7 +1174,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle) {
|
if (pHandle) {
|
||||||
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId);
|
||||||
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
||||||
if (pSTInfo->interval.interval > 0) {
|
if (pSTInfo->interval.interval > 0) {
|
||||||
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark);
|
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark);
|
||||||
|
@ -1889,11 +1934,12 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pTableList = pTableListInfo;
|
pInfo->pTableList = pTableListInfo;
|
||||||
pInfo->pColMatchInfo = colList;
|
pInfo->pColMatchInfo = colList;
|
||||||
pInfo->pRes = createResDataBlock(pDescNode);
|
pInfo->pRes = createResDataBlock(pDescNode);
|
||||||
pInfo->readHandle = *pReadHandle;
|
pInfo->readHandle = *pReadHandle;
|
||||||
pInfo->curPos = 0;
|
pInfo->curPos = 0;
|
||||||
|
|
||||||
pOperator->name = "TagScanOperator";
|
pOperator->name = "TagScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
||||||
|
|
||||||
|
@ -1919,10 +1965,7 @@ _error:
|
||||||
|
|
||||||
typedef struct STableMergeScanInfo {
|
typedef struct STableMergeScanInfo {
|
||||||
STableListInfo* tableListInfo;
|
STableListInfo* tableListInfo;
|
||||||
int32_t tableStartIndex;
|
int32_t currentGroupId;
|
||||||
int32_t tableEndIndex;
|
|
||||||
bool hasGroupId;
|
|
||||||
uint64_t groupId;
|
|
||||||
|
|
||||||
SArray* dataReaders; // array of tsdbReaderT*
|
SArray* dataReaders; // array of tsdbReaderT*
|
||||||
SReadHandle readHandle;
|
SReadHandle readHandle;
|
||||||
|
@ -1968,12 +2011,6 @@ typedef struct STableMergeScanInfo {
|
||||||
SSampleExecInfo sample; // sample execution info
|
SSampleExecInfo sample; // sample execution info
|
||||||
} STableMergeScanInfo;
|
} STableMergeScanInfo;
|
||||||
|
|
||||||
int32_t compareTableKeyInfoByGid(const void* p1, const void* p2) {
|
|
||||||
const STableKeyInfo* info1 = p1;
|
|
||||||
const STableKeyInfo* info2 = p2;
|
|
||||||
return info1->groupId - info2->groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
||||||
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId) {
|
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId) {
|
||||||
int32_t code = getTableList(pHandle->meta, &pTableScanNode->scan, pTableListInfo);
|
int32_t code = getTableList(pHandle->meta, &pTableScanNode->scan, pTableListInfo);
|
||||||
|
@ -1985,55 +2022,9 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
|
||||||
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags);
|
||||||
generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
|
||||||
if (groupKeys) {
|
|
||||||
taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid);
|
|
||||||
}
|
|
||||||
taosArrayDestroy(groupKeys);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t doCreateMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
|
||||||
STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId,
|
|
||||||
uint64_t taskId) {
|
|
||||||
SQueryTableDataCond cond = {0};
|
|
||||||
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
return code;
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) {
|
|
||||||
STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo));
|
|
||||||
subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
|
||||||
taosArrayPush(subListInfo->pTableList, taosArrayGet(pTableListInfo->pTableList, i));
|
|
||||||
|
|
||||||
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, subListInfo, queryId, taskId);
|
|
||||||
taosArrayPush(arrayReader, &pReader);
|
|
||||||
|
|
||||||
taosArrayDestroy(subListInfo->pTableList);
|
|
||||||
taosMemoryFree(subListInfo);
|
|
||||||
}
|
|
||||||
cleanupQueryTableDataCond(&cond);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
_error:
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, STableListInfo* pTableListInfo,
|
|
||||||
int32_t tableStartIdx, int32_t tableEndIdx, SArray* arrayReader, uint64_t queryId,
|
|
||||||
uint64_t taskId) {
|
|
||||||
for (int32_t i = tableStartIdx; i <= tableEndIdx; ++i) {
|
|
||||||
STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo));
|
|
||||||
subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
|
||||||
taosArrayPush(subListInfo->pTableList, taosArrayGet(pTableListInfo->pTableList, i));
|
|
||||||
|
|
||||||
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, pQueryCond, subListInfo, queryId, taskId);
|
|
||||||
taosArrayPush(arrayReader, &pReader);
|
|
||||||
|
|
||||||
taosArrayDestroy(subListInfo->pTableList);
|
|
||||||
taosMemoryFree(subListInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2225,32 +2216,34 @@ SArray* generateSortByTsInfo(int32_t order) {
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, SArray* tableList, SArray* arrayReader, uint64_t queryId,
|
||||||
|
uint64_t taskId) {
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(tableList); ++i) {
|
||||||
|
SArray* tmp = taosArrayInit(1, sizeof(STableKeyInfo));
|
||||||
|
taosArrayPush(tmp, taosArrayGet(tableList, i));
|
||||||
|
|
||||||
|
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, pQueryCond, tmp, queryId, taskId);
|
||||||
|
taosArrayPush(arrayReader, &pReader);
|
||||||
|
|
||||||
|
taosArrayDestroy(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
STableMergeScanInfo* pInfo = pOperator->info;
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
{
|
SArray* tableList = taosArrayGetP(pInfo->tableListInfo->pGroupList, pInfo->currentGroupId);
|
||||||
size_t tableListSize = taosArrayGetSize(pInfo->tableListInfo->pTableList);
|
|
||||||
int32_t i = pInfo->tableStartIndex + 1;
|
|
||||||
for (; i < tableListSize; ++i) {
|
|
||||||
STableKeyInfo* tableKeyInfo = taosArrayGet(pInfo->tableListInfo->pTableList, i);
|
|
||||||
if (tableKeyInfo->groupId != pInfo->groupId) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pInfo->tableEndIndex = i - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tableStartIdx = pInfo->tableStartIndex;
|
createMultipleDataReaders(&pInfo->cond, &pInfo->readHandle, tableList,
|
||||||
int32_t tableEndIdx = pInfo->tableEndIndex;
|
|
||||||
|
|
||||||
STableListInfo* tableListInfo = pInfo->tableListInfo;
|
|
||||||
createMultipleDataReaders(&pInfo->cond, &pInfo->readHandle, tableListInfo, tableStartIdx, tableEndIdx,
|
|
||||||
pInfo->dataReaders, pInfo->queryId, pInfo->taskId);
|
pInfo->dataReaders, pInfo->queryId, pInfo->taskId);
|
||||||
|
|
||||||
// todo the total available buffer should be determined by total capacity of buffer of this task.
|
// todo the total available buffer should be determined by total capacity of buffer of this task.
|
||||||
// the additional one is reserved for merge result
|
// the additional one is reserved for merge result
|
||||||
pInfo->sortBufSize = pInfo->bufPageSize * (tableEndIdx - tableStartIdx + 1 + 1);
|
int32_t tableLen = taosArrayGetSize(tableList);
|
||||||
|
pInfo->sortBufSize = pInfo->bufPageSize * ((tableLen==0?1:tableLen) + 1);
|
||||||
int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize;
|
int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize;
|
||||||
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
||||||
pInfo->pSortInputBlock, pTaskInfo->id.str);
|
pInfo->pSortInputBlock, pTaskInfo->id.str);
|
||||||
|
@ -2337,38 +2330,43 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
longjmp(pTaskInfo->env, code);
|
longjmp(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
size_t tableListSize = taosArrayGetSize(pInfo->tableListInfo->pTableList);
|
|
||||||
if (!pInfo->hasGroupId) {
|
|
||||||
pInfo->hasGroupId = true;
|
|
||||||
|
|
||||||
if (tableListSize == 0) {
|
if (pInfo->currentGroupId == -1) {
|
||||||
|
pInfo->currentGroupId++;
|
||||||
|
if (pInfo->currentGroupId >= taosArrayGetSize(pInfo->tableListInfo->pGroupList)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pInfo->tableStartIndex = 0;
|
|
||||||
pInfo->groupId = ((STableKeyInfo*)taosArrayGet(pInfo->tableListInfo->pTableList, pInfo->tableStartIndex))->groupId;
|
|
||||||
startGroupTableMergeScan(pOperator);
|
startGroupTableMergeScan(pOperator);
|
||||||
}
|
}
|
||||||
SSDataBlock* pBlock = NULL;
|
SSDataBlock* pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator);
|
||||||
while (pInfo->tableStartIndex < tableListSize) {
|
if (pBlock != NULL) {
|
||||||
pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator);
|
uint64_t* groupId = taosHashGet(pInfo->tableListInfo->map, &(pBlock->info.uid), sizeof(uint64_t));
|
||||||
if (pBlock != NULL) {
|
if(groupId) pBlock->info.groupId = *groupId;
|
||||||
pBlock->info.groupId = pInfo->groupId;
|
|
||||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||||
return pBlock;
|
return pBlock;
|
||||||
} else {
|
|
||||||
stopGroupTableMergeScan(pOperator);
|
|
||||||
if (pInfo->tableEndIndex >= tableListSize - 1) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pInfo->tableStartIndex = pInfo->tableEndIndex + 1;
|
|
||||||
pInfo->groupId =
|
|
||||||
((STableKeyInfo*)taosArrayGet(pInfo->tableListInfo->pTableList, pInfo->tableStartIndex))->groupId;
|
|
||||||
startGroupTableMergeScan(pOperator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopGroupTableMergeScan(pOperator);
|
||||||
|
pInfo->currentGroupId++;
|
||||||
|
if (pInfo->currentGroupId >= taosArrayGetSize(pInfo->tableListInfo->pGroupList)) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
startGroupTableMergeScan(pOperator);
|
||||||
|
|
||||||
|
pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator);
|
||||||
|
if (pBlock != NULL) {
|
||||||
|
uint64_t* groupId = taosHashGet(pInfo->tableListInfo->map, &(pBlock->info.uid), sizeof(uint64_t));
|
||||||
|
if(groupId) pBlock->info.groupId = *groupId;
|
||||||
|
|
||||||
|
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2445,6 +2443,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
pInfo->dataReaders = taosArrayInit(64, POINTER_BYTES);
|
pInfo->dataReaders = taosArrayInit(64, POINTER_BYTES);
|
||||||
pInfo->queryId = queryId;
|
pInfo->queryId = queryId;
|
||||||
pInfo->taskId = taskId;
|
pInfo->taskId = taskId;
|
||||||
|
pInfo->currentGroupId = -1;
|
||||||
|
|
||||||
pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam));
|
pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam));
|
||||||
|
|
||||||
|
|
|
@ -3902,6 +3902,7 @@ typedef struct SMergeIntervalAggOperatorInfo {
|
||||||
SIntervalAggOperatorInfo intervalAggOperatorInfo;
|
SIntervalAggOperatorInfo intervalAggOperatorInfo;
|
||||||
|
|
||||||
SHashObj* groupIntervalHash;
|
SHashObj* groupIntervalHash;
|
||||||
|
void* groupIntervalIter;
|
||||||
bool hasGroupId;
|
bool hasGroupId;
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
SSDataBlock* prefetchedBlock;
|
SSDataBlock* prefetchedBlock;
|
||||||
|
@ -3914,6 +3915,23 @@ void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput);
|
destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, STimeWindow* win, SSDataBlock* pResultBlock) {
|
||||||
|
SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info;
|
||||||
|
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
|
||||||
|
bool ascScan = (iaInfo->order == TSDB_ORDER_ASC);
|
||||||
|
SExprSupp* pExprSup = &pOperatorInfo->exprSupp;
|
||||||
|
|
||||||
|
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId);
|
||||||
|
SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf,
|
||||||
|
GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
|
||||||
|
ASSERT(p1 != NULL);
|
||||||
|
finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo,
|
||||||
|
pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo);
|
||||||
|
taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock,
|
static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock,
|
||||||
STimeWindow* newWin) {
|
STimeWindow* newWin) {
|
||||||
SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info;
|
SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info;
|
||||||
|
@ -3928,20 +3946,9 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newWin == NULL || (ascScan && newWin->skey > prevWin->ekey || (!ascScan) && newWin->skey < prevWin->ekey)) {
|
if ((ascScan && newWin->skey > prevWin->skey || (!ascScan) && newWin->skey < prevWin->skey)) {
|
||||||
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &prevWin->skey, TSDB_KEYSIZE, tableGroupId);
|
finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock);
|
||||||
SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf,
|
taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow));
|
||||||
GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
|
|
||||||
ASSERT(p1 != NULL);
|
|
||||||
|
|
||||||
finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo,
|
|
||||||
pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo);
|
|
||||||
taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
|
|
||||||
if (newWin == NULL) {
|
|
||||||
taosHashRemove(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId));
|
|
||||||
} else {
|
|
||||||
taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4090,12 +4097,17 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.groupId = miaInfo->groupId;
|
pRes->info.groupId = miaInfo->groupId;
|
||||||
} else {
|
}
|
||||||
void* p = taosHashIterate(miaInfo->groupIntervalHash, NULL);
|
|
||||||
if (p != NULL) {
|
if (miaInfo->inputBlocksFinished) {
|
||||||
|
void* win = taosHashIterate(miaInfo->groupIntervalHash, miaInfo->groupIntervalIter);
|
||||||
|
if (win != NULL) {
|
||||||
|
miaInfo->groupIntervalIter = win;
|
||||||
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint64_t* pKey = taosHashGetKey(p, &len);
|
uint64_t* pTableGroupId = taosHashGetKey(win, &len);
|
||||||
outputPrevIntervalResult(pOperator, *pKey, pRes, NULL);
|
finalizeWindowResult(pOperator, *pTableGroupId, win, pRes);
|
||||||
|
pRes->info.groupId = *pTableGroupId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4118,6 +4130,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
|
||||||
}
|
}
|
||||||
|
|
||||||
miaInfo->groupIntervalHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_NO_LOCK);
|
miaInfo->groupIntervalHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_NO_LOCK);
|
||||||
|
miaInfo->groupIntervalIter = NULL;
|
||||||
|
|
||||||
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
|
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,10 @@ bool blockDistSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t blockDistFunction(SqlFunctionCtx *pCtx);
|
int32_t blockDistFunction(SqlFunctionCtx *pCtx);
|
||||||
int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
int32_t groupKeyFunction(SqlFunctionCtx* pCtx);
|
||||||
|
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,7 +79,8 @@ static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_
|
||||||
|
|
||||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||||
if (!IS_NUMERIC_TYPE(para1Type) || !IS_NUMERIC_TYPE(para2Type)) {
|
if ((!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) ||
|
||||||
|
(!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type))) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,13 +110,13 @@ static int32_t translateLogarithm(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||||
if (!IS_NUMERIC_TYPE(para1Type)) {
|
if (!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (2 == numOfParams) {
|
if (2 == numOfParams) {
|
||||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||||
if (!IS_NUMERIC_TYPE(para2Type)) {
|
if (!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type)) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1515,6 +1516,16 @@ static bool getBlockDistFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
pFunc->node.resType = ((SExprNode*)pPara)->resType;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
|
@ -1857,7 +1868,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "last_row",
|
.name = "last_row",
|
||||||
.type = FUNCTION_TYPE_LAST_ROW,
|
.type = FUNCTION_TYPE_LAST_ROW,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||||
.translateFunc = translateLastRow,
|
.translateFunc = translateLastRow,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = minmaxFunctionSetup,
|
.initFunc = minmaxFunctionSetup,
|
||||||
|
@ -2024,7 +2035,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "diff",
|
.name = "diff",
|
||||||
.type = FUNCTION_TYPE_DIFF,
|
.type = FUNCTION_TYPE_DIFF,
|
||||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||||
.translateFunc = translateDiff,
|
.translateFunc = translateDiff,
|
||||||
.getEnvFunc = getDiffFuncEnv,
|
.getEnvFunc = getDiffFuncEnv,
|
||||||
.initFunc = diffFunctionSetup,
|
.initFunc = diffFunctionSetup,
|
||||||
|
@ -2034,7 +2045,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "statecount",
|
.name = "statecount",
|
||||||
.type = FUNCTION_TYPE_STATE_COUNT,
|
.type = FUNCTION_TYPE_STATE_COUNT,
|
||||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||||
.translateFunc = translateStateCount,
|
.translateFunc = translateStateCount,
|
||||||
.getEnvFunc = getStateFuncEnv,
|
.getEnvFunc = getStateFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
|
@ -2044,7 +2055,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "stateduration",
|
.name = "stateduration",
|
||||||
.type = FUNCTION_TYPE_STATE_DURATION,
|
.type = FUNCTION_TYPE_STATE_DURATION,
|
||||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||||
.translateFunc = translateStateDuration,
|
.translateFunc = translateStateDuration,
|
||||||
.getEnvFunc = getStateFuncEnv,
|
.getEnvFunc = getStateFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
|
@ -2054,7 +2065,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "csum",
|
.name = "csum",
|
||||||
.type = FUNCTION_TYPE_CSUM,
|
.type = FUNCTION_TYPE_CSUM,
|
||||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||||
.translateFunc = translateCsum,
|
.translateFunc = translateCsum,
|
||||||
.getEnvFunc = getCsumFuncEnv,
|
.getEnvFunc = getCsumFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
|
@ -2064,7 +2075,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "mavg",
|
.name = "mavg",
|
||||||
.type = FUNCTION_TYPE_MAVG,
|
.type = FUNCTION_TYPE_MAVG,
|
||||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC,
|
||||||
.translateFunc = translateMavg,
|
.translateFunc = translateMavg,
|
||||||
.getEnvFunc = getMavgFuncEnv,
|
.getEnvFunc = getMavgFuncEnv,
|
||||||
.initFunc = mavgFunctionSetup,
|
.initFunc = mavgFunctionSetup,
|
||||||
|
@ -2499,7 +2510,17 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.type = FUNCTION_TYPE_BLOCK_DIST_INFO,
|
.type = FUNCTION_TYPE_BLOCK_DIST_INFO,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC,
|
||||||
.translateFunc = translateBlockDistInfoFunc,
|
.translateFunc = translateBlockDistInfoFunc,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
.name = "_group_key",
|
||||||
|
.type = FUNCTION_TYPE_GROUP_KEY,
|
||||||
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
|
.translateFunc = translateGroupKey,
|
||||||
|
.getEnvFunc = getGroupKeyFuncEnv,
|
||||||
|
.initFunc = functionSetup,
|
||||||
|
.processFunc = groupKeyFunction,
|
||||||
|
.finalizeFunc = groupKeyFinalize,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,12 @@ typedef struct SRateInfo {
|
||||||
int8_t hasResult; // flag to denote has value
|
int8_t hasResult; // flag to denote has value
|
||||||
} SRateInfo;
|
} SRateInfo;
|
||||||
|
|
||||||
|
typedef struct SGroupKeyInfo{
|
||||||
|
bool hasResult;
|
||||||
|
char data[];
|
||||||
|
} SGroupKeyInfo;
|
||||||
|
|
||||||
|
|
||||||
#define SET_VAL(_info, numOfElem, res) \
|
#define SET_VAL(_info, numOfElem, res) \
|
||||||
do { \
|
do { \
|
||||||
if ((numOfElem) <= 0) { \
|
if ((numOfElem) <= 0) { \
|
||||||
|
@ -2402,6 +2408,12 @@ bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
|
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
pEnv->calcMemSize = sizeof(SGroupKeyInfo) + pNode->node.resType.bytes;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowIndex) {
|
static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowIndex) {
|
||||||
if (pTsColInfo == NULL) {
|
if (pTsColInfo == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5349,6 +5361,43 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return pResInfo->numOfRes;
|
return pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t bytes = pInputCol->info.bytes;
|
||||||
|
|
||||||
|
int32_t startIndex = pInput->startRowIndex;
|
||||||
|
if (colDataIsNull_s(pInputCol, startIndex)) {
|
||||||
|
pInfo->hasResult = false;
|
||||||
|
goto _group_key_over;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->hasResult = true;
|
||||||
|
char* data = colDataGetData(pInputCol, startIndex);
|
||||||
|
memcpy(pInfo->data, data, bytes);
|
||||||
|
|
||||||
|
_group_key_over:
|
||||||
|
|
||||||
|
SET_VAL(pResInfo, 1, 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
|
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
colDataAppend(pCol, pBlock->info.rows, pInfo->data, pInfo->hasResult ? false : true);
|
||||||
|
|
||||||
|
return pResInfo->numOfRes;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t interpFunction(SqlFunctionCtx* pCtx) {
|
int32_t interpFunction(SqlFunctionCtx* pCtx) {
|
||||||
#if 0
|
#if 0
|
||||||
int32_t fillType = (int32_t) pCtx->param[2].i64;
|
int32_t fillType = (int32_t) pCtx->param[2].i64;
|
||||||
|
|
|
@ -41,8 +41,7 @@
|
||||||
} \
|
} \
|
||||||
(pDst)->fldname = strdup((pSrc)->fldname); \
|
(pDst)->fldname = strdup((pSrc)->fldname); \
|
||||||
if (NULL == (pDst)->fldname) { \
|
if (NULL == (pDst)->fldname) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -53,8 +52,7 @@
|
||||||
} \
|
} \
|
||||||
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
|
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
|
||||||
if (NULL == (pDst)->fldname) { \
|
if (NULL == (pDst)->fldname) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -65,8 +63,7 @@
|
||||||
} \
|
} \
|
||||||
(pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \
|
(pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \
|
||||||
if (NULL == (pDst)->fldname) { \
|
if (NULL == (pDst)->fldname) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -77,8 +74,7 @@
|
||||||
} \
|
} \
|
||||||
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
|
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
|
||||||
if (NULL == (pDst)->fldname) { \
|
if (NULL == (pDst)->fldname) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -89,27 +85,25 @@
|
||||||
} \
|
} \
|
||||||
(pDst)->fldname = cloneFunc((pSrc)->fldname); \
|
(pDst)->fldname = cloneFunc((pSrc)->fldname); \
|
||||||
if (NULL == (pDst)->fldname) { \
|
if (NULL == (pDst)->fldname) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
|
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
|
||||||
do { \
|
do { \
|
||||||
if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
|
if (TSDB_CODE_SUCCESS != copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
|
||||||
nodesDestroyNode((SNode*)pDst); \
|
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||||
return NULL; \
|
} \
|
||||||
} \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static SNode* exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
||||||
COPY_OBJECT_FIELD(resType, sizeof(SDataType));
|
COPY_OBJECT_FIELD(resType, sizeof(SDataType));
|
||||||
COPY_CHAR_ARRAY_FIELD(aliasName);
|
COPY_CHAR_ARRAY_FIELD(aliasName);
|
||||||
COPY_CHAR_ARRAY_FIELD(userAlias);
|
COPY_CHAR_ARRAY_FIELD(userAlias);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
static int32_t columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_SCALAR_FIELD(tableId);
|
COPY_SCALAR_FIELD(tableId);
|
||||||
COPY_SCALAR_FIELD(tableType);
|
COPY_SCALAR_FIELD(tableType);
|
||||||
|
@ -122,10 +116,10 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||||
COPY_CHAR_ARRAY_FIELD(colName);
|
COPY_CHAR_ARRAY_FIELD(colName);
|
||||||
COPY_SCALAR_FIELD(dataBlockId);
|
COPY_SCALAR_FIELD(dataBlockId);
|
||||||
COPY_SCALAR_FIELD(slotId);
|
COPY_SCALAR_FIELD(slotId);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_CHAR_POINT_FIELD(literal);
|
COPY_CHAR_POINT_FIELD(literal);
|
||||||
COPY_SCALAR_FIELD(isDuration);
|
COPY_SCALAR_FIELD(isDuration);
|
||||||
|
@ -135,7 +129,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(typeData);
|
COPY_SCALAR_FIELD(typeData);
|
||||||
COPY_SCALAR_FIELD(unit);
|
COPY_SCALAR_FIELD(unit);
|
||||||
if (!pSrc->translate) {
|
if (!pSrc->translate) {
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
switch (pSrc->node.resType.type) {
|
switch (pSrc->node.resType.type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
@ -164,8 +158,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
int32_t len = varDataTLen(pSrc->datum.p) + 1;
|
int32_t len = varDataTLen(pSrc->datum.p) + 1;
|
||||||
pDst->datum.p = taosMemoryCalloc(1, len);
|
pDst->datum.p = taosMemoryCalloc(1, len);
|
||||||
if (NULL == pDst->datum.p) {
|
if (NULL == pDst->datum.p) {
|
||||||
nodesDestroyNode((SNode*)pDst);
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
memcpy(pDst->datum.p, pSrc->datum.p, len);
|
memcpy(pDst->datum.p, pSrc->datum.p, len);
|
||||||
break;
|
break;
|
||||||
|
@ -177,42 +170,42 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) {
|
static int32_t operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_SCALAR_FIELD(opType);
|
COPY_SCALAR_FIELD(opType);
|
||||||
CLONE_NODE_FIELD(pLeft);
|
CLONE_NODE_FIELD(pLeft);
|
||||||
CLONE_NODE_FIELD(pRight);
|
CLONE_NODE_FIELD(pRight);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) {
|
static int32_t logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_SCALAR_FIELD(condType);
|
COPY_SCALAR_FIELD(condType);
|
||||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
|
static int32_t functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_CHAR_ARRAY_FIELD(functionName);
|
COPY_CHAR_ARRAY_FIELD(functionName);
|
||||||
COPY_SCALAR_FIELD(funcId);
|
COPY_SCALAR_FIELD(funcId);
|
||||||
COPY_SCALAR_FIELD(funcType);
|
COPY_SCALAR_FIELD(funcType);
|
||||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||||
COPY_SCALAR_FIELD(udfBufSize);
|
COPY_SCALAR_FIELD(udfBufSize);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* tableNodeCopy(const STableNode* pSrc, STableNode* pDst) {
|
static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_CHAR_ARRAY_FIELD(dbName);
|
COPY_CHAR_ARRAY_FIELD(dbName);
|
||||||
COPY_CHAR_ARRAY_FIELD(tableName);
|
COPY_CHAR_ARRAY_FIELD(tableName);
|
||||||
COPY_CHAR_ARRAY_FIELD(tableAlias);
|
COPY_CHAR_ARRAY_FIELD(tableAlias);
|
||||||
COPY_SCALAR_FIELD(precision);
|
COPY_SCALAR_FIELD(precision);
|
||||||
COPY_SCALAR_FIELD(singleTable);
|
COPY_SCALAR_FIELD(singleTable);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static STableMeta* tableMetaClone(const STableMeta* pSrc) {
|
static STableMeta* tableMetaClone(const STableMeta* pSrc) {
|
||||||
|
@ -235,101 +228,103 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) {
|
||||||
return pDst;
|
return pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) {
|
static int32_t realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||||
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
||||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||||
COPY_CHAR_ARRAY_FIELD(qualDbName);
|
COPY_CHAR_ARRAY_FIELD(qualDbName);
|
||||||
COPY_SCALAR_FIELD(ratio);
|
COPY_SCALAR_FIELD(ratio);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) {
|
static int32_t tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||||
CLONE_NODE_FIELD(pSubquery);
|
CLONE_NODE_FIELD(pSubquery);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) {
|
static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
COPY_BASE_OBJECT_FIELD(table, tableNodeCopy);
|
||||||
COPY_SCALAR_FIELD(joinType);
|
COPY_SCALAR_FIELD(joinType);
|
||||||
CLONE_NODE_FIELD(pLeft);
|
CLONE_NODE_FIELD(pLeft);
|
||||||
CLONE_NODE_FIELD(pRight);
|
CLONE_NODE_FIELD(pRight);
|
||||||
CLONE_NODE_FIELD(pOnCond);
|
CLONE_NODE_FIELD(pOnCond);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) {
|
static int32_t targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(dataBlockId);
|
COPY_SCALAR_FIELD(dataBlockId);
|
||||||
COPY_SCALAR_FIELD(slotId);
|
COPY_SCALAR_FIELD(slotId);
|
||||||
CLONE_NODE_FIELD(pExpr);
|
CLONE_NODE_FIELD(pExpr);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) {
|
static int32_t groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(groupingSetType);
|
COPY_SCALAR_FIELD(groupingSetType);
|
||||||
CLONE_NODE_LIST_FIELD(pParameterList);
|
CLONE_NODE_LIST_FIELD(pParameterList);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) {
|
static int32_t orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pExpr);
|
CLONE_NODE_FIELD(pExpr);
|
||||||
COPY_SCALAR_FIELD(order);
|
COPY_SCALAR_FIELD(order);
|
||||||
COPY_SCALAR_FIELD(nullOrder);
|
COPY_SCALAR_FIELD(nullOrder);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) {
|
static int32_t limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(limit);
|
COPY_SCALAR_FIELD(limit);
|
||||||
COPY_SCALAR_FIELD(offset);
|
COPY_SCALAR_FIELD(offset);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) {
|
static int32_t stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pCol);
|
CLONE_NODE_FIELD(pCol);
|
||||||
CLONE_NODE_FIELD(pExpr);
|
CLONE_NODE_FIELD(pExpr);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
||||||
CLONE_NODE_FIELD_EX(pCol, SColumnNode*);
|
CLONE_NODE_FIELD_EX(pCol, SColumnNode*);
|
||||||
CLONE_NODE_FIELD_EX(pGap, SValueNode*);
|
CLONE_NODE_FIELD_EX(pGap, SValueNode*);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) {
|
static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pCol);
|
CLONE_NODE_FIELD(pCol);
|
||||||
CLONE_NODE_FIELD(pInterval);
|
CLONE_NODE_FIELD(pInterval);
|
||||||
CLONE_NODE_FIELD(pOffset);
|
CLONE_NODE_FIELD(pOffset);
|
||||||
CLONE_NODE_FIELD(pSliding);
|
CLONE_NODE_FIELD(pSliding);
|
||||||
CLONE_NODE_FIELD(pFill);
|
CLONE_NODE_FIELD(pFill);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
||||||
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||||
CLONE_NODE_LIST_FIELD(pNodeList);
|
CLONE_NODE_LIST_FIELD(pNodeList);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(mode);
|
COPY_SCALAR_FIELD(mode);
|
||||||
CLONE_NODE_FIELD(pValues);
|
CLONE_NODE_FIELD(pValues);
|
||||||
CLONE_NODE_FIELD(pWStartTs);
|
CLONE_NODE_FIELD(pWStartTs);
|
||||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
||||||
CLONE_NODE_LIST_FIELD(pTargets);
|
CLONE_NODE_LIST_FIELD(pTargets);
|
||||||
CLONE_NODE_FIELD(pConditions);
|
CLONE_NODE_FIELD(pConditions);
|
||||||
CLONE_NODE_LIST_FIELD(pChildren);
|
CLONE_NODE_LIST_FIELD(pChildren);
|
||||||
COPY_SCALAR_FIELD(optimizedFlag);
|
COPY_SCALAR_FIELD(optimizedFlag);
|
||||||
COPY_SCALAR_FIELD(precision);
|
COPY_SCALAR_FIELD(precision);
|
||||||
return (SNode*)pDst;
|
CLONE_NODE_FIELD(pLimit);
|
||||||
|
CLONE_NODE_FIELD(pSlimit);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||||
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
||||||
|
@ -357,36 +352,32 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(tsColId);
|
COPY_SCALAR_FIELD(tsColId);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
CLONE_NODE_LIST_FIELD(pPartTags);
|
CLONE_NODE_LIST_FIELD(pPartTags);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
COPY_SCALAR_FIELD(joinType);
|
COPY_SCALAR_FIELD(joinType);
|
||||||
CLONE_NODE_FIELD(pOnConditions);
|
CLONE_NODE_FIELD(pOnConditions);
|
||||||
COPY_SCALAR_FIELD(isSingleTableJoin);
|
COPY_SCALAR_FIELD(isSingleTableJoin);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
|
static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pGroupKeys);
|
CLONE_NODE_LIST_FIELD(pGroupKeys);
|
||||||
CLONE_NODE_LIST_FIELD(pAggFuncs);
|
CLONE_NODE_LIST_FIELD(pAggFuncs);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) {
|
static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pProjections);
|
CLONE_NODE_LIST_FIELD(pProjections);
|
||||||
COPY_CHAR_ARRAY_FIELD(stmtName);
|
COPY_CHAR_ARRAY_FIELD(stmtName);
|
||||||
COPY_SCALAR_FIELD(limit);
|
return TSDB_CODE_SUCCESS;
|
||||||
COPY_SCALAR_FIELD(offset);
|
|
||||||
COPY_SCALAR_FIELD(slimit);
|
|
||||||
COPY_SCALAR_FIELD(soffset);
|
|
||||||
return (SNode*)pDst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) {
|
static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
COPY_SCALAR_FIELD(modifyType);
|
COPY_SCALAR_FIELD(modifyType);
|
||||||
COPY_SCALAR_FIELD(msgType);
|
COPY_SCALAR_FIELD(msgType);
|
||||||
|
@ -395,25 +386,25 @@ static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModif
|
||||||
COPY_SCALAR_FIELD(tableType);
|
COPY_SCALAR_FIELD(tableType);
|
||||||
COPY_CHAR_ARRAY_FIELD(tableFName);
|
COPY_CHAR_ARRAY_FIELD(tableFName);
|
||||||
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) {
|
static int32_t logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
COPY_SCALAR_FIELD(srcGroupId);
|
COPY_SCALAR_FIELD(srcGroupId);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) {
|
static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pMergeKeys);
|
CLONE_NODE_LIST_FIELD(pMergeKeys);
|
||||||
CLONE_NODE_LIST_FIELD(pInputs);
|
CLONE_NODE_LIST_FIELD(pInputs);
|
||||||
COPY_SCALAR_FIELD(numOfChannels);
|
COPY_SCALAR_FIELD(numOfChannels);
|
||||||
COPY_SCALAR_FIELD(srcGroupId);
|
COPY_SCALAR_FIELD(srcGroupId);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
COPY_SCALAR_FIELD(winType);
|
COPY_SCALAR_FIELD(winType);
|
||||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
|
@ -430,37 +421,37 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
COPY_SCALAR_FIELD(windowAlgo);
|
COPY_SCALAR_FIELD(windowAlgo);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
|
static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
COPY_SCALAR_FIELD(mode);
|
COPY_SCALAR_FIELD(mode);
|
||||||
CLONE_NODE_FIELD(pWStartTs);
|
CLONE_NODE_FIELD(pWStartTs);
|
||||||
CLONE_NODE_FIELD(pValues);
|
CLONE_NODE_FIELD(pValues);
|
||||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) {
|
static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pSortKeys);
|
CLONE_NODE_LIST_FIELD(pSortKeys);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) {
|
static int32_t logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) {
|
static int32_t logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) {
|
static int32_t logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||||
|
@ -468,26 +459,26 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL
|
||||||
COPY_SCALAR_FIELD(fillMode);
|
COPY_SCALAR_FIELD(fillMode);
|
||||||
CLONE_NODE_FIELD(pFillValues);
|
CLONE_NODE_FIELD(pFillValues);
|
||||||
CLONE_NODE_FIELD(pTimeSeries);
|
CLONE_NODE_FIELD(pTimeSeries);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
static int32_t logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
||||||
COPY_OBJECT_FIELD(id, sizeof(SSubplanId));
|
COPY_OBJECT_FIELD(id, sizeof(SSubplanId));
|
||||||
CLONE_NODE_FIELD_EX(pNode, SLogicNode*);
|
CLONE_NODE_FIELD_EX(pNode, SLogicNode*);
|
||||||
COPY_SCALAR_FIELD(subplanType);
|
COPY_SCALAR_FIELD(subplanType);
|
||||||
COPY_SCALAR_FIELD(level);
|
COPY_SCALAR_FIELD(level);
|
||||||
COPY_SCALAR_FIELD(splitFlag);
|
COPY_SCALAR_FIELD(splitFlag);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) {
|
static int32_t physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) {
|
||||||
CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*);
|
CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*);
|
||||||
CLONE_NODE_FIELD(pConditions);
|
CLONE_NODE_FIELD(pConditions);
|
||||||
CLONE_NODE_LIST_FIELD(pChildren);
|
CLONE_NODE_LIST_FIELD(pChildren);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
static int32_t physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||||
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
||||||
|
@ -495,14 +486,14 @@ static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(suid);
|
COPY_SCALAR_FIELD(suid);
|
||||||
COPY_SCALAR_FIELD(tableType);
|
COPY_SCALAR_FIELD(tableType);
|
||||||
COPY_OBJECT_FIELD(tableName, sizeof(SName));
|
COPY_OBJECT_FIELD(tableName, sizeof(SName));
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) {
|
static int32_t physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) {
|
||||||
return physiScanCopy(pSrc, pDst);
|
return physiScanCopy(pSrc, pDst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) {
|
static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
||||||
COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2);
|
COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2);
|
||||||
COPY_OBJECT_FIELD(scanRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(scanRange, sizeof(STimeWindow));
|
||||||
|
@ -519,18 +510,18 @@ static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhys
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(tsColId);
|
COPY_SCALAR_FIELD(tsColId);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) {
|
static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
COPY_BASE_OBJECT_FIELD(scan, physiScanCopy);
|
||||||
COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet));
|
COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet));
|
||||||
COPY_SCALAR_FIELD(showRewrite);
|
COPY_SCALAR_FIELD(showRewrite);
|
||||||
COPY_SCALAR_FIELD(accountId);
|
COPY_SCALAR_FIELD(accountId);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) {
|
static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pExprs);
|
CLONE_NODE_LIST_FIELD(pExprs);
|
||||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
|
@ -539,59 +530,59 @@ static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pD
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) {
|
static int32_t physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
||||||
COPY_SCALAR_FIELD(interval);
|
COPY_SCALAR_FIELD(interval);
|
||||||
COPY_SCALAR_FIELD(offset);
|
COPY_SCALAR_FIELD(offset);
|
||||||
COPY_SCALAR_FIELD(sliding);
|
COPY_SCALAR_FIELD(sliding);
|
||||||
COPY_SCALAR_FIELD(intervalUnit);
|
COPY_SCALAR_FIELD(intervalUnit);
|
||||||
COPY_SCALAR_FIELD(slidingUnit);
|
COPY_SCALAR_FIELD(slidingUnit);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) {
|
static int32_t physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
COPY_BASE_OBJECT_FIELD(window, physiWindowCopy);
|
||||||
COPY_SCALAR_FIELD(gap);
|
COPY_SCALAR_FIELD(gap);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) {
|
static int32_t physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, physiNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pExprs);
|
CLONE_NODE_LIST_FIELD(pExprs);
|
||||||
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
||||||
CLONE_NODE_LIST_FIELD(pTargets);
|
CLONE_NODE_LIST_FIELD(pTargets);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
|
static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(dataBlockId);
|
COPY_SCALAR_FIELD(dataBlockId);
|
||||||
CLONE_NODE_LIST_FIELD(pSlots);
|
CLONE_NODE_LIST_FIELD(pSlots);
|
||||||
COPY_SCALAR_FIELD(totalRowSize);
|
COPY_SCALAR_FIELD(totalRowSize);
|
||||||
COPY_SCALAR_FIELD(outputRowSize);
|
COPY_SCALAR_FIELD(outputRowSize);
|
||||||
COPY_SCALAR_FIELD(precision);
|
COPY_SCALAR_FIELD(precision);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) {
|
static int32_t slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(slotId);
|
COPY_SCALAR_FIELD(slotId);
|
||||||
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||||
COPY_SCALAR_FIELD(reserve);
|
COPY_SCALAR_FIELD(reserve);
|
||||||
COPY_SCALAR_FIELD(output);
|
COPY_SCALAR_FIELD(output);
|
||||||
COPY_SCALAR_FIELD(tag);
|
COPY_SCALAR_FIELD(tag);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) {
|
static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) {
|
||||||
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
|
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
|
||||||
COPY_SCALAR_FIELD(taskId);
|
COPY_SCALAR_FIELD(taskId);
|
||||||
COPY_SCALAR_FIELD(schedId);
|
COPY_SCALAR_FIELD(schedId);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||||
COPY_SCALAR_FIELD(isDistinct);
|
COPY_SCALAR_FIELD(isDistinct);
|
||||||
CLONE_NODE_LIST_FIELD(pProjectionList);
|
CLONE_NODE_LIST_FIELD(pProjectionList);
|
||||||
CLONE_NODE_FIELD(pFromTable);
|
CLONE_NODE_FIELD(pFromTable);
|
||||||
|
@ -609,116 +600,166 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||||
COPY_SCALAR_FIELD(isTimeOrderQuery);
|
COPY_SCALAR_FIELD(isTimeOrderQuery);
|
||||||
COPY_SCALAR_FIELD(hasAggFuncs);
|
COPY_SCALAR_FIELD(hasAggFuncs);
|
||||||
COPY_SCALAR_FIELD(hasRepeatScanFuncs);
|
COPY_SCALAR_FIELD(hasRepeatScanFuncs);
|
||||||
return (SNode*)pDst;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* nodesCloneNode(const SNode* pNode) {
|
SNode* nodesCloneNode(const SNode* pNode) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pDst = nodesMakeNode(nodeType(pNode));
|
SNode* pDst = nodesMakeNode(nodeType(pNode));
|
||||||
if (NULL == pDst) {
|
if (NULL == pDst) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
case QUERY_NODE_COLUMN:
|
case QUERY_NODE_COLUMN:
|
||||||
return columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_VALUE:
|
case QUERY_NODE_VALUE:
|
||||||
return valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
return operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst);
|
code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_CONDITION:
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
return logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst);
|
code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_FUNCTION:
|
case QUERY_NODE_FUNCTION:
|
||||||
return functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst);
|
code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_REAL_TABLE:
|
case QUERY_NODE_REAL_TABLE:
|
||||||
return realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst);
|
code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_TEMP_TABLE:
|
case QUERY_NODE_TEMP_TABLE:
|
||||||
return tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst);
|
code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_JOIN_TABLE:
|
case QUERY_NODE_JOIN_TABLE:
|
||||||
return joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst);
|
code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_GROUPING_SET:
|
case QUERY_NODE_GROUPING_SET:
|
||||||
return groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst);
|
code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_ORDER_BY_EXPR:
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst);
|
code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LIMIT:
|
case QUERY_NODE_LIMIT:
|
||||||
return limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst);
|
code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_STATE_WINDOW:
|
case QUERY_NODE_STATE_WINDOW:
|
||||||
return stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst);
|
code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SESSION_WINDOW:
|
case QUERY_NODE_SESSION_WINDOW:
|
||||||
return sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst);
|
code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_INTERVAL_WINDOW:
|
case QUERY_NODE_INTERVAL_WINDOW:
|
||||||
return intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst);
|
code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_NODE_LIST:
|
case QUERY_NODE_NODE_LIST:
|
||||||
return nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst);
|
code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_FILL:
|
case QUERY_NODE_FILL:
|
||||||
return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
|
code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_TARGET:
|
case QUERY_NODE_TARGET:
|
||||||
return targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst);
|
code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_DATABLOCK_DESC:
|
case QUERY_NODE_DATABLOCK_DESC:
|
||||||
return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SLOT_DESC:
|
case QUERY_NODE_SLOT_DESC:
|
||||||
return slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst);
|
code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||||
return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LEFT_VALUE:
|
case QUERY_NODE_LEFT_VALUE:
|
||||||
return pDst;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
break;
|
||||||
case QUERY_NODE_SELECT_STMT:
|
case QUERY_NODE_SELECT_STMT:
|
||||||
return selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||||
return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||||
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
return logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst);
|
code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
return logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst);
|
code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||||
return logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst);
|
code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_FILL:
|
case QUERY_NODE_LOGIC_PLAN_FILL:
|
||||||
return logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst);
|
code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_SORT:
|
case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||||
return logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst);
|
code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_PARTITION:
|
case QUERY_NODE_LOGIC_PLAN_PARTITION:
|
||||||
return logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst);
|
code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC:
|
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC:
|
||||||
return logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst);
|
code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||||
return logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst);
|
code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst);
|
code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
return physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst);
|
code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
|
||||||
return physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst);
|
code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||||
return physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst);
|
code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
||||||
return physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst);
|
code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
|
||||||
return physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst);
|
code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||||
return physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst);
|
code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nodesDestroyNode(pDst);
|
|
||||||
nodesError("nodesCloneNode unknown node = %s", nodesNodeName(nodeType(pNode)));
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return NULL;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
nodesDestroyNode(pDst);
|
||||||
|
nodesError("nodesCloneNode failed node = %s", nodesNodeName(nodeType(pNode)));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* nodesCloneList(const SNodeList* pList) {
|
SNodeList* nodesCloneList(const SNodeList* pList) {
|
||||||
|
@ -726,19 +767,15 @@ SNodeList* nodesCloneList(const SNodeList* pList) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* pDst = nodesMakeList();
|
SNodeList* pDst = NULL;
|
||||||
if (NULL == pDst) {
|
SNode* pNode;
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
SNode* pNode;
|
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
SNode* pNewNode = nodesCloneNode(pNode);
|
int32_t code = nodesListMakeStrictAppend(&pDst, nodesCloneNode(pNode));
|
||||||
if (NULL == pNewNode) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
nodesDestroyList(pDst);
|
nodesDestroyList(pDst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
nodesListAppend(pDst, pNewNode);
|
|
||||||
}
|
}
|
||||||
return pDst;
|
return pDst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
|
||||||
static const char* jkLogicPlanTargets = "Targets";
|
static const char* jkLogicPlanTargets = "Targets";
|
||||||
static const char* jkLogicPlanConditions = "Conditions";
|
static const char* jkLogicPlanConditions = "Conditions";
|
||||||
static const char* jkLogicPlanChildren = "Children";
|
static const char* jkLogicPlanChildren = "Children";
|
||||||
|
static const char* jkLogicPlanLimit = "Limit";
|
||||||
|
static const char* jkLogicPlanSlimit = "SLimit";
|
||||||
|
|
||||||
static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SLogicNode* pNode = (const SLogicNode*)pObj;
|
const SLogicNode* pNode = (const SLogicNode*)pObj;
|
||||||
|
@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkLogicPlanChildren, pNode->pChildren);
|
code = nodeListToJson(pJson, jkLogicPlanChildren, pNode->pChildren);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkLogicPlanLimit, nodeToJson, pNode->pLimit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkLogicPlanSlimit, nodeToJson, pNode->pSlimit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkLogicPlanChildren, &pNode->pChildren);
|
code = jsonToNodeList(pJson, jkLogicPlanChildren, &pNode->pChildren);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkLogicPlanLimit, &pNode->pLimit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkLogicPlanSlimit, &pNode->pSlimit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* jkProjectLogicPlanProjections = "Projections";
|
static const char* jkProjectLogicPlanProjections = "Projections";
|
||||||
static const char* jkProjectLogicPlanLimit = "Limit";
|
|
||||||
static const char* jkProjectLogicPlanOffset = "Offset";
|
|
||||||
static const char* jkProjectLogicPlanSlimit = "SLimit";
|
|
||||||
static const char* jkProjectLogicPlanSoffset = "SOffset";
|
|
||||||
|
|
||||||
static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj;
|
const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj;
|
||||||
|
@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkProjectLogicPlanProjections, pNode->pProjections);
|
code = nodeListToJson(pJson, jkProjectLogicPlanProjections, pNode->pProjections);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanLimit, pNode->limit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanOffset, pNode->offset);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSoffset, pNode->soffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkProjectLogicPlanProjections, &pNode->pProjections);
|
code = jsonToNodeList(pJson, jkProjectLogicPlanProjections, &pNode->pProjections);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanLimit, &pNode->limit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanOffset, &pNode->offset);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSoffset, &pNode->soffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
static const char* jkPhysiPlanOutputDataBlockDesc = "OutputDataBlockDesc";
|
static const char* jkPhysiPlanOutputDataBlockDesc = "OutputDataBlockDesc";
|
||||||
static const char* jkPhysiPlanConditions = "Conditions";
|
static const char* jkPhysiPlanConditions = "Conditions";
|
||||||
static const char* jkPhysiPlanChildren = "Children";
|
static const char* jkPhysiPlanChildren = "Children";
|
||||||
|
static const char* jkPhysiPlanLimit = "Limit";
|
||||||
|
static const char* jkPhysiPlanSlimit = "SLimit";
|
||||||
|
|
||||||
static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SPhysiNode* pNode = (const SPhysiNode*)pObj;
|
const SPhysiNode* pNode = (const SPhysiNode*)pObj;
|
||||||
|
@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkPhysiPlanChildren, pNode->pChildren);
|
code = nodeListToJson(pJson, jkPhysiPlanChildren, pNode->pChildren);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkPhysiPlanLimit, nodeToJson, pNode->pLimit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkPhysiPlanSlimit, nodeToJson, pNode->pSlimit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkPhysiPlanChildren, &pNode->pChildren);
|
code = jsonToNodeList(pJson, jkPhysiPlanChildren, &pNode->pChildren);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkPhysiPlanLimit, &pNode->pLimit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkPhysiPlanSlimit, &pNode->pSlimit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* jkProjectPhysiPlanProjections = "Projections";
|
static const char* jkProjectPhysiPlanProjections = "Projections";
|
||||||
static const char* jkProjectPhysiPlanLimit = "Limit";
|
|
||||||
static const char* jkProjectPhysiPlanOffset = "Offset";
|
|
||||||
static const char* jkProjectPhysiPlanSlimit = "SLimit";
|
|
||||||
static const char* jkProjectPhysiPlanSoffset = "SOffset";
|
|
||||||
|
|
||||||
static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj;
|
const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj;
|
||||||
|
@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkProjectPhysiPlanProjections, pNode->pProjections);
|
code = nodeListToJson(pJson, jkProjectPhysiPlanProjections, pNode->pProjections);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanLimit, pNode->limit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanOffset, pNode->offset);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSlimit, pNode->slimit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSoffset, pNode->soffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkProjectPhysiPlanProjections, &pNode->pProjections);
|
code = jsonToNodeList(pJson, jkProjectPhysiPlanProjections, &pNode->pProjections);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanLimit, &pNode->limit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanOffset, &pNode->offset);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSlimit, &pNode->slimit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSoffset, &pNode->soffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2322,6 +2294,7 @@ static const char* jkSubplanType = "SubplanType";
|
||||||
static const char* jkSubplanMsgType = "MsgType";
|
static const char* jkSubplanMsgType = "MsgType";
|
||||||
static const char* jkSubplanLevel = "Level";
|
static const char* jkSubplanLevel = "Level";
|
||||||
static const char* jkSubplanDbFName = "DbFName";
|
static const char* jkSubplanDbFName = "DbFName";
|
||||||
|
static const char* jkSubplanUser = "User";
|
||||||
static const char* jkSubplanNodeAddr = "NodeAddr";
|
static const char* jkSubplanNodeAddr = "NodeAddr";
|
||||||
static const char* jkSubplanRootNode = "RootNode";
|
static const char* jkSubplanRootNode = "RootNode";
|
||||||
static const char* jkSubplanDataSink = "DataSink";
|
static const char* jkSubplanDataSink = "DataSink";
|
||||||
|
@ -2344,6 +2317,9 @@ static int32_t subplanToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkSubplanDbFName, pNode->dbFName);
|
code = tjsonAddStringToObject(pJson, jkSubplanDbFName, pNode->dbFName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddStringToObject(pJson, jkSubplanUser, pNode->user);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkSubplanNodeAddr, queryNodeAddrToJson, &pNode->execNode);
|
code = tjsonAddObject(pJson, jkSubplanNodeAddr, queryNodeAddrToJson, &pNode->execNode);
|
||||||
}
|
}
|
||||||
|
@ -2380,6 +2356,9 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkSubplanDbFName, pNode->dbFName);
|
code = tjsonGetStringValue(pJson, jkSubplanDbFName, pNode->dbFName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetStringValue(pJson, jkSubplanUser, pNode->user);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonToObject(pJson, jkSubplanNodeAddr, jsonToQueryNodeAddr, &pNode->execNode);
|
code = tjsonToObject(pJson, jkSubplanNodeAddr, jsonToQueryNodeAddr, &pNode->execNode);
|
||||||
}
|
}
|
||||||
|
@ -3165,6 +3144,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkLimitLimit = "Limit";
|
||||||
|
static const char* jkLimitOffset = "Offset";
|
||||||
|
|
||||||
|
static int32_t limitNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SLimitNode* pNode = (const SLimitNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = tjsonAddIntegerToObject(pJson, jkLimitLimit, pNode->limit);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkLimitOffset, pNode->offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToLimitNode(const SJson* pJson, void* pObj) {
|
||||||
|
SLimitNode* pNode = (SLimitNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = tjsonGetBigIntValue(pJson, jkLimitLimit, &pNode->limit);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkLimitOffset, &pNode->offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkStateWindowCol = "StateWindowCol";
|
static const char* jkStateWindowCol = "StateWindowCol";
|
||||||
static const char* jkStateWindowExpr = "StateWindowExpr";
|
static const char* jkStateWindowExpr = "StateWindowExpr";
|
||||||
|
|
||||||
|
@ -4031,7 +4035,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
case QUERY_NODE_ORDER_BY_EXPR:
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
return orderByExprNodeToJson(pObj, pJson);
|
return orderByExprNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LIMIT:
|
case QUERY_NODE_LIMIT:
|
||||||
break;
|
return limitNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_STATE_WINDOW:
|
case QUERY_NODE_STATE_WINDOW:
|
||||||
return stateWindowNodeToJson(pObj, pJson);
|
return stateWindowNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SESSION_WINDOW:
|
case QUERY_NODE_SESSION_WINDOW:
|
||||||
|
@ -4191,6 +4195,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToTempTableNode(pJson, pObj);
|
return jsonToTempTableNode(pJson, pObj);
|
||||||
case QUERY_NODE_ORDER_BY_EXPR:
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
return jsonToOrderByExprNode(pJson, pObj);
|
return jsonToOrderByExprNode(pJson, pObj);
|
||||||
|
case QUERY_NODE_LIMIT:
|
||||||
|
return jsonToLimitNode(pJson, pObj);
|
||||||
case QUERY_NODE_STATE_WINDOW:
|
case QUERY_NODE_STATE_WINDOW:
|
||||||
return jsonToStateWindowNode(pJson, pObj);
|
return jsonToStateWindowNode(pJson, pObj);
|
||||||
case QUERY_NODE_SESSION_WINDOW:
|
case QUERY_NODE_SESSION_WINDOW:
|
||||||
|
|
|
@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
||||||
|
@ -371,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
||||||
|
|
||||||
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); }
|
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); }
|
||||||
|
|
||||||
|
static void destroyExprNode(SExprNode* pExpr) { taosArrayDestroy(pExpr->pAssociation); }
|
||||||
|
|
||||||
void nodesDestroyNode(SNode* pNode) {
|
void nodesDestroyNode(SNode* pNode) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return;
|
return;
|
||||||
|
@ -378,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
|
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
case QUERY_NODE_COLUMN: // pProjectRef is weak reference, no need to release
|
case QUERY_NODE_COLUMN: // pProjectRef is weak reference, no need to release
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_VALUE: {
|
case QUERY_NODE_VALUE: {
|
||||||
SValueNode* pValue = (SValueNode*)pNode;
|
SValueNode* pValue = (SValueNode*)pNode;
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
taosMemoryFreeClear(pValue->literal);
|
taosMemoryFreeClear(pValue->literal);
|
||||||
if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) {
|
if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) {
|
||||||
taosMemoryFreeClear(pValue->datum.p);
|
taosMemoryFreeClear(pValue->datum.p);
|
||||||
|
@ -389,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
}
|
}
|
||||||
case QUERY_NODE_OPERATOR: {
|
case QUERY_NODE_OPERATOR: {
|
||||||
SOperatorNode* pOp = (SOperatorNode*)pNode;
|
SOperatorNode* pOp = (SOperatorNode*)pNode;
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
nodesDestroyNode(pOp->pLeft);
|
nodesDestroyNode(pOp->pLeft);
|
||||||
nodesDestroyNode(pOp->pRight);
|
nodesDestroyNode(pOp->pRight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_CONDITION:
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
nodesDestroyList(((SLogicConditionNode*)pNode)->pParameterList);
|
nodesDestroyList(((SLogicConditionNode*)pNode)->pParameterList);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_FUNCTION:
|
case QUERY_NODE_FUNCTION:
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
nodesDestroyList(((SFunctionNode*)pNode)->pParameterList);
|
nodesDestroyList(((SFunctionNode*)pNode)->pParameterList);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_REAL_TABLE: {
|
case QUERY_NODE_REAL_TABLE: {
|
||||||
|
@ -644,7 +652,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT: {
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: {
|
||||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
|
@ -831,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||||
nodesDestroyList(pPhyNode->pExprs);
|
nodesDestroyList(pPhyNode->pExprs);
|
||||||
nodesDestroyList(pPhyNode->pSortKeys);
|
nodesDestroyList(pPhyNode->pSortKeys);
|
||||||
|
nodesDestroyList(pPhyNode->pTargets);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
|
@ -1094,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SListCell* nodesListGetCell(SNodeList* pList, int32_t index) {
|
||||||
|
SNode* node;
|
||||||
|
FOREACH(node, pList) {
|
||||||
|
if (0 == index--) {
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void nodesDestroyList(SNodeList* pList) {
|
void nodesDestroyList(SNodeList* pList) {
|
||||||
if (NULL == pList) {
|
if (NULL == pList) {
|
||||||
return;
|
return;
|
||||||
|
@ -1200,6 +1220,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) {
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
case TSDB_DATA_TYPE_JSON:
|
||||||
pNode->datum.p = (char*)value;
|
pNode->datum.p = (char*)value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
||||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
||||||
SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||||
|
SNode* pStreamOptions);
|
||||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName);
|
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName);
|
||||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
|
|
|
@ -388,6 +388,8 @@ cmd ::= SHOW SNODES.
|
||||||
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
|
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
|
||||||
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
|
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
|
||||||
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
|
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
|
||||||
|
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
||||||
|
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
|
||||||
|
|
||||||
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
||||||
|
@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
||||||
// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
|
// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
|
||||||
cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); }
|
cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); }
|
||||||
|
|
||||||
index_options(A) ::= . { A = NULL; }
|
|
||||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||||
NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); }
|
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
|
||||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||||
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); }
|
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E)
|
||||||
|
sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); }
|
||||||
|
|
||||||
%type func_list { SNodeList* }
|
%type func_list { SNodeList* }
|
||||||
%destructor func_list { nodesDestroyList($$); }
|
%destructor func_list { nodesDestroyList($$); }
|
||||||
|
@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
|
||||||
|
|
||||||
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
||||||
|
|
||||||
|
sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); }
|
||||||
|
sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
|
sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
|
|
||||||
/************************************************ create/drop topic ***************************************************/
|
/************************************************ create/drop topic ***************************************************/
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); }
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); }
|
||||||
|
|
|
@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset,
|
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||||
SNode* pSliding) {
|
SNode* pStreamOptions) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||||
CHECK_OUT_OF_MEM(pOptions);
|
CHECK_OUT_OF_MEM(pOptions);
|
||||||
|
@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
|
||||||
pOptions->pInterval = pInterval;
|
pOptions->pInterval = pInterval;
|
||||||
pOptions->pOffset = pOffset;
|
pOptions->pOffset = pOffset;
|
||||||
pOptions->pSliding = pSliding;
|
pOptions->pSliding = pSliding;
|
||||||
|
pOptions->pStreamOptions = pStreamOptions;
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowConsumers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -456,6 +461,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
pCxt->pStmt = pStmt;
|
pCxt->pStmt = pStmt;
|
||||||
switch (nodeType(pStmt)) {
|
switch (nodeType(pStmt)) {
|
||||||
|
@ -517,6 +527,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
|
return collectMetaKeyFromShowConsumers(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
|
@ -538,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
||||||
return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt);
|
return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
|
return collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,17 +175,23 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||||
|
strcpy(aliasName, ((SExprNode*)pProject)->aliasName);
|
||||||
int32_t code = scalarCalculateConstants(pProject, pNew);
|
int32_t code = scalarCalculateConstants(pProject, pNew);
|
||||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) {
|
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) {
|
||||||
|
strcpy(((SExprNode*)*pNew)->aliasName, aliasName);
|
||||||
int32_t size = taosArrayGetSize(pAssociation);
|
int32_t size = taosArrayGetSize(pAssociation);
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
SNode** pCol = taosArrayGetP(pAssociation, i);
|
SNode** pCol = taosArrayGetP(pAssociation, i);
|
||||||
|
nodesDestroyNode(*pCol);
|
||||||
*pCol = nodesCloneNode(*pNew);
|
*pCol = nodesCloneNode(*pNew);
|
||||||
if (NULL == *pCol) {
|
if (NULL == *pCol) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taosArrayDestroy(pAssociation);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +202,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) {
|
||||||
return NULL == ((SExprNode*)pProj)->pAssociation;
|
return NULL == ((SExprNode*)pProj)->pAssociation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* createConstantValue() {
|
||||||
|
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
|
if (NULL == pVal) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pVal->node.resType.type = TSDB_DATA_TYPE_INT;
|
||||||
|
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||||
|
const int32_t val = 1;
|
||||||
|
nodesSetValueNodeValue(pVal, (void*)&val);
|
||||||
|
pVal->translate = true;
|
||||||
|
return (SNode*)pVal;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
||||||
SNode* pProj = NULL;
|
SNode* pProj = NULL;
|
||||||
WHERE_EACH(pProj, pSelect->pProjectionList) {
|
WHERE_EACH(pProj, pSelect->pProjectionList) {
|
||||||
|
@ -212,6 +231,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
||||||
}
|
}
|
||||||
WHERE_NEXT;
|
WHERE_NEXT;
|
||||||
}
|
}
|
||||||
|
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
||||||
|
return nodesListStrictAppend(pSelect->pProjectionList, createConstantValue());
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
typedef struct SBlockKeyTuple {
|
typedef struct SBlockKeyTuple {
|
||||||
TSKEY skey;
|
TSKEY skey;
|
||||||
void* payloadAddr;
|
void* payloadAddr;
|
||||||
|
int16_t index;
|
||||||
} SBlockKeyTuple;
|
} SBlockKeyTuple;
|
||||||
|
|
||||||
typedef struct SBlockKeyInfo {
|
typedef struct SBlockKeyInfo {
|
||||||
|
@ -36,7 +37,6 @@ typedef struct SBlockKeyInfo {
|
||||||
static int32_t rowDataCompar(const void* lhs, const void* rhs) {
|
static int32_t rowDataCompar(const void* lhs, const void* rhs) {
|
||||||
TSKEY left = *(TSKEY*)lhs;
|
TSKEY left = *(TSKEY*)lhs;
|
||||||
TSKEY right = *(TSKEY*)rhs;
|
TSKEY right = *(TSKEY*)rhs;
|
||||||
|
|
||||||
if (left == right) {
|
if (left == right) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,6 +44,16 @@ static int32_t rowDataCompar(const void* lhs, const void* rhs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t rowDataComparStable(const void* lhs, const void* rhs) {
|
||||||
|
TSKEY left = *(TSKEY*)lhs;
|
||||||
|
TSKEY right = *(TSKEY*)rhs;
|
||||||
|
if (left == right) {
|
||||||
|
return ((SBlockKeyTuple*)lhs)->index - ((SBlockKeyTuple*)rhs)->index;
|
||||||
|
} else {
|
||||||
|
return left > right ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) {
|
void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) {
|
||||||
pColList->numOfCols = numOfCols;
|
pColList->numOfCols = numOfCols;
|
||||||
pColList->numOfBound = numOfCols;
|
pColList->numOfBound = numOfCols;
|
||||||
|
@ -343,6 +353,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
|
||||||
while (n < nRows) {
|
while (n < nRows) {
|
||||||
pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData);
|
pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData);
|
||||||
pBlkKeyTuple->payloadAddr = pBlockData;
|
pBlkKeyTuple->payloadAddr = pBlockData;
|
||||||
|
pBlkKeyTuple->index = n;
|
||||||
|
|
||||||
// next loop
|
// next loop
|
||||||
pBlockData += extendedRowSize;
|
pBlockData += extendedRowSize;
|
||||||
|
@ -354,7 +365,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
|
||||||
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
||||||
|
|
||||||
// todo. qsort is unstable, if timestamp is same, should get the last one
|
// todo. qsort is unstable, if timestamp is same, should get the last one
|
||||||
qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataCompar);
|
qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable);
|
||||||
|
|
||||||
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|
|
@ -63,6 +63,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"CONNECTION", TK_CONNECTION},
|
{"CONNECTION", TK_CONNECTION},
|
||||||
{"CONNECTIONS", TK_CONNECTIONS},
|
{"CONNECTIONS", TK_CONNECTIONS},
|
||||||
{"CONSUMER", TK_CONSUMER},
|
{"CONSUMER", TK_CONSUMER},
|
||||||
|
{"CONSUMERS", TK_CONSUMERS},
|
||||||
{"COUNT", TK_COUNT},
|
{"COUNT", TK_COUNT},
|
||||||
{"CREATE", TK_CREATE},
|
{"CREATE", TK_CREATE},
|
||||||
{"CONTAINS", TK_CONTAINS},
|
{"CONTAINS", TK_CONTAINS},
|
||||||
|
@ -188,6 +189,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"STREAM", TK_STREAM},
|
{"STREAM", TK_STREAM},
|
||||||
{"STREAMS", TK_STREAMS},
|
{"STREAMS", TK_STREAMS},
|
||||||
{"STRICT", TK_STRICT},
|
{"STRICT", TK_STRICT},
|
||||||
|
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
|
||||||
{"SYNCDB", TK_SYNCDB},
|
{"SYNCDB", TK_SYNCDB},
|
||||||
{"SYSINFO", TK_SYSINFO},
|
{"SYSINFO", TK_SYSINFO},
|
||||||
{"TABLE", TK_TABLE},
|
{"TABLE", TK_TABLE},
|
||||||
|
|
|
@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
setColumnInfoByExpr(pTable, (SExprNode*)pNode, &pCol);
|
|
||||||
nodesListAppend(pList, (SNode*)pCol);
|
nodesListAppend(pList, (SNode*)pCol);
|
||||||
|
SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1);
|
||||||
|
setColumnInfoByExpr(pTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -707,7 +708,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||||
res = translateColumnUseAlias(pCxt, pCol, &found);
|
res = translateColumnUseAlias(pCxt, pCol, &found);
|
||||||
}
|
}
|
||||||
if (DEAL_RES_ERROR != res && !found) {
|
if (DEAL_RES_ERROR != res && !found) {
|
||||||
res = translateColumnWithoutPrefix(pCxt, pCol);
|
if (NULL != pCxt->pCurrSetOperator) {
|
||||||
|
res = generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName);
|
||||||
|
} else {
|
||||||
|
res = translateColumnWithoutPrefix(pCxt, pCol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -2656,6 +2661,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) {
|
||||||
|
if ((NULL != pLimit && pLimit->offset < 0)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_OFFSET_LESS_ZERO);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
||||||
int32_t code = translateQuery(pCxt, pSetOperator->pLeft);
|
int32_t code = translateQuery(pCxt, pSetOperator->pLeft);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -2671,6 +2683,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateSetOperOrderBy(pCxt, pSetOperator);
|
code = translateSetOperOrderBy(pCxt, pSetOperator);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkSetOperLimit(pCxt, (SLimitNode*)pSetOperator->pLimit);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3566,9 +3581,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) {
|
||||||
}
|
}
|
||||||
*pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN);
|
*pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN);
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, pFuncs) {
|
FOREACH(pNode, pFuncs) { taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); }
|
||||||
taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3867,6 +3880,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
|
||||||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
||||||
pReq->slidingUnit =
|
pReq->slidingUnit =
|
||||||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
||||||
|
if (NULL != pStmt->pOptions->pStreamOptions) {
|
||||||
|
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
||||||
|
pReq->maxDelay = (NULL != pStreamOpt->pDelay ? ((SValueNode*)pStreamOpt->pDelay)->datum.i : 0);
|
||||||
|
pReq->watermark = (NULL != pStreamOpt->pWatermark ? ((SValueNode*)pStreamOpt->pWatermark)->datum.i : 0);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId);
|
int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -3888,6 +3906,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != pStmt->pOptions->pStreamOptions) {
|
||||||
|
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
||||||
|
if (NULL != pStreamOpt->pWatermark &&
|
||||||
|
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) {
|
||||||
|
return pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) {
|
||||||
|
return pCxt->errCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SMCreateSmaReq createSmaReq = {0};
|
SMCreateSmaReq createSmaReq = {0};
|
||||||
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
|
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -4611,7 +4641,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema**
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
||||||
*numOfCols = 2;
|
*numOfCols = 2;
|
||||||
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||||
if (NULL == (*pSchema)) {
|
if (NULL == (*pSchema)) {
|
||||||
|
@ -4629,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||||
if (NULL == pRoot) {
|
if (NULL == pRoot) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4649,7 +4678,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
return extractShowCreateTableResultSchema(numOfCols, pSchema);
|
return extractShowCreateTableResultSchema(numOfCols, pSchema);
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
return extractShowLocalVariablesResultSchema(numOfCols, pSchema);
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
|
return extractShowVariablesResultSchema(numOfCols, pSchema);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4683,6 +4713,8 @@ static const char* getSysDbName(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
return TSDB_PERFORMANCE_SCHEMA_DB;
|
return TSDB_PERFORMANCE_SCHEMA_DB;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -4738,6 +4770,10 @@ static const char* getSysTableName(ENodeType type) {
|
||||||
return TSDB_PERFS_TABLE_APPS;
|
return TSDB_PERFS_TABLE_APPS;
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return TSDB_INS_TABLE_DNODE_VARIABLES;
|
return TSDB_INS_TABLE_DNODE_VARIABLES;
|
||||||
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
|
return TSDB_PERFS_TABLE_CONSUMERS;
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
|
return TSDB_PERFS_TABLE_SUBSCRIPTIONS;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5874,8 +5910,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
|
@ -5974,6 +6011,14 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_ALTER_LOCAL_STMT:
|
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
|
pQuery->haveResultSet = true;
|
||||||
|
pQuery->execMode = QUERY_EXEC_MODE_RPC;
|
||||||
|
if (NULL != pCxt->pCmdMsg) {
|
||||||
|
TSWAP(pQuery->pCmdMsg, pCxt->pCmdMsg);
|
||||||
|
pQuery->msgType = pQuery->pCmdMsg->msgType;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_RPC;
|
pQuery->execMode = QUERY_EXEC_MODE_RPC;
|
||||||
if (NULL != pCxt->pCmdMsg) {
|
if (NULL != pCxt->pCmdMsg) {
|
||||||
|
|
|
@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST
|
||||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||||
tNameExtractFullName(pName, fullName);
|
tNameExtractFullName(pName, fullName);
|
||||||
STableCfg* pCfg = NULL;
|
STableCfg* pCfg = NULL;
|
||||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pOutput = tableCfgDup(pCfg);
|
*pOutput = tableCfgDup(pCfg);
|
||||||
if (NULL == *pOutput) {
|
if (NULL == *pOutput) {
|
||||||
|
@ -929,7 +929,7 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) {
|
||||||
|
|
||||||
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
||||||
SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0);
|
SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0);
|
||||||
if (pRes->code) {
|
if (TSDB_CODE_SUCCESS != pRes->code) {
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,95 +25,125 @@
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define TD_USE_WINSOCK
|
#define TD_USE_WINSOCK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mockCatalog.h"
|
#include "mockCatalog.h"
|
||||||
|
|
||||||
|
#include "systable.h"
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void generateInformationSchema(MockCatalogService* mcs) {
|
void generateInformationSchema(MockCatalogService* mcs) {
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1)
|
||||||
builder.done();
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1)
|
|
||||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1)
|
|
||||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1)
|
|
||||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1)
|
|
||||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1)
|
|
||||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2)
|
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
|
||||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2)
|
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
|
||||||
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
|
||||||
builder.done();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2)
|
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
|
||||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder =
|
ITableBuilder& builder =
|
||||||
mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1)
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_DATABASES, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_FUNCTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_INDEXES, TSDB_SYSTEM_TABLE, 2)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_STABLES, TSDB_SYSTEM_TABLE, 2)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLES, TSDB_SYSTEM_TABLE, 2)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "configs", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN);
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnode_variables", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("dnode_id", TSDB_DATA_TYPE_INT);
|
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("dnode_id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void generatePerformanceSchema(MockCatalogService* mcs) {
|
void generatePerformanceSchema(MockCatalogService* mcs) {
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "trans", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "streams", TSDB_SYSTEM_TABLE, 1)
|
ITableBuilder& builder =
|
||||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
|
builder.done();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra
|
||||||
return g_mockCatalogService->catalogGetDnodeList(pDnodeList);
|
return g_mockCatalogService->catalogGetDnodeList(pDnodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) {
|
int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||||
|
STableCfg** pCfg) {
|
||||||
*pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg));
|
*pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,13 +166,10 @@ class MockCatalogServiceImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetDnodeList(SArray** pDnodes) const {
|
int32_t catalogGetDnodeList(SArray** pDnodes) const {
|
||||||
SMetaRes res = {0};
|
*pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet));
|
||||||
res.pRes = taosArrayInit(dnode_.size(), sizeof(SEpSet));
|
|
||||||
for (const auto& dnode : dnode_) {
|
for (const auto& dnode : dnode_) {
|
||||||
taosArrayPush((SArray*)res.pRes, &dnode.second);
|
taosArrayPush(*pDnodes, &dnode.second);
|
||||||
}
|
}
|
||||||
*pDnodes = taosArrayInit(1, sizeof(SMetaRes));
|
|
||||||
taosArrayPush(*pDnodes, &res);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +197,7 @@ class MockCatalogServiceImpl {
|
||||||
code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex);
|
code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) {
|
if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) {
|
||||||
code = catalogGetDnodeList(&pMetaData->pDnodeList);
|
code = getAllDnodeList(&pMetaData->pDnodeList);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg);
|
code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg);
|
||||||
|
@ -565,6 +562,14 @@ class MockCatalogServiceImpl {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t getAllDnodeList(SArray** pDnodes) const {
|
||||||
|
SMetaRes res = {0};
|
||||||
|
catalogGetDnodeList((SArray**)&res.pRes);
|
||||||
|
*pDnodes = taosArrayInit(1, sizeof(SMetaRes));
|
||||||
|
taosArrayPush(*pDnodes, &res);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t id_;
|
uint64_t id_;
|
||||||
std::unique_ptr<TableBuilder> builder_;
|
std::unique_ptr<TableBuilder> builder_;
|
||||||
DbMetaCache meta_;
|
DbMetaCache meta_;
|
||||||
|
|
|
@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) {
|
||||||
TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) {
|
TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||||
|
|
||||||
run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||||
|
|
||||||
run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||||
|
|
||||||
run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE);
|
run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||||
|
|
||||||
// run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)");
|
run("SELECT CSUM(c3) FROM t1 STATE_WINDOW(c1)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC);
|
||||||
|
|
||||||
|
run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserSelectTest, useDefinedFunc) {
|
TEST_F(ParserSelectTest, useDefinedFunc) {
|
||||||
|
@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) {
|
||||||
run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1");
|
run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserSelectTest, setOperatorSemanticCheck) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1 ORDER BY ts", TSDB_CODE_PAR_INVALID_COLUMN);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserSelectTest, informationSchema) {
|
TEST_F(ParserSelectTest, informationSchema) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {};
|
||||||
// todo SHOW apps
|
// todo SHOW apps
|
||||||
// todo SHOW connections
|
// todo SHOW connections
|
||||||
|
|
||||||
|
TEST_F(ParserShowToUseTest, showConsumers) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
setCheckDdlFunc(
|
||||||
|
[&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); });
|
||||||
|
|
||||||
|
run("SHOW CONSUMERS");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showCreateDatabase) {
|
TEST_F(ParserShowToUseTest, showCreateDatabase) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) {
|
||||||
run("SHOW streams");
|
run("SHOW streams");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserShowToUseTest, showSubscriptions) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
setCheckDdlFunc(
|
||||||
|
[&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); });
|
||||||
|
|
||||||
|
run("SHOW SUBSCRIPTIONS");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showTransactions) {
|
TEST_F(ParserShowToUseTest, showTransactions) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,6 @@ class ParserDdlTest : public ParserTestBase {
|
||||||
virtual void checkDdl(const SQuery* pQuery, ParserStage stage) {
|
virtual void checkDdl(const SQuery* pQuery, ParserStage stage) {
|
||||||
ASSERT_NE(pQuery, nullptr);
|
ASSERT_NE(pQuery, nullptr);
|
||||||
ASSERT_NE(pQuery->pRoot, nullptr);
|
ASSERT_NE(pQuery->pRoot, nullptr);
|
||||||
if (QUERY_EXEC_MODE_RPC == pQuery->execMode) {
|
|
||||||
ASSERT_EQ(pQuery->haveResultSet, false);
|
|
||||||
ASSERT_EQ(pQuery->numOfResCols, 0);
|
|
||||||
ASSERT_EQ(pQuery->pResSchema, nullptr);
|
|
||||||
ASSERT_EQ(pQuery->precision, 0);
|
|
||||||
}
|
|
||||||
if (nullptr != checkDdl_) {
|
if (nullptr != checkDdl_) {
|
||||||
checkDdl_(pQuery, stage);
|
checkDdl_(pQuery, stage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
typedef struct SLogicPlanContext {
|
typedef struct SLogicPlanContext {
|
||||||
SPlanContext* pPlanCxt;
|
SPlanContext* pPlanCxt;
|
||||||
|
SLogicNode* pCurrRoot;
|
||||||
} SLogicPlanContext;
|
} SLogicPlanContext;
|
||||||
|
|
||||||
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**);
|
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**);
|
||||||
|
@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||||
pNode->precision = precision;
|
pNode->precision = precision;
|
||||||
code = pushLogicNode(pCxt, pRoot, pNode);
|
code = pushLogicNode(pCxt, pRoot, pNode);
|
||||||
|
pCxt->pCurrRoot = pNode;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pNode);
|
nodesDestroyNode((SNode*)pNode);
|
||||||
|
@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
||||||
return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot);
|
return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols,
|
static EScanType getScanType(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pScanPseudoCols,
|
||||||
int8_t tableType) {
|
SNodeList* pScanCols, int8_t tableType) {
|
||||||
if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) {
|
||||||
return SCAN_TYPE_STREAM;
|
return SCAN_TYPE_STREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSelect->hasLastRowFunc) {
|
||||||
|
return SCAN_TYPE_LAST_ROW;
|
||||||
|
}
|
||||||
|
|
||||||
if (NULL == pScanCols) {
|
if (NULL == pScanCols) {
|
||||||
// select count(*) from t
|
// select count(*) from t
|
||||||
return NULL == pScanPseudoCols
|
return NULL == pScanPseudoCols
|
||||||
|
@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM);
|
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM);
|
||||||
}
|
}
|
||||||
|
|
||||||
pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType);
|
pScan->scanType = getScanType(pCxt, pSelect, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
||||||
|
@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable,
|
|
||||||
SLogicNode** pLogicNode) {
|
|
||||||
SScanLogicNode* pScan = NULL;
|
|
||||||
int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan);
|
|
||||||
|
|
||||||
SNodeList* pFuncs = NULL;
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
pScan->scanType = SCAN_TYPE_LAST_ROW;
|
|
||||||
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = createColumnByLastRow(pFuncs, &pScan->pScanCols);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
*pLogicNode = (SLogicNode*)pScan;
|
|
||||||
} else {
|
|
||||||
nodesDestroyNode((SNode*)pScan);
|
|
||||||
}
|
|
||||||
nodesDestroyList(pFuncs);
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable,
|
static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode);
|
return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode);
|
||||||
|
@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
switch (nodeType(pTable)) {
|
switch (nodeType(pTable)) {
|
||||||
case QUERY_NODE_REAL_TABLE:
|
case QUERY_NODE_REAL_TABLE:
|
||||||
if (pSelect->hasLastRowFunc) {
|
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
||||||
return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
|
||||||
} else {
|
|
||||||
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
|
||||||
}
|
|
||||||
case QUERY_NODE_TEMP_TABLE:
|
case QUERY_NODE_TEMP_TABLE:
|
||||||
return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode);
|
return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode);
|
||||||
case QUERY_NODE_JOIN_TABLE:
|
case QUERY_NODE_JOIN_TABLE:
|
||||||
|
@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
||||||
}
|
}
|
||||||
pNode->precision = pSelect->precision;
|
pNode->precision = pSelect->precision;
|
||||||
*pLogicNode = pNode;
|
*pLogicNode = pNode;
|
||||||
|
pCxt->pCurrRoot = pNode;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets);
|
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) {
|
||||||
|
code = nodesListMakeStrictAppend(&pFill->node.pTargets,
|
||||||
|
nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
pFill->mode = pFillNode->mode;
|
pFill->mode = pFillNode->mode;
|
||||||
pFill->timeRange = pFillNode->timeRange;
|
pFill->timeRange = pFillNode->timeRange;
|
||||||
|
@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets);
|
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL == pSort->node.pTargets) {
|
||||||
|
code = nodesListMakeStrictAppend(&pSort->node.pTargets,
|
||||||
|
nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pSort->pSortKeys = nodesCloneList(pSelect->pOrderByList);
|
pSort->pSortKeys = nodesCloneList(pSelect->pOrderByList);
|
||||||
|
@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pSelect->pLimit) {
|
pProject->node.pLimit = (SNode*)pSelect->pLimit;
|
||||||
pProject->limit = pSelect->pLimit->limit;
|
pProject->node.pSlimit = (SNode*)pSelect->pSlimit;
|
||||||
pProject->offset = pSelect->pLimit->offset;
|
|
||||||
} else {
|
|
||||||
pProject->limit = -1;
|
|
||||||
pProject->offset = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != pSelect->pSlimit) {
|
|
||||||
pProject->slimit = ((SLimitNode*)pSelect->pSlimit)->limit;
|
|
||||||
pProject->soffset = ((SLimitNode*)pSelect->pSlimit)->offset;
|
|
||||||
} else {
|
|
||||||
pProject->slimit = -1;
|
|
||||||
pProject->soffset = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
|
|
||||||
int32_t code =
|
int32_t code =
|
||||||
nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets);
|
nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL == pPartition->node.pTargets) {
|
||||||
|
code = nodesListMakeStrictAppend(&pPartition->node.pTargets, nodesListGetNode(pCxt->pCurrRoot->pTargets, 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList);
|
pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList);
|
||||||
|
@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pSort->node.pLimit = pSetOperator->pLimit;
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
pSort->node.pTargets = nodesCloneList(pSetOperator->pProjectionList);
|
pSort->node.pTargets = nodesCloneList(pSetOperator->pProjectionList);
|
||||||
|
@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pSetOperator->pLimit) {
|
if (NULL == pSetOperator->pOrderByList) {
|
||||||
pProject->limit = ((SLimitNode*)pSetOperator->pLimit)->limit;
|
pProject->node.pLimit = pSetOperator->pLimit;
|
||||||
pProject->offset = ((SLimitNode*)pSetOperator->pLimit)->offset;
|
|
||||||
} else {
|
|
||||||
pProject->limit = -1;
|
|
||||||
pProject->offset = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL == pSetOperator->pOrderByList) {
|
||||||
|
pAgg->node.pLimit = pSetOperator->pLimit;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
pAgg->pGroupKeys = nodesCloneList(pSetOperator->pProjectionList);
|
pAgg->pGroupKeys = nodesCloneList(pSetOperator->pProjectionList);
|
||||||
if (NULL == pAgg->pGroupKeys) {
|
if (NULL == pAgg->pGroupKeys) {
|
||||||
|
|
|
@ -1061,6 +1061,7 @@ static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
strcpy(pFunc->functionName, "tbname");
|
strcpy(pFunc->functionName, "tbname");
|
||||||
pFunc->funcType = FUNCTION_TYPE_TBNAME;
|
pFunc->funcType = FUNCTION_TYPE_TBNAME;
|
||||||
|
pFunc->node.resType = ((SColumnNode*)*pNode)->node.resType;
|
||||||
nodesDestroyNode(*pNode);
|
nodesDestroyNode(*pNode);
|
||||||
*pNode = (SNode*)pFunc;
|
*pNode = (SNode*)pFunc;
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
|
@ -1117,8 +1118,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode;
|
SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode;
|
||||||
if (-1 != pProjectNode->limit || -1 != pProjectNode->slimit || -1 != pProjectNode->offset ||
|
if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) {
|
||||||
-1 != pProjectNode->soffset) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1189,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
|
||||||
{.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize},
|
{.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize},
|
||||||
{.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize},
|
{.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize},
|
||||||
{.pName = "SmaIndex", .optimizeFunc = smaOptimize},
|
{.pName = "SmaIndex", .optimizeFunc = smaOptimize},
|
||||||
// {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize},
|
{.pName = "PartitionTags", .optimizeFunc = partTagsOptimize},
|
||||||
{.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}
|
{.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pPhysiNode->pLimit = pLogicNode->pLimit;
|
||||||
|
pPhysiNode->pSlimit = pLogicNode->pSlimit;
|
||||||
|
|
||||||
int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc);
|
int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pPhysiNode);
|
nodesDestroyNode((SNode*)pPhysiNode);
|
||||||
|
@ -921,11 +924,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pProject->limit = pProjectLogicNode->limit;
|
|
||||||
pProject->offset = pProjectLogicNode->offset;
|
|
||||||
pProject->slimit = pProjectLogicNode->slimit;
|
|
||||||
pProject->soffset = pProjectLogicNode->soffset;
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (0 == LIST_LENGTH(pChildren)) {
|
if (0 == LIST_LENGTH(pChildren)) {
|
||||||
pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections);
|
pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections);
|
||||||
|
@ -1199,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
nodesDestroyNode((SNode*)pSort);
|
nodesDestroyNode((SNode*)pSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodesDestroyList(pPrecalcExprs);
|
||||||
|
nodesDestroyList(pSortKeys);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,6 +1453,9 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl
|
||||||
pSubplan->id = pLogicSubplan->id;
|
pSubplan->id = pLogicSubplan->id;
|
||||||
pSubplan->subplanType = pLogicSubplan->subplanType;
|
pSubplan->subplanType = pLogicSubplan->subplanType;
|
||||||
pSubplan->level = pLogicSubplan->level;
|
pSubplan->level = pLogicSubplan->level;
|
||||||
|
if (NULL != pCxt->pPlanCxt->pUser) {
|
||||||
|
strcpy(pSubplan->user, pCxt->pPlanCxt->pUser);
|
||||||
|
}
|
||||||
return pSubplan;
|
return pSubplan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1040,6 +1040,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS
|
||||||
if (NULL == pExchange->node.pTargets) {
|
if (NULL == pExchange->node.pTargets) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
TSWAP(pExchange->node.pLimit, pProject->node.pLimit);
|
||||||
|
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue