Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ec643cee
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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,发现更多精彩内容 >>
提交
ec643cee
编写于
4月 12, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: is_null expression returned an incorrect result
上级
5a70bddb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
20 deletion
+72
-20
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+43
-7
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+17
-13
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+10
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
ec643cee
...
...
@@ -597,6 +597,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2623)
#define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ec643cee
...
...
@@ -21,7 +21,7 @@
#include "parUtil.h"
#include "ttime.h"
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) :
((SValueNode*)(pVal))->datum.i
)
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) :
getBigintFromValueNode((SValueNode*)(pVal))
)
typedef
struct
STranslateContext
{
SParseContext
*
pParseCxt
;
...
...
@@ -380,6 +380,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
pVal
->
node
.
resType
.
precision
=
precision
;
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -452,6 +453,9 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
}
else
{
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
}
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -1041,6 +1045,27 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
code
;
}
static
int64_t
getUnitPerMinute
(
uint8_t
precision
)
{
switch
(
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
return
MILLISECOND_PER_MINUTE
;
case
TSDB_TIME_PRECISION_MICRO
:
return
MILLISECOND_PER_MINUTE
*
1000L
;
case
TSDB_TIME_PRECISION_NANO
:
return
NANOSECOND_PER_MINUTE
;
default:
break
;
}
return
MILLISECOND_PER_MINUTE
;
}
static
int64_t
getBigintFromValueNode
(
SValueNode
*
pVal
)
{
if
(
pVal
->
isDuration
)
{
return
pVal
->
datum
.
i
/
getUnitPerMinute
(
pVal
->
node
.
resType
.
precision
);
}
return
pVal
->
datum
.
i
;
}
static
int32_t
buildCreateDbRetentions
(
const
SNodeList
*
pRetentions
,
SCreateDbReq
*
pReq
)
{
if
(
NULL
!=
pRetentions
)
{
pReq
->
pRetensions
=
taosArrayInit
(
LIST_LENGTH
(
pRetentions
),
sizeof
(
SRetention
));
...
...
@@ -1098,7 +1123,10 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
return
pCxt
->
errCode
;
}
int64_t
val
=
pVal
->
datum
.
i
;
if
(
pVal
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
}
int64_t
val
=
getBigintFromValueNode
(
pVal
);
if
(
val
<
minVal
||
val
>
maxVal
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
,
pName
,
val
,
minVal
,
maxVal
);
}
...
...
@@ -1187,9 +1215,18 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
}
}
int32_t
daysToKeep0
=
((
SValueNode
*
)
nodesListGetNode
(
pKeep
,
0
))
->
datum
.
i
;
int32_t
daysToKeep1
=
((
SValueNode
*
)
nodesListGetNode
(
pKeep
,
1
))
->
datum
.
i
;
int32_t
daysToKeep2
=
((
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
))
->
datum
.
i
;
SValueNode
*
pKeep0
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
0
);
SValueNode
*
pKeep1
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
1
);
SValueNode
*
pKeep2
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
);
if
((
pKeep0
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep0
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep0
->
unit
&&
TIME_UNIT_DAY
!=
pKeep0
->
unit
))
||
(
pKeep1
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep1
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep1
->
unit
&&
TIME_UNIT_DAY
!=
pKeep1
->
unit
))
||
(
pKeep2
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep2
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep2
->
unit
&&
TIME_UNIT_DAY
!=
pKeep2
->
unit
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
}
int32_t
daysToKeep0
=
getBigintFromValueNode
(
pKeep0
);
int32_t
daysToKeep1
=
getBigintFromValueNode
(
pKeep1
);
int32_t
daysToKeep2
=
getBigintFromValueNode
(
pKeep2
);
if
(
daysToKeep0
<
TSDB_MIN_KEEP
||
daysToKeep1
<
TSDB_MIN_KEEP
||
daysToKeep2
<
TSDB_MIN_KEEP
||
daysToKeep0
>
TSDB_MAX_KEEP
||
daysToKeep1
>
TSDB_MAX_KEEP
||
daysToKeep2
>
TSDB_MAX_KEEP
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
...
...
@@ -1240,8 +1277,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
code
=
checkRangeOption
(
pCxt
,
"compression"
,
pOptions
->
pCompressionLevel
,
TSDB_MIN_COMP_LEVEL
,
TSDB_MAX_COMP_LEVEL
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"daysPerFile"
,
pOptions
->
pDaysPerFile
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
code
=
checkRangeOption
(
pCxt
,
"daysPerFile"
,
pOptions
->
pDaysPerFile
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"fsyncPeriod"
,
pOptions
->
pFsyncPeriod
,
TSDB_MIN_FSYNC_PERIOD
,
TSDB_MAX_FSYNC_PERIOD
);
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
ec643cee
...
...
@@ -62,35 +62,39 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL
:
return
"This interval value is too small : %s"
;
case
TSDB_CODE_PAR_DB_NOT_SPECIFIED
:
return
"
db
not specified"
;
return
"
Database
not specified"
;
case
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
:
return
"Invalid identifier name : %s"
;
case
TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR
:
return
"
c
orresponding super table not in this db"
;
return
"
C
orresponding super table not in this db"
;
case
TSDB_CODE_PAR_INVALID_RANGE_OPTION
:
return
"
i
nvalid option %s: %"
PRId64
" valid range: [%d, %d]"
;
return
"
I
nvalid option %s: %"
PRId64
" valid range: [%d, %d]"
;
case
TSDB_CODE_PAR_INVALID_STR_OPTION
:
return
"
i
nvalid option %s: %s"
;
return
"
I
nvalid option %s: %s"
;
case
TSDB_CODE_PAR_INVALID_ENUM_OPTION
:
return
"
i
nvalid option %s: %"
PRId64
", only %d, %d allowed"
;
return
"
I
nvalid option %s: %"
PRId64
", only %d, %d allowed"
;
case
TSDB_CODE_PAR_INVALID_TTL_OPTION
:
return
"
i
nvalid option ttl: %"
PRId64
", should be greater than or equal to %d"
;
return
"
I
nvalid option ttl: %"
PRId64
", should be greater than or equal to %d"
;
case
TSDB_CODE_PAR_INVALID_KEEP_NUM
:
return
"
i
nvalid number of keep options"
;
return
"
I
nvalid number of keep options"
;
case
TSDB_CODE_PAR_INVALID_KEEP_ORDER
:
return
"
i
nvalid keep value, should be keep0 <= keep1 <= keep2"
;
return
"
I
nvalid keep value, should be keep0 <= keep1 <= keep2"
;
case
TSDB_CODE_PAR_INVALID_KEEP_VALUE
:
return
"
i
nvalid option keep: %d, %d, %d valid range: [%d, %d]"
;
return
"
I
nvalid option keep: %d, %d, %d valid range: [%d, %d]"
;
case
TSDB_CODE_PAR_INVALID_COMMENT_OPTION
:
return
"
i
nvalid option comment, length cannot exceed %d"
;
return
"
I
nvalid option comment, length cannot exceed %d"
;
case
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
:
return
"
i
nvalid option %s: %f valid range: [%d, %d]"
;
return
"
I
nvalid option %s: %f valid range: [%d, %d]"
;
case
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
:
return
"
i
nvalid option rollup: only one function is allowed"
;
return
"
I
nvalid option rollup: only one function is allowed"
;
case
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
:
return
"
i
nvalid option retentions"
;
return
"
I
nvalid option retentions"
;
case
TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST
:
return
"GROUP BY and WINDOW-clause can't be used together"
;
case
TSDB_CODE_PAR_INVALID_OPTION_UNIT
:
return
"Invalid option %s unit: %c, only m, h, d allowed"
;
case
TSDB_CODE_PAR_INVALID_KEEP_UNIT
:
return
"Invalid option keep unit: %c, %c, %c, only m, h, d allowed"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
default:
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
ec643cee
...
...
@@ -226,6 +226,16 @@ TEST_F(ParserTest, selectExpression) {
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
selectCondition
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT c1 FROM t1 where ts in (true, false)"
);
ASSERT_TRUE
(
run
());
bind
(
"SELECT * FROM t1 where c1 > 10 and c1 is not null"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
selectPseudoColumn
)
{
setDatabase
(
"root"
,
"test"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录