Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed834ce8
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看板
未验证
提交
ed834ce8
编写于
1月 12, 2022
作者:
D
dapan1121
提交者:
GitHub
1月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9746 from taosdata/feature/TD-12252-new
[TD-12252]<feature>(connector,query,insert,other,tools,taosAdapter):d…
上级
67e9d380
bc9031bd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
28 deletion
+64
-28
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-12
tests/develop-test/2-query/escape.py
tests/develop-test/2-query/escape.py
+60
-14
tests/pytest/query/queryRegex.py
tests/pytest/query/queryRegex.py
+2
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
ed834ce8
...
...
@@ -5046,20 +5046,10 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
regex_t
regex
;
char
regErrBuf
[
256
]
=
{
0
};
//remove the quote at the begin end of original sql string.
uint32_t
lenPattern
=
pRight
->
exprToken
.
n
-
2
;
char
*
pattern
=
malloc
(
lenPattern
+
1
);
strncpy
(
pattern
,
pRight
->
exprToken
.
z
+
1
,
lenPattern
);
pattern
[
lenPattern
]
=
'\0'
;
tfree
(
pRight
->
value
.
pz
);
pRight
->
value
.
pz
=
pattern
;
pRight
->
value
.
nLen
=
lenPattern
;
int
cflags
=
REG_EXTENDED
;
if
((
errCode
=
regcomp
(
&
regex
,
p
attern
,
cflags
))
!=
0
)
{
if
((
errCode
=
regcomp
(
&
regex
,
p
Right
->
value
.
pz
,
cflags
))
!=
0
)
{
regerror
(
errCode
,
&
regex
,
regErrBuf
,
sizeof
(
regErrBuf
));
tscError
(
"Failed to compile regex pattern %s. reason %s"
,
p
attern
,
regErrBuf
);
tscError
(
"Failed to compile regex pattern %s. reason %s"
,
p
Right
->
value
.
pz
,
regErrBuf
);
return
invalidOperationMsg
(
msgBuf
,
msg3
);
}
regfree
(
&
regex
);
...
...
tests/develop-test/2-query/escape.py
浏览文件 @
ed834ce8
...
...
@@ -60,6 +60,10 @@ class TDTestCase:
tdSql
.
query
(
r
'show tables like "zz\\ "'
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
r
"insert into `zz\\ ` values(1591060658000, 1)"
)
tdSql
.
query
(
r
'select * from `zz\\ `'
)
tdSql
.
checkRows
(
1
)
# [TD-11071]
tdSql
.
execute
(
'create table es (ts timestamp, s int) tags(j int)'
)
tdSql
.
execute
(
r
'create table `zz\t` using es tags(11)'
)
...
...
@@ -73,45 +77,87 @@ class TDTestCase:
tdSql
.
checkData
(
3
,
0
,
r
' '
)
# [TD-6232]
tdSql
.
execute
(
'create table tt(ts timestamp, i
nchar(128))'
)
tdSql
.
execute
(
r
'create table tt(ts timestamp, `i\t`
nchar(128))'
)
tdSql
.
execute
(
r
"insert into tt values(1591060628000, '\t')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060638000, '\n')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060648000, '\r')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060658000, '\\')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060658000, '\\
t
')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060668000, '\"')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060678000, '\'')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060688000, '\%')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060688100, '\\%')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060688200, '\\\%')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060698000, '\_')"
)
tdSql
.
execute
(
r
"insert into tt values(1591060708000, '\9')"
)
tdSql
.
query
(
r
"select * from tt where
i
='\t'"
)
tdSql
.
query
(
r
"select * from tt where
`i\t`
='\t'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where
i
='\n'"
)
tdSql
.
query
(
r
"select * from tt where
`i\t`
='\n'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where
i
='\r'"
)
tdSql
.
query
(
r
"select * from tt where
`i\t`
='\r'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where i='\\'"
)
tdSql
.
checkData
(
0
,
1
,
'
\r
'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\\t'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where i='\"'"
)
tdSql
.
checkData
(
0
,
1
,
r
'\t'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\"'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where
i
='\''"
)
tdSql
.
query
(
r
"select * from tt where
`i\t`
='\''"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where i='\%'"
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\%'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
r
'\%'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\\%'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
r
'\%'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\\\%'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where i='\_'"
)
tdSql
.
checkData
(
0
,
1
,
r
'\\%'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\_'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where i='\9'"
)
tdSql
.
checkData
(
0
,
1
,
r
'\_'
)
tdSql
.
query
(
r
"select * from tt where `i\t`='\9'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where
i
='9'"
)
tdSql
.
query
(
r
"select * from tt where
`i\t`
='9'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
r
'create table tb(ts timestamp, `i\t` binary(128))'
)
tdSql
.
execute
(
r
"insert into tb values(1591060628000, '\t')"
)
tdSql
.
query
(
r
"select * from tb where `i\t`='\t'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
r
"insert into tb values(1591060629000, '\\%')"
)
tdSql
.
query
(
r
"select * from tb where `i\t`='\%'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
r
'\%'
)
# [TD-12815] like wildcard(%, _) are not supported nchar
tdSql
.
execute
(
r
"insert into tt values(1591070708000, 'h%d')"
)
tdSql
.
execute
(
r
"insert into tt values(1591080708000, 'h_j')"
)
tdSql
.
query
(
r
"select * from tt where i like 'h\%d'"
)
tdSql
.
execute
(
r
"insert into tt values(1591090708000, 'h\\j')"
)
tdSql
.
query
(
r
"select * from tt where `i\t` like 'h\%d'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where `i\t` like 'h\_j'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where `i\t` like 'h\\j'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
r
"select * from tt where
i like 'h\_
j'"
)
tdSql
.
query
(
r
"select * from tt where
`i\t` match 'h\\\\
j'"
)
tdSql
.
checkRows
(
1
)
# normal test
tdSql
.
error
(
r
"select * from tt where i\t='\t'"
)
tdSql
.
error
(
r
"select * from zz\t where s=1"
)
tdSql
.
error
(
r
"select i\t from tt where `i\t`='\t'"
)
tdSql
.
execute
(
r
'create table `\n`(ts timestamp, `i\"` nchar(128))'
)
tdSql
.
execute
(
r
"insert into `\n` values(1591060708000, 'js')"
)
tdSql
.
query
(
r
"select `i\"` from `\n` where `i\"`='js'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'js'
)
tdSql
.
query
(
r
'show tables like "\\n"'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
r
"\n"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/pytest/query/queryRegex.py
浏览文件 @
ed834ce8
...
...
@@ -92,10 +92,10 @@ class TDTestCase:
tdSql
.
error
(
'select * from stb_test where c0 nmatch abc'
)
tdSql
.
query
(
"select * from stb_1 where c0 match '
\\\\
'"
)
tdSql
.
query
(
r
"select * from stb_1 where c0 match '\\\\'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from stb_1 where c0 nmatch '
\\\\
'"
)
tdSql
.
query
(
r
"select * from stb_1 where c0 nmatch '\\\\'"
)
tdSql
.
checkRows
(
3
)
#2021-10-20 for https://jira.taosdata.com:18080/browse/TD-10708
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录