Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4cb6085
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
d4cb6085
编写于
4月 14, 2023
作者:
D
dapan1121
提交者:
GitHub
4月 14, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20885 from taosdata/fix/TS-3108
fix: fix timestamp constant comparison precision error
上级
96d2c5b9
b5147734
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
6 deletion
+45
-6
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+1
-1
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+3
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+19
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+22
-5
未找到文件。
include/libs/function/functionMgt.h
浏览文件 @
d4cb6085
...
...
@@ -189,7 +189,7 @@ bool fmIsScalarFunc(int32_t funcId);
bool
fmIsVectorFunc
(
int32_t
funcId
);
bool
fmIsIndefiniteRowsFunc
(
int32_t
funcId
);
bool
fmIsStringFunc
(
int32_t
funcId
);
bool
fmIsDate
t
imeFunc
(
int32_t
funcId
);
bool
fmIsDate
T
imeFunc
(
int32_t
funcId
);
bool
fmIsSelectFunc
(
int32_t
funcId
);
bool
fmIsTimelineFunc
(
int32_t
funcId
);
bool
fmIsTimeorderFunc
(
int32_t
funcId
);
...
...
source/libs/function/src/functionMgt.c
浏览文件 @
d4cb6085
...
...
@@ -174,6 +174,8 @@ bool fmIsSelectFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC
bool
fmIsTimelineFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_TIMELINE_FUNC
);
}
bool
fmIsDateTimeFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_DATETIME_FUNC
);
}
bool
fmIsPseudoColumnFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_PSEUDO_COLUMN_FUNC
);
}
bool
fmIsScanPseudoColumnFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SCAN_PC_FUNC
);
}
...
...
@@ -184,6 +186,7 @@ bool fmIsWindowClauseFunc(int32_t funcId) { return fmIsAggFunc(funcId) || fmIsWi
bool
fmIsIndefiniteRowsFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_INDEFINITE_ROWS_FUNC
);
}
bool
fmIsSpecialDataRequiredFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SPECIAL_DATA_REQUIRED
);
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
d4cb6085
...
...
@@ -1569,6 +1569,21 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateDateTimeFunc
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
if
(
!
fmIsDateTimeFunc
(
pFunc
->
funcId
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
return
TSDB_CODE_SUCCESS
;
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
pFunc
->
node
.
resType
.
precision
=
pSelect
->
precision
;
return
TSDB_CODE_SUCCESS
;
}
static
bool
hasFillClause
(
SNode
*
pCurrStmt
)
{
if
(
!
isSelectStmt
(
pCurrStmt
))
{
return
false
;
...
...
@@ -1708,6 +1723,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCurrStmt
;
pSelect
->
hasAggFuncs
=
pSelect
->
hasAggFuncs
?
true
:
fmIsAggFunc
(
pFunc
->
funcId
);
pSelect
->
hasRepeatScanFuncs
=
pSelect
->
hasRepeatScanFuncs
?
true
:
fmIsRepeatScanFunc
(
pFunc
->
funcId
);
if
(
fmIsIndefiniteRowsFunc
(
pFunc
->
funcId
))
{
pSelect
->
hasIndefiniteRowsFunc
=
true
;
pSelect
->
returnRows
=
fmGetFuncReturnRows
(
pFunc
);
...
...
@@ -1856,6 +1872,9 @@ static int32_t translateNormalFunction(STranslateContext* pCxt, SFunctionNode* p
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateTimelineFunc
(
pCxt
,
pFunc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateDateTimeFunc
(
pCxt
,
pFunc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateBlockDistFunc
(
pCxt
,
pFunc
);
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
d4cb6085
...
...
@@ -1038,23 +1038,40 @@ bool sclContainsAggFuncNode(SNode *pNode) {
return
aggFunc
;
}
static
uint8_t
sclGetOpValueNodeTsPrecision
(
SNode
*
pLeft
,
SNode
*
pRight
)
{
uint8_t
lPrec
=
((
SExprNode
*
)
pLeft
)
->
resType
.
precision
;
uint8_t
rPrec
=
((
SExprNode
*
)
pRight
)
->
resType
.
precision
;
uint8_t
lType
=
((
SExprNode
*
)
pLeft
)
->
resType
.
type
;
uint8_t
rType
=
((
SExprNode
*
)
pRight
)
->
resType
.
type
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
lType
&&
TSDB_DATA_TYPE_TIMESTAMP
==
rType
)
{
return
TMAX
(
lPrec
,
rPrec
);
}
else
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
lType
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
rType
)
{
return
lPrec
;
}
else
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
rType
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
lType
)
{
return
rPrec
;
}
return
0
;
}
int32_t
sclConvertOpValueNodeTs
(
SOperatorNode
*
node
,
SScalarCtx
*
ctx
)
{
int32_t
code
=
0
;
if
(
node
->
pLeft
&&
SCL_IS_VAR_VALUE_NODE
(
node
->
pLeft
))
{
if
(
node
->
pRight
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pRight
)
->
resType
.
type
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
((
SExprNode
*
)
node
->
pRight
)
->
resType
.
precision
,
(
SValueNode
*
)
node
->
pLeft
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
)
,
(
SValueNode
*
)
node
->
pLeft
));
}
}
else
if
(
node
->
pRight
&&
SCL_IS_NOTNULL_CONST_NODE
(
node
->
pRight
))
{
if
(
node
->
pLeft
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
type
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pRight
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
precision
,
(
SValueNode
*
)
node
->
pRight
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
)
,
(
SValueNode
*
)
node
->
pRight
));
}
else
if
(
QUERY_NODE_NODE_LIST
==
node
->
pRight
->
type
)
{
SNode
*
pNode
;
FOREACH
(
pNode
,
((
SNodeListNode
*
)
node
->
pRight
)
->
pNodeList
)
{
if
(
SCL_IS_VAR_VALUE_NODE
(
pNode
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
precision
,
(
SValueNode
*
)
pNode
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
pNode
)
,
(
SValueNode
*
)
pNode
));
}
}
}
...
...
@@ -1077,7 +1094,7 @@ int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
if
(
NULL
==
node
->
pCase
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pCase
))
{
SNode
*
pNode
;
FOREACH
(
pNode
,
node
->
pWhenThenList
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录