Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
14b4adc6
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
14b4adc6
编写于
11月 15, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: memory leak
上级
901c9b8f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
82 deletion
+91
-82
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+12
-12
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+79
-70
未找到文件。
source/libs/scalar/src/filter.c
浏览文件 @
14b4adc6
...
...
@@ -248,9 +248,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
}
}
// if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
// return 28;
// }
// if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
// return 28;
// }
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
...
...
@@ -1087,7 +1087,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
info
->
units
=
(
SFilterUnit
*
)
tmp
;
info
->
units
=
(
SFilterUnit
*
)
tmp
;
memset
(
info
->
units
+
psize
,
0
,
sizeof
(
*
info
->
units
)
*
FILTER_DEFAULT_UNIT_SIZE
);
}
...
...
@@ -1169,7 +1169,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
SScalarParam
out
=
{.
columnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
))};
out
.
columnData
->
info
.
type
=
type
;
out
.
columnData
->
info
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
//
reserved space for simple_copy
out
.
columnData
->
info
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
//
reserved space for simple_copy
for
(
int32_t
i
=
0
;
i
<
listNode
->
pNodeList
->
length
;
++
i
)
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
cell
->
pNode
;
...
...
@@ -1191,7 +1191,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
filterAddField
(
info
,
NULL
,
(
void
**
)
&
out
.
columnData
->
pData
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
out
.
columnData
->
pData
=
NULL
;
}
else
{
void
*
data
=
taosMemoryCalloc
(
1
,
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
);
//
reserved space for simple_copy
void
*
data
=
taosMemoryCalloc
(
1
,
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
);
//
reserved space for simple_copy
if
(
NULL
==
data
)
{
FLT_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -1633,11 +1633,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
//if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) {
// qDebug("VAL%d => [type:TS][val:[%" PRIi64 "] - [%" PRId64 "]]", i, *(int64_t *)field->data,
// *(((int64_t *)field->data) + 1));
//} else {
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
// TODO
//
if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) {
//
qDebug("VAL%d => [type:TS][val:[%" PRIi64 "] - [%" PRId64 "]]", i, *(int64_t *)field->data,
//
*(((int64_t *)field->data) + 1));
//
} else {
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
// TODO
//}
}
else
if
(
field
->
data
)
{
qDebug
(
"VAL%d => [type:NIL][val:NIL]"
,
i
);
// TODO
...
...
@@ -1719,7 +1719,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
ctx
->
isrange
);
if
(
ctx
->
isrange
)
{
SFilterRangeNode
*
r
=
ctx
->
rs
;
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
while
(
r
)
{
char
str
[
256
]
=
{
0
};
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_NULL
))
{
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
14b4adc6
...
...
@@ -23,12 +23,13 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) {
int32_t
sclConvertToTsValueNode
(
int8_t
precision
,
SValueNode
*
valueNode
)
{
char
*
timeStr
=
valueNode
->
datum
.
p
;
int
32_t
code
=
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
precision
,
&
valueNode
->
datum
.
i
);
int
64_t
value
=
0
;
int32_t
code
=
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
precision
,
&
value
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
taosMemoryFree
(
timeStr
);
valueNode
->
datum
.
i
=
value
;
valueNode
->
typeData
=
valueNode
->
datum
.
i
;
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
...
...
@@ -61,7 +62,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
return
TSDB_CODE_SUCCESS
;
}
int32_t
sclConvertValueToSclParam
(
SValueNode
*
pValueNode
,
SScalarParam
*
out
,
int32_t
*
overflow
)
{
int32_t
sclConvertValueToSclParam
(
SValueNode
*
pValueNode
,
SScalarParam
*
out
,
int32_t
*
overflow
)
{
SScalarParam
in
=
{.
numOfRows
=
1
};
int32_t
code
=
sclCreateColumnInfoData
(
&
pValueNode
->
node
.
resType
,
1
,
&
in
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -78,7 +79,7 @@ int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int
}
int32_t
sclExtendResRows
(
SScalarParam
*
pDst
,
SScalarParam
*
pSrc
,
SArray
*
pBlockList
)
{
SSDataBlock
*
pb
=
taosArrayGetP
(
pBlockList
,
0
);
SSDataBlock
*
pb
=
taosArrayGetP
(
pBlockList
,
0
);
SScalarParam
*
pLeft
=
taosMemoryCalloc
(
1
,
sizeof
(
SScalarParam
));
if
(
NULL
==
pLeft
)
{
sclError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SScalarParam
));
...
...
@@ -90,7 +91,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
if
(
pDst
->
numOfRows
<
pb
->
info
.
rows
)
{
colInfoDataEnsureCapacity
(
pDst
->
columnData
,
pb
->
info
.
rows
,
true
);
}
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
OP_TYPE_ASSIGN
);
OperatorFn
(
pLeft
,
pSrc
,
pDst
,
TSDB_ORDER_ASC
);
...
...
@@ -566,7 +567,7 @@ _return:
SCL_RET
(
code
);
}
int32_t
sclGetNodeRes
(
SNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
**
res
)
{
int32_t
sclGetNodeRes
(
SNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
**
res
)
{
if
(
NULL
==
node
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -576,48 +577,53 @@ int32_t sclGetNodeRes(SNode* node, SScalarCtx *ctx, SScalarParam **res) {
if
(
NULL
==
*
res
)
{
SCL_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SCL_ERR_RET
(
sclInitParam
(
node
,
*
res
,
ctx
,
&
rowNum
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
sclWalkCaseWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pCase
,
SScalarParam
*
pElse
,
SScalarParam
*
pComp
,
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
)
{
SNode
*
node
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
int32_t
sclWalkCaseWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pCase
,
SScalarParam
*
pElse
,
SScalarParam
*
pComp
,
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
)
{
SNode
*
node
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
vectorCompareImpl
(
pCase
,
pWhen
,
pComp
,
rowIdx
,
1
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
bool
*
equal
=
(
bool
*
)
colDataGetData
(
pComp
->
columnData
,
rowIdx
);
bool
*
equal
=
(
bool
*
)
colDataGetData
(
pComp
->
columnData
,
rowIdx
);
if
(
*
equal
)
{
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)));
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)));
if
(
0
==
rowIdx
&&
1
==
pCase
->
numOfRows
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
totalRows
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
}
goto
_return
;
}
}
if
(
pElse
)
{
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)));
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)));
if
(
0
==
rowIdx
&&
1
==
pCase
->
numOfRows
&&
1
==
pElse
->
numOfRows
&&
totalRows
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
}
goto
_return
;
}
...
...
@@ -629,7 +635,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
}
_return:
sclFreeParam
(
pWhen
);
sclFreeParam
(
pThen
);
taosMemoryFree
(
pWhen
);
...
...
@@ -638,32 +644,34 @@ _return:
SCL_RET
(
code
);
}
int32_t
sclWalkWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pElse
,
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
,
bool
preSingle
)
{
SNode
*
node
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
int32_t
sclWalkWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pElse
,
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
,
bool
preSingle
)
{
SNode
*
node
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
pWhen
=
NULL
;
pThen
=
NULL
;
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
rowIdx
:
0
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
rowIdx
:
0
));
if
(
*
whenValue
)
{
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)));
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
)));
if
(
preSingle
&&
0
==
rowIdx
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
totalRows
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
}
goto
_return
;
}
...
...
@@ -674,13 +682,14 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
}
if
(
pElse
)
{
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)));
colDataAppend
(
output
->
columnData
,
rowIdx
,
colDataGetData
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)),
colDataIsNull_s
(
pElse
->
columnData
,
(
pElse
->
numOfRows
>
1
?
rowIdx
:
0
)));
if
(
preSingle
&&
0
==
rowIdx
&&
1
==
pElse
->
numOfRows
&&
totalRows
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
}
goto
_return
;
}
...
...
@@ -860,14 +869,14 @@ _return:
}
int32_t
sclExecCaseWhen
(
SCaseWhenNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SScalarParam
*
pCase
=
NULL
;
SScalarParam
*
pElse
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
SScalarParam
comp
=
{
0
};
int32_t
rowNum
=
1
;
bool
complete
=
false
;
int32_t
rowNum
=
1
;
bool
complete
=
false
;
if
(
NULL
==
node
->
pWhenThenList
||
node
->
pWhenThenList
->
length
<=
0
)
{
sclError
(
"invalid whenThen list"
);
...
...
@@ -875,24 +884,24 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
}
if
(
ctx
->
pBlockList
)
{
SSDataBlock
*
pb
=
taosArrayGetP
(
ctx
->
pBlockList
,
0
);
SSDataBlock
*
pb
=
taosArrayGetP
(
ctx
->
pBlockList
,
0
);
rowNum
=
pb
->
info
.
rows
;
output
->
numOfRows
=
pb
->
info
.
rows
;
}
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
node
->
node
.
resType
,
rowNum
,
output
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pCase
,
ctx
,
&
pCase
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pElse
,
ctx
,
&
pElse
));
SDataType
compType
=
{
0
};
compType
.
type
=
TSDB_DATA_TYPE_BOOL
;
compType
.
bytes
=
tDataTypes
[
compType
.
type
].
bytes
;
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
compType
,
rowNum
,
&
comp
));
SNode
*
tnode
=
NULL
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
node
->
pWhenThenList
->
pHead
->
pNode
;
SNode
*
tnode
=
NULL
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
node
->
pWhenThenList
->
pHead
->
pNode
;
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
...
...
@@ -903,17 +912,19 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
if
(
pCase
)
{
vectorCompare
(
pCase
,
pWhen
,
&
comp
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
bool
*
equal
=
(
bool
*
)
colDataGetData
(
comp
.
columnData
,
(
comp
.
numOfRows
>
1
?
i
:
0
));
bool
*
equal
=
(
bool
*
)
colDataGetData
(
comp
.
columnData
,
(
comp
.
numOfRows
>
1
?
i
:
0
));
if
(
*
equal
)
{
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
if
(
0
==
i
&&
1
==
pCase
->
numOfRows
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
break
;
}
}
else
{
SCL_ERR_JRET
(
sclWalkCaseWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pCase
,
pElse
,
&
comp
,
output
,
i
,
rowNum
,
&
complete
));
SCL_ERR_JRET
(
sclWalkCaseWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pCase
,
pElse
,
&
comp
,
output
,
i
,
rowNum
,
&
complete
));
if
(
complete
)
{
break
;
}
...
...
@@ -921,15 +932,17 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
i
:
0
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
i
:
0
));
if
(
*
whenValue
)
{
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
if
(
0
==
i
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
break
;
}
}
else
{
SCL_ERR_JRET
(
sclWalkWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pElse
,
output
,
i
,
rowNum
,
&
complete
,
(
pWhen
->
numOfRows
==
1
&&
pThen
->
numOfRows
==
1
)));
SCL_ERR_JRET
(
sclWalkWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pElse
,
output
,
i
,
rowNum
,
&
complete
,
(
pWhen
->
numOfRows
==
1
&&
pThen
->
numOfRows
==
1
)));
if
(
complete
)
{
break
;
}
...
...
@@ -965,7 +978,6 @@ _return:
SCL_RET
(
code
);
}
EDealRes
sclRewriteNullInOptr
(
SNode
**
pNode
,
SScalarCtx
*
ctx
,
EOperatorType
opType
)
{
if
(
opType
<=
OP_TYPE_CALC_MAX
)
{
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
...
...
@@ -1089,8 +1101,7 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SNode
*
tnode
=
NULL
;
if
((
!
fmIsScalarFunc
(
node
->
funcId
)
&&
(
!
ctx
->
dual
))
||
fmIsUserDefinedFunc
(
node
->
funcId
))
{
if
((
!
fmIsScalarFunc
(
node
->
funcId
)
&&
(
!
ctx
->
dual
))
||
fmIsUserDefinedFunc
(
node
->
funcId
))
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -1229,20 +1240,20 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
}
EDealRes
sclRewriteCaseWhen
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewriteCaseWhen
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
*
pNode
;
if
((
!
SCL_IS_CONST_NODE
(
node
->
pCase
))
||
(
!
SCL_IS_CONST_NODE
(
node
->
pElse
)))
{
return
DEAL_RES_CONTINUE
;
}
SNode
*
tnode
=
NULL
;
SNode
*
tnode
=
NULL
;
FOREACH
(
tnode
,
node
->
pWhenThenList
)
{
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
tnode
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
tnode
;
if
(
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pWhen
)
||
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pThen
))
{
return
DEAL_RES_CONTINUE
;
}
}
}
SScalarParam
output
=
{
0
};
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
...
...
@@ -1275,13 +1286,12 @@ EDealRes sclRewriteCaseWhen(SNode** pNode, SScalarCtx *ctx) {
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
*
pNode
=
(
SNode
*
)
res
;
sclFreeParam
(
&
output
);
return
DEAL_RES_CONTINUE
;
}
EDealRes
sclConstantsRewriter
(
SNode
**
pNode
,
void
*
pContext
)
{
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
...
...
@@ -1408,9 +1418,9 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
}
EDealRes
sclWalkCaseWhen
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclWalkCaseWhen
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
if
(
ctx
->
code
)
{
...
...
@@ -1425,11 +1435,10 @@ EDealRes sclWalkCaseWhen(SNode* pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
}
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
QUERY_NODE_LEFT_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_WHEN_THEN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
QUERY_NODE_LEFT_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_WHEN_THEN
==
nodeType
(
pNode
))
{
return
DEAL_RES_CONTINUE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录