Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ff5c1f1c
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,发现更多精彩内容 >>
提交
ff5c1f1c
编写于
8月 26, 2022
作者:
G
gccgdb1234
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of github.com:taosdata/TDengine into 3.0
上级
290ff929
def21870
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
102 addition
and
15 deletion
+102
-15
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+1
-1
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+14
-14
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+2
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+85
-0
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
ff5c1f1c
...
...
@@ -476,7 +476,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
if
(
code
)
goto
_err
;
if
(
!
state
->
aBlockL
)
{
state
->
aBlockL
=
taosArrayInit
(
0
,
sizeof
(
SBlock
Idx
));
state
->
aBlockL
=
taosArrayInit
(
0
,
sizeof
(
SBlock
L
));
}
else
{
taosArrayClear
(
state
->
aBlockL
);
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
ff5c1f1c
...
...
@@ -303,7 +303,7 @@ static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t le
}
SExprNode
*
pPara1
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
!
IS_
VA
R_DATA_TYPE
(
pPara1
->
resType
.
type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
pPara1
->
resType
.
type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -317,7 +317,7 @@ static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len
}
SExprNode
*
pPara1
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
!
IS_
VA
R_DATA_TYPE
(
pPara1
->
resType
.
type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
pPara1
->
resType
.
type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -546,7 +546,7 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
// param2
if
(
3
==
numOfParams
)
{
uint8_t
para3Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
))
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
para3Type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
para3Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -593,7 +593,7 @@ static int32_t translateApercentileImpl(SFunctionNode* pFunc, char* pErrBuf, int
// param2
if
(
3
==
numOfParams
)
{
uint8_t
para3Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
))
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
para3Type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
para3Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1388,7 +1388,7 @@ static int32_t translateSample(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
}
// set result type
if
(
IS_
VA
R_DATA_TYPE
(
colType
))
{
if
(
IS_
ST
R_DATA_TYPE
(
colType
))
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pCol
->
resType
.
bytes
,
.
type
=
colType
};
}
else
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
colType
].
bytes
,
.
type
=
colType
};
...
...
@@ -1431,7 +1431,7 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
}
// set result type
if
(
IS_
VA
R_DATA_TYPE
(
colType
))
{
if
(
IS_
ST
R_DATA_TYPE
(
colType
))
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pCol
->
resType
.
bytes
,
.
type
=
colType
};
}
else
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
colType
].
bytes
,
.
type
=
colType
};
...
...
@@ -1514,7 +1514,7 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
for
(
int32_t
i
=
1
;
i
<
3
;
++
i
)
{
nodeType
=
nodeType
(
nodesListGetNode
(
pFunc
->
pParameterList
,
i
));
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
i
))
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
paraType
)
||
QUERY_NODE_VALUE
!=
nodeType
)
{
if
(
!
IS_
ST
R_DATA_TYPE
(
paraType
)
||
QUERY_NODE_VALUE
!=
nodeType
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1682,7 +1682,7 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
!
IS_
VA
R_DATA_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1714,7 +1714,7 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
for
(
int32_t
i
=
0
;
i
<
numOfParams
;
++
i
)
{
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
paraType
)
&&
!
IS_NULL_TYPE
(
paraType
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
paraType
)
&&
!
IS_NULL_TYPE
(
paraType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
TSDB_DATA_TYPE_NCHAR
==
paraType
)
{
...
...
@@ -1770,7 +1770,7 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
uint8_t
para0Type
=
pPara0
->
resType
.
type
;
uint8_t
para1Type
=
pPara1
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
para0Type
)
||
!
IS_INTEGER_TYPE
(
para1Type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(
para0Type
)
||
!
IS_INTEGER_TYPE
(
para1Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1802,7 +1802,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
uint8_t
para2Type
=
pFunc
->
node
.
resType
.
type
;
int32_t
para2Bytes
=
pFunc
->
node
.
resType
.
bytes
;
if
(
IS_
VA
R_DATA_TYPE
(
para2Type
))
{
if
(
IS_
ST
R_DATA_TYPE
(
para2Type
))
{
para2Bytes
-=
VARSTR_HEADER_SIZE
;
}
if
(
para2Bytes
<=
0
||
para2Bytes
>
4096
)
{
// cast dst var type length limits to 4096 bytes
...
...
@@ -1859,7 +1859,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
!
IS_
VA
R_DATA_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
))
{
if
(
!
IS_
ST
R_DATA_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1878,7 +1878,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
((
!
IS_
VA
R_DATA_TYPE
(
para1Type
)
&&
!
IS_INTEGER_TYPE
(
para1Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para1Type
)
||
if
((
!
IS_
ST
R_DATA_TYPE
(
para1Type
)
&&
!
IS_INTEGER_TYPE
(
para1Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para1Type
)
||
!
IS_INTEGER_TYPE
(
para2Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -1911,7 +1911,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
i
))
->
resType
.
type
;
if
(
!
IS_
VA
R_DATA_TYPE
(
paraType
)
&&
!
IS_INTEGER_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
if
(
!
IS_
ST
R_DATA_TYPE
(
paraType
)
&&
!
IS_INTEGER_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
...
source/libs/scalar/inc/sclInt.h
浏览文件 @
ff5c1f1c
...
...
@@ -45,6 +45,8 @@ typedef struct SScalarCtx {
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
#define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN)
#define SCL_DOWNGRADE_DATETYPE(_type) ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT)
#define sclFatal(...) qFatal(__VA_ARGS__)
#define sclError(...) qError(__VA_ARGS__)
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
ff5c1f1c
...
...
@@ -9,6 +9,7 @@
#include "scalar.h"
#include "tudf.h"
#include "ttime.h"
#include "tcompare.h"
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
)
{
if
(
OP_TYPE_IS_NULL
==
type
||
OP_TYPE_IS_NOT_NULL
==
type
||
OP_TYPE_IS_TRUE
==
type
||
OP_TYPE_IS_NOT_TRUE
==
type
...
...
@@ -219,6 +220,82 @@ void sclFreeParamList(SScalarParam *param, int32_t paramNum) {
taosMemoryFree
(
param
);
}
void
sclDowngradeValueType
(
SValueNode
*
valueNode
)
{
switch
(
valueNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BIGINT
:
{
int8_t
i8
=
valueNode
->
datum
.
i
;
if
(
i8
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TINYINT
;
*
(
int8_t
*
)
&
valueNode
->
typeData
=
i8
;
break
;
}
int16_t
i16
=
valueNode
->
datum
.
i
;
if
(
i16
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_SMALLINT
;
*
(
int16_t
*
)
&
valueNode
->
typeData
=
i16
;
break
;
}
int32_t
i32
=
valueNode
->
datum
.
i
;
if
(
i32
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_INT
;
*
(
int32_t
*
)
&
valueNode
->
typeData
=
i32
;
break
;
}
break
;
}
case
TSDB_DATA_TYPE_UBIGINT
:{
uint8_t
u8
=
valueNode
->
datum
.
i
;
if
(
u8
==
valueNode
->
datum
.
i
)
{
int8_t
i8
=
valueNode
->
datum
.
i
;
if
(
i8
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TINYINT
;
*
(
int8_t
*
)
&
valueNode
->
typeData
=
i8
;
}
else
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_UTINYINT
;
*
(
uint8_t
*
)
&
valueNode
->
typeData
=
u8
;
}
break
;
}
uint16_t
u16
=
valueNode
->
datum
.
i
;
if
(
u16
==
valueNode
->
datum
.
i
)
{
int16_t
i16
=
valueNode
->
datum
.
i
;
if
(
i16
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_SMALLINT
;
*
(
int16_t
*
)
&
valueNode
->
typeData
=
i16
;
}
else
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_USMALLINT
;
*
(
uint16_t
*
)
&
valueNode
->
typeData
=
u16
;
}
break
;
}
uint32_t
u32
=
valueNode
->
datum
.
i
;
if
(
u32
==
valueNode
->
datum
.
i
)
{
int32_t
i32
=
valueNode
->
datum
.
i
;
if
(
i32
==
valueNode
->
datum
.
i
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_INT
;
*
(
int32_t
*
)
&
valueNode
->
typeData
=
i32
;
}
else
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_UINT
;
*
(
uint32_t
*
)
&
valueNode
->
typeData
=
u32
;
}
break
;
}
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
float
f
=
valueNode
->
datum
.
d
;
if
(
FLT_EQUAL
(
f
,
valueNode
->
datum
.
d
))
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_FLOAT
;
*
(
float
*
)
&
valueNode
->
typeData
=
f
;
break
;
}
break
;
}
default:
break
;
}
}
int32_t
sclInitParam
(
SNode
*
node
,
SScalarParam
*
param
,
SScalarCtx
*
ctx
,
int32_t
*
rowNum
)
{
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_LEFT_VALUE
:
{
...
...
@@ -675,6 +752,10 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
return
DEAL_RES_ERROR
;
}
}
if
(
SCL_IS_COMPARISON_OPERATOR
(
node
->
opType
)
&&
SCL_DOWNGRADE_DATETYPE
(
valueNode
->
node
.
resType
.
type
))
{
sclDowngradeValueType
(
valueNode
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pRight
)))
{
...
...
@@ -692,6 +773,10 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
return
DEAL_RES_ERROR
;
}
}
if
(
SCL_IS_COMPARISON_OPERATOR
(
node
->
opType
)
&&
SCL_DOWNGRADE_DATETYPE
(
valueNode
->
node
.
resType
.
type
))
{
sclDowngradeValueType
(
valueNode
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_NODE_LIST
==
nodeType
(
node
->
pRight
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录