Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e6c15da7
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e6c15da7
编写于
6月 05, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/qnode
上级
31f10572
a4166b73
变更
53
展开全部
显示空白变更内容
内联
并排
Showing
53 changed file
with
4998 addition
and
3661 deletion
+4998
-3661
Jenkinsfile2
Jenkinsfile2
+132
-20
include/common/tdatablock.h
include/common/tdatablock.h
+2
-0
include/common/tmsg.h
include/common/tmsg.h
+34
-13
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-2
include/common/ttokendef.h
include/common/ttokendef.h
+60
-59
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+2
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+18
-2
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+19
-13
source/common/src/tmsg.c
source/common/src/tmsg.c
+129
-1
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+0
-1
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+9
-2
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+5
-22
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+58
-25
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+35
-6
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+47
-33
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+33
-5
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+73
-35
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+112
-100
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+449
-27
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+3
-3
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+10
-16
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+32
-1
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+2
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+162
-2
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+3
-0
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+9
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+23
-12
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+6
-0
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+20
-9
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+145
-139
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+9
-7
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2262
-2722
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+15
-1
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+2
-2
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+61
-74
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+8
-145
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-1
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+4
-0
source/util/src/tcompare.c
source/util/src/tcompare.c
+29
-0
tests/script/tsim/stream/session0.sim
tests/script/tsim/stream/session0.sim
+11
-11
tests/script/tsim/stream/session1.sim
tests/script/tsim/stream/session1.sim
+10
-0
tests/script/tsim/stream/state0.sim
tests/script/tsim/stream/state0.sim
+477
-0
tests/script/tsim/stream/triggerSession0.sim
tests/script/tsim/stream/triggerSession0.sim
+1
-1
tests/system-test/1-insert/alter_stable.py
tests/system-test/1-insert/alter_stable.py
+144
-0
tests/system-test/1-insert/alter_table.py
tests/system-test/1-insert/alter_table.py
+170
-0
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+149
-146
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+3
-1
未找到文件。
Jenkinsfile2
浏览文件 @
e6c15da7
...
@@ -4,8 +4,10 @@ import jenkins.model.CauseOfInterruption
...
@@ -4,8 +4,10 @@ import jenkins.model.CauseOfInterruption
node {
node {
}
}
def skipbuild=0
win_test_stage = 0
def win_stop=0
linux_ready = 0
linux_node_ip = ""
linux_node_pass = ""
def abortPreviousBuilds() {
def abortPreviousBuilds() {
def currentJobName = env.JOB_NAME
def currentJobName = env.JOB_NAME
...
@@ -227,6 +229,16 @@ def pre_test_win(){
...
@@ -227,6 +229,16 @@ def pre_test_win(){
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
git submodule update --init --recursive
git submodule update --init --recursive
'''
'''
bat '''
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
git branch
git reset --hard
git pull
'''
bat '''
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
git log -5
'''
}
}
def pre_test_build_win() {
def pre_test_build_win() {
bat '''
bat '''
...
@@ -246,8 +258,38 @@ def pre_test_build_win() {
...
@@ -246,8 +258,38 @@ def pre_test_build_win() {
jom -j 6 || exit 8
jom -j 6 || exit 8
time /t
time /t
'''
'''
bat '''
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
python -m pip install .
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
'''
return 1
return 1
}
}
def run_win_ctest() {
bat '''
echo "windows ctest ..."
time /t
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
ctest -j 1 || exit 7
time /t
'''
}
def run_win_test() {
echo "LINUX NODE: ${linux_node_ip} - ${linux_node_pass}"
bat '''
echo "windows test ..."
cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python
python -m pip install .
xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
ls -l C:\\Windows\\System32\\taos.dll
time /t
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community\\tests\\system-test
echo "node: ''' + linux_node_ip + ''':''' + linux_node_pass + '''"
echo "testing ..."
test-all.bat "{\\\"host\\\":\\\"''' + linux_node_ip + '''\\\",\\\"port\\\":22,\\\"user\\\":\\\"root\\\",\\\"password\\\":\\\"''' + linux_node_pass + '''\\\",\\\"path\\\":\\\"/var/lib/jenkins/workspace/TDinternal\\\"}"
time /t
'''
}
pipeline {
pipeline {
agent none
agent none
...
@@ -264,8 +306,22 @@ pipeline {
...
@@ -264,8 +306,22 @@ pipeline {
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 "}
steps {
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
timeout(time: 55, unit: 'MINUTES'){
pre_test_win()
pre_test_win()
pre_test_build_win()
pre_test_build_win()
run_win_ctest()
script {
while(linux_ready == 0) {
sleep(8)
}
}
run_win_test()
}
}
script {
win_test_stage = 1
}
}
}
}
}
stage('linux test') {
stage('linux test') {
...
@@ -275,12 +331,25 @@ pipeline {
...
@@ -275,12 +331,25 @@ pipeline {
changeRequest()
changeRequest()
}
}
steps {
steps {
script {
linux_node_ip = sh (
script: 'jq .ip /home/node_info.json | sed "s/\\\"//g"',
returnStdout: true
).trim()
linux_node_pass = sh (
script: 'jq .password /home/node_info.json | sed "s/\\\"//g" |sed "s/\\!/^^^^^^^^\\!/g"',
returnStdout: true
).trim()
echo "${linux_node_ip}:${linux_node_pass}"
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
timeout(time: 40, unit: 'MINUTES'){
timeout(time: 40, unit: 'MINUTES'){
pre_test()
pre_test()
script {
script {
sh '''
sh '''
cd ${WKC}/tests/parallel_test
date
date
rm -rf ${WKC}/debug
cd ${WKC}/tests/parallel_test
time ./container_build.sh -w ${WKDIR} -t 8 -e
time ./container_build.sh -w ${WKDIR} -t 8 -e
rm -f /tmp/cases.task
rm -f /tmp/cases.task
./collect_cases.sh -e
./collect_cases.sh -e
...
@@ -294,6 +363,49 @@ pipeline {
...
@@ -294,6 +363,49 @@ pipeline {
}
}
}
}
}
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
timeout(time: 15, unit: 'MINUTES'){
script {
sh '''
echo "packaging ..."
date
rm -rf ${WKC}/release/*
cd ${WKC}/packaging
./release.sh -v cluster -n 3.0.0.100 -s static
'''
sh '''
echo "install ..."
cd ${WKC}/release
tar xzf TDengine-enterprise-server-3.0.0.100-Linux-x64.tar.gz
cd TDengine-enterprise-server-3.0.0.100
service taosd stop || :
rm -rf /var/lib/taos
./install.sh -e no
'''
sh '''
echo "checking ..."
which taos
which taosd
rm -rf ${WK}/debug
mv ${WKC}/debug ${WK}/
'''
sh '''
echo "install taospy ..."
cd ${WKPY}
pip3 install .
'''
}
}
}
script {
linux_ready = 1
}
script {
while(win_test_stage == 0){
sleep(12)
}
}
}
}
}
}
}
}
}
...
...
include/common/tdatablock.h
浏览文件 @
e6c15da7
...
@@ -186,6 +186,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
...
@@ -186,6 +186,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
*
(
double
*
)
p
=
*
(
double
*
)
v
;
*
(
double
*
)
p
=
*
(
double
*
)
v
;
}
}
int32_t
getJsonValueLen
(
const
char
*
data
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
int32_t
*
capacity
,
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
...
...
include/common/tmsg.h
浏览文件 @
e6c15da7
...
@@ -2297,6 +2297,11 @@ typedef struct {
...
@@ -2297,6 +2297,11 @@ typedef struct {
int32_t
tSerializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropSmaReq
*
pReq
);
int32_t
tSerializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropSmaReq
*
pReq
);
int32_t
tDeserializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropSmaReq
*
pReq
);
int32_t
tDeserializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropSmaReq
*
pReq
);
typedef
struct
{
int32_t
vgId
;
SEpSet
epSet
;
}
SVgEpSet
;
typedef
struct
{
typedef
struct
{
int8_t
version
;
// for compatibility(default 0)
int8_t
version
;
// for compatibility(default 0)
int8_t
intervalUnit
;
// MACRO: TIME_UNIT_XXX
int8_t
intervalUnit
;
// MACRO: TIME_UNIT_XXX
...
@@ -2306,6 +2311,7 @@ typedef struct {
...
@@ -2306,6 +2311,7 @@ typedef struct {
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
int32_t
exprLen
;
int32_t
exprLen
;
int32_t
tagsFilterLen
;
int32_t
tagsFilterLen
;
int32_t
numOfVgroups
;
int64_t
indexUid
;
int64_t
indexUid
;
tb_uid_t
tableUid
;
// super/child/common table uid
tb_uid_t
tableUid
;
// super/child/common table uid
int64_t
interval
;
int64_t
interval
;
...
@@ -2313,6 +2319,7 @@ typedef struct {
...
@@ -2313,6 +2319,7 @@ typedef struct {
int64_t
sliding
;
int64_t
sliding
;
char
*
expr
;
// sma expression
char
*
expr
;
// sma expression
char
*
tagsFilter
;
char
*
tagsFilter
;
SVgEpSet
vgEpSet
[];
}
STSma
;
// Time-range-wise SMA
}
STSma
;
// Time-range-wise SMA
typedef
STSma
SVCreateTSmaReq
;
typedef
STSma
SVCreateTSmaReq
;
...
@@ -2398,16 +2405,26 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
...
@@ -2398,16 +2405,26 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
}
}
typedef
struct
{
typedef
struct
{
int64_t
tsmaI
ndexUid
;
int64_t
i
ndexUid
;
STimeWindow
queryWindow
;
STimeWindow
queryWindow
;
}
SVGetTsmaExpWndsReq
;
}
SVGetTsmaExpWndsReq
;
#define SMA_WNDS_EXPIRE_FLAG (0x1)
#define SMA_WNDS_IS_EXPIRE(flag) (((flag)&SMA_WNDS_EXPIRE_FLAG) != 0)
#define SMA_WNDS_SET_EXPIRE(flag) ((flag) |= SMA_WNDS_EXPIRE_FLAG)
typedef
struct
{
typedef
struct
{
int64_t
tsmaIndexUid
;
int64_t
indexUid
;
int8_t
flags
;
// 0x1 all window expired
int32_t
numExpWnds
;
int32_t
numExpWnds
;
TSKEY
*
expWndsStartTs
;
TSKEY
wndSKeys
[]
;
}
SVGetTsmaExpWndsRsp
;
}
SVGetTsmaExpWndsRsp
;
int32_t
tEncodeSVGetTSmaExpWndsReq
(
SEncoder
*
pCoder
,
const
SVGetTsmaExpWndsReq
*
pReq
);
int32_t
tDecodeSVGetTsmaExpWndsReq
(
SDecoder
*
pCoder
,
SVGetTsmaExpWndsReq
*
pReq
);
int32_t
tEncodeSVGetTSmaExpWndsRsp
(
SEncoder
*
pCoder
,
const
SVGetTsmaExpWndsRsp
*
pReq
);
int32_t
tDecodeSVGetTsmaExpWndsRsp
(
SDecoder
*
pCoder
,
SVGetTsmaExpWndsRsp
*
pReq
);
typedef
struct
{
typedef
struct
{
int
idx
;
int
idx
;
}
SMCreateFullTextReq
;
}
SMCreateFullTextReq
;
...
@@ -2671,23 +2688,27 @@ typedef struct {
...
@@ -2671,23 +2688,27 @@ typedef struct {
int32_t
tEncodeSVSubmitReq
(
SEncoder
*
pCoder
,
const
SVSubmitReq
*
pReq
);
int32_t
tEncodeSVSubmitReq
(
SEncoder
*
pCoder
,
const
SVSubmitReq
*
pReq
);
int32_t
tDecodeSVSubmitReq
(
SDecoder
*
pCoder
,
SVSubmitReq
*
pReq
);
int32_t
tDecodeSVSubmitReq
(
SDecoder
*
pCoder
,
SVSubmitReq
*
pReq
);
// TDMT_VND_DELETE
typedef
struct
{
typedef
struct
{
TSKEY
sKey
;
int64_t
delUid
;
TSKEY
eKey
;
int64_t
tbUid
;
// super/child/normal table
int8_t
type
;
// table type
// super table
int16_t
nWnds
;
char
*
stbName
;
char
*
tbFullName
;
char
*
subPlan
;
// child/normal
STimeWindow
wnds
[];
char
*
tbName
;
}
SVDeleteReq
;
}
SVDeleteReq
;
int32_t
tEncodeSVDeleteReq
(
SEncoder
*
pCoder
,
const
SVDeleteReq
*
pReq
);
int32_t
tDecodeSVDeleteReq
(
SDecoder
*
pCoder
,
SVDeleteReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
code
;
int32_t
code
;
// TODO
int64_t
affectedRows
;
}
SVDeleteRsp
;
}
SVDeleteRsp
;
int32_t
tEncodeSVDeleteRsp
(
SEncoder
*
pCoder
,
const
SVDeleteRsp
*
pReq
);
int32_t
tDecodeSVDeleteRsp
(
SDecoder
*
pCoder
,
SVDeleteRsp
*
pReq
);
#pragma pack(pop)
#pragma pack(pop)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsgdef.h
浏览文件 @
e6c15da7
...
@@ -152,8 +152,7 @@ enum {
...
@@ -152,8 +152,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_SYSTABLE_RETRIEVE
,
"retrieve"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SYSTABLE_RETRIEVE
,
"retrieve"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GRANT
,
"grant"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GRANT
,
"grant"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_AUTH
,
"auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_AUTH
,
"auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CONFIRM_WRITE
,
"mnode-confirm-write"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_APPLY_MSG
,
"mnode-apply"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_APPLY_MSG
,
"mnode-apply-msg"
,
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
)
...
...
include/common/ttokendef.h
浏览文件 @
e6c15da7
...
@@ -193,65 +193,66 @@
...
@@ -193,65 +193,66 @@
#define TK_REDISTRIBUTE 175
#define TK_REDISTRIBUTE 175
#define TK_SPLIT 176
#define TK_SPLIT 176
#define TK_SYNCDB 177
#define TK_SYNCDB 177
#define TK_NULL 178
#define TK_DELETE 178
#define TK_NK_QUESTION 179
#define TK_NULL 179
#define TK_NK_ARROW 180
#define TK_NK_QUESTION 180
#define TK_ROWTS 181
#define TK_NK_ARROW 181
#define TK_TBNAME 182
#define TK_ROWTS 182
#define TK_QSTARTTS 183
#define TK_TBNAME 183
#define TK_QENDTS 184
#define TK_QSTARTTS 184
#define TK_WSTARTTS 185
#define TK_QENDTS 185
#define TK_WENDTS 186
#define TK_WSTARTTS 186
#define TK_WDURATION 187
#define TK_WENDTS 187
#define TK_CAST 188
#define TK_WDURATION 188
#define TK_NOW 189
#define TK_CAST 189
#define TK_TODAY 190
#define TK_NOW 190
#define TK_TIMEZONE 191
#define TK_TODAY 191
#define TK_COUNT 192
#define TK_TIMEZONE 192
#define TK_FIRST 193
#define TK_COUNT 193
#define TK_LAST 194
#define TK_FIRST 194
#define TK_LAST_ROW 195
#define TK_LAST 195
#define TK_BETWEEN 196
#define TK_LAST_ROW 196
#define TK_IS 197
#define TK_BETWEEN 197
#define TK_NK_LT 198
#define TK_IS 198
#define TK_NK_GT 199
#define TK_NK_LT 199
#define TK_NK_LE 200
#define TK_NK_GT 200
#define TK_NK_GE 201
#define TK_NK_LE 201
#define TK_NK_NE 202
#define TK_NK_GE 202
#define TK_MATCH 203
#define TK_NK_NE 203
#define TK_NMATCH 204
#define TK_MATCH 204
#define TK_CONTAINS 205
#define TK_NMATCH 205
#define TK_JOIN 206
#define TK_CONTAINS 206
#define TK_INNER 207
#define TK_JOIN 207
#define TK_SELECT 208
#define TK_INNER 208
#define TK_DISTINCT 209
#define TK_SELECT 209
#define TK_WHERE 210
#define TK_DISTINCT 210
#define TK_PARTITION 211
#define TK_WHERE 211
#define TK_BY 212
#define TK_PARTITION 212
#define TK_SESSION 213
#define TK_BY 213
#define TK_STATE_WINDOW 214
#define TK_SESSION 214
#define TK_SLIDING 215
#define TK_STATE_WINDOW 215
#define TK_FILL 216
#define TK_SLIDING 216
#define TK_VALUE 217
#define TK_FILL 217
#define TK_NONE 218
#define TK_VALUE 218
#define TK_PREV 219
#define TK_NONE 219
#define TK_LINEAR 220
#define TK_PREV 220
#define TK_NEXT 221
#define TK_LINEAR 221
#define TK_HAVING 222
#define TK_NEXT 222
#define TK_ORDER 223
#define TK_HAVING 223
#define TK_SLIMIT 224
#define TK_ORDER 224
#define TK_SOFFSET 225
#define TK_SLIMIT 225
#define TK_LIMIT 226
#define TK_SOFFSET 226
#define TK_OFFSET 227
#define TK_LIMIT 227
#define TK_ASC 228
#define TK_OFFSET 228
#define TK_NULLS 229
#define TK_ASC 229
#define TK_ID 230
#define TK_NULLS 230
#define TK_NK_BITNOT 231
#define TK_ID 231
#define TK_INSERT 232
#define TK_NK_BITNOT 232
#define TK_VALUES 233
#define TK_INSERT 233
#define TK_IMPORT 234
#define TK_VALUES 234
#define TK_NK_SEMI 235
#define TK_IMPORT 235
#define TK_FILE 236
#define TK_NK_SEMI 236
#define TK_FILE 237
#define TK_NK_SPACE 300
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_COMMENT 301
...
...
include/libs/nodes/nodes.h
浏览文件 @
e6c15da7
...
@@ -180,6 +180,7 @@ typedef enum ENodeType {
...
@@ -180,6 +180,7 @@ typedef enum ENodeType {
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
,
QUERY_NODE_DELETE_STMT
,
QUERY_NODE_QUERY
,
QUERY_NODE_QUERY
,
// logic plan node
// logic plan node
...
@@ -218,6 +219,7 @@ typedef enum ENodeType {
...
@@ -218,6 +219,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_PARTITION
,
QUERY_NODE_PHYSICAL_PLAN_PARTITION
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
e6c15da7
...
@@ -338,6 +338,8 @@ typedef struct SStateWinodwPhysiNode {
...
@@ -338,6 +338,8 @@ typedef struct SStateWinodwPhysiNode {
SNode
*
pStateKey
;
SNode
*
pStateKey
;
}
SStateWinodwPhysiNode
;
}
SStateWinodwPhysiNode
;
typedef
SStateWinodwPhysiNode
SStreamStateWinodwPhysiNode
;
typedef
struct
SSortPhysiNode
{
typedef
struct
SSortPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of order_by_clause and parameter expression of aggregate function
SNodeList
*
pExprs
;
// these are expression list of order_by_clause and parameter expression of aggregate function
...
...
include/libs/nodes/querynodes.h
浏览文件 @
e6c15da7
...
@@ -60,6 +60,7 @@ typedef struct SColumnNode {
...
@@ -60,6 +60,7 @@ typedef struct SColumnNode {
int8_t
tableType
;
int8_t
tableType
;
col_id_t
colId
;
col_id_t
colId
;
EColumnType
colType
;
// column or tag
EColumnType
colType
;
// column or tag
bool
hasIndex
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
...
@@ -258,6 +259,7 @@ typedef struct SSetOperator {
...
@@ -258,6 +259,7 @@ typedef struct SSetOperator {
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNode
*
pLimit
;
SNode
*
pLimit
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
}
SSetOperator
;
}
SSetOperator
;
typedef
enum
ESqlClause
{
typedef
enum
ESqlClause
{
...
@@ -272,6 +274,17 @@ typedef enum ESqlClause {
...
@@ -272,6 +274,17 @@ typedef enum ESqlClause {
SQL_CLAUSE_ORDER_BY
SQL_CLAUSE_ORDER_BY
}
ESqlClause
;
}
ESqlClause
;
typedef
struct
SDeleteStmt
{
ENodeType
type
;
// QUERY_NODE_DELETE_STMT
SNode
*
pFromTable
;
// FROM clause
SNode
*
pWhere
;
// WHERE clause
SNode
*
pCountFunc
;
// count the number of rows affected
SNode
*
pTagIndexCond
;
// pWhere divided into pTagIndexCond and timeRange
STimeWindow
timeRange
;
uint8_t
precision
;
bool
deleteZeroRows
;
}
SDeleteStmt
;
typedef
enum
{
typedef
enum
{
PAYLOAD_TYPE_KV
=
0
,
PAYLOAD_TYPE_KV
=
0
,
PAYLOAD_TYPE_RAW
=
1
,
PAYLOAD_TYPE_RAW
=
1
,
...
@@ -363,8 +376,11 @@ bool nodesIsRegularOp(const SOperatorNode* pOp);
...
@@ -363,8 +376,11 @@ bool nodesIsRegularOp(const SOperatorNode* pOp);
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
);
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
);
int32_t
nodesSetValueNodeValue
(
SValueNode
*
pNode
,
void
*
value
);
int32_t
nodesSetValueNodeValue
(
SValueNode
*
pNode
,
void
*
value
);
char
*
nodesGetStrValueFromNode
(
SValueNode
*
pNode
);
char
*
nodesGetStrValueFromNode
(
SValueNode
*
pNode
);
char
*
getFillModeString
(
EFillMode
mode
);
void
nodesValueNodeToVariant
(
const
SValueNode
*
pNode
,
SVariant
*
pVal
);
void
valueNodeToVariant
(
const
SValueNode
*
pNode
,
SVariant
*
pVal
);
char
*
nodesGetFillModeString
(
EFillMode
mode
);
int32_t
nodesMergeConds
(
SNode
**
pDst
,
SNodeList
**
pSrc
);
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/taoserror.h
浏览文件 @
e6c15da7
...
@@ -649,6 +649,7 @@ int32_t* taosGetErrno();
...
@@ -649,6 +649,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_COL_JSON TAOS_DEF_ERROR_CODE(0, 0x2652)
#define TSDB_CODE_PAR_INVALID_COL_JSON TAOS_DEF_ERROR_CODE(0, 0x2652)
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2654)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2654)
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/src/clientImpl.c
浏览文件 @
e6c15da7
...
@@ -1234,7 +1234,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
...
@@ -1234,7 +1234,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TD_TAG_JSON
)
{
}
else
if
(
jsonInnerType
==
TD_TAG_JSON
)
{
char
*
jsonString
=
parseTagDatatoJson
(
jsonInnerData
);
char
*
jsonString
=
parseTagDatatoJson
(
pStart
);
STR_TO_VARSTR
(
dst
,
jsonString
);
STR_TO_VARSTR
(
dst
,
jsonString
);
taosMemoryFree
(
jsonString
);
taosMemoryFree
(
jsonString
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
...
...
source/common/src/tdatablock.c
浏览文件 @
e6c15da7
...
@@ -99,6 +99,24 @@ void colDataTrim(SColumnInfoData* pColumnInfoData) {
...
@@ -99,6 +99,24 @@ void colDataTrim(SColumnInfoData* pColumnInfoData) {
// TODO
// TODO
}
}
int32_t
getJsonValueLen
(
const
char
*
data
)
{
int32_t
dataLen
=
0
;
if
(
*
data
==
TSDB_DATA_TYPE_NULL
)
{
dataLen
=
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_NCHAR
)
{
dataLen
=
varDataTLen
(
data
+
CHAR_BYTES
)
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_DOUBLE
)
{
dataLen
=
DOUBLE_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TD_TAG_JSON
)
{
// json string
dataLen
=
((
STag
*
)(
data
))
->
len
;
}
else
{
ASSERT
(
0
);
}
return
dataLen
;
}
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
)
{
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
)
{
ASSERT
(
pColumnInfoData
!=
NULL
);
ASSERT
(
pColumnInfoData
!=
NULL
);
...
@@ -118,19 +136,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
...
@@ -118,19 +136,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
int32_t
dataLen
=
0
;
int32_t
dataLen
=
0
;
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
*
pData
==
TSDB_DATA_TYPE_NULL
)
{
dataLen
=
getJsonValueLen
(
pData
);
dataLen
=
CHAR_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_NCHAR
)
{
dataLen
=
varDataTLen
(
pData
+
CHAR_BYTES
)
+
CHAR_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_DOUBLE
)
{
dataLen
=
DOUBLE_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
pData
==
TD_TAG_JSON
)
{
// json string
dataLen
=
((
STag
*
)(
pData
))
->
len
;
}
else
{
ASSERT
(
0
);
}
}
else
{
}
else
{
dataLen
=
varDataTLen
(
pData
);
dataLen
=
varDataTLen
(
pData
);
}
}
...
...
source/common/src/tmsg.c
浏览文件 @
e6c15da7
...
@@ -3661,6 +3661,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
...
@@ -3661,6 +3661,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
if
(
tEncodeCStr
(
pCoder
,
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pSma
->
exprLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pSma
->
exprLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pSma
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pSma
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pSma
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
indexUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
indexUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
tableUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
tableUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
interval
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSma
->
interval
)
<
0
)
return
-
1
;
...
@@ -3672,7 +3673,17 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
...
@@ -3672,7 +3673,17 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
if
(
pSma
->
tagsFilterLen
>
0
)
{
if
(
pSma
->
tagsFilterLen
>
0
)
{
if
(
tEncodeCStr
(
pCoder
,
pSma
->
tagsFilter
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pSma
->
tagsFilter
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
v
=
0
;
v
<
pSma
->
numOfVgroups
;
++
v
)
{
if
(
tEncodeI32
(
pCoder
,
pSma
->
vgEpSet
[
v
].
vgId
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pCoder
,
pSma
->
vgEpSet
[
v
].
epSet
.
inUse
)
<
0
)
return
-
1
;
int8_t
numOfEps
=
pSma
->
vgEpSet
[
v
].
epSet
.
numOfEps
;
if
(
tEncodeI8
(
pCoder
,
numOfEps
)
<
0
)
return
-
1
;
for
(
int32_t
n
=
0
;
n
<
numOfEps
;
++
n
)
{
const
SEp
*
pEp
=
&
pSma
->
vgEpSet
[
v
].
epSet
.
eps
[
n
];
if
(
tEncodeCStr
(
pCoder
,
pEp
->
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeU16
(
pCoder
,
pEp
->
port
)
<
0
)
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -3685,6 +3696,7 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
...
@@ -3685,6 +3696,7 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
if
(
tDecodeCStrTo
(
pCoder
,
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pCoder
,
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
exprLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
exprLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
indexUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
indexUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
tableUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
tableUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
interval
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
interval
)
<
0
)
return
-
1
;
...
@@ -3700,6 +3712,17 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
...
@@ -3700,6 +3712,17 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
}
else
{
}
else
{
pSma
->
tagsFilter
=
NULL
;
pSma
->
tagsFilter
=
NULL
;
}
}
for
(
int32_t
v
=
0
;
v
<
pSma
->
numOfVgroups
;
++
v
)
{
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
vgEpSet
[
v
].
vgId
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
vgEpSet
[
v
].
epSet
.
inUse
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
vgEpSet
[
v
].
epSet
.
numOfEps
)
<
0
)
return
-
1
;
int8_t
numOfEps
=
pSma
->
vgEpSet
[
v
].
epSet
.
numOfEps
;
for
(
int32_t
n
=
0
;
n
<
numOfEps
;
++
n
)
{
SEp
*
pEp
=
&
pSma
->
vgEpSet
[
v
].
epSet
.
eps
[
n
];
if
(
tDecodeCStrTo
(
pCoder
,
pEp
->
fqdn
)
<
0
)
return
-
1
;
if
(
tDecodeU16
(
pCoder
,
&
pEp
->
port
)
<
0
)
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -3742,6 +3765,111 @@ int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) {
...
@@ -3742,6 +3765,111 @@ int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) {
return
0
;
return
0
;
}
}
int32_t
tEncodeSVGetTSmaExpWndsReq
(
SEncoder
*
pCoder
,
const
SVGetTsmaExpWndsReq
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
indexUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
queryWindow
.
skey
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
queryWindow
.
ekey
)
<
0
)
return
-
1
;
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSVGetTsmaExpWndsReq
(
SDecoder
*
pCoder
,
SVGetTsmaExpWndsReq
*
pReq
)
{
if
(
tStartDecode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
indexUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
queryWindow
.
skey
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
queryWindow
.
ekey
)
<
0
)
return
-
1
;
tEndDecode
(
pCoder
);
return
0
;
}
int32_t
tEncodeSVGetTSmaExpWndsRsp
(
SEncoder
*
pCoder
,
const
SVGetTsmaExpWndsRsp
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
indexUid
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pCoder
,
pReq
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pReq
->
numExpWnds
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numExpWnds
;
++
i
)
{
if
(
tEncodeI64
(
pCoder
,
pReq
->
wndSKeys
[
i
])
<
0
)
return
-
1
;
}
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSVGetTsmaExpWndsRsp
(
SDecoder
*
pCoder
,
SVGetTsmaExpWndsRsp
*
pReq
)
{
if
(
tStartDecode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
indexUid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
numExpWnds
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numExpWnds
;
++
i
)
{
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
wndSKeys
[
i
])
<
0
)
return
-
1
;
}
tEndDecode
(
pCoder
);
return
0
;
}
int32_t
tEncodeSVDeleteReq
(
SEncoder
*
pCoder
,
const
SVDeleteReq
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
delUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
tbUid
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pCoder
,
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI16v
(
pCoder
,
pReq
->
nWnds
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pReq
->
tbFullName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pReq
->
subPlan
)
<
0
)
return
-
1
;
for
(
int16_t
i
=
0
;
i
<
pReq
->
nWnds
;
++
i
)
{
if
(
tEncodeI64
(
pCoder
,
pReq
->
wnds
[
i
].
skey
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
wnds
[
i
].
ekey
)
<
0
)
return
-
1
;
}
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSVDeleteReq
(
SDecoder
*
pCoder
,
SVDeleteReq
*
pReq
)
{
if
(
tStartDecode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
delUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
tbUid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nWnds
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
&
pReq
->
tbFullName
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
&
pReq
->
subPlan
)
<
0
)
return
-
1
;
for
(
int16_t
i
=
0
;
i
<
pReq
->
nWnds
;
++
i
)
{
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
wnds
[
i
].
skey
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
wnds
[
i
].
ekey
)
<
0
)
return
-
1
;
}
tEndDecode
(
pCoder
);
return
0
;
}
int32_t
tEncodeSVDeleteRsp
(
SEncoder
*
pCoder
,
const
SVDeleteRsp
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pReq
->
code
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
affectedRows
)
<
0
)
return
-
1
;
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSVDeleteRsp
(
SDecoder
*
pCoder
,
SVDeleteRsp
*
pReq
)
{
if
(
tStartDecode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
code
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
affectedRows
)
<
0
)
return
-
1
;
tEndDecode
(
pCoder
);
return
0
;
}
int32_t
tSerializeSCMCreateStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateStreamReq
*
pReq
)
{
int32_t
tSerializeSCMCreateStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateStreamReq
*
pReq
)
{
int32_t
sqlLen
=
0
;
int32_t
sqlLen
=
0
;
int32_t
astLen
=
0
;
int32_t
astLen
=
0
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
e6c15da7
...
@@ -197,7 +197,6 @@ SArray *mmGetMsgHandles() {
...
@@ -197,7 +197,6 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GRANT
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GRANT
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_AUTH
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_AUTH
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CONFIRM_WRITE
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
mmPutNodeMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
mmPutNodeMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
mmPutNodeMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
mmPutNodeMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
e6c15da7
...
@@ -29,12 +29,18 @@ typedef enum {
...
@@ -29,12 +29,18 @@ typedef enum {
TRANS_STOP_FUNC_MQ_REB
=
4
,
TRANS_STOP_FUNC_MQ_REB
=
4
,
}
ETrnFunc
;
}
ETrnFunc
;
typedef
enum
{
TRANS_ACTION_NULL
=
0
,
TRANS_ACTION_MSG
=
1
,
TRANS_ACTION_RAW
=
2
,
}
ETrnAct
;
typedef
struct
{
typedef
struct
{
int32_t
id
;
int32_t
id
;
int32_t
errCode
;
int32_t
errCode
;
int32_t
acceptableCode
;
int32_t
acceptableCode
;
int8_t
stage
;
int8_t
stage
;
int8_t
actionType
;
// 0-msg, 1-raw
ETrnAct
actionType
;
int8_t
rawWritten
;
int8_t
rawWritten
;
int8_t
msgSent
;
int8_t
msgSent
;
int8_t
msgReceived
;
int8_t
msgReceived
;
...
@@ -57,6 +63,7 @@ void mndTransDrop(STrans *pTrans);
...
@@ -57,6 +63,7 @@ void mndTransDrop(STrans *pTrans);
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendNullLog
(
STrans
*
pTrans
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
...
@@ -65,7 +72,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname);
...
@@ -65,7 +72,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname);
void
mndTransSetSerial
(
STrans
*
pTrans
);
void
mndTransSetSerial
(
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransProcessRsp
(
SRpcMsg
*
pRsp
);
int32_t
mndTransProcessRsp
(
SRpcMsg
*
pRsp
);
void
mndTransPullup
(
SMnode
*
pMnode
);
void
mndTransPullup
(
SMnode
*
pMnode
);
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
e6c15da7
...
@@ -34,9 +34,6 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOld, SMnodeObj *pNe
...
@@ -34,9 +34,6 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOld, SMnodeObj *pNe
static
int32_t
mndProcessCreateMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessCreateMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessAlterMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessAlterMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessDropMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessDropMnodeReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessCreateMnodeRsp
(
SRpcMsg
*
pRsp
);
static
int32_t
mndProcessAlterMnodeRsp
(
SRpcMsg
*
pRsp
);
static
int32_t
mndProcessDropMnodeRsp
(
SRpcMsg
*
pRsp
);
static
int32_t
mndRetrieveMnodes
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveMnodes
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
);
...
@@ -53,11 +50,11 @@ int32_t mndInitMnode(SMnode *pMnode) {
...
@@ -53,11 +50,11 @@ int32_t mndInitMnode(SMnode *pMnode) {
};
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_MNODE
,
mndProcessCreateMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_MNODE
,
mndProcessCreateMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CREATE_MNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_MNODE
,
mndProcessAlterMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_MNODE
,
mndProcessAlterMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_MNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_MNODE
,
mndProcessDropMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_MNODE
,
mndProcessDropMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CREATE_MNODE_RSP
,
mndProcessCreateMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_MNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_MNODE_RSP
,
mndProcessAlterMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_MNODE_RSP
,
mndProcessDropMnodeRsp
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndRetrieveMnodes
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndRetrieveMnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndCancelGetNextMnode
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndCancelGetNextMnode
);
...
@@ -367,7 +364,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
...
@@ -367,7 +364,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndTransAppendNullLog
(
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
@@ -549,6 +546,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
...
@@ -549,6 +546,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndTransAppendNullLog
(
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
@@ -616,21 +614,6 @@ _OVER:
...
@@ -616,21 +614,6 @@ _OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessCreateMnodeRsp
(
SRpcMsg
*
pRsp
)
{
mndTransProcessRsp
(
pRsp
);
return
0
;
}
static
int32_t
mndProcessAlterMnodeRsp
(
SRpcMsg
*
pRsp
)
{
mndTransProcessRsp
(
pRsp
);
return
0
;
}
static
int32_t
mndProcessDropMnodeRsp
(
SRpcMsg
*
pRsp
)
{
mndTransProcessRsp
(
pRsp
);
return
0
;
}
static
int32_t
mndRetrieveMnodes
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveMnodes
(
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
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
e6c15da7
...
@@ -88,12 +88,14 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
...
@@ -88,12 +88,14 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
for
(
int32_t
i
=
0
;
i
<
actionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
actionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
rawDataLen
+=
(
sdbGetRawTotalSize
(
pAction
->
pRaw
)
+
sizeof
(
int32_t
));
rawDataLen
+=
(
sdbGetRawTotalSize
(
pAction
->
pRaw
)
+
sizeof
(
int32_t
));
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
}
else
{
// empty
}
}
rawDataLen
+=
sizeof
(
pAction
->
actionType
);
rawDataLen
+=
sizeof
(
int8_t
);
}
}
return
rawDataLen
;
return
rawDataLen
;
...
@@ -137,18 +139,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -137,18 +139,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
}
else
{
// nothing
}
}
}
}
...
@@ -159,18 +163,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -159,18 +163,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
}
else
{
// nothing
}
}
}
}
...
@@ -181,18 +187,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -181,18 +187,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
acceptableCode
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
actionType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
stage
,
_OVER
)
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
int32_t
len
=
sdbGetRawTotalSize
(
pAction
->
pRaw
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
rawWritten
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pRaw
,
len
,
_OVER
)
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
),
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pAction
->
msgType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgSent
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgReceived
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
,
_OVER
)
}
else
{
// nothing
}
}
}
}
...
@@ -252,6 +260,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -252,6 +260,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
int16_t
policy
=
0
;
int16_t
policy
=
0
;
int16_t
conflict
=
0
;
int16_t
conflict
=
0
;
int16_t
exec
=
0
;
int16_t
exec
=
0
;
int8_t
actionType
=
0
;
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
stage
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
stage
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
policy
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
policy
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
conflict
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
conflict
,
_OVER
)
...
@@ -279,9 +288,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -279,9 +288,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
actionType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
actionType
,
_OVER
)
action
.
actionType
=
actionType
;
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
if
(
action
.
actionType
)
{
if
(
action
.
actionType
==
TRANS_ACTION_RAW
)
{
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
dataLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
dataLen
,
_OVER
)
action
.
pRaw
=
taosMemoryMalloc
(
dataLen
);
action
.
pRaw
=
taosMemoryMalloc
(
dataLen
);
...
@@ -290,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -290,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pRaw
=
NULL
;
action
.
pRaw
=
NULL
;
}
else
{
}
else
if
(
action
.
actionType
==
TRANS_ACTION_MSG
)
{
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
...
@@ -301,6 +311,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -301,6 +311,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pCont
=
NULL
;
action
.
pCont
=
NULL
;
}
else
{
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
}
}
}
}
...
@@ -308,9 +320,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -308,9 +320,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
actionType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
actionType
,
_OVER
)
action
.
actionType
=
actionType
;
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
if
(
action
.
actionType
)
{
if
(
action
.
actionType
==
TRANS_ACTION_RAW
)
{
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
dataLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
dataLen
,
_OVER
)
action
.
pRaw
=
taosMemoryMalloc
(
dataLen
);
action
.
pRaw
=
taosMemoryMalloc
(
dataLen
);
...
@@ -319,7 +332,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -319,7 +332,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
undoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
undoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pRaw
=
NULL
;
action
.
pRaw
=
NULL
;
}
else
{
}
else
if
(
action
.
actionType
==
TRANS_ACTION_MSG
)
{
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
...
@@ -330,6 +343,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -330,6 +343,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
undoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
undoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pCont
=
NULL
;
action
.
pCont
=
NULL
;
}
else
{
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
}
}
}
}
...
@@ -337,7 +352,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -337,7 +352,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
id
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
errCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
action
.
acceptableCode
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
actionType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
actionType
,
_OVER
)
action
.
actionType
=
actionType
;
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
stage
,
_OVER
)
if
(
action
.
actionType
)
{
if
(
action
.
actionType
)
{
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
rawWritten
,
_OVER
)
...
@@ -348,7 +364,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -348,7 +364,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
action
.
pRaw
,
dataLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
commitActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
commitActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pRaw
=
NULL
;
action
.
pRaw
=
NULL
;
}
else
{
}
else
if
(
action
.
actionType
==
TRANS_ACTION_MSG
)
{
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
),
_OVER
);
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
action
.
msgType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
action
.
msgSent
,
_OVER
)
...
@@ -359,6 +375,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -359,6 +375,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
action
.
pCont
,
action
.
contLen
,
_OVER
);
if
(
taosArrayPush
(
pTrans
->
commitActions
,
&
action
)
==
NULL
)
goto
_OVER
;
if
(
taosArrayPush
(
pTrans
->
commitActions
,
&
action
)
==
NULL
)
goto
_OVER
;
action
.
pCont
=
NULL
;
action
.
pCont
=
NULL
;
}
else
{
if
(
taosArrayPush
(
pTrans
->
redoActions
,
&
action
)
==
NULL
)
goto
_OVER
;
}
}
}
}
...
@@ -552,10 +570,12 @@ static void mndTransDropActions(SArray *pArray) {
...
@@ -552,10 +570,12 @@ static void mndTransDropActions(SArray *pArray) {
int32_t
size
=
taosArrayGetSize
(
pArray
);
int32_t
size
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
taosMemoryFreeClear
(
pAction
->
pRaw
);
taosMemoryFreeClear
(
pAction
->
pRaw
);
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
taosMemoryFreeClear
(
pAction
->
pCont
);
taosMemoryFreeClear
(
pAction
->
pCont
);
}
else
{
// nothing
}
}
}
}
...
@@ -583,27 +603,34 @@ static int32_t mndTransAppendAction(SArray *pArray, STransAction *pAction) {
...
@@ -583,27 +603,34 @@ static int32_t mndTransAppendAction(SArray *pArray, STransAction *pAction) {
}
}
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
STransAction
action
=
{.
stage
=
TRN_STAGE_REDO_ACTION
,
.
actionType
=
true
,
.
pRaw
=
pRaw
};
STransAction
action
=
{.
stage
=
TRN_STAGE_REDO_ACTION
,
.
actionType
=
TRANS_ACTION_RAW
,
.
pRaw
=
pRaw
};
return
mndTransAppendAction
(
pTrans
->
redoActions
,
&
action
);
}
int32_t
mndTransAppendNullLog
(
STrans
*
pTrans
)
{
STransAction
action
=
{.
stage
=
TRN_STAGE_REDO_ACTION
,
.
actionType
=
TRANS_ACTION_NULL
};
return
mndTransAppendAction
(
pTrans
->
redoActions
,
&
action
);
return
mndTransAppendAction
(
pTrans
->
redoActions
,
&
action
);
}
}
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
STransAction
action
=
{.
stage
=
TRN_STAGE_UNDO_ACTION
,
.
actionType
=
true
,
.
pRaw
=
pRaw
};
STransAction
action
=
{.
stage
=
TRN_STAGE_UNDO_ACTION
,
.
actionType
=
TRANS_ACTION_RAW
,
.
pRaw
=
pRaw
};
return
mndTransAppendAction
(
pTrans
->
undoActions
,
&
action
);
return
mndTransAppendAction
(
pTrans
->
undoActions
,
&
action
);
}
}
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
STransAction
action
=
{.
stage
=
TRN_STAGE_COMMIT_ACTION
,
.
actionType
=
true
,
.
pRaw
=
pRaw
};
STransAction
action
=
{.
stage
=
TRN_STAGE_COMMIT_ACTION
,
.
actionType
=
TRANS_ACTION_RAW
,
.
pRaw
=
pRaw
};
return
mndTransAppendAction
(
pTrans
->
commitActions
,
&
action
);
return
mndTransAppendAction
(
pTrans
->
commitActions
,
&
action
);
}
}
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
)
{
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
)
{
pAction
->
stage
=
TRN_STAGE_REDO_ACTION
;
pAction
->
stage
=
TRN_STAGE_REDO_ACTION
;
pAction
->
actionType
=
TRANS_ACTION_MSG
;
return
mndTransAppendAction
(
pTrans
->
redoActions
,
pAction
);
return
mndTransAppendAction
(
pTrans
->
redoActions
,
pAction
);
}
}
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
)
{
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
)
{
pAction
->
stage
=
TRN_STAGE_UNDO_ACTION
;
pAction
->
stage
=
TRN_STAGE_UNDO_ACTION
;
pAction
->
actionType
=
TRANS_ACTION_MSG
;
return
mndTransAppendAction
(
pTrans
->
undoActions
,
pAction
);
return
mndTransAppendAction
(
pTrans
->
undoActions
,
pAction
);
}
}
...
@@ -782,7 +809,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
...
@@ -782,7 +809,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
}
}
}
}
void
mndTransProcessRsp
(
SRpcMsg
*
pRsp
)
{
int32_t
mndTransProcessRsp
(
SRpcMsg
*
pRsp
)
{
SMnode
*
pMnode
=
pRsp
->
info
.
node
;
SMnode
*
pMnode
=
pRsp
->
info
.
node
;
int64_t
signature
=
(
int64_t
)(
pRsp
->
info
.
ahandle
);
int64_t
signature
=
(
int64_t
)(
pRsp
->
info
.
ahandle
);
int32_t
transId
=
(
int32_t
)(
signature
>>
32
);
int32_t
transId
=
(
int32_t
)(
signature
>>
32
);
...
@@ -827,6 +854,7 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
...
@@ -827,6 +854,7 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
_OVER:
_OVER:
mndReleaseTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
return
0
;
}
}
static
void
mndTransResetActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SArray
*
pArray
)
{
static
void
mndTransResetActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SArray
*
pArray
)
{
...
@@ -899,10 +927,15 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
...
@@ -899,10 +927,15 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
}
}
static
int32_t
mndTransExecSingleAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
STransAction
*
pAction
)
{
static
int32_t
mndTransExecSingleAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
STransAction
*
pAction
)
{
if
(
pAction
->
actionType
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
return
mndTransWriteSingleLog
(
pMnode
,
pTrans
,
pAction
);
return
mndTransWriteSingleLog
(
pMnode
,
pTrans
,
pAction
);
}
else
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
return
mndTransSendSingleMsg
(
pMnode
,
pTrans
,
pAction
);
return
mndTransSendSingleMsg
(
pMnode
,
pTrans
,
pAction
);
}
else
{
pAction
->
rawWritten
=
0
;
pAction
->
errCode
=
0
;
mDebug
(
"trans:%d, %s:%d null action executed"
,
pTrans
->
id
,
mndTransStr
(
pAction
->
stage
),
pAction
->
id
);
return
0
;
}
}
}
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
e6c15da7
...
@@ -366,16 +366,18 @@ typedef struct SCatchSupporter {
...
@@ -366,16 +366,18 @@ typedef struct SCatchSupporter {
}
SCatchSupporter
;
}
SCatchSupporter
;
typedef
struct
SStreamAggSupporter
{
typedef
struct
SStreamAggSupporter
{
SArray
*
pResultRows
;
// SResultWindowInfo
SArray
*
pResultRows
;
int32_t
keySize
;
int32_t
keySize
;
char
*
pKeyBuf
;
// window key buffer
char
*
pKeyBuf
;
// window key buffer
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
SArray
*
pScanWindow
;
}
SStreamAggSupporter
;
}
SStreamAggSupporter
;
typedef
struct
SessionWindowSupporter
{
typedef
struct
SessionWindowSupporter
{
SStreamAggSupporter
*
pStreamAggSup
;
SStreamAggSupporter
*
pStreamAggSup
;
int64_t
gap
;
int64_t
gap
;
uint8_t
parentType
;
}
SessionWindowSupporter
;
}
SessionWindowSupporter
;
typedef
struct
SStreamBlockScanInfo
{
typedef
struct
SStreamBlockScanInfo
{
...
@@ -406,6 +408,7 @@ typedef struct SStreamBlockScanInfo {
...
@@ -406,6 +408,7 @@ typedef struct SStreamBlockScanInfo {
SArray
*
childIds
;
SArray
*
childIds
;
SessionWindowSupporter
sessionSup
;
SessionWindowSupporter
sessionSup
;
bool
assignBlockUid
;
// assign block uid to groupId, temporarily used for generating rollup SMA.
bool
assignBlockUid
;
// assign block uid to groupId, temporarily used for generating rollup SMA.
int32_t
scanWinIndex
;
}
SStreamBlockScanInfo
;
}
SStreamBlockScanInfo
;
typedef
struct
SSysTableScanInfo
{
typedef
struct
SSysTableScanInfo
{
...
@@ -503,7 +506,7 @@ typedef struct SProjectOperatorInfo {
...
@@ -503,7 +506,7 @@ typedef struct SProjectOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SSDataBlock
*
existDataBlock
;
SSDataBlock
*
existDataBlock
;
SArray
*
pPseudoColInfo
;
SArray
*
pPseudoColInfo
;
SLimit
limit
;
SLimit
limit
;
...
@@ -593,6 +596,11 @@ typedef struct SResultWindowInfo {
...
@@ -593,6 +596,11 @@ typedef struct SResultWindowInfo {
bool
isClosed
;
bool
isClosed
;
}
SResultWindowInfo
;
}
SResultWindowInfo
;
typedef
struct
SStateWindowInfo
{
SResultWindowInfo
winInfo
;
SStateKeys
stateKey
;
}
SStateWindowInfo
;
typedef
struct
SStreamSessionAggOperatorInfo
{
typedef
struct
SStreamSessionAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SStreamAggSupporter
streamAggSup
;
SStreamAggSupporter
streamAggSup
;
...
@@ -606,7 +614,7 @@ typedef struct SStreamSessionAggOperatorInfo {
...
@@ -606,7 +614,7 @@ typedef struct SStreamSessionAggOperatorInfo {
SSDataBlock
*
pDelRes
;
SSDataBlock
*
pDelRes
;
SHashObj
*
pStDeleted
;
SHashObj
*
pStDeleted
;
void
*
pDelIterator
;
void
*
pDelIterator
;
SArray
*
pChildren
;
// cache for children's result;
SArray
*
pChildren
;
// cache for children's result;
final stream operator
}
SStreamSessionAggOperatorInfo
;
}
SStreamSessionAggOperatorInfo
;
typedef
struct
STimeSliceOperatorInfo
{
typedef
struct
STimeSliceOperatorInfo
{
...
@@ -630,6 +638,22 @@ typedef struct SStateWindowOperatorInfo {
...
@@ -630,6 +638,22 @@ typedef struct SStateWindowOperatorInfo {
// bool reptScan;
// bool reptScan;
}
SStateWindowOperatorInfo
;
}
SStateWindowOperatorInfo
;
typedef
struct
SStreamStateAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SStreamAggSupporter
streamAggSup
;
SGroupResInfo
groupResInfo
;
int32_t
primaryTsIndex
;
// primary timestamp slot id
int32_t
order
;
// current SSDataBlock scan order
STimeWindowAggSupp
twAggSup
;
SColumn
stateCol
;
// start row index
SqlFunctionCtx
*
pDummyCtx
;
// for combine
SSDataBlock
*
pDelRes
;
SHashObj
*
pSeDeleted
;
void
*
pDelIterator
;
SArray
*
pScanWindow
;
SArray
*
pChildren
;
// cache for children's result;
}
SStreamStateAggOperatorInfo
;
typedef
struct
SSortedMergeOperatorInfo
{
typedef
struct
SSortedMergeOperatorInfo
{
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
...
@@ -706,7 +730,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scan
...
@@ -706,7 +730,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scan
int32_t
getBufferPgSize
(
int32_t
rowSize
,
uint32_t
*
defaultPgsz
,
uint32_t
*
defaultBufsz
);
int32_t
getBufferPgSize
(
int32_t
rowSize
,
uint32_t
*
defaultPgsz
,
uint32_t
*
defaultBufsz
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
,
SArray
*
pColMatchInfo
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
...
@@ -738,7 +762,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
...
@@ -738,7 +762,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
S
Node
*
pCondition
,
S
ExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pIndexMap
,
SExecTaskInfo
*
pTaskInfo
);
SArray
*
pIndexMap
,
SExecTaskInfo
*
pTaskInfo
);
...
@@ -787,6 +811,10 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pE
...
@@ -787,6 +811,10 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pE
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamStateAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
#if 0
#if 0
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
#endif
#endif
...
@@ -838,7 +866,8 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
...
@@ -838,7 +866,8 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
int32_t
startPos
,
TSKEY
ekey
,
__block_search_fn_t
searchFn
,
STableQueryInfo
*
item
,
int32_t
startPos
,
TSKEY
ekey
,
__block_search_fn_t
searchFn
,
STableQueryInfo
*
item
,
int32_t
order
);
int32_t
order
);
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
);
int32_t
initSessionAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
);
int32_t
initStateAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
);
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int64_t
tableGroupId
,
int32_t
interBufSize
);
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int64_t
tableGroupId
,
int32_t
interBufSize
);
SResultWindowInfo
*
getSessionTimeWindow
(
SArray
*
pWinInfos
,
TSKEY
ts
,
int64_t
gap
,
SResultWindowInfo
*
getSessionTimeWindow
(
SArray
*
pWinInfos
,
TSKEY
ts
,
int64_t
gap
,
int32_t
*
pIndex
);
int32_t
*
pIndex
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e6c15da7
...
@@ -345,7 +345,6 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
...
@@ -345,7 +345,6 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
// In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
// pResultRowInfo object.
// pResultRowInfo object.
if
(
p1
!=
NULL
)
{
if
(
p1
!=
NULL
)
{
// todo
// todo
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
ASSERT
(
pResult
->
pageId
==
p1
->
pageId
&&
pResult
->
offset
==
p1
->
offset
);
ASSERT
(
pResult
->
pageId
==
p1
->
pageId
&&
pResult
->
offset
==
p1
->
offset
);
...
@@ -369,7 +368,8 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
...
@@ -369,7 +368,8 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// add a new result set for a new group
// add a new result set for a new group
SResultRowPosition
pos
=
{.
pageId
=
pResult
->
pageId
,
.
offset
=
pResult
->
offset
};
SResultRowPosition
pos
=
{.
pageId
=
pResult
->
pageId
,
.
offset
=
pResult
->
offset
};
taosHashPut
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
pos
,
sizeof
(
SResultRowPosition
));
taosHashPut
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
pos
,
sizeof
(
SResultRowPosition
));
}
}
// 2. set the new time window to be the new active time window
// 2. set the new time window to be the new active time window
...
@@ -551,7 +551,6 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow
...
@@ -551,7 +551,6 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow
colDataAppendInt64
(
pColData
,
4
,
&
pQueryWindow
->
ekey
);
colDataAppendInt64
(
pColData
,
4
,
&
pQueryWindow
->
ekey
);
}
}
void
doApplyFunctions
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
void
doApplyFunctions
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
)
{
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
)
{
...
@@ -1219,9 +1218,9 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo) { pTaskInfo->code = TSDB_CODE_TSC_Q
...
@@ -1219,9 +1218,9 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo) { pTaskInfo->code = TSDB_CODE_TSC_Q
static
bool
isCachedLastQuery
(
STaskAttr
*
pQueryAttr
)
{
static
bool
isCachedLastQuery
(
STaskAttr
*
pQueryAttr
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfOutput
;
++
i
)
{
int32_t
functionId
=
getExprFunctionId
(
&
pQueryAttr
->
pExpr1
[
i
]);
int32_t
functionId
=
getExprFunctionId
(
&
pQueryAttr
->
pExpr1
[
i
]);
// if (functionId == FUNCTION_LAST || functionId == FUNCTION_LAST_DST) {
// if (functionId == FUNCTION_LAST || functionId == FUNCTION_LAST_DST) {
// continue;
// continue;
// }
// }
return
false
;
return
false
;
}
}
...
@@ -1283,7 +1282,6 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
...
@@ -1283,7 +1282,6 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
hasOtherFunc = true;
hasOtherFunc = true;
}
}
#endif
#endif
}
}
if
(
hasFirstLastFunc
&&
status
==
BLK_DATA_NOT_LOAD
)
{
if
(
hasFirstLastFunc
&&
status
==
BLK_DATA_NOT_LOAD
)
{
...
@@ -1765,7 +1763,6 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity, int32_t numOf
...
@@ -1765,7 +1763,6 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity, int32_t numOf
// if (i > 0) pBInfo->pCtx[i].pTsOutput = pBInfo->pCtx[i - 1].pOutput;
// if (i > 0) pBInfo->pCtx[i].pTsOutput = pBInfo->pCtx[i - 1].pOutput;
}
}
#endif
#endif
}
}
}
}
...
@@ -1824,7 +1821,8 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
...
@@ -1824,7 +1821,8 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
}
}
static
void
extractQualifiedTupleByFilterResult
(
SSDataBlock
*
pBlock
,
const
int8_t
*
rowRes
,
bool
keep
);
static
void
extractQualifiedTupleByFilterResult
(
SSDataBlock
*
pBlock
,
const
int8_t
*
rowRes
,
bool
keep
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
,
SArray
*
pColMatchInfo
)
{
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
)
{
if
(
pFilterNode
==
NULL
)
{
if
(
pFilterNode
==
NULL
)
{
return
;
return
;
}
}
...
@@ -3669,6 +3667,8 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
...
@@ -3669,6 +3667,8 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
longjmp
(
pTaskInfo
->
env
,
code
);
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
doFilter
(
pProjectInfo
->
pFilterNode
,
pBlock
);
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
order
,
scanFlag
,
false
);
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
order
,
scanFlag
,
false
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pInfo
->
pRes
->
info
.
rows
+
pBlock
->
info
.
rows
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pInfo
->
pRes
->
info
.
rows
+
pBlock
->
info
.
rows
);
...
@@ -4044,7 +4044,7 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
...
@@ -4044,7 +4044,7 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
}
}
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
)
{
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -4056,8 +4056,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
...
@@ -4056,8 +4056,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
pInfo
->
slimit
=
*
pSlimit
;
pInfo
->
slimit
=
*
pSlimit
;
pInfo
->
curOffset
=
pLimit
->
offset
;
pInfo
->
curOffset
=
pLimit
->
offset
;
pInfo
->
curSOffset
=
pSlimit
->
offset
;
pInfo
->
curSOffset
=
pSlimit
->
offset
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
pFilterNode
=
pCondition
;
int32_t
numOfCols
=
num
;
int32_t
numOfCols
=
num
;
int32_t
numOfRows
=
4096
;
int32_t
numOfRows
=
4096
;
...
@@ -4259,7 +4259,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
...
@@ -4259,7 +4259,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
pExp
->
base
.
resSchema
=
createResSchema
(
pType
->
type
,
pType
->
bytes
,
pTargetNode
->
slotId
,
pType
->
scale
,
pExp
->
base
.
resSchema
=
createResSchema
(
pType
->
type
,
pType
->
bytes
,
pTargetNode
->
slotId
,
pType
->
scale
,
pType
->
precision
,
pValNode
->
node
.
aliasName
);
pType
->
precision
,
pValNode
->
node
.
aliasName
);
pExp
->
base
.
pParam
[
0
].
type
=
FUNC_PARAM_TYPE_VALUE
;
pExp
->
base
.
pParam
[
0
].
type
=
FUNC_PARAM_TYPE_VALUE
;
v
alueNodeToVariant
(
pValNode
,
&
pExp
->
base
.
pParam
[
0
].
param
);
nodesV
alueNodeToVariant
(
pValNode
,
&
pExp
->
base
.
pParam
[
0
].
param
);
}
else
if
(
type
==
QUERY_NODE_FUNCTION
)
{
}
else
if
(
type
==
QUERY_NODE_FUNCTION
)
{
pExp
->
pExpr
->
nodeType
=
QUERY_NODE_FUNCTION
;
pExp
->
pExpr
->
nodeType
=
QUERY_NODE_FUNCTION
;
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
...
@@ -4302,7 +4302,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
...
@@ -4302,7 +4302,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
}
else
if
(
p1
->
type
==
QUERY_NODE_VALUE
)
{
}
else
if
(
p1
->
type
==
QUERY_NODE_VALUE
)
{
SValueNode
*
pvn
=
(
SValueNode
*
)
p1
;
SValueNode
*
pvn
=
(
SValueNode
*
)
p1
;
pExp
->
base
.
pParam
[
j
].
type
=
FUNC_PARAM_TYPE_VALUE
;
pExp
->
base
.
pParam
[
j
].
type
=
FUNC_PARAM_TYPE_VALUE
;
v
alueNodeToVariant
(
pvn
,
&
pExp
->
base
.
pParam
[
j
].
param
);
nodesV
alueNodeToVariant
(
pvn
,
&
pExp
->
base
.
pParam
[
j
].
param
);
}
}
}
}
}
else
if
(
type
==
QUERY_NODE_OPERATOR
)
{
}
else
if
(
type
==
QUERY_NODE_OPERATOR
)
{
...
@@ -4389,7 +4389,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4389,7 +4389,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
}
SArray
*
groupKyes
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionKeys
);
SArray
*
groupKyes
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionKeys
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
pDataReader
,
pHandle
,
groupKyes
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
pDataReader
,
pHandle
,
groupKyes
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
...
@@ -4419,8 +4420,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4419,8 +4420,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
}
SArray
*
tableIdList
=
extractTableIdList
(
pTableListInfo
);
SArray
*
tableIdList
=
extractTableIdList
(
pTableListInfo
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
SOperatorInfo
*
pOperator
=
tableIdList
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
tableIdList
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
taosArrayDestroy
(
tableIdList
);
taosArrayDestroy
(
tableIdList
);
return
pOperator
;
return
pOperator
;
...
@@ -4486,7 +4487,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4486,7 +4487,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
SLimit
limit
=
{.
limit
=
pProjPhyNode
->
limit
,
.
offset
=
pProjPhyNode
->
offset
};
SLimit
limit
=
{.
limit
=
pProjPhyNode
->
limit
,
.
offset
=
pProjPhyNode
->
offset
};
SLimit
slimit
=
{.
limit
=
pProjPhyNode
->
slimit
,
.
offset
=
pProjPhyNode
->
soffset
};
SLimit
slimit
=
{.
limit
=
pProjPhyNode
->
slimit
,
.
offset
=
pProjPhyNode
->
soffset
};
pOptr
=
createProjectOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
&
limit
,
&
slimit
,
pTaskInfo
);
pOptr
=
createProjectOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
&
limit
,
&
slimit
,
p
ProjPhyNode
->
node
.
pConditions
,
p
TaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
type
)
{
SAggPhysiNode
*
pAggNode
=
(
SAggPhysiNode
*
)
pPhyNode
;
SAggPhysiNode
*
pAggNode
=
(
SAggPhysiNode
*
)
pPhyNode
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
...
@@ -4519,18 +4520,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4519,18 +4520,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
.
offset
=
pIntervalPhyNode
->
offset
,
.
offset
=
pIntervalPhyNode
->
offset
,
.
precision
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
node
.
resType
.
precision
};
.
precision
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
node
.
resType
.
precision
};
STimeWindowAggSupp
as
=
{.
waterMark
=
pIntervalPhyNode
->
window
.
watermark
,
STimeWindowAggSupp
as
=
{
.
waterMark
=
pIntervalPhyNode
->
window
.
watermark
,
.
calTrigger
=
pIntervalPhyNode
->
window
.
triggerType
,
.
calTrigger
=
pIntervalPhyNode
->
window
.
triggerType
,
.
maxTs
=
INT64_MIN
,
.
maxTs
=
INT64_MIN
,
.
winMap
=
NULL
,};
.
winMap
=
NULL
,
};
if
(
isSmaStream
(
pIntervalPhyNode
->
window
.
triggerType
))
{
if
(
isSmaStream
(
pIntervalPhyNode
->
window
.
triggerType
))
{
if
(
FLT_LESS
(
pIntervalPhyNode
->
window
.
filesFactor
,
1
.
000000
))
{
if
(
FLT_LESS
(
pIntervalPhyNode
->
window
.
filesFactor
,
1
.
000000
))
{
as
.
calTrigger
=
STREAM_TRIGGER_AT_ONCE_SMA
;
as
.
calTrigger
=
STREAM_TRIGGER_AT_ONCE_SMA
;
}
else
{
}
else
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_TIMESTAMP
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_TIMESTAMP
);
as
.
winMap
=
taosHashInit
(
64
,
hashFn
,
true
,
HASH_NO_LOCK
);
as
.
winMap
=
taosHashInit
(
64
,
hashFn
,
true
,
HASH_NO_LOCK
);
as
.
waterMark
=
getSmaWaterMark
(
interval
.
interval
,
as
.
waterMark
=
getSmaWaterMark
(
interval
.
interval
,
pIntervalPhyNode
->
window
.
filesFactor
);
pIntervalPhyNode
->
window
.
filesFactor
);
as
.
calTrigger
=
STREAM_TRIGGER_WINDOW_CLOSE_SMA
;
as
.
calTrigger
=
STREAM_TRIGGER_WINDOW_CLOSE_SMA
;
}
}
}
}
...
@@ -4598,6 +4600,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4598,6 +4600,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SColumnNode
*
pColNode
=
(
SColumnNode
*
)((
STargetNode
*
)
pStateNode
->
pStateKey
)
->
pExpr
;
SColumnNode
*
pColNode
=
(
SColumnNode
*
)((
STargetNode
*
)
pStateNode
->
pStateKey
)
->
pExpr
;
SColumn
col
=
extractColumnFromColumnNode
(
pColNode
);
SColumn
col
=
extractColumnFromColumnNode
(
pColNode
);
pOptr
=
createStatewindowOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
&
as
,
tsSlotId
,
&
col
,
pTaskInfo
);
pOptr
=
createStatewindowOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
&
as
,
tsSlotId
,
&
col
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
==
type
)
{
pOptr
=
createStreamStateAggOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_JOIN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_JOIN
==
type
)
{
SJoinPhysiNode
*
pJoinNode
=
(
SJoinPhysiNode
*
)
pPhyNode
;
SJoinPhysiNode
*
pJoinNode
=
(
SJoinPhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
...
@@ -5183,14 +5187,17 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
...
@@ -5183,14 +5187,17 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
)
{
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
,
size_t
size
)
{
pSup
->
keySize
=
sizeof
(
int64_t
)
+
sizeof
(
TSKEY
);
pSup
->
keySize
=
sizeof
(
int64_t
)
+
sizeof
(
TSKEY
);
pSup
->
pKeyBuf
=
taosMemoryCalloc
(
1
,
pSup
->
keySize
);
pSup
->
pKeyBuf
=
taosMemoryCalloc
(
1
,
pSup
->
keySize
);
pSup
->
pResultRows
=
taosArrayInit
(
1024
,
size
of
(
SResultWindowInfo
)
);
pSup
->
pResultRows
=
taosArrayInit
(
1024
,
size
);
if
(
pSup
->
pKeyBuf
==
NULL
||
pSup
->
pResultRows
==
NULL
)
{
if
(
pSup
->
pKeyBuf
==
NULL
||
pSup
->
pResultRows
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pSup
->
pScanWindow
=
taosArrayInit
(
4
,
sizeof
(
STimeWindow
));
int32_t
pageSize
=
4096
;
int32_t
pageSize
=
4096
;
while
(
pageSize
<
pSup
->
resultRowSize
*
4
)
{
while
(
pageSize
<
pSup
->
resultRowSize
*
4
)
{
pageSize
<<=
1u
;
pageSize
<<=
1u
;
...
@@ -5203,16 +5210,23 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
...
@@ -5203,16 +5210,23 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey) {
return
createDiskbasedBuf
(
&
pSup
->
pResultBuf
,
pageSize
,
bufSize
,
pKey
,
TD_TMP_DIR_PATH
);
return
createDiskbasedBuf
(
&
pSup
->
pResultBuf
,
pageSize
,
bufSize
,
pKey
,
TD_TMP_DIR_PATH
);
}
}
int32_t
initSessionAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
)
{
return
initStreamAggSupporter
(
pSup
,
pKey
,
sizeof
(
SResultWindowInfo
));
}
int32_t
initStateAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
)
{
return
initStreamAggSupporter
(
pSup
,
pKey
,
sizeof
(
SStateWindowInfo
));
}
int64_t
getSmaWaterMark
(
int64_t
interval
,
double
filesFactor
)
{
int64_t
getSmaWaterMark
(
int64_t
interval
,
double
filesFactor
)
{
int64_t
waterMark
=
0
;
int64_t
waterMark
=
0
;
ASSERT
(
FLT_GREATEREQUAL
(
filesFactor
,
0
.
000000
));
ASSERT
(
FLT_GREATEREQUAL
(
filesFactor
,
0
.
000000
));
waterMark
=
-
1
*
filesFactor
;
waterMark
=
-
1
*
filesFactor
;
return
waterMark
;
return
waterMark
;
}
}
bool
isSmaStream
(
int8_t
triggerType
)
{
bool
isSmaStream
(
int8_t
triggerType
)
{
if
(
triggerType
==
STREAM_TRIGGER_AT_ONCE
||
if
(
triggerType
==
STREAM_TRIGGER_AT_ONCE
||
triggerType
==
STREAM_TRIGGER_WINDOW_CLOSE
)
{
triggerType
==
STREAM_TRIGGER_WINDOW_CLOSE
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
e6c15da7
...
@@ -93,7 +93,15 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
...
@@ -93,7 +93,15 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
if
(
pkey
->
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
dataLen
=
getJsonValueLen
(
val
);
if
(
memcmp
(
pkey
->
pData
,
val
,
dataLen
)
==
0
){
continue
;
}
else
{
return
false
;
}
}
else
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
int32_t
len
=
varDataLen
(
val
);
int32_t
len
=
varDataLen
(
val
);
if
(
len
==
varDataLen
(
pkey
->
pData
)
&&
memcmp
(
varDataVal
(
pkey
->
pData
),
varDataVal
(
val
),
len
)
==
0
)
{
if
(
len
==
varDataLen
(
pkey
->
pData
)
&&
memcmp
(
varDataVal
(
pkey
->
pData
),
varDataVal
(
val
),
len
)
==
0
)
{
continue
;
continue
;
...
@@ -129,7 +137,10 @@ void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock*
...
@@ -129,7 +137,10 @@ void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock*
}
else
{
}
else
{
pkey
->
isNull
=
false
;
pkey
->
isNull
=
false
;
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
if
(
pkey
->
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
dataLen
=
getJsonValueLen
(
val
);
memcpy
(
pkey
->
pData
,
val
,
dataLen
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
memcpy
(
pkey
->
pData
,
val
,
varDataTLen
(
val
));
memcpy
(
pkey
->
pData
,
val
,
varDataTLen
(
val
));
ASSERT
(
varDataTLen
(
val
)
<=
pkey
->
bytes
);
ASSERT
(
varDataTLen
(
val
)
<=
pkey
->
bytes
);
}
else
{
}
else
{
...
@@ -153,7 +164,11 @@ int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
...
@@ -153,7 +164,11 @@ int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
}
}
isNull
[
i
]
=
0
;
isNull
[
i
]
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
if
(
pkey
->
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
dataLen
=
getJsonValueLen
(
pkey
->
pData
);
memcpy
(
pStart
,
(
pkey
->
pData
),
dataLen
);
pStart
+=
dataLen
;
}
else
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
varDataCopy
(
pStart
,
pkey
->
pData
);
varDataCopy
(
pStart
,
pkey
->
pData
);
pStart
+=
varDataTLen
(
pkey
->
pData
);
pStart
+=
varDataTLen
(
pkey
->
pData
);
ASSERT
(
varDataTLen
(
pkey
->
pData
)
<=
pkey
->
bytes
);
ASSERT
(
varDataTLen
(
pkey
->
pData
)
<=
pkey
->
bytes
);
...
@@ -178,7 +193,10 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
...
@@ -178,7 +193,10 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
char
*
dest
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
char
*
dest
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
char
*
data
=
colDataGetData
(
pColInfoData
,
rowIndex
);
char
*
data
=
colDataGetData
(
pColInfoData
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
if
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
dataLen
=
getJsonValueLen
(
data
);
memcpy
(
dest
,
data
,
dataLen
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
varDataCopy
(
dest
,
data
);
varDataCopy
(
dest
,
data
);
}
else
{
}
else
{
memcpy
(
dest
,
data
,
pColInfoData
->
info
.
bytes
);
memcpy
(
dest
,
data
,
pColInfoData
->
info
.
bytes
);
...
@@ -341,7 +359,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
...
@@ -341,7 +359,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
while
(
1
)
{
while
(
1
)
{
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doFilter
(
pInfo
->
pCondition
,
pRes
,
NULL
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
bool
hasRemain
=
hashRemainDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
bool
hasRemain
=
hashRemainDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
if
(
!
hasRemain
)
{
if
(
!
hasRemain
)
{
...
@@ -447,6 +465,16 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -447,6 +465,16 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
offset
[(
*
rows
)]
=
-
1
;
offset
[(
*
rows
)]
=
-
1
;
contentLen
=
0
;
contentLen
=
0
;
}
else
if
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
){
offset
[
*
rows
]
=
(
*
columnLen
);
char
*
src
=
colDataGetData
(
pColInfoData
,
j
);
int32_t
dataLen
=
getJsonValueLen
(
src
);
memcpy
(
data
+
(
*
columnLen
),
src
,
dataLen
);
int32_t
v
=
(
data
+
(
*
columnLen
)
+
dataLen
-
(
char
*
)
pPage
);
ASSERT
(
v
>
0
);
contentLen
=
dataLen
;
}
else
{
}
else
{
offset
[
*
rows
]
=
(
*
columnLen
);
offset
[
*
rows
]
=
(
*
columnLen
);
char
*
src
=
colDataGetData
(
pColInfoData
,
j
);
char
*
src
=
colDataGetData
(
pColInfoData
,
j
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
e6c15da7
...
@@ -256,7 +256,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
...
@@ -256,7 +256,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
}
}
int64_t
st
=
taosGetTimestampMs
();
int64_t
st
=
taosGetTimestampMs
();
doFilter
(
pTableScanInfo
->
pFilterNode
,
pBlock
,
pTableScanInfo
->
pColMatchInfo
);
doFilter
(
pTableScanInfo
->
pFilterNode
,
pBlock
);
int64_t
et
=
taosGetTimestampMs
();
int64_t
et
=
taosGetTimestampMs
();
pTableScanInfo
->
readRecorder
.
filterTime
+=
(
et
-
st
);
pTableScanInfo
->
readRecorder
.
filterTime
+=
(
et
-
st
);
...
@@ -706,16 +706,23 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
...
@@ -706,16 +706,23 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
taosArrayClear
(
pInfo
->
pBlockLists
);
taosArrayClear
(
pInfo
->
pBlockLists
);
}
}
static
bool
isSessionWindow
(
SStreamBlockScanInfo
*
pInfo
)
{
return
pInfo
->
sessionSup
.
pStreamAggSup
!=
NULL
;
}
static
bool
isSessionWindow
(
SStreamBlockScanInfo
*
pInfo
)
{
return
pInfo
->
sessionSup
.
parentType
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
;
}
static
bool
isStateWindow
(
SStreamBlockScanInfo
*
pInfo
)
{
return
pInfo
->
sessionSup
.
parentType
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
;
}
static
bool
prepareDataScan
(
SStreamBlockScanInfo
*
pInfo
)
{
static
bool
prepareDataScan
(
SStreamBlockScanInfo
*
pInfo
)
{
SSDataBlock
*
pSDB
=
pInfo
->
pUpdateRes
;
SSDataBlock
*
pSDB
=
pInfo
->
pUpdateRes
;
if
(
pInfo
->
updateResIndex
<
pSDB
->
info
.
rows
)
{
STimeWindow
win
=
{.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
,};
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDB
->
pDataBlock
,
0
);
bool
needRead
=
false
;
if
(
!
isStateWindow
(
pInfo
)
&&
pInfo
->
updateResIndex
<
pSDB
->
info
.
rows
)
{
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDB
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
TSKEY
*
tsCols
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
TSKEY
*
tsCols
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
SResultRowInfo
dumyInfo
;
SResultRowInfo
dumyInfo
;
dumyInfo
.
cur
.
pageId
=
-
1
;
dumyInfo
.
cur
.
pageId
=
-
1
;
STimeWindow
win
;
if
(
isSessionWindow
(
pInfo
))
{
if
(
isSessionWindow
(
pInfo
))
{
SStreamAggSupporter
*
pAggSup
=
pInfo
->
sessionSup
.
pStreamAggSup
;
SStreamAggSupporter
*
pAggSup
=
pInfo
->
sessionSup
.
pStreamAggSup
;
int64_t
gap
=
pInfo
->
sessionSup
.
gap
;
int64_t
gap
=
pInfo
->
sessionSup
.
gap
;
...
@@ -731,15 +738,28 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
...
@@ -731,15 +738,28 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
pInfo
->
updateResIndex
+=
getNumOfRowsInTimeWindow
(
&
pSDB
->
info
,
tsCols
,
pInfo
->
updateResIndex
,
win
.
ekey
,
pInfo
->
updateResIndex
+=
getNumOfRowsInTimeWindow
(
&
pSDB
->
info
,
tsCols
,
pInfo
->
updateResIndex
,
win
.
ekey
,
binarySearchForKey
,
NULL
,
TSDB_ORDER_ASC
);
binarySearchForKey
,
NULL
,
TSDB_ORDER_ASC
);
}
}
needRead
=
true
;
}
else
if
(
isStateWindow
(
pInfo
))
{
SArray
*
pWins
=
pInfo
->
sessionSup
.
pStreamAggSup
->
pScanWindow
;
int32_t
size
=
taosArrayGetSize
(
pWins
);
if
(
pInfo
->
scanWinIndex
<
size
)
{
win
=
*
(
STimeWindow
*
)
taosArrayGet
(
pWins
,
pInfo
->
scanWinIndex
);
pInfo
->
scanWinIndex
++
;
needRead
=
true
;
}
else
{
pInfo
->
scanWinIndex
=
0
;
taosArrayClear
(
pWins
);
}
}
if
(
!
needRead
)
{
return
false
;
}
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pOperatorDumy
->
info
;
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pOperatorDumy
->
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
;
return
true
;
return
true
;
}
else
{
return
false
;
}
}
}
static
SSDataBlock
*
doDataScan
(
SStreamBlockScanInfo
*
pInfo
)
{
static
SSDataBlock
*
doDataScan
(
SStreamBlockScanInfo
*
pInfo
)
{
...
@@ -754,36 +774,39 @@ static SSDataBlock* doDataScan(SStreamBlockScanInfo* pInfo) {
...
@@ -754,36 +774,39 @@ static SSDataBlock* doDataScan(SStreamBlockScanInfo* pInfo) {
return
pResult
;
return
pResult
;
}
}
static
SSDataBlock
*
getUpdateDataBlock
(
SStreamBlockScanInfo
*
pInfo
,
bool
invertible
)
{
static
void
getUpdateDataBlock
(
SStreamBlockScanInfo
*
pInfo
,
bool
invertible
,
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
SSDataBlock
*
pBlock
,
SSDataBlock
*
pUpdateBlock
)
{
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
ASSERT
(
pColDataInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
TSKEY
*
ts
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
TSKEY
*
ts
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
for
(
int32_t
i
=
0
;
i
<
p
Info
->
pRes
->
info
.
rows
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
p
Block
->
info
.
rows
;
i
++
)
{
if
(
updateInfoIsUpdated
(
pInfo
->
pUpdateInfo
,
p
Info
->
pRes
->
info
.
uid
,
ts
[
i
]))
{
if
(
updateInfoIsUpdated
(
pInfo
->
pUpdateInfo
,
p
Block
->
info
.
uid
,
ts
[
i
]))
{
taosArrayPush
(
pInfo
->
tsArray
,
ts
+
i
);
taosArrayPush
(
pInfo
->
tsArray
,
ts
+
i
);
}
}
}
}
if
(
!
pUpdateBlock
)
{
taosArrayClear
(
pInfo
->
tsArray
);
return
;
}
int32_t
size
=
taosArrayGetSize
(
pInfo
->
tsArray
);
int32_t
size
=
taosArrayGetSize
(
pInfo
->
tsArray
);
if
(
size
>
0
&&
invertible
)
{
if
(
size
>
0
&&
invertible
)
{
// T
ODO
(liuyao) get from tsdb
// T
odo
(liuyao) get from tsdb
// SSDataBlock* p = createOneDataBlock(p
Info->pRes
, true);
// SSDataBlock* p = createOneDataBlock(p
Block
, true);
// p->info.type = STREAM_INVERT;
// p->info.type = STREAM_INVERT;
// taosArrayClear(pInfo->tsArray);
// taosArrayClear(pInfo->tsArray);
// return p;
// return p;
SSDataBlock
*
pDataBlock
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
SColumnInfoData
*
pCol
=
(
SColumnInfoData
*
)
taosArrayGet
(
pUpdateBlock
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
SColumnInfoData
*
pCol
=
(
SColumnInfoData
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
0
);
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
colInfoDataEnsureCapacity
(
pCol
,
0
,
size
);
colInfoDataEnsureCapacity
(
pCol
,
0
,
size
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
TSKEY
*
pTs
=
(
TSKEY
*
)
taosArrayGet
(
pInfo
->
tsArray
,
i
);
TSKEY
*
pTs
=
(
TSKEY
*
)
taosArrayGet
(
pInfo
->
tsArray
,
i
);
colDataAppend
(
pCol
,
i
,
(
char
*
)
pTs
,
false
);
colDataAppend
(
pCol
,
i
,
(
char
*
)
pTs
,
false
);
}
}
p
Data
Block
->
info
.
rows
=
size
;
p
Update
Block
->
info
.
rows
=
size
;
p
Data
Block
->
info
.
type
=
STREAM_REPROCESS
;
p
Update
Block
->
info
.
type
=
STREAM_REPROCESS
;
blockDataUpdateTsWindow
(
p
Data
Block
,
0
);
blockDataUpdateTsWindow
(
p
Update
Block
,
0
);
taosArrayClear
(
pInfo
->
tsArray
);
taosArrayClear
(
pInfo
->
tsArray
);
return
pDataBlock
;
}
}
return
NULL
;
}
}
static
SSDataBlock
*
doStreamBlockScan
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
doStreamBlockScan
(
SOperatorInfo
*
pOperator
)
{
...
@@ -815,16 +838,27 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -815,16 +838,27 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
}
else
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_UPDATERES
)
{
}
else
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_UPDATERES
)
{
blockDataCleanup
(
pInfo
->
pRes
);
blockDataCleanup
(
pInfo
->
pRes
);
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
if
(
!
isStateWindow
(
pInfo
))
{
prepareDataScan
(
pInfo
);
prepareDataScan
(
pInfo
);
}
return
pInfo
->
pUpdateRes
;
return
pInfo
->
pUpdateRes
;
}
else
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_DATAREADER
)
{
}
else
{
if
(
isStateWindow
(
pInfo
)
&&
taosArrayGetSize
(
pInfo
->
sessionSup
.
pStreamAggSup
->
pScanWindow
)
>
0
)
{
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
pInfo
->
updateResIndex
=
pInfo
->
pUpdateRes
->
info
.
rows
;
prepareDataScan
(
pInfo
);
}
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_DATAREADER
)
{
SSDataBlock
*
pSDB
=
doDataScan
(
pInfo
);
SSDataBlock
*
pSDB
=
doDataScan
(
pInfo
);
if
(
pSDB
==
NULL
)
{
if
(
pSDB
==
NULL
)
{
pInfo
->
scanMode
=
STREAM_SCAN_FROM_READERHANDLE
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_READERHANDLE
;
}
else
{
}
else
{
getUpdateDataBlock
(
pInfo
,
true
,
pSDB
,
NULL
);
return
pSDB
;
return
pSDB
;
}
}
}
}
}
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
blockDataCleanup
(
pInfo
->
pRes
);
blockDataCleanup
(
pInfo
->
pRes
);
...
@@ -894,7 +928,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -894,7 +928,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
addTagPseudoColumnData
(
&
pInfo
->
readHandle
,
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
pInfo
->
pRes
);
addTagPseudoColumnData
(
&
pInfo
->
readHandle
,
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
pInfo
->
pRes
);
}
}
doFilter
(
pInfo
->
pCondition
,
pInfo
->
pRes
,
NULL
);
doFilter
(
pInfo
->
pCondition
,
pInfo
->
pRes
);
blockDataUpdateTsWindow
(
pInfo
->
pRes
,
0
);
blockDataUpdateTsWindow
(
pInfo
->
pRes
,
0
);
break
;
break
;
}
}
...
@@ -906,7 +940,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -906,7 +940,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
if
(
rows
==
0
)
{
if
(
rows
==
0
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
}
else
if
(
pInfo
->
pUpdateInfo
)
{
}
else
if
(
pInfo
->
pUpdateInfo
)
{
SSDataBlock
*
upRes
=
getUpdateDataBlock
(
pInfo
,
true
);
SSDataBlock
*
upRes
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
getUpdateDataBlock
(
pInfo
,
true
,
pInfo
->
pRes
,
upRes
);
if
(
upRes
)
{
if
(
upRes
)
{
pInfo
->
pUpdateRes
=
upRes
;
pInfo
->
pUpdateRes
=
upRes
;
if
(
upRes
->
info
.
type
==
STREAM_REPROCESS
)
{
if
(
upRes
->
info
.
type
==
STREAM_REPROCESS
)
{
...
@@ -950,6 +985,9 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
...
@@ -950,6 +985,9 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
int16_t
colId
=
id
->
colId
;
int16_t
colId
=
id
->
colId
;
taosArrayPush
(
pColIds
,
&
colId
);
taosArrayPush
(
pColIds
,
&
colId
);
if
(
id
->
colId
==
pTableScanNode
->
tsColId
)
{
pInfo
->
primaryTsIndex
=
id
->
targetSlotId
;
}
}
}
// set the extract column id to streamHandle
// set the extract column id to streamHandle
...
@@ -974,7 +1012,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
...
@@ -974,7 +1012,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
pTwSup
->
waterMark
=
getSmaWaterMark
(
pSTInfo
->
interval
.
interval
,
pTwSup
->
waterMark
=
getSmaWaterMark
(
pSTInfo
->
interval
.
interval
,
pTableScanNode
->
filesFactor
);
pTableScanNode
->
filesFactor
);
}
}
pInfo
->
primaryTsIndex
=
0
;
// pTableScanNode->tsColId;
if
(
pSTInfo
->
interval
.
interval
>
0
&&
pDataReader
)
{
if
(
pSTInfo
->
interval
.
interval
>
0
&&
pDataReader
)
{
pInfo
->
pUpdateInfo
=
updateInfoInitP
(
&
pSTInfo
->
interval
,
pTwSup
->
waterMark
);
pInfo
->
pUpdateInfo
=
updateInfoInitP
(
&
pSTInfo
->
interval
,
pTwSup
->
waterMark
);
}
else
{
}
else
{
...
...
source/libs/executor/src/tfill.c
浏览文件 @
e6c15da7
...
@@ -22,17 +22,18 @@
...
@@ -22,17 +22,18 @@
#include "thash.h"
#include "thash.h"
#include "ttime.h"
#include "ttime.h"
#include "function.h"
#include "tdatablock.h"
#include "executorInt.h"
#include "executorInt.h"
#include "function.h"
#include "querynodes.h"
#include "querynodes.h"
#include "tdatablock.h"
#include "tfill.h"
#include "tfill.h"
#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC)
#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC)
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) ((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) \
((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
static
void
setTagsValue
(
SFillInfo
*
pFillInfo
,
void
**
data
,
int32_t
genRows
)
{
static
void
setTagsValue
(
SFillInfo
*
pFillInfo
,
void
**
data
,
int32_t
genRows
)
{
for
(
int32_t
j
=
0
;
j
<
pFillInfo
->
numOfCols
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pFillInfo
->
numOfCols
;
++
j
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
j
];
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
j
];
if
(
TSDB_COL_IS_NORMAL_COL
(
pCol
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pCol
->
flag
))
{
if
(
TSDB_COL_IS_NORMAL_COL
(
pCol
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pCol
->
flag
))
{
continue
;
continue
;
...
@@ -60,16 +61,17 @@ static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex)
...
@@ -60,16 +61,17 @@ static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex)
static
void
doSetVal
(
SColumnInfoData
*
pDstColInfoData
,
int32_t
rowIndex
,
const
SGroupKeys
*
pKey
);
static
void
doSetVal
(
SColumnInfoData
*
pDstColInfoData
,
int32_t
rowIndex
,
const
SGroupKeys
*
pKey
);
static
void
doFillOneRowResult
(
SFillInfo
*
pFillInfo
,
SSDataBlock
*
pBlock
,
SSDataBlock
*
pSrcBlock
,
int64_t
ts
,
bool
outOfBound
)
{
static
void
doFillOneRowResult
(
SFillInfo
*
pFillInfo
,
SSDataBlock
*
pBlock
,
SSDataBlock
*
pSrcBlock
,
int64_t
ts
,
bool
outOfBound
)
{
SPoint
point1
,
point2
,
point
;
SPoint
point1
,
point2
,
point
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pFillInfo
->
order
);
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pFillInfo
->
order
);
// set the primary timestamp column value
// set the primary timestamp column value
int32_t
index
=
pFillInfo
->
numOfCurrent
;
int32_t
index
=
pFillInfo
->
numOfCurrent
;
SColumnInfoData
*
pCol0
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pCol0
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
char
*
val
=
colDataGetData
(
pCol0
,
index
);
char
*
val
=
colDataGetData
(
pCol0
,
index
);
*
(
TSKEY
*
)
val
=
pFillInfo
->
currentKey
;
*
(
TSKEY
*
)
val
=
pFillInfo
->
currentKey
;
// set the other values
// set the other values
if
(
pFillInfo
->
type
==
TSDB_FILL_PREV
)
{
if
(
pFillInfo
->
type
==
TSDB_FILL_PREV
)
{
...
@@ -142,7 +144,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSData
...
@@ -142,7 +144,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSData
}
else
{
// fill with user specified value for each column
}
else
{
// fill with user specified value for each column
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
)
/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/
)
{
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
)
/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/
)
{
continue
;
continue
;
}
}
...
@@ -165,9 +167,10 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSData
...
@@ -165,9 +167,10 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSData
}
}
}
}
// setTagsValue(pFillInfo, data, index);
// setTagsValue(pFillInfo, data, index);
SInterval
*
pInterval
=
&
pFillInfo
->
interval
;
SInterval
*
pInterval
=
&
pFillInfo
->
interval
;
pFillInfo
->
currentKey
=
taosTimeAdd
(
pFillInfo
->
currentKey
,
pInterval
->
sliding
*
step
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
pFillInfo
->
currentKey
=
taosTimeAdd
(
pFillInfo
->
currentKey
,
pInterval
->
sliding
*
step
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
pFillInfo
->
numOfCurrent
++
;
pFillInfo
->
numOfCurrent
++
;
}
}
...
@@ -236,9 +239,11 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -236,9 +239,11 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
copyCurrentRowIntoBuf
(
pFillInfo
,
pFillInfo
->
index
,
pFillInfo
->
next
);
copyCurrentRowIntoBuf
(
pFillInfo
,
pFillInfo
->
index
,
pFillInfo
->
next
);
}
}
if
(((
pFillInfo
->
currentKey
<
ts
&&
ascFill
)
||
(
pFillInfo
->
currentKey
>
ts
&&
!
ascFill
))
&&
pFillInfo
->
numOfCurrent
<
outputRows
)
{
if
(((
pFillInfo
->
currentKey
<
ts
&&
ascFill
)
||
(
pFillInfo
->
currentKey
>
ts
&&
!
ascFill
))
&&
pFillInfo
->
numOfCurrent
<
outputRows
)
{
// fill the gap between two input rows
// fill the gap between two input rows
while
(((
pFillInfo
->
currentKey
<
ts
&&
ascFill
)
||
(
pFillInfo
->
currentKey
>
ts
&&
!
ascFill
))
&&
pFillInfo
->
numOfCurrent
<
outputRows
)
{
while
(((
pFillInfo
->
currentKey
<
ts
&&
ascFill
)
||
(
pFillInfo
->
currentKey
>
ts
&&
!
ascFill
))
&&
pFillInfo
->
numOfCurrent
<
outputRows
)
{
doFillOneRowResult
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
ts
,
false
);
doFillOneRowResult
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
ts
,
false
);
}
}
...
@@ -259,7 +264,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -259,7 +264,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
// assign rows to dst buffer
// assign rows to dst buffer
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
)
/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/
)
{
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
)
/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/
)
{
continue
;
continue
;
}
}
...
@@ -277,7 +282,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -277,7 +282,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
saveColData
(
pFillInfo
->
prev
,
i
,
src
,
isNull
);
saveColData
(
pFillInfo
->
prev
,
i
,
src
,
isNull
);
}
else
{
// i > 0 and data is null , do interpolation
}
else
{
// i > 0 and data is null , do interpolation
if
(
pFillInfo
->
type
==
TSDB_FILL_PREV
)
{
if
(
pFillInfo
->
type
==
TSDB_FILL_PREV
)
{
SGroupKeys
*
pKey
=
taosArrayGet
(
pFillInfo
->
prev
,
i
);
SGroupKeys
*
pKey
=
taosArrayGet
(
pFillInfo
->
prev
,
i
);
doSetVal
(
pDst
,
pFillInfo
->
numOfCurrent
,
pKey
);
doSetVal
(
pDst
,
pFillInfo
->
numOfCurrent
,
pKey
);
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_LINEAR
)
{
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_LINEAR
)
{
bool
isNull
=
colDataIsNull_s
(
pSrc
,
pFillInfo
->
index
);
bool
isNull
=
colDataIsNull_s
(
pSrc
,
pFillInfo
->
index
);
...
@@ -286,7 +291,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -286,7 +291,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NULL
)
{
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NULL
)
{
colDataAppendNULL
(
pDst
,
pFillInfo
->
numOfCurrent
);
colDataAppendNULL
(
pDst
,
pFillInfo
->
numOfCurrent
);
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NEXT
)
{
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NEXT
)
{
SGroupKeys
*
pKey
=
taosArrayGet
(
pFillInfo
->
next
,
i
);
SGroupKeys
*
pKey
=
taosArrayGet
(
pFillInfo
->
next
,
i
);
doSetVal
(
pDst
,
pFillInfo
->
numOfCurrent
,
pKey
);
doSetVal
(
pDst
,
pFillInfo
->
numOfCurrent
,
pKey
);
}
else
{
}
else
{
SVariant
*
pVar
=
&
pFillInfo
->
pFillCol
[
i
].
fillVal
;
SVariant
*
pVar
=
&
pFillInfo
->
pFillCol
[
i
].
fillVal
;
...
@@ -296,9 +301,10 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -296,9 +301,10 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
}
}
// set the tag value for final result
// set the tag value for final result
// setTagsValue(pFillInfo, data, pFillInfo->numOfCurrent);
// setTagsValue(pFillInfo, data, pFillInfo->numOfCurrent);
SInterval
*
pInterval
=
&
pFillInfo
->
interval
;
SInterval
*
pInterval
=
&
pFillInfo
->
interval
;
pFillInfo
->
currentKey
=
taosTimeAdd
(
pFillInfo
->
currentKey
,
pInterval
->
sliding
*
step
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
pFillInfo
->
currentKey
=
taosTimeAdd
(
pFillInfo
->
currentKey
,
pInterval
->
sliding
*
step
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
pFillInfo
->
index
+=
1
;
pFillInfo
->
index
+=
1
;
pFillInfo
->
numOfCurrent
+=
1
;
pFillInfo
->
numOfCurrent
+=
1
;
...
@@ -306,9 +312,9 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -306,9 +312,9 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
if
(
pFillInfo
->
index
>=
pFillInfo
->
numOfRows
||
pFillInfo
->
numOfCurrent
>=
outputRows
)
{
if
(
pFillInfo
->
index
>=
pFillInfo
->
numOfRows
||
pFillInfo
->
numOfCurrent
>=
outputRows
)
{
/* the raw data block is exhausted, next value does not exists */
/* the raw data block is exhausted, next value does not exists */
// if (pFillInfo->index >= pFillInfo->numOfRows) {
// if (pFillInfo->index >= pFillInfo->numOfRows) {
// taosMemoryFreeClear(*next);
// taosMemoryFreeClear(*next);
// }
// }
pFillInfo
->
numOfTotal
+=
pFillInfo
->
numOfCurrent
;
pFillInfo
->
numOfTotal
+=
pFillInfo
->
numOfCurrent
;
return
pFillInfo
->
numOfCurrent
;
return
pFillInfo
->
numOfCurrent
;
}
}
...
@@ -318,7 +324,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
...
@@ -318,7 +324,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
}
}
static
void
saveColData
(
SArray
*
rowBuf
,
int32_t
columnIndex
,
const
char
*
src
,
bool
isNull
)
{
static
void
saveColData
(
SArray
*
rowBuf
,
int32_t
columnIndex
,
const
char
*
src
,
bool
isNull
)
{
SGroupKeys
*
pKey
=
taosArrayGet
(
rowBuf
,
columnIndex
);
SGroupKeys
*
pKey
=
taosArrayGet
(
rowBuf
,
columnIndex
);
if
(
isNull
)
{
if
(
isNull
)
{
pKey
->
isNull
=
true
;
pKey
->
isNull
=
true
;
}
else
{
}
else
{
...
@@ -399,7 +405,8 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
...
@@ -399,7 +405,8 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
}
}
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
const
char
*
id
)
{
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
const
char
*
id
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -413,13 +420,25 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
...
@@ -413,13 +420,25 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
taosResetFillInfo
(
pFillInfo
,
skey
);
taosResetFillInfo
(
pFillInfo
,
skey
);
pFillInfo
->
order
=
order
;
pFillInfo
->
order
=
order
;
switch
(
fillType
)
{
switch
(
fillType
)
{
case
FILL_MODE_NONE
:
pFillInfo
->
type
=
TSDB_FILL_NONE
;
break
;
case
FILL_MODE_NONE
:
case
FILL_MODE_PREV
:
pFillInfo
->
type
=
TSDB_FILL_PREV
;
break
;
pFillInfo
->
type
=
TSDB_FILL_NONE
;
case
FILL_MODE_NULL
:
pFillInfo
->
type
=
TSDB_FILL_NULL
;
break
;
break
;
case
FILL_MODE_LINEAR
:
pFillInfo
->
type
=
TSDB_FILL_LINEAR
;
break
;
case
FILL_MODE_PREV
:
case
FILL_MODE_NEXT
:
pFillInfo
->
type
=
TSDB_FILL_NEXT
;
break
;
pFillInfo
->
type
=
TSDB_FILL_PREV
;
case
FILL_MODE_VALUE
:
pFillInfo
->
type
=
TSDB_FILL_SET_VALUE
;
break
;
break
;
case
FILL_MODE_NULL
:
pFillInfo
->
type
=
TSDB_FILL_NULL
;
break
;
case
FILL_MODE_LINEAR
:
pFillInfo
->
type
=
TSDB_FILL_LINEAR
;
break
;
case
FILL_MODE_NEXT
:
pFillInfo
->
type
=
TSDB_FILL_NEXT
;
break
;
case
FILL_MODE_VALUE
:
pFillInfo
->
type
=
TSDB_FILL_SET_VALUE
;
break
;
default:
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
return
NULL
;
...
@@ -433,12 +452,12 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
...
@@ -433,12 +452,12 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
pFillInfo
->
id
=
id
;
pFillInfo
->
id
=
id
;
pFillInfo
->
interval
=
*
pInterval
;
pFillInfo
->
interval
=
*
pInterval
;
// if (numOfTags > 0) {
// if (numOfTags > 0) {
pFillInfo
->
pTags
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SFillTagColInfo
));
pFillInfo
->
pTags
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SFillTagColInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pFillInfo
->
pTags
[
i
].
col
.
colId
=
-
2
;
// TODO
pFillInfo
->
pTags
[
i
].
col
.
colId
=
-
2
;
// TODO
}
}
// }
// }
pFillInfo
->
next
=
taosArrayInit
(
numOfCols
,
sizeof
(
SGroupKeys
));
pFillInfo
->
next
=
taosArrayInit
(
numOfCols
,
sizeof
(
SGroupKeys
));
pFillInfo
->
prev
=
taosArrayInit
(
numOfCols
,
sizeof
(
SGroupKeys
));
pFillInfo
->
prev
=
taosArrayInit
(
numOfCols
,
sizeof
(
SGroupKeys
));
...
@@ -468,7 +487,7 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
...
@@ -468,7 +487,7 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
taosArrayDestroy
(
pFillInfo
->
prev
);
taosArrayDestroy
(
pFillInfo
->
prev
);
taosArrayDestroy
(
pFillInfo
->
next
);
taosArrayDestroy
(
pFillInfo
->
next
);
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfTags
;
++
i
)
{
taosMemoryFreeClear
(
pFillInfo
->
pTags
[
i
].
tagVal
);
taosMemoryFreeClear
(
pFillInfo
->
pTags
[
i
].
tagVal
);
}
}
...
@@ -493,7 +512,7 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
...
@@ -493,7 +512,7 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
}
}
void
taosFillSetInputDataBlock
(
SFillInfo
*
pFillInfo
,
const
SSDataBlock
*
pInput
)
{
void
taosFillSetInputDataBlock
(
SFillInfo
*
pFillInfo
,
const
SSDataBlock
*
pInput
)
{
pFillInfo
->
pSrcBlock
=
(
SSDataBlock
*
)
pInput
;
pFillInfo
->
pSrcBlock
=
(
SSDataBlock
*
)
pInput
;
}
}
bool
taosFillHasMoreResults
(
SFillInfo
*
pFillInfo
)
{
bool
taosFillHasMoreResults
(
SFillInfo
*
pFillInfo
)
{
...
@@ -513,7 +532,7 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
...
@@ -513,7 +532,7 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
int64_t
getNumOfResultsAfterFillGap
(
SFillInfo
*
pFillInfo
,
TSKEY
ekey
,
int32_t
maxNumOfRows
)
{
int64_t
getNumOfResultsAfterFillGap
(
SFillInfo
*
pFillInfo
,
TSKEY
ekey
,
int32_t
maxNumOfRows
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pFillInfo
->
pSrcBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pFillInfo
->
pSrcBlock
->
pDataBlock
,
0
);
int64_t
*
tsList
=
(
int64_t
*
)
pCol
->
pData
;
int64_t
*
tsList
=
(
int64_t
*
)
pCol
->
pData
;
int32_t
numOfRows
=
taosNumOfRemainRows
(
pFillInfo
);
int32_t
numOfRows
=
taosNumOfRemainRows
(
pFillInfo
);
TSKEY
ekey1
=
ekey
;
TSKEY
ekey1
=
ekey
;
...
@@ -524,12 +543,8 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
...
@@ -524,12 +543,8 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
int64_t
numOfRes
=
-
1
;
int64_t
numOfRes
=
-
1
;
if
(
numOfRows
>
0
)
{
// still fill gap within current data block, not generating data after the result set.
if
(
numOfRows
>
0
)
{
// still fill gap within current data block, not generating data after the result set.
TSKEY
lastKey
=
tsList
[
pFillInfo
->
numOfRows
-
1
];
TSKEY
lastKey
=
tsList
[
pFillInfo
->
numOfRows
-
1
];
numOfRes
=
taosTimeCountInterval
(
numOfRes
=
taosTimeCountInterval
(
lastKey
,
pFillInfo
->
currentKey
,
pFillInfo
->
interval
.
sliding
,
lastKey
,
pFillInfo
->
interval
.
slidingUnit
,
pFillInfo
->
interval
.
precision
);
pFillInfo
->
currentKey
,
pFillInfo
->
interval
.
sliding
,
pFillInfo
->
interval
.
slidingUnit
,
pFillInfo
->
interval
.
precision
);
numOfRes
+=
1
;
numOfRes
+=
1
;
assert
(
numOfRes
>=
numOfRows
);
assert
(
numOfRes
>=
numOfRows
);
}
else
{
// reach the end of data
}
else
{
// reach the end of data
...
@@ -537,19 +552,16 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
...
@@ -537,19 +552,16 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
(
ekey1
>
pFillInfo
->
currentKey
&&
!
FILL_IS_ASC_FILL
(
pFillInfo
)))
{
(
ekey1
>
pFillInfo
->
currentKey
&&
!
FILL_IS_ASC_FILL
(
pFillInfo
)))
{
return
0
;
return
0
;
}
}
numOfRes
=
taosTimeCountInterval
(
numOfRes
=
taosTimeCountInterval
(
ekey1
,
pFillInfo
->
currentKey
,
pFillInfo
->
interval
.
sliding
,
ekey1
,
pFillInfo
->
interval
.
slidingUnit
,
pFillInfo
->
interval
.
precision
);
pFillInfo
->
currentKey
,
pFillInfo
->
interval
.
sliding
,
pFillInfo
->
interval
.
slidingUnit
,
pFillInfo
->
interval
.
precision
);
numOfRes
+=
1
;
numOfRes
+=
1
;
}
}
return
(
numOfRes
>
maxNumOfRows
)
?
maxNumOfRows
:
numOfRes
;
return
(
numOfRes
>
maxNumOfRows
)
?
maxNumOfRows
:
numOfRes
;
}
}
int32_t
taosGetLinearInterpolationVal
(
SPoint
*
point
,
int32_t
outputType
,
SPoint
*
point1
,
SPoint
*
point2
,
int32_t
inputType
)
{
int32_t
taosGetLinearInterpolationVal
(
SPoint
*
point
,
int32_t
outputType
,
SPoint
*
point1
,
SPoint
*
point2
,
int32_t
inputType
)
{
double
v1
=
-
1
,
v2
=
-
1
;
double
v1
=
-
1
,
v2
=
-
1
;
GET_TYPED_DATA
(
v1
,
double
,
inputType
,
point1
->
val
);
GET_TYPED_DATA
(
v1
,
double
,
inputType
,
point1
->
val
);
GET_TYPED_DATA
(
v2
,
double
,
inputType
,
point2
->
val
);
GET_TYPED_DATA
(
v2
,
double
,
inputType
,
point2
->
val
);
...
@@ -570,20 +582,20 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
...
@@ -570,20 +582,20 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
if
(
remain
==
0
)
{
if
(
remain
==
0
)
{
appendFilledResult
(
pFillInfo
,
p
,
numOfRes
);
appendFilledResult
(
pFillInfo
,
p
,
numOfRes
);
}
else
{
}
else
{
fillResultImpl
(
pFillInfo
,
p
,
(
int32_t
)
numOfRes
);
fillResultImpl
(
pFillInfo
,
p
,
(
int32_t
)
numOfRes
);
assert
(
numOfRes
==
pFillInfo
->
numOfCurrent
);
assert
(
numOfRes
==
pFillInfo
->
numOfCurrent
);
}
}
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64", current:%d, total:%d, %p",
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64",
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey, pFillInfo->numOfCurrent,
// current:%d, total:%d, %p",
// pFillInfo->numOfTotal, pFillInfo->handle);
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
// pFillInfo->numOfCurrent,
// pFillInfo->numOfTotal, pFillInfo->handle);
return
numOfRes
;
return
numOfRes
;
}
}
int64_t
getFillInfoStart
(
struct
SFillInfo
*
pFillInfo
)
{
int64_t
getFillInfoStart
(
struct
SFillInfo
*
pFillInfo
)
{
return
pFillInfo
->
start
;
}
return
pFillInfo
->
start
;
}
SFillColInfo
*
createFillColInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
const
struct
SNodeListNode
*
pValNode
)
{
SFillColInfo
*
createFillColInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
const
struct
SNodeListNode
*
pValNode
)
{
SFillColInfo
*
pFillCol
=
taosMemoryCalloc
(
numOfOutput
,
sizeof
(
SFillColInfo
));
SFillColInfo
*
pFillCol
=
taosMemoryCalloc
(
numOfOutput
,
sizeof
(
SFillColInfo
));
...
@@ -591,8 +603,8 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
...
@@ -591,8 +603,8 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
return
NULL
;
return
NULL
;
}
}
size_t
len
=
(
pValNode
!=
NULL
)
?
LIST_LENGTH
(
pValNode
->
pNodeList
)
:
0
;
size_t
len
=
(
pValNode
!=
NULL
)
?
LIST_LENGTH
(
pValNode
->
pNodeList
)
:
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExprInfo
=
&
pExpr
[
i
];
SExprInfo
*
pExprInfo
=
&
pExpr
[
i
];
pFillCol
[
i
].
pExpr
=
pExprInfo
;
pFillCol
[
i
].
pExpr
=
pExprInfo
;
pFillCol
[
i
].
tagIndex
=
-
2
;
pFillCol
[
i
].
tagIndex
=
-
2
;
...
@@ -600,10 +612,10 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
...
@@ -600,10 +612,10 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
// todo refactor
// todo refactor
if
(
len
>
0
)
{
if
(
len
>
0
)
{
// if the user specified value is less than the column, alway use the last one as the fill value
// if the user specified value is less than the column, alway use the last one as the fill value
int32_t
index
=
(
i
>=
len
)
?
(
len
-
1
)
:
i
;
int32_t
index
=
(
i
>=
len
)
?
(
len
-
1
)
:
i
;
SValueNode
*
pv
=
(
SValueNode
*
)
nodesListGetNode
(
pValNode
->
pNodeList
,
index
);
SValueNode
*
pv
=
(
SValueNode
*
)
nodesListGetNode
(
pValNode
->
pNodeList
,
index
);
v
alueNodeToVariant
(
pv
,
&
pFillCol
[
i
].
fillVal
);
nodesV
alueNodeToVariant
(
pv
,
&
pFillCol
[
i
].
fillVal
);
}
}
if
(
pExprInfo
->
base
.
numOfParams
>
0
)
{
if
(
pExprInfo
->
base
.
numOfParams
>
0
)
{
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e6c15da7
此差异已折叠。
点击以展开。
source/libs/function/src/builtinsimpl.c
浏览文件 @
e6c15da7
...
@@ -610,8 +610,7 @@ int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
...
@@ -610,8 +610,7 @@ int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
pDBuf
->
dsum
+=
pSBuf
->
dsum
;
pDBuf
->
dsum
+=
pSBuf
->
dsum
;
}
}
pDResInfo
->
numOfRes
=
TMAX
(
pDResInfo
->
numOfRes
,
pSResInfo
->
numOfRes
);
SET_VAL
(
pDResInfo
,
*
((
int64_t
*
)
pDBuf
),
1
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1394,7 +1393,7 @@ int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3
...
@@ -1394,7 +1393,7 @@ int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3
pDBuf
->
v
=
pSBuf
->
v
;
pDBuf
->
v
=
pSBuf
->
v
;
}
}
}
}
SET_VAL
(
pDResInfo
,
*
((
int64_t
*
)
pDBuf
),
1
);
pDResInfo
->
numOfRes
=
TMAX
(
pDResInfo
->
numOfRes
,
pSResInfo
->
numOfRes
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1639,6 +1638,7 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
...
@@ -1639,6 +1638,7 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
pDBuf
->
quadraticDSum
+=
pSBuf
->
quadraticDSum
;
pDBuf
->
quadraticDSum
+=
pSBuf
->
quadraticDSum
;
}
}
pDBuf
->
count
+=
pSBuf
->
count
;
pDBuf
->
count
+=
pSBuf
->
count
;
pDResInfo
->
numOfRes
=
TMAX
(
pDResInfo
->
numOfRes
,
pSResInfo
->
numOfRes
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
e6c15da7
...
@@ -31,7 +31,7 @@ typedef struct SIFParam {
...
@@ -31,7 +31,7 @@ typedef struct SIFParam {
SHashObj
*
pFilter
;
SHashObj
*
pFilter
;
SArray
*
result
;
SArray
*
result
;
char
*
condValue
;
char
*
condValue
;
SIdxFltStatus
status
;
SIdxFltStatus
status
;
uint8_t
colValType
;
uint8_t
colValType
;
...
@@ -45,7 +45,7 @@ typedef struct SIFParam {
...
@@ -45,7 +45,7 @@ typedef struct SIFParam {
typedef
struct
SIFCtx
{
typedef
struct
SIFCtx
{
int32_t
code
;
int32_t
code
;
SHashObj
*
pRes
;
/* element is SIFParam */
SHashObj
*
pRes
;
/* element is SIFParam */
bool
noExec
;
// true: just iterate condition tree, and add hint to executor plan
bool
noExec
;
// true: just iterate condition tree, and add hint to executor plan
SIndexMetaArg
arg
;
SIndexMetaArg
arg
;
// SIdxFltStatus st;
// SIdxFltStatus st;
...
@@ -128,7 +128,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
...
@@ -128,7 +128,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
// covert data From snode;
// covert data From snode;
SValueNode
*
vn
=
(
SValueNode
*
)
node
;
SValueNode
*
vn
=
(
SValueNode
*
)
node
;
char
*
pData
=
nodesGetValueFromNode
(
vn
);
char
*
pData
=
nodesGetValueFromNode
(
vn
);
SDataType
*
pType
=
&
vn
->
node
.
resType
;
SDataType
*
pType
=
&
vn
->
node
.
resType
;
int32_t
type
=
pType
->
type
;
int32_t
type
=
pType
->
type
;
int32_t
valLen
=
0
;
int32_t
valLen
=
0
;
...
@@ -140,7 +140,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
...
@@ -140,7 +140,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
dataLen
=
0
;
dataLen
=
0
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_NCHAR
)
{
dataLen
=
varDataTLen
(
pData
+
CHAR_BYTES
);
dataLen
=
varDataTLen
(
pData
+
CHAR_BYTES
);
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_
BIGINT
||
*
pData
==
TSDB_DATA_TYPE_
DOUBLE
)
{
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_DOUBLE
)
{
dataLen
=
LONG_BYTES
;
dataLen
=
LONG_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_BOOL
)
{
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
;
dataLen
=
CHAR_BYTES
;
...
@@ -457,10 +457,6 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta
...
@@ -457,10 +457,6 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
SIF_ERR_JRET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SIFParam
*
params
=
NULL
;
SIFParam
*
params
=
NULL
;
SIF_ERR_RET
(
sifInitOperParams
(
&
params
,
node
,
ctx
));
SIF_ERR_RET
(
sifInitOperParams
(
&
params
,
node
,
ctx
));
...
@@ -469,14 +465,12 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
...
@@ -469,14 +465,12 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
sif_func_t
operFn
=
sifNullFunc
;
sif_func_t
operFn
=
sifNullFunc
;
code
=
sifGetOperFn
(
node
->
opType
,
&
operFn
,
&
output
->
status
);
code
=
sifGetOperFn
(
node
->
opType
,
&
operFn
,
&
output
->
status
);
if
(
ctx
->
noExec
)
{
if
(
!
ctx
->
noExec
)
{
SIF_RET
(
code
);
code
=
operFn
(
&
params
[
0
],
nParam
>
1
?
&
params
[
1
]
:
NULL
,
output
);
}
else
{
return
operFn
(
&
params
[
0
],
nParam
>
1
?
&
params
[
1
]
:
NULL
,
output
);
}
}
_return:
taosMemoryFree
(
params
);
taosMemoryFree
(
params
);
SIF_RET
(
code
)
;
return
code
;
}
}
static
int32_t
sifExecLogic
(
SLogicConditionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
static
int32_t
sifExecLogic
(
SLogicConditionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
...
@@ -486,7 +480,7 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou
...
@@ -486,7 +480,7 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou
return
TSDB_CODE_QRY_INVALID_INPUT
;
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
}
int32_t
code
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SIFParam
*
params
=
NULL
;
SIFParam
*
params
=
NULL
;
SIF_ERR_RET
(
sifInitParamList
(
&
params
,
node
->
pParameterList
,
ctx
));
SIF_ERR_RET
(
sifInitParamList
(
&
params
,
node
->
pParameterList
,
ctx
));
...
@@ -664,7 +658,7 @@ int32_t doFilterTag(const SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *re
...
@@ -664,7 +658,7 @@ int32_t doFilterTag(const SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *re
// todo move to the initialization function
// todo move to the initialization function
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
SArray
*
output
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
SArray
*
output
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
SIFParam
param
=
{.
arg
=
*
metaArg
,
.
result
=
output
};
SIFParam
param
=
{.
arg
=
*
metaArg
,
.
result
=
output
};
SIF_ERR_RET
(
sifCalculate
((
SNode
*
)
pFilterNode
,
&
param
));
SIF_ERR_RET
(
sifCalculate
((
SNode
*
)
pFilterNode
,
&
param
));
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
e6c15da7
...
@@ -98,6 +98,7 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
...
@@ -98,6 +98,7 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
COPY_SCALAR_FIELD
(
tableType
);
COPY_SCALAR_FIELD
(
tableType
);
COPY_SCALAR_FIELD
(
colId
);
COPY_SCALAR_FIELD
(
colId
);
COPY_SCALAR_FIELD
(
colType
);
COPY_SCALAR_FIELD
(
colType
);
COPY_SCALAR_FIELD
(
hasIndex
);
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
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
e6c15da7
...
@@ -178,6 +178,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -178,6 +178,8 @@ const char* nodesNodeName(ENodeType type) {
return
"ShowQueriesStmt"
;
return
"ShowQueriesStmt"
;
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
return
"ShowVnodeStmt"
;
return
"ShowVnodeStmt"
;
case
QUERY_NODE_DELETE_STMT
:
return
"DeleteStmt"
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
"LogicScan"
;
return
"LogicScan"
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -242,6 +244,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -242,6 +244,8 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiStreamSessionWindow"
;
return
"PhysiStreamSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
return
"PhysiStateWindow"
;
return
"PhysiStateWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
return
"PhysiStreamStateWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
"PhysiPartition"
;
return
"PhysiPartition"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
...
@@ -2742,6 +2746,28 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
...
@@ -2742,6 +2746,28 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkStateWindowCol
=
"StateWindowCol"
;
static
const
char
*
jkStateWindowExpr
=
"StateWindowExpr"
;
static
int32_t
stateWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SStateWindowNode
*
pNode
=
(
const
SStateWindowNode
*
)
pObj
;
int32_t
code
=
tjsonAddObject
(
pJson
,
jkStateWindowCol
,
nodeToJson
,
pNode
->
pCol
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkStateWindowExpr
,
nodeToJson
,
pNode
->
pExpr
);
}
return
code
;
}
static
int32_t
jsonToStateWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SStateWindowNode
*
pNode
=
(
SStateWindowNode
*
)
pObj
;
int32_t
code
=
jsonToNodeObject
(
pJson
,
jkStateWindowCol
,
(
SNode
**
)
&
pNode
->
pCol
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkStateWindowExpr
,
(
SNode
**
)
&
pNode
->
pExpr
);
}
return
code
;
}
static
const
char
*
jkSessionWindowTsPrimaryKey
=
"TsPrimaryKey"
;
static
const
char
*
jkSessionWindowTsPrimaryKey
=
"TsPrimaryKey"
;
static
const
char
*
jkSessionWindowGap
=
"Gap"
;
static
const
char
*
jkSessionWindowGap
=
"Gap"
;
...
@@ -3519,8 +3545,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -3519,8 +3545,9 @@ 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
:
case
QUERY_NODE_STATE_WINDOW
:
break
;
break
;
case
QUERY_NODE_STATE_WINDOW
:
return
stateWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
return
sessionWindowNodeToJson
(
pObj
,
pJson
);
return
sessionWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_INTERVAL_WINDOW
:
case
QUERY_NODE_INTERVAL_WINDOW
:
...
@@ -3624,6 +3651,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -3624,6 +3651,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
return
physiSessionWindowNodeToJson
(
pObj
,
pJson
);
return
physiSessionWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
return
physiStateWindowNodeToJson
(
pObj
,
pJson
);
return
physiStateWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
physiPartitionNodeToJson
(
pObj
,
pJson
);
return
physiPartitionNodeToJson
(
pObj
,
pJson
);
...
@@ -3660,6 +3688,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -3660,6 +3688,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_STATE_WINDOW
:
return
jsonToStateWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
return
jsonToSessionWindowNode
(
pJson
,
pObj
);
return
jsonToSessionWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_INTERVAL_WINDOW
:
case
QUERY_NODE_INTERVAL_WINDOW
:
...
@@ -3743,6 +3773,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -3743,6 +3773,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
return
jsonToPhysiSessionWindowNode
(
pJson
,
pObj
);
return
jsonToPhysiSessionWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
return
jsonToPhysiStateWindowNode
(
pJson
,
pObj
);
return
jsonToPhysiStateWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
jsonToPhysiPartitionNode
(
pJson
,
pObj
);
return
jsonToPhysiPartitionNode
(
pJson
,
pObj
);
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
e6c15da7
...
@@ -520,7 +520,8 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
...
@@ -520,7 +520,8 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
:
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
{
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
{
SStateWinodwPhysiNode
*
pState
=
(
SStateWinodwPhysiNode
*
)
pNode
;
SStateWinodwPhysiNode
*
pState
=
(
SStateWinodwPhysiNode
*
)
pNode
;
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
e6c15da7
...
@@ -208,6 +208,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -208,6 +208,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_KILL_QUERY_STMT
:
case
QUERY_NODE_KILL_QUERY_STMT
:
case
QUERY_NODE_KILL_TRANSACTION_STMT
:
case
QUERY_NODE_KILL_TRANSACTION_STMT
:
return
makeNode
(
type
,
sizeof
(
SKillStmt
));
return
makeNode
(
type
,
sizeof
(
SKillStmt
));
case
QUERY_NODE_DELETE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDeleteStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -272,6 +274,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -272,6 +274,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SStreamSessionWinodwPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SStreamSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SStateWinodwPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SStateWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SStreamStateWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
makeNode
(
type
,
sizeof
(
SPartitionPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SPartitionPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
...
@@ -1305,7 +1309,7 @@ int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeT
...
@@ -1305,7 +1309,7 @@ int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeT
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
char
*
g
etFillModeString
(
EFillMode
mode
)
{
char
*
nodesG
etFillModeString
(
EFillMode
mode
)
{
switch
(
mode
)
{
switch
(
mode
)
{
case
FILL_MODE_NONE
:
case
FILL_MODE_NONE
:
return
"none"
;
return
"none"
;
...
@@ -1353,7 +1357,7 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
...
@@ -1353,7 +1357,7 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
return
num
;
return
num
;
}
}
void
v
alueNodeToVariant
(
const
SValueNode
*
pNode
,
SVariant
*
pVal
)
{
void
nodesV
alueNodeToVariant
(
const
SValueNode
*
pNode
,
SVariant
*
pVal
)
{
pVal
->
nType
=
pNode
->
node
.
resType
.
type
;
pVal
->
nType
=
pNode
->
node
.
resType
.
type
;
pVal
->
nLen
=
pNode
->
node
.
resType
.
bytes
;
pVal
->
nLen
=
pNode
->
node
.
resType
.
bytes
;
switch
(
pNode
->
node
.
resType
.
type
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
...
@@ -1394,3 +1398,159 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
...
@@ -1394,3 +1398,159 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
break
;
break
;
}
}
}
}
int32_t
nodesMergeConds
(
SNode
**
pDst
,
SNodeList
**
pSrc
)
{
if
(
NULL
==
*
pSrc
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
1
==
LIST_LENGTH
(
*
pSrc
))
{
*
pDst
=
nodesListGetNode
(
*
pSrc
,
0
);
nodesClearList
(
*
pSrc
);
}
else
{
SLogicConditionNode
*
pLogicCond
=
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
if
(
NULL
==
pLogicCond
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pLogicCond
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pLogicCond
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
pLogicCond
->
pParameterList
=
*
pSrc
;
*
pDst
=
(
SNode
*
)
pLogicCond
;
}
*
pSrc
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
typedef
struct
SClassifyConditionCxt
{
bool
hasPrimaryKey
;
bool
hasTagIndexCol
;
bool
hasOtherCol
;
}
SClassifyConditionCxt
;
static
EDealRes
classifyConditionImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
SClassifyConditionCxt
*
pCxt
=
(
SClassifyConditionCxt
*
)
pContext
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pCol
->
colId
)
{
pCxt
->
hasPrimaryKey
=
true
;
}
else
if
(
pCol
->
hasIndex
)
{
pCxt
->
hasTagIndexCol
=
true
;
}
else
{
pCxt
->
hasOtherCol
=
true
;
}
return
*
((
bool
*
)
pContext
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_END
;
}
return
DEAL_RES_CONTINUE
;
}
typedef
enum
EConditionType
{
COND_TYPE_PRIMARY_KEY
=
1
,
COND_TYPE_TAG_INDEX
,
COND_TYPE_NORMAL
}
EConditionType
;
static
EConditionType
classifyCondition
(
SNode
*
pNode
)
{
SClassifyConditionCxt
cxt
=
{.
hasPrimaryKey
=
false
,
.
hasTagIndexCol
=
false
,
.
hasOtherCol
=
false
};
nodesWalkExpr
(
pNode
,
classifyConditionImpl
,
&
cxt
);
return
cxt
.
hasOtherCol
?
COND_TYPE_NORMAL
:
(
cxt
.
hasPrimaryKey
&&
cxt
.
hasTagIndexCol
?
COND_TYPE_NORMAL
:
(
cxt
.
hasPrimaryKey
?
COND_TYPE_PRIMARY_KEY
:
COND_TYPE_TAG_INDEX
));
}
static
int32_t
partitionLogicCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)(
*
pCondition
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pPrimaryKeyConds
=
NULL
;
SNodeList
*
pTagConds
=
NULL
;
SNodeList
*
pOtherConds
=
NULL
;
SNode
*
pCond
=
NULL
;
FOREACH
(
pCond
,
pLogicCond
->
pParameterList
)
{
switch
(
classifyCondition
(
pCond
))
{
case
COND_TYPE_PRIMARY_KEY
:
if
(
NULL
!=
pPrimaryKeyCond
)
{
code
=
nodesListMakeAppend
(
&
pPrimaryKeyConds
,
nodesCloneNode
(
pCond
));
}
break
;
case
COND_TYPE_TAG_INDEX
:
if
(
NULL
!=
pTagCond
)
{
code
=
nodesListMakeAppend
(
&
pTagConds
,
nodesCloneNode
(
pCond
));
}
break
;
case
COND_TYPE_NORMAL
:
default:
if
(
NULL
!=
pOtherCond
)
{
code
=
nodesListMakeAppend
(
&
pOtherConds
,
nodesCloneNode
(
pCond
));
}
break
;
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
SNode
*
pTempPrimaryKeyCond
=
NULL
;
SNode
*
pTempTagCond
=
NULL
;
SNode
*
pTempOtherCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempPrimaryKeyCond
,
&
pPrimaryKeyConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempTagCond
,
&
pTagConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempOtherCond
,
&
pOtherConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
!=
pPrimaryKeyCond
)
{
*
pPrimaryKeyCond
=
pTempPrimaryKeyCond
;
}
if
(
NULL
!=
pTagCond
)
{
*
pTagCond
=
pTempTagCond
;
}
if
(
NULL
!=
pOtherCond
)
{
*
pOtherCond
=
pTempOtherCond
;
}
nodesDestroyNode
(
*
pCondition
);
*
pCondition
=
NULL
;
}
else
{
nodesDestroyList
(
pPrimaryKeyConds
);
nodesDestroyList
(
pTagConds
);
nodesDestroyList
(
pOtherConds
);
nodesDestroyNode
(
pTempPrimaryKeyCond
);
nodesDestroyNode
(
pTempTagCond
);
nodesDestroyNode
(
pTempOtherCond
);
}
return
code
;
}
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
*
pCondition
)
&&
LOGIC_COND_TYPE_AND
==
((
SLogicConditionNode
*
)
*
pCondition
)
->
condType
)
{
return
partitionLogicCond
(
pCondition
,
pPrimaryKeyCond
,
pTagCond
,
pOtherCond
);
}
switch
(
classifyCondition
(
*
pCondition
))
{
case
COND_TYPE_PRIMARY_KEY
:
if
(
NULL
!=
pPrimaryKeyCond
)
{
*
pPrimaryKeyCond
=
*
pCondition
;
}
break
;
case
COND_TYPE_TAG_INDEX
:
if
(
NULL
!=
pTagCond
)
{
*
pTagCond
=
*
pCondition
;
}
break
;
case
COND_TYPE_NORMAL
:
default:
if
(
NULL
!=
pOtherCond
)
{
*
pOtherCond
=
*
pCondition
;
}
break
;
}
*
pCondition
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
source/libs/parser/inc/parAst.h
浏览文件 @
e6c15da7
...
@@ -193,6 +193,7 @@ SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId);
...
@@ -193,6 +193,7 @@ SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId);
SNode
*
createSyncdbStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createSyncdbStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createDeleteStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pTable
,
SNode
*
pWhere
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
e6c15da7
...
@@ -481,6 +481,9 @@ dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C).
...
@@ -481,6 +481,9 @@ dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C).
/************************************************ syncdb **************************************************************/
/************************************************ syncdb **************************************************************/
cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); }
cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); }
/************************************************ syncdb **************************************************************/
cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B). { pCxt->pRootNode = createDeleteStmt(pCxt, A, B); }
/************************************************ select **************************************************************/
/************************************************ select **************************************************************/
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
e6c15da7
...
@@ -1488,3 +1488,12 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
...
@@ -1488,3 +1488,12 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
strncpy
(
pStmt
->
userName
,
pUserName
->
z
,
pUserName
->
n
);
strncpy
(
pStmt
->
userName
,
pUserName
->
z
,
pUserName
->
n
);
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createDeleteStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pTable
,
SNode
*
pWhere
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SDeleteStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DELETE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
pFromTable
=
pTable
;
pStmt
->
pWhere
=
pWhere
;
return
(
SNode
*
)
pStmt
;
}
source/libs/parser/src/parAstParser.c
浏览文件 @
e6c15da7
...
@@ -113,21 +113,26 @@ static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFu
...
@@ -113,21 +113,26 @@ static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFu
return
reserveUdfInCache
(
pFunc
->
functionName
,
pCxt
->
pComCxt
->
pMetaCache
);
return
reserveUdfInCache
(
pFunc
->
functionName
,
pCxt
->
pComCxt
->
pMetaCache
);
}
}
static
EDealRes
collectMetaKeyFromRealTable
(
SCollectMetaKeyFromExprCxt
*
pCxt
,
SRealTableNode
*
pRealTable
)
{
static
int32_t
collectMetaKeyFromRealTableImpl
(
SCollectMetaKeyCxt
*
pCxt
,
SRealTableNode
*
pRealTable
,
pCxt
->
errCode
=
reserveTableMetaInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
AUTH_TYPE
authType
)
{
pRealTable
->
table
.
tableName
,
pCxt
->
pComCxt
->
pMetaCache
);
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pRealTable
->
table
.
tableName
,
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
pMetaCache
);
pCxt
->
errCode
=
reserveTableVgroupInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pRealTable
->
table
.
tableName
,
pCxt
->
pComCxt
->
pMetaCache
);
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pRealTable
->
table
.
tableName
,
pCxt
->
pMetaCache
);
}
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errC
ode
)
{
if
(
TSDB_CODE_SUCCESS
==
c
ode
)
{
pCxt
->
errCode
=
reserveUserAuthInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pCxt
->
pComCxt
->
pParseCxt
->
pUser
,
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pRealTable
->
table
.
dbName
,
authType
,
pRealTable
->
table
.
dbName
,
AUTH_TYPE_READ
,
pCxt
->
pCom
Cxt
->
pMetaCache
);
p
Cxt
->
pMetaCache
);
}
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pCxt
->
errCode
=
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pCxt
->
pMetaCache
);
reserveDbVgInfoInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pCxt
->
pComCxt
->
pMetaCache
);
}
}
return
code
;
}
static
EDealRes
collectMetaKeyFromRealTable
(
SCollectMetaKeyFromExprCxt
*
pCxt
,
SRealTableNode
*
pRealTable
)
{
pCxt
->
errCode
=
collectMetaKeyFromRealTableImpl
(
pCxt
->
pComCxt
,
pRealTable
,
AUTH_TYPE_READ
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
}
...
@@ -347,6 +352,10 @@ static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SSho
...
@@ -347,6 +352,10 @@ static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SSho
pCxt
->
pMetaCache
);
pCxt
->
pMetaCache
);
}
}
static
int32_t
collectMetaKeyFromDelete
(
SCollectMetaKeyCxt
*
pCxt
,
SDeleteStmt
*
pStmt
)
{
return
collectMetaKeyFromRealTableImpl
(
pCxt
,
(
SRealTableNode
*
)
pStmt
->
pFromTable
,
AUTH_TYPE_WRITE
);
}
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
...
@@ -405,6 +414,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -405,6 +414,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowTopics
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowTopics
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
collectMetaKeyFromShowTransactions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowTransactions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_DELETE_STMT
:
return
collectMetaKeyFromDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/parAuthenticator.c
浏览文件 @
e6c15da7
...
@@ -80,6 +80,10 @@ static int32_t authDropUser(SAuthCxt* pCxt, SDropUserStmt* pStmt) {
...
@@ -80,6 +80,10 @@ static int32_t authDropUser(SAuthCxt* pCxt, SDropUserStmt* pStmt) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
authDelete
(
SAuthCxt
*
pCxt
,
SDeleteStmt
*
pDelete
)
{
return
checkAuth
(
pCxt
,
((
SRealTableNode
*
)
pDelete
->
pFromTable
)
->
table
.
dbName
,
AUTH_TYPE_WRITE
);
}
static
int32_t
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
static
int32_t
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
...
@@ -88,6 +92,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
...
@@ -88,6 +92,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
return
authSelect
(
pCxt
,
(
SSelectStmt
*
)
pStmt
);
return
authSelect
(
pCxt
,
(
SSelectStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_USER_STMT
:
case
QUERY_NODE_DROP_USER_STMT
:
return
authDropUser
(
pCxt
,
(
SDropUserStmt
*
)
pStmt
);
return
authDropUser
(
pCxt
,
(
SDropUserStmt
*
)
pStmt
);
case
QUERY_NODE_DELETE_STMT
:
return
authDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
e6c15da7
...
@@ -135,11 +135,11 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab
...
@@ -135,11 +135,11 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab
return
code
;
return
code
;
}
}
static
int32_t
calcConstFromTable
(
SCalcConstContext
*
pCxt
,
S
SelectStmt
*
pSelect
)
{
static
int32_t
calcConstFromTable
(
SCalcConstContext
*
pCxt
,
S
Node
*
pTable
)
{
return
rewriteConditionForFromTable
(
pCxt
,
p
Select
->
pFrom
Table
);
return
rewriteConditionForFromTable
(
pCxt
,
pTable
);
}
}
static
void
rewriteConstCondition
(
S
SelectStmt
*
pSelect
,
SNode
**
pCond
)
{
static
void
rewriteConstCondition
(
S
Node
**
pCond
,
bool
*
pAlwaysFalse
)
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
*
pCond
))
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
*
pCond
))
{
return
;
return
;
}
}
...
@@ -147,11 +147,11 @@ static void rewriteConstCondition(SSelectStmt* pSelect, SNode** pCond) {
...
@@ -147,11 +147,11 @@ static void rewriteConstCondition(SSelectStmt* pSelect, SNode** pCond) {
nodesDestroyNode
(
*
pCond
);
nodesDestroyNode
(
*
pCond
);
*
pCond
=
NULL
;
*
pCond
=
NULL
;
}
else
{
}
else
{
pSelect
->
isEmptyResult
=
true
;
*
pAlwaysFalse
=
true
;
}
}
}
}
static
int32_t
calcConstS
electCondition
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SNode
**
pCond
)
{
static
int32_t
calcConstS
tmtCondition
(
SCalcConstContext
*
pCxt
,
SNode
**
pCond
,
bool
*
pAlwaysFalse
)
{
if
(
NULL
==
*
pCond
)
{
if
(
NULL
==
*
pCond
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -161,7 +161,7 @@ static int32_t calcConstSelectCondition(SCalcConstContext* pCxt, SSelectStmt* pS
...
@@ -161,7 +161,7 @@ static int32_t calcConstSelectCondition(SCalcConstContext* pCxt, SSelectStmt* pS
code
=
calcConstNode
(
pCond
);
code
=
calcConstNode
(
pCond
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
rewriteConstCondition
(
p
Select
,
pCond
);
rewriteConstCondition
(
p
Cond
,
pAlwaysFalse
);
}
}
return
code
;
return
code
;
}
}
...
@@ -233,12 +233,12 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) {
...
@@ -233,12 +233,12 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) {
}
}
static
int32_t
calcConstSelect
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
subquery
)
{
static
int32_t
calcConstSelect
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
subquery
)
{
int32_t
code
=
calcConstFromTable
(
pCxt
,
pSelect
);
int32_t
code
=
calcConstFromTable
(
pCxt
,
pSelect
->
pFromTable
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstProjections
(
pCxt
,
pSelect
,
subquery
);
code
=
calcConstProjections
(
pCxt
,
pSelect
,
subquery
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstS
electCondition
(
pCxt
,
pSelect
,
&
pSelect
->
pWhere
);
code
=
calcConstS
tmtCondition
(
pCxt
,
&
pSelect
->
pWhere
,
&
pSelect
->
isEmptyResult
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstList
(
pSelect
->
pPartitionByList
);
code
=
calcConstList
(
pSelect
->
pPartitionByList
);
...
@@ -250,7 +250,7 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
...
@@ -250,7 +250,7 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
code
=
calcConstGroupBy
(
pCxt
,
pSelect
);
code
=
calcConstGroupBy
(
pCxt
,
pSelect
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstS
electCondition
(
pCxt
,
pSelect
,
&
pSelect
->
pHaving
);
code
=
calcConstS
tmtCondition
(
pCxt
,
&
pSelect
->
pHaving
,
&
pSelect
->
isEmptyResult
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstList
(
pSelect
->
pOrderByList
);
code
=
calcConstList
(
pSelect
->
pOrderByList
);
...
@@ -258,6 +258,14 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
...
@@ -258,6 +258,14 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
return
code
;
return
code
;
}
}
static
int32_t
calcConstDelete
(
SCalcConstContext
*
pCxt
,
SDeleteStmt
*
pDelete
)
{
int32_t
code
=
calcConstFromTable
(
pCxt
,
pDelete
->
pFromTable
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstStmtCondition
(
pCxt
,
&
pDelete
->
pWhere
,
&
pDelete
->
deleteZeroRows
);
}
return
code
;
}
static
int32_t
calcConstQuery
(
SCalcConstContext
*
pCxt
,
SNode
*
pStmt
,
bool
subquery
)
{
static
int32_t
calcConstQuery
(
SCalcConstContext
*
pCxt
,
SNode
*
pStmt
,
bool
subquery
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
...
@@ -275,6 +283,9 @@ static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subque
...
@@ -275,6 +283,9 @@ static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subque
}
}
break
;
break
;
}
}
case
QUERY_NODE_DELETE_STMT
:
code
=
calcConstDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
break
;
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
e6c15da7
...
@@ -68,6 +68,7 @@ static SKeyword keywordTable[] = {
...
@@ -68,6 +68,7 @@ static SKeyword keywordTable[] = {
{
"DATABASES"
,
TK_DATABASES
},
{
"DATABASES"
,
TK_DATABASES
},
{
"DAYS"
,
TK_DAYS
},
{
"DAYS"
,
TK_DAYS
},
{
"DBS"
,
TK_DBS
},
{
"DBS"
,
TK_DBS
},
{
"DELETE"
,
TK_DELETE
},
{
"DESC"
,
TK_DESC
},
{
"DESC"
,
TK_DESC
},
{
"DESCRIBE"
,
TK_DESCRIBE
},
{
"DESCRIBE"
,
TK_DESCRIBE
},
{
"DISTINCT"
,
TK_DISTINCT
},
{
"DISTINCT"
,
TK_DISTINCT
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e6c15da7
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
e6c15da7
...
@@ -178,6 +178,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -178,6 +178,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Only tag can be json type"
;
return
"Only tag can be json type"
;
case
TSDB_CODE_PAR_VALUE_TOO_LONG
:
case
TSDB_CODE_PAR_VALUE_TOO_LONG
:
return
"Value too long for column/tag: %s"
;
return
"Value too long for column/tag: %s"
;
case
TSDB_CODE_PAR_INVALID_DELETE_WHERE
:
return
"The DELETE statement must have a definite time window range"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
@@ -322,7 +324,7 @@ static bool isValidateTag(char* input) {
...
@@ -322,7 +324,7 @@ static bool isValidateTag(char* input) {
return
true
;
return
true
;
}
}
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
retCode
=
TSDB_CODE_SUCCESS
;
int32_t
retCode
=
TSDB_CODE_SUCCESS
;
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
SHashObj
*
keyHash
=
NULL
;
SHashObj
*
keyHash
=
NULL
;
...
@@ -371,7 +373,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -371,7 +373,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
}
}
STagVal
val
=
{
0
};
STagVal
val
=
{
0
};
val
.
pKey
=
jsonKey
;
val
.
pKey
=
jsonKey
;
taosHashPut
(
keyHash
,
jsonKey
,
keyLen
,
&
keyLen
,
CHAR_BYTES
);
// add key to hash to remove dumplicate, value is useless
taosHashPut
(
keyHash
,
jsonKey
,
keyLen
,
&
keyLen
,
CHAR_BYTES
);
// add key to hash to remove dumplicate, value is useless
if
(
item
->
type
==
cJSON_String
)
{
// add json value format: type|data
if
(
item
->
type
==
cJSON_String
)
{
// add json value format: type|data
char
*
jsonValue
=
item
->
valuestring
;
char
*
jsonValue
=
item
->
valuestring
;
...
@@ -382,8 +385,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -382,8 +385,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
goto
end
;
goto
end
;
}
}
val
.
type
=
TSDB_DATA_TYPE_NCHAR
;
val
.
type
=
TSDB_DATA_TYPE_NCHAR
;
if
(
valLen
>
0
&&
!
taosMbsToUcs4
(
jsonValue
,
valLen
,
(
TdUcs4
*
)
tmp
,
if
(
valLen
>
0
&&
!
taosMbsToUcs4
(
jsonValue
,
valLen
,
(
TdUcs4
*
)
tmp
,
(
int32_t
)(
valLen
*
TSDB_NCHAR_SIZE
),
&
valLen
))
{
(
int32_t
)(
valLen
*
TSDB_NCHAR_SIZE
),
&
valLen
))
{
uError
(
"charset:%s to %s. val:%s, errno:%s, convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
jsonValue
,
uError
(
"charset:%s to %s. val:%s, errno:%s, convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
jsonValue
,
strerror
(
errno
));
strerror
(
errno
));
retCode
=
buildSyntaxErrMsg
(
pMsgBuf
,
"charset convert json error"
,
jsonValue
);
retCode
=
buildSyntaxErrMsg
(
pMsgBuf
,
"charset convert json error"
,
jsonValue
);
...
@@ -413,7 +415,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -413,7 +415,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
end:
end:
taosHashCleanup
(
keyHash
);
taosHashCleanup
(
keyHash
);
if
(
retCode
==
TSDB_CODE_SUCCESS
)
{
if
(
retCode
==
TSDB_CODE_SUCCESS
)
{
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
}
}
cJSON_Delete
(
root
);
cJSON_Delete
(
root
);
...
...
source/libs/parser/src/sql.c
浏览文件 @
e6c15da7
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
e6c15da7
...
@@ -21,7 +21,21 @@ namespace ParserTest {
...
@@ -21,7 +21,21 @@ namespace ParserTest {
class
ParserInitialDTest
:
public
ParserDdlTest
{};
class
ParserInitialDTest
:
public
ParserDdlTest
{};
// todo delete
// DELETE FROM tb_name [WHERE condition]
TEST_F
(
ParserInitialDTest
,
delete
)
{
useDb
(
"root"
,
"test"
);
run
(
"DELETE FROM t1"
);
run
(
"DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d"
);
}
TEST_F
(
ParserInitialDTest
,
deleteSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
run
(
"DELETE FROM t1 WHERE c1 > 10"
,
TSDB_CODE_PAR_INVALID_DELETE_WHERE
,
PARSER_STAGE_TRANSLATE
);
}
// todo desc
// todo desc
// todo describe
// todo describe
// todo DROP account
// todo DROP account
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
e6c15da7
...
@@ -229,14 +229,14 @@ TEST_F(ParserSelectTest, subquery) {
...
@@ -229,14 +229,14 @@ TEST_F(ParserSelectTest, subquery) {
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
}
}
TEST_F
(
ParserSelectTest
,
subquerySemantic
Error
)
{
TEST_F
(
ParserSelectTest
,
subquerySemantic
Check
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"
,
TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY
,
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"
,
TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY
,
PARSER_STAGE_TRANSLATE
);
PARSER_STAGE_TRANSLATE
);
}
}
TEST_F
(
ParserSelectTest
,
semantic
Error
)
{
TEST_F
(
ParserSelectTest
,
semantic
Check
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
// TSDB_CODE_PAR_INVALID_COLUMN
// TSDB_CODE_PAR_INVALID_COLUMN
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
e6c15da7
...
@@ -21,8 +21,10 @@ typedef struct SLogicPlanContext {
...
@@ -21,8 +21,10 @@ typedef struct SLogicPlanContext {
SPlanContext
*
pPlanCxt
;
SPlanContext
*
pPlanCxt
;
}
SLogicPlanContext
;
}
SLogicPlanContext
;
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
SSelectStmt
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
void
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateSelectLogicNode
)(
SLogicPlanContext
*
,
SSelectStmt
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateSetOpLogicNode
)(
SLogicPlanContext
*
,
SSetOperator
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateSetOpLogicNode
)(
SLogicPlanContext
*
,
SSetOperator
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateDeleteLogicNode
)(
SLogicPlanContext
*
,
SDeleteStmt
*
,
SLogicNode
**
);
static
int32_t
doCreateLogicNodeByTable
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SNode
*
pTable
,
static
int32_t
doCreateLogicNodeByTable
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SNode
*
pTable
,
SLogicNode
**
pLogicNode
);
SLogicNode
**
pLogicNode
);
...
@@ -119,12 +121,12 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo
...
@@ -119,12 +121,12 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
create
ChildLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
FCreateLogicNode
func
,
static
int32_t
create
RootLogicNode
(
SLogicPlanContext
*
pCxt
,
void
*
pStmt
,
uint8_t
precision
,
FCreateLogicNode
func
,
SLogicNode
**
pRoot
)
{
SLogicNode
**
pRoot
)
{
SLogicNode
*
pNode
=
NULL
;
SLogicNode
*
pNode
=
NULL
;
int32_t
code
=
func
(
pCxt
,
pS
elec
t
,
&
pNode
);
int32_t
code
=
func
(
pCxt
,
pS
tm
t
,
&
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
pNode
->
precision
=
p
Select
->
p
recision
;
pNode
->
precision
=
precision
;
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
@@ -133,56 +135,10 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
...
@@ -133,56 +135,10 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
return
code
;
return
code
;
}
}
// typedef struct SCreateColumnCxt {
static
int32_t
createSelectRootLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
FCreateSelectLogicNode
func
,
// int32_t errCode;
SLogicNode
**
pRoot
)
{
// SNodeList* pList;
return
createRootLogicNode
(
pCxt
,
pSelect
,
pSelect
->
precision
,
(
FCreateLogicNode
)
func
,
pRoot
);
// } SCreateColumnCxt;
}
// static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
// SCreateColumnCxt* pCxt = (SCreateColumnCxt*)pContext;
// switch (nodeType(pNode)) {
// case QUERY_NODE_COLUMN: {
// SNode* pCol = nodesCloneNode(pNode);
// if (NULL == pCol) {
// return DEAL_RES_ERROR;
// }
// return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
// }
// case QUERY_NODE_OPERATOR:
// case QUERY_NODE_LOGIC_CONDITION:
// case QUERY_NODE_FUNCTION: {
// SExprNode* pExpr = (SExprNode*)pNode;
// SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
// if (NULL == pCol) {
// return DEAL_RES_ERROR;
// }
// pCol->node.resType = pExpr->resType;
// strcpy(pCol->colName, pExpr->aliasName);
// return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
// }
// default:
// break;
// }
// return DEAL_RES_CONTINUE;
// }
// static int32_t createColumnByRewriteExps(SNodeList* pExprs, SNodeList** pList) {
// SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList)};
// if (NULL == cxt.pList) {
// return TSDB_CODE_OUT_OF_MEMORY;
// }
// nodesWalkExprs(pExprs, doCreateColumn, &cxt);
// if (TSDB_CODE_SUCCESS != cxt.errCode) {
// nodesDestroyList(cxt.pList);
// return cxt.errCode;
// }
// if (NULL == *pList) {
// *pList = cxt.pList;
// }
// return cxt.errCode;
// }
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pScanPseudoCols
,
SNodeList
*
pScanCols
,
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pScanPseudoCols
,
SNodeList
*
pScanCols
,
STableMeta
*
pMeta
)
{
STableMeta
*
pMeta
)
{
...
@@ -783,25 +739,25 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -783,25 +739,25 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
SLogicNode
*
pRoot
=
NULL
;
SLogicNode
*
pRoot
=
NULL
;
int32_t
code
=
createLogicNodeByTable
(
pCxt
,
pSelect
,
pSelect
->
pFromTable
,
&
pRoot
);
int32_t
code
=
createLogicNodeByTable
(
pCxt
,
pSelect
,
pSelect
->
pFromTable
,
&
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createPartitionLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createPartitionLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createWindowLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createWindowLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createFillLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createFillLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createDistinctLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createDistinctLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createSortLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createSortLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
Child
LogicNode
(
pCxt
,
pSelect
,
createProjectLogicNode
,
&
pRoot
);
code
=
create
SelectRoot
LogicNode
(
pCxt
,
pSelect
,
createProjectLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -813,17 +769,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -813,17 +769,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
return
code
;
return
code
;
}
}
static
int32_t
createSetOpChildLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
static
int32_t
createSetOpRootLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
FCreateSetOpLogicNode
func
,
FCreateSetOpLogicNode
func
,
SLogicNode
**
pRoot
)
{
SLogicNode
**
pRoot
)
{
SLogicNode
*
pNode
=
NULL
;
return
createRootLogicNode
(
pCxt
,
pSetOperator
,
pSetOperator
->
precision
,
(
FCreateLogicNode
)
func
,
pRoot
);
int32_t
code
=
func
(
pCxt
,
pSetOperator
,
&
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pNode
);
}
return
code
;
}
}
static
int32_t
createSetOpSortLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createSetOpSortLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
...
@@ -970,7 +918,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator*
...
@@ -970,7 +918,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator*
SLogicNode
*
pRoot
=
NULL
;
SLogicNode
*
pRoot
=
NULL
;
int32_t
code
=
createSetOpLogicNode
(
pCxt
,
pSetOperator
,
&
pRoot
);
int32_t
code
=
createSetOpLogicNode
(
pCxt
,
pSetOperator
,
&
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createSetOp
Child
LogicNode
(
pCxt
,
pSetOperator
,
createSetOpSortLogicNode
,
&
pRoot
);
code
=
createSetOp
Root
LogicNode
(
pCxt
,
pSetOperator
,
createSetOpSortLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1008,6 +956,43 @@ static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpS
...
@@ -1008,6 +956,43 @@ static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpS
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
createDeleteRootLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
FCreateDeleteLogicNode
func
,
SLogicNode
**
pRoot
)
{
return
createRootLogicNode
(
pCxt
,
pDelete
,
pDelete
->
precision
,
(
FCreateLogicNode
)
func
,
pRoot
);
}
static
int32_t
createDeleteScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
createDeleteAggLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
createDeleteModifyTableLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
createDeleteLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
SLogicNode
*
pRoot
=
NULL
;
int32_t
code
=
createDeleteRootLogicNode
(
pCxt
,
pDelete
,
createDeleteScanLogicNode
,
&
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createDeleteRootLogicNode
(
pCxt
,
pDelete
,
createDeleteAggLogicNode
,
&
pRoot
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createDeleteRootLogicNode
(
pCxt
,
pDelete
,
createDeleteModifyTableLogicNode
,
&
pRoot
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
pRoot
;
}
else
{
nodesDestroyNode
(
pRoot
);
}
return
code
;
}
static
int32_t
createQueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SNode
*
pStmt
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createQueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SNode
*
pStmt
,
SLogicNode
**
pLogicNode
)
{
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
...
@@ -1018,6 +1003,8 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi
...
@@ -1018,6 +1003,8 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi
return
createQueryLogicNode
(
pCxt
,
((
SExplainStmt
*
)
pStmt
)
->
pQuery
,
pLogicNode
);
return
createQueryLogicNode
(
pCxt
,
((
SExplainStmt
*
)
pStmt
)
->
pQuery
,
pLogicNode
);
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
createSetOperatorLogicNode
(
pCxt
,
(
SSetOperator
*
)
pStmt
,
pLogicNode
);
return
createSetOperatorLogicNode
(
pCxt
,
(
SSetOperator
*
)
pStmt
,
pLogicNode
);
case
QUERY_NODE_DELETE_STMT
:
return
createDeleteLogicNode
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
,
pLogicNode
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
e6c15da7
...
@@ -108,7 +108,8 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
...
@@ -108,7 +108,8 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
return
false
;
return
false
;
}
}
if
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
))
{
if
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
))
{
return
(
WINDOW_TYPE_INTERVAL
==
((
SWindowLogicNode
*
)
pNode
->
pParent
)
->
winType
);
return
true
;
// return (WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType);
}
}
return
!
osdHaveNormalCol
(((
SAggLogicNode
*
)
pNode
->
pParent
)
->
pGroupKeys
);
return
!
osdHaveNormalCol
(((
SAggLogicNode
*
)
pNode
->
pParent
)
->
pGroupKeys
);
}
}
...
@@ -217,8 +218,7 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
...
@@ -217,8 +218,7 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
}
}
static
void
setScanWindowInfo
(
SScanLogicNode
*
pScan
)
{
static
void
setScanWindowInfo
(
SScanLogicNode
*
pScan
)
{
if
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pScan
->
node
.
pParent
)
&&
if
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pScan
->
node
.
pParent
))
{
WINDOW_TYPE_INTERVAL
==
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
winType
)
{
pScan
->
interval
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
interval
;
pScan
->
interval
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
interval
;
pScan
->
offset
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
offset
;
pScan
->
offset
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
offset
;
pScan
->
sliding
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
sliding
;
pScan
->
sliding
=
((
SWindowLogicNode
*
)
pScan
->
node
.
pParent
)
->
sliding
;
...
@@ -268,30 +268,6 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
...
@@ -268,30 +268,6 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
return
code
;
return
code
;
}
}
static
int32_t
cpdMergeConds
(
SNode
**
pDst
,
SNodeList
**
pSrc
)
{
if
(
NULL
==
*
pSrc
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
1
==
LIST_LENGTH
(
*
pSrc
))
{
*
pDst
=
nodesListGetNode
(
*
pSrc
,
0
);
nodesClearList
(
*
pSrc
);
}
else
{
SLogicConditionNode
*
pLogicCond
=
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
if
(
NULL
==
pLogicCond
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pLogicCond
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pLogicCond
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
pLogicCond
->
pParameterList
=
*
pSrc
;
*
pDst
=
(
SNode
*
)
pLogicCond
;
}
*
pSrc
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cpdCondAppend
(
SNode
**
pCond
,
SNode
**
pAdditionalCond
)
{
static
int32_t
cpdCondAppend
(
SNode
**
pCond
,
SNode
**
pAdditionalCond
)
{
if
(
NULL
==
*
pCond
)
{
if
(
NULL
==
*
pCond
)
{
TSWAP
(
*
pCond
,
*
pAdditionalCond
);
TSWAP
(
*
pCond
,
*
pAdditionalCond
);
...
@@ -310,119 +286,6 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) {
...
@@ -310,119 +286,6 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) {
return
code
;
return
code
;
}
}
static
EDealRes
cpdIsPrimaryKeyCondImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
((
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pNode
)
->
colId
)
?
true
:
false
);
return
*
((
bool
*
)
pContext
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_END
;
}
return
DEAL_RES_CONTINUE
;
}
static
bool
cpdIsPrimaryKeyCond
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pNode
))
{
return
false
;
}
bool
isPrimaryKeyCond
=
false
;
nodesWalkExpr
(
pNode
,
cpdIsPrimaryKeyCondImpl
,
&
isPrimaryKeyCond
);
return
isPrimaryKeyCond
;
}
static
EDealRes
cpdIsTagCondImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
((
COLUMN_TYPE_TAG
==
((
SColumnNode
*
)
pNode
)
->
colType
)
?
true
:
false
);
return
*
((
bool
*
)
pContext
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_END
;
}
return
DEAL_RES_CONTINUE
;
}
static
bool
cpdIsTagCond
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pNode
))
{
return
false
;
}
bool
isTagCond
=
false
;
nodesWalkExpr
(
pNode
,
cpdIsTagCondImpl
,
&
isTagCond
);
return
isTagCond
;
}
static
int32_t
cpdPartitionScanLogicCond
(
SScanLogicNode
*
pScan
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)
pScan
->
node
.
pConditions
;
if
(
LOGIC_COND_TYPE_AND
!=
pLogicCond
->
condType
)
{
*
pPrimaryKeyCond
=
NULL
;
*
pOtherCond
=
pScan
->
node
.
pConditions
;
pScan
->
node
.
pConditions
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pPrimaryKeyConds
=
NULL
;
SNodeList
*
pTagConds
=
NULL
;
SNodeList
*
pOtherConds
=
NULL
;
SNode
*
pCond
=
NULL
;
FOREACH
(
pCond
,
pLogicCond
->
pParameterList
)
{
if
(
cpdIsPrimaryKeyCond
(
pCond
))
{
code
=
nodesListMakeAppend
(
&
pPrimaryKeyConds
,
nodesCloneNode
(
pCond
));
}
else
if
(
cpdIsTagCond
(
pScan
->
node
.
pConditions
))
{
code
=
nodesListMakeAppend
(
&
pTagConds
,
nodesCloneNode
(
pCond
));
}
else
{
code
=
nodesListMakeAppend
(
&
pOtherConds
,
nodesCloneNode
(
pCond
));
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
SNode
*
pTempPrimaryKeyCond
=
NULL
;
SNode
*
pTempTagCond
=
NULL
;
SNode
*
pTempOtherCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpdMergeConds
(
&
pTempPrimaryKeyCond
,
&
pPrimaryKeyConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpdMergeConds
(
&
pTempTagCond
,
&
pTagConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpdMergeConds
(
&
pTempOtherCond
,
&
pOtherConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPrimaryKeyCond
=
pTempPrimaryKeyCond
;
*
pTagCond
=
pTempTagCond
;
*
pOtherCond
=
pTempOtherCond
;
nodesDestroyNode
(
pScan
->
node
.
pConditions
);
pScan
->
node
.
pConditions
=
NULL
;
}
else
{
nodesDestroyList
(
pPrimaryKeyConds
);
nodesDestroyList
(
pTagConds
);
nodesDestroyList
(
pOtherConds
);
nodesDestroyNode
(
pTempPrimaryKeyCond
);
nodesDestroyNode
(
pTempTagCond
);
nodesDestroyNode
(
pTempOtherCond
);
}
return
code
;
}
static
int32_t
cpdPartitionScanCond
(
SScanLogicNode
*
pScan
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pScan
->
node
.
pConditions
))
{
return
cpdPartitionScanLogicCond
(
pScan
,
pPrimaryKeyCond
,
pTagCond
,
pOtherCond
);
}
if
(
cpdIsPrimaryKeyCond
(
pScan
->
node
.
pConditions
))
{
*
pPrimaryKeyCond
=
pScan
->
node
.
pConditions
;
}
else
if
(
cpdIsTagCond
(
pScan
->
node
.
pConditions
))
{
*
pTagCond
=
pScan
->
node
.
pConditions
;
}
else
{
*
pOtherCond
=
pScan
->
node
.
pConditions
;
}
pScan
->
node
.
pConditions
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cpdCalcTimeRange
(
SScanLogicNode
*
pScan
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pOtherCond
)
{
static
int32_t
cpdCalcTimeRange
(
SScanLogicNode
*
pScan
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pOtherCond
)
{
bool
isStrict
=
false
;
bool
isStrict
=
false
;
int32_t
code
=
filterGetTimeRange
(
*
pPrimaryKeyCond
,
&
pScan
->
scanRange
,
&
isStrict
);
int32_t
code
=
filterGetTimeRange
(
*
pPrimaryKeyCond
,
&
pScan
->
scanRange
,
&
isStrict
);
...
@@ -472,7 +335,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode*
...
@@ -472,7 +335,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode*
SNode
*
pPrimaryKeyCond
=
NULL
;
SNode
*
pPrimaryKeyCond
=
NULL
;
SNode
*
pTagCond
=
NULL
;
SNode
*
pTagCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
int32_t
code
=
cpdPartitionScanCond
(
pScan
,
&
pPrimaryKeyCond
,
&
pTagCond
,
&
pOtherCond
);
int32_t
code
=
nodesPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pTagCond
,
&
pOtherCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrimaryKeyCond
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrimaryKeyCond
)
{
code
=
cpdCalcTimeRange
(
pScan
,
&
pPrimaryKeyCond
,
&
pOtherCond
);
code
=
cpdCalcTimeRange
(
pScan
,
&
pPrimaryKeyCond
,
&
pOtherCond
);
}
}
...
@@ -565,16 +428,16 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo
...
@@ -565,16 +428,16 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo
SNode
*
pTempRightChildCond
=
NULL
;
SNode
*
pTempRightChildCond
=
NULL
;
SNode
*
pTempRemainCond
=
NULL
;
SNode
*
pTempRemainCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpd
MergeConds
(
&
pTempOnCond
,
&
pOnConds
);
code
=
nodes
MergeConds
(
&
pTempOnCond
,
&
pOnConds
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpd
MergeConds
(
&
pTempLeftChildCond
,
&
pLeftChildConds
);
code
=
nodes
MergeConds
(
&
pTempLeftChildCond
,
&
pLeftChildConds
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpd
MergeConds
(
&
pTempRightChildCond
,
&
pRightChildConds
);
code
=
nodes
MergeConds
(
&
pTempRightChildCond
,
&
pRightChildConds
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
cpd
MergeConds
(
&
pTempRemainCond
,
&
pRemainConds
);
code
=
nodes
MergeConds
(
&
pTempRemainCond
,
&
pRemainConds
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
e6c15da7
...
@@ -980,7 +980,9 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
...
@@ -980,7 +980,9 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
static
int32_t
createStateWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
static
int32_t
createStateWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SStateWinodwPhysiNode
*
pState
=
(
SStateWinodwPhysiNode
*
)
makePhysiNode
(
SStateWinodwPhysiNode
*
pState
=
(
SStateWinodwPhysiNode
*
)
makePhysiNode
(
pCxt
,
getPrecision
(
pChildren
),
(
SLogicNode
*
)
pWindowLogicNode
,
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
);
pCxt
,
getPrecision
(
pChildren
),
(
SLogicNode
*
)
pWindowLogicNode
,
(
pCxt
->
pPlanCxt
->
streamQuery
?
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
:
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
));
if
(
NULL
==
pState
)
{
if
(
NULL
==
pState
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
e6c15da7
...
@@ -36,6 +36,10 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
...
@@ -36,6 +36,10 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 or tag1 < 2"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"
);
}
}
TEST_F
(
PlanOptimizeTest
,
orderByPrimaryKey
)
{
TEST_F
(
PlanOptimizeTest
,
orderByPrimaryKey
)
{
...
...
source/util/src/tcompare.c
浏览文件 @
e6c15da7
...
@@ -227,6 +227,33 @@ int32_t compareJsonContainsKey(const void* pLeft, const void* pRight) {
...
@@ -227,6 +227,33 @@ int32_t compareJsonContainsKey(const void* pLeft, const void* pRight) {
return
1
;
return
1
;
}
}
// string > number > bool > null
// ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison
int32_t
compareJsonVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
char
leftType
=
*
(
char
*
)
pLeft
;
char
rightType
=
*
(
char
*
)
pRight
;
if
(
leftType
!=
rightType
){
return
leftType
>
rightType
?
1
:
-
1
;
}
char
*
realDataLeft
=
POINTER_SHIFT
(
pLeft
,
CHAR_BYTES
);
char
*
realDataRight
=
POINTER_SHIFT
(
pRight
,
CHAR_BYTES
);
if
(
leftType
==
TSDB_DATA_TYPE_BOOL
)
{
DEFAULT_COMP
(
GET_INT8_VAL
(
realDataLeft
),
GET_INT8_VAL
(
realDataRight
));
}
else
if
(
leftType
==
TSDB_DATA_TYPE_DOUBLE
){
DEFAULT_DOUBLE_COMP
(
GET_DOUBLE_VAL
(
realDataLeft
),
GET_DOUBLE_VAL
(
realDataRight
));
}
else
if
(
leftType
==
TSDB_DATA_TYPE_NCHAR
){
return
compareLenPrefixedWStr
(
realDataLeft
,
realDataRight
);
}
else
if
(
leftType
==
TSDB_DATA_TYPE_NULL
)
{
return
0
;
}
else
{
assert
(
0
);
}
}
int32_t
compareJsonValDesc
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
compareJsonVal
(
pRight
,
pLeft
);
}
/*
/*
* Compare two strings
* Compare two strings
* TSDB_MATCH: Match
* TSDB_MATCH: Match
...
@@ -601,6 +628,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) {
...
@@ -601,6 +628,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) {
return
(
order
==
TSDB_ORDER_ASC
)
?
compareLenPrefixedStr
:
compareLenPrefixedStrDesc
;
return
(
order
==
TSDB_ORDER_ASC
)
?
compareLenPrefixedStr
:
compareLenPrefixedStrDesc
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
return
(
order
==
TSDB_ORDER_ASC
)
?
compareLenPrefixedWStr
:
compareLenPrefixedWStrDesc
;
return
(
order
==
TSDB_ORDER_ASC
)
?
compareLenPrefixedWStr
:
compareLenPrefixedWStrDesc
;
case
TSDB_DATA_TYPE_JSON
:
return
(
order
==
TSDB_ORDER_ASC
)
?
compareJsonVal
:
compareJsonValDesc
;
default:
default:
return
(
order
==
TSDB_ORDER_ASC
)
?
compareInt32Val
:
compareInt32ValDesc
;
return
(
order
==
TSDB_ORDER_ASC
)
?
compareInt32Val
:
compareInt32ValDesc
;
}
}
...
...
tests/script/tsim/stream/session0.sim
浏览文件 @
e6c15da7
...
@@ -70,42 +70,42 @@ endi
...
@@ -70,42 +70,42 @@ endi
# row 1
# row 1
if $data11 != 3 then
if $data11 != 3 then
print ======$data
0
1
print ======$data
1
1
return -1
return -1
endi
endi
if $data12 != 10 then
if $data12 != 10 then
print ======$data
0
2
print ======$data
1
2
return -1
return -1
endi
endi
if $data13 != 10 then
if $data13 != 10 then
print ======$data
0
3
print ======$data
1
3
return -1
return -1
endi
endi
if $data14 != 1.100000000 then
if $data14 != 1.100000000 then
print ======$data
0
4
print ======$data
1
4
return -1
return -1
endi
endi
if $data15 != 0.000000000 then
if $data15 != 0.000000000 then
print ======$data
0
5
print ======$data
1
5
return -1
return -1
endi
endi
if $data16 != 10 then
if $data16 != 10 then
print ======$data
0
5
print ======$data
1
5
return -1
return -1
endi
endi
if $data17 != 1.100000000 then
if $data17 != 1.100000000 then
print ======$data
05
print ======$data
17
return -1
return -1
endi
endi
if $data18 != 5 then
if $data18 != 5 then
print ======$data
05
print ======$data
18
return -1
return -1
endi
endi
...
@@ -145,17 +145,17 @@ if $data05 != 0.816496581 then
...
@@ -145,17 +145,17 @@ if $data05 != 0.816496581 then
endi
endi
if $data06 != 3 then
if $data06 != 3 then
print ======$data0
5
print ======$data0
6
return -1
return -1
endi
endi
if $data07 != 1.100000000 then
if $data07 != 1.100000000 then
print ======$data0
5
print ======$data0
7
return -1
return -1
endi
endi
if $data08 != 13 then
if $data08 != 13 then
print ======$data0
5
print ======$data0
8
return -1
return -1
endi
endi
...
...
tests/script/tsim/stream/session1.sim
浏览文件 @
e6c15da7
...
@@ -187,4 +187,14 @@ if $data34 != 19 then
...
@@ -187,4 +187,14 @@ if $data34 != 19 then
return -1
return -1
endi
endi
sql insert into t1 values(1648791000000,1,1,1,1.1,23);
sleep 300
sql select * from streamt order by s desc;
# row 0
if $data01 != 1 then
print ======$data01
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/stream/state0.sim
0 → 100644
浏览文件 @
e6c15da7
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect
print =============== create database
sql create database test vgroups 1
sql show databases
if $rows != 3 then
return -1
endi
print $data00 $data01 $data02
sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
sql create stream streams1 trigger at_once into streamt1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0,1);
sql insert into t1 values(1648791213000,1,2,3,1.0,2);
sql select * from streamt1 order by c desc;
sleep 300
if $rows != 1 then
print ======$rows
return -1;
endi
sql insert into t1 values(1648791214000,1,2,3,1.0,3);
sql select * from streamt1 order by c desc;
sleep 300
if $rows != 1 then
print ======$rows
return -1;
endi
sql insert into t1 values(1648791213010,2,2,3,1.0,4);
sql insert into t1 values(1648791213000,1,2,3,1.0,5);
sql insert into t1 values(1648791214000,1,2,3,1.0,6);
$loop_count = 0
loop1:
sql select * from streamt1 where c >=4 order by `_wstartts`;
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 3 then
print ======$rows
goto loop1
return -1
endi
# row 0
if $data01 != 1 then
print ======$data01
return -1
endi
if $data02 != 1 then
print ======$data02
return -1
endi
if $data03 != 1 then
print ======$data03
return -1
endi
if $data04 != 1 then
print ======$data04
return -1
endi
if $data05 != 3 then
print ======$data05
return -1
endi
if $data06 != 5 then
print ======$data06
return -1
endi
# row 1
if $data11 != 1 then
print ======$data11
return -1
endi
if $data12 != 1 then
print ======$data12
return -1
endi
if $data13 != 2 then
print ======$data13
return -1
endi
if $data14 != 2 then
print ======$data14
return -1
endi
if $data15 != 3 then
print ======$data15
return -1
endi
if $data16 != 4 then
print ======$data16
return -1
endi
# row 2
if $data21 != 1 then
print ======$data21
return -1
endi
if $data22 != 1 then
print ======$data22
return -1
endi
if $data23 != 1 then
print ======$data23
return -1
endi
if $data24 != 1 then
print ======$data24
return -1
endi
if $data25 != 3 then
print ======$data25
return -1
endi
if $data26 != 6 then
print ======$data26
return -1
endi
sql insert into t1 values(1648791213011,1,2,3,1.0,7);
loop2:
$loop_count = 0
sql select * from streamt1 where c in (5,4,7) order by `_wstartts`;
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
# row 2
if $data21 != 2 then
print ======$data21
goto loop2
return -1
endi
if $data22 != 2 then
print ======$data22
goto loop2
return -1
endi
if $data23 != 2 then
print ======$data23
goto loop2
return -1
endi
if $data24 != 1 then
print ======$data24
goto loop2
return -1
endi
if $data25 != 3 then
print ======$data25
goto loop2
return -1
endi
if $data26 != 7 then
print ======$data26
goto loop2
return -1
endi
sql insert into t1 values(1648791213011,1,2,3,1.0,8);
loop21:
$loop_count = 0
sql select * from streamt1 where c in (5,4,8) order by `_wstartts`;
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $data26 != 8 then
print ======$data26
goto loop21
return -1
endi
sql insert into t1 values(1648791213020,1,2,3,1.0,9);
sql insert into t1 values(1648791213020,3,2,3,1.0,10);
sql insert into t1 values(1648791214000,1,2,3,1.0,11);
sql insert into t1 values(1648791213011,10,20,10,10.0,12);
loop3:
$loop_count = 0
sql select * from streamt1 where c in (5,4,10,11,12) order by `_wstartts`;
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
# row 2
if $data21 != 1 then
print ======$data21
goto loop3
return -1
endi
if $data22 != 1 then
print ======$data22
goto loop3
return -1
endi
if $data23 != 10 then
print ======$data23
goto loop3
return -1
endi
if $data24 != 10 then
print ======$data24
goto loop3
return -1
endi
if $data25 != 10 then
print ======$data25
goto loop3
return -1
endi
if $data26 != 12 then
print ======$data26
goto loop3
return -1
endi
# row 3
if $data31 != 1 then
print ======$data31
goto loop3
return -1
endi
if $data32 != 1 then
print ======$data32
goto loop3
return -1
endi
if $data33 != 3 then
print ======$data33
goto loop3
return -1
endi
if $data34 != 3 then
print ======$data34
goto loop3
return -1
endi
if $data35 != 3 then
print ======$data35
goto loop3
return -1
endi
if $data36 != 10 then
print ======$data36
goto loop3
return -1
endi
# row 4
if $data41 != 1 then
print ======$data41
goto loop3
return -1
endi
if $data42 != 1 then
print ======$data42
goto loop3
return -1
endi
if $data43 != 1 then
print ======$data43
goto loop3
return -1
endi
if $data44 != 1 then
print ======$data44
goto loop3
return -1
endi
if $data45 != 3 then
print ======$data45
goto loop3
return -1
endi
if $data46 != 11 then
print ======$data46
goto loop3
return -1
endi
sql insert into t1 values(1648791213030,3,12,12,12.0,13);
sql insert into t1 values(1648791214040,1,13,13,13.0,14);
sql insert into t1 values(1648791213030,3,14,14,14.0,15) (1648791214020,15,15,15,15.0,16);
loop4:
$loop_count = 0
sql select * from streamt1 where c in (14,15,16) order by `_wstartts`;
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 3 then
print ======$rows
goto loop4
return -1;
endi
# row 0
if $data01 != 2 then
print ======$data01
goto loop4
return -1
endi
if $data02 != 2 then
print ======$data02
goto loop4
return -1
endi
if $data03 != 6 then
print ======$data03
goto loop4
return -1
endi
if $data04 != 3 then
print ======$data04
goto loop4
return -1
endi
if $data05 != 3 then
print ======$data05
goto loop4
return -1
endi
if $data06 != 15 then
print ======$data06
goto loop4
return -1
endi
# row 1
if $data11 != 1 then
print ======$data11
goto loop4
return -1
endi
if $data12 != 1 then
print ======$data12
goto loop4
return -1
endi
if $data13 != 15 then
print ======$data13
goto loop4
return -1
endi
if $data14 != 15 then
print ======$data14
goto loop4
return -1
endi
if $data15 != 15 then
print ======$data15
goto loop4
return -1
endi
if $data16 != 16 then
print ======$data16
goto loop4
return -1
endi
# row 2
if $data21 != 1 then
print ======$data21
goto loop4
return -1
endi
if $data22 != 1 then
print ======$data22
goto loop4
return -1
endi
if $data23 != 1 then
print ======$data23
goto loop4
return -1
endi
if $data24 != 1 then
print ======$data24
goto loop4
return -1
endi
if $data25 != 13 then
print ======$data25
goto loop4
return -1
endi
if $data26 != 14 then
print ======$data26
goto loop4
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/stream/triggerSession0.sim
浏览文件 @
e6c15da7
...
@@ -102,4 +102,4 @@ if $data21 != 1 then
...
@@ -102,4 +102,4 @@ if $data21 != 1 then
return -1
return -1
endi
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
\ No newline at end of file
tests/system-test/1-insert/alter_stable.py
0 → 100644
浏览文件 @
e6c15da7
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
random
import
string
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
def
get_long_name
(
self
,
length
,
mode
=
"mixed"
):
"""
generate long name
mode could be numbers/letters/letters_mixed/mixed
"""
if
mode
==
"numbers"
:
population
=
string
.
digits
elif
mode
==
"letters"
:
population
=
string
.
ascii_letters
.
lower
()
elif
mode
==
"letters_mixed"
:
population
=
string
.
ascii_letters
.
upper
()
+
string
.
ascii_letters
.
lower
()
else
:
population
=
string
.
ascii_letters
.
lower
()
+
string
.
digits
return
""
.
join
(
random
.
choices
(
population
,
k
=
length
))
def
alter_stable_column_check
(
self
,
dbname
,
stbname
,
tbname
):
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
execute
(
f
'create stable
{
stbname
}
(ts timestamp, c1 tinyint, c2 smallint, c3 int,
\
c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) '
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")'
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
add column c14 int'
)
tdSql
.
query
(
f
'select c14 from
{
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
add column `c15` int'
)
tdSql
.
query
(
f
'select c15 from
{
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
17
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
drop column c14'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
16
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
drop column `c15`'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
15
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify column c12 binary(30)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
12
,
2
,
30
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify column `c12` binary(35)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
12
,
2
,
35
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column `c12` binary(34)'
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify column c13 nchar(30)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
13
,
2
,
30
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c13 nchar(29)'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
rename column c1 c21'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c1 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c4 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c8 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c1 unsigned int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c9 double'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c10 float'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c11 int'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
alter_stable_tag_check
(
self
,
dbname
,
stbname
,
tbname
):
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
execute
(
f
'create stable
{
stbname
}
(ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int,
\
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) '
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(now,1)'
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
add tag t14 int'
)
tdSql
.
query
(
f
'select t14 from
{
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
add tag `t15` int'
)
tdSql
.
query
(
f
'select t14 from
{
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
18
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
drop tag t14'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
17
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
drop tag `t15`'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkRows
(
16
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify tag t12 binary(30)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
14
,
2
,
30
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify tag `t12` binary(35)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
14
,
2
,
35
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag `t12` binary(34)'
)
tdSql
.
execute
(
f
'alter stable
{
stbname
}
modify tag t13 nchar(30)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
15
,
2
,
30
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag t13 nchar(29)'
)
tdSql
.
execute
(
f
'alter table
{
stbname
}
rename tag t1 t21'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
3
,
0
,
't21'
)
tdSql
.
execute
(
f
'alter table
{
stbname
}
rename tag `t21` t1'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkData
(
3
,
0
,
't1'
)
for
i
in
[
'bigint'
,
'unsigned int'
,
'float'
,
'double'
,
'binary(10)'
,
'nchar(10)'
]:
for
j
in
[
1
,
2
,
3
]:
tdSql
.
error
(
f
'alter table
{
stbname
}
modify tag t
{
j
}
{
i
}
'
)
for
i
in
[
'int'
,
'unsigned int'
,
'float'
,
'binary(10)'
,
'nchar(10)'
]:
tdSql
.
error
(
f
'alter table
{
stbname
}
modify tag t8
{
i
}
'
)
tdSql
.
error
(
f
'alter table
{
stbname
}
modify tag t4 int'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
run
(
self
):
dbname
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
stbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
tbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
self
.
alter_stable_column_check
(
dbname
,
stbname
,
tbname
)
self
.
alter_stable_tag_check
(
dbname
,
stbname
,
tbname
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/1-insert/alter_table.py
0 → 100644
浏览文件 @
e6c15da7
此差异已折叠。
点击以展开。
tests/system-test/2-query/json_tag.py
浏览文件 @
e6c15da7
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
e6c15da7
...
@@ -19,7 +19,8 @@ python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
...
@@ -19,7 +19,8 @@ python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
python3 ./test.py
-f
1-insert/opentsdb_telnet_line_taosc_insert.py
python3 ./test.py
-f
1-insert/opentsdb_telnet_line_taosc_insert.py
python3 ./test.py
-f
1-insert/opentsdb_json_taosc_insert.py
python3 ./test.py
-f
1-insert/opentsdb_json_taosc_insert.py
#python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py
#python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py
python3 ./test.py
-f
1-insert/alter_stable.py
python3 ./test.py
-f
1-insert/alter_table.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/varchar.py
python3 ./test.py
-f
2-query/varchar.py
...
@@ -79,6 +80,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
...
@@ -79,6 +80,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
# TD-15983 subquery output duplicate name column.
# TD-15983 subquery output duplicate name column.
# Please Xiangyang Guo modify the following script
# Please Xiangyang Guo modify the following script
# python3 ./test.py -f 2-query/nestedQuery_str.py
# python3 ./test.py -f 2-query/nestedQuery_str.py
python3 ./test.py
-f
2-query/avg.py
python3 ./test.py
-f
2-query/avg.py
python3 ./test.py
-f
2-query/elapsed.py
python3 ./test.py
-f
2-query/elapsed.py
python3 ./test.py
-f
2-query/csum.py
python3 ./test.py
-f
2-query/csum.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录