Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
6cef55cc
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6cef55cc
编写于
4月 01, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]fix bug found in regression test.
上级
5fe62829
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
22 deletion
+46
-22
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+46
-22
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
6cef55cc
...
...
@@ -3728,6 +3728,39 @@ static int32_t setExprToCond(tSqlExpr** parent, tSqlExpr* pExpr, const char* msg
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
validateNullExpr
(
tSqlExpr
*
pExpr
,
char
*
msgBuf
)
{
const
char
*
msg
=
"only support is [not] null"
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pRight
->
tokenId
==
TK_NULL
&&
(
!
(
pExpr
->
tokenId
==
TK_ISNULL
||
pExpr
->
tokenId
==
TK_NOTNULL
)))
{
return
invalidSqlErrMsg
(
msgBuf
,
msg
);
}
return
TSDB_CODE_SUCCESS
;
}
// check for like expression
static
int32_t
validateLikeExpr
(
tSqlExpr
*
pExpr
,
STableMeta
*
pTableMeta
,
int32_t
index
,
char
*
msgBuf
)
{
const
char
*
msg1
=
"wildcard string should be less than 20 characters"
;
const
char
*
msg2
=
"illegal column name"
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pExpr
->
tokenId
==
TK_LIKE
)
{
if
(
pRight
->
value
.
nLen
>
TSDB_PATTERN_STRING_MAX_LEN
)
{
return
invalidSqlErrMsg
(
msgBuf
,
msg1
);
}
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
if
((
!
isTablenameToken
(
&
pLeft
->
colInfo
))
&&
!
IS_VAR_DATA_TYPE
(
pSchema
[
index
].
type
))
{
return
invalidSqlErrMsg
(
msgBuf
,
msg2
);
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
handleExprInQueryCond
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pExpr
,
SCondExpr
*
pCondExpr
,
int32_t
*
type
,
int32_t
parentOptr
)
{
const
char
*
msg1
=
"table query cannot use tags filter"
;
...
...
@@ -3737,8 +3770,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
const
char
*
msg5
=
"not support ordinary column join"
;
const
char
*
msg6
=
"only one query condition on tbname allowed"
;
const
char
*
msg7
=
"only in/like allowed in filter table name"
;
const
char
*
msg8
=
"wildcard string should be less than 20 characters"
;
const
char
*
msg9
=
"only support is [not] null"
;
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
tSqlExpr
*
pRight
=
(
*
pExpr
)
->
pRight
;
...
...
@@ -3755,6 +3786,18 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
// validate the null expression
int32_t
code
=
validateNullExpr
(
*
pExpr
,
tscGetErrorMsgPayload
(
pCmd
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// validate the like expression
code
=
validateLikeExpr
(
*
pExpr
,
pTableMeta
,
index
.
columnIndex
,
tscGetErrorMsgPayload
(
pCmd
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
if
(
!
validateJoinExprNode
(
pCmd
,
pQueryInfo
,
*
pExpr
,
&
index
))
{
return
TSDB_CODE_TSC_INVALID_SQL
;
...
...
@@ -3776,7 +3819,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
int16_t
leftIdx
=
index
.
tableIndex
;
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
(
getColumnIndexByName
(
pCmd
,
&
pRight
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -3823,20 +3865,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
// check for like expression
if
((
*
pExpr
)
->
tokenId
==
TK_LIKE
)
{
if
(
pRight
->
value
.
nLen
>
TSDB_PATTERN_STRING_MAX_LEN
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg8
);
}
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
if
((
!
isTablenameToken
(
&
pLeft
->
colInfo
))
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_BINARY
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
// in case of in operator, keep it in a seprate attribute
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
!
validTableNameOptr
(
*
pExpr
))
{
...
...
@@ -3882,10 +3910,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
if
(
pRight
->
tokenId
==
TK_NULL
&&
(
!
((
*
pExpr
)
->
tokenId
==
TK_ISNULL
||
(
*
pExpr
)
->
tokenId
==
TK_NOTNULL
)))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg9
);
}
ret
=
setExprToCond
(
&
pCondExpr
->
pColumnCond
,
*
pExpr
,
NULL
,
parentOptr
,
pQueryInfo
->
msg
);
*
pExpr
=
NULL
;
// remove it from expr tree
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录