Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4f8f083a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
未验证
提交
4f8f083a
编写于
12月 21, 2021
作者:
M
Minglei Jin
提交者:
GitHub
12月 21, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9149 from taosdata/fix/TS-821-dev
[TS-821]<fix>: fixed bug that 'like' worked imporperly in Windows
上级
db527014
81d13772
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
10 deletion
+86
-10
src/query/src/qFilterfunc.c
src/query/src/qFilterfunc.c
+1
-1
src/util/inc/tcompare.h
src/util/inc/tcompare.h
+1
-1
src/util/src/tcompare.c
src/util/src/tcompare.c
+73
-8
tests/pytest/query/queryLike.py
tests/pytest/query/queryLike.py
+11
-0
未找到文件。
src/query/src/qFilterfunc.c
浏览文件 @
4f8f083a
...
...
@@ -183,7 +183,7 @@ bool likeOperator(SColumnFilterElem *pFilter, const char *minval, const char *ma
return
patternMatch
((
char
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
),
&
info
)
==
TSDB_PATTERN_MATCH
;
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
return
WCSPatternMatch
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
,
&
info
)
==
TSDB_PATTERN_MATCH
;
return
WCSPatternMatch
((
uint32_t
*
)
pFilter
->
filterInfo
.
pz
,
(
uint32_t
*
)
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
,
&
info
)
==
TSDB_PATTERN_MATCH
;
}
else
{
return
false
;
}
...
...
src/util/inc/tcompare.h
浏览文件 @
4f8f083a
...
...
@@ -44,7 +44,7 @@ typedef struct SPatternCompareInfo {
int
patternMatch
(
const
char
*
pattern
,
const
char
*
str
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int
WCSPatternMatch
(
const
wchar_t
*
pattern
,
const
wchar
_t
*
str
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int
WCSPatternMatch
(
const
uint32_t
*
pattern
,
const
uint32
_t
*
str
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int32_t
doCompare
(
const
char
*
a
,
const
char
*
b
,
int32_t
type
,
size_t
size
);
...
...
src/util/src/tcompare.c
浏览文件 @
4f8f083a
...
...
@@ -321,29 +321,94 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
return
(
str
[
j
]
==
0
||
j
>=
size
)
?
TSDB_PATTERN_MATCH
:
TSDB_PATTERN_NOMATCH
;
}
int
WCSPatternMatch
(
const
wchar_t
*
patterStr
,
const
wchar_t
*
str
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
)
{
wchar_t
c
,
c1
;
wchar_t
matchOne
=
L'_'
;
// "_"
wchar_t
matchAll
=
L'%'
;
// "%"
static
uint32_t
*
taosWcschr
(
const
uint32_t
*
wcs
,
const
uint32_t
wc
)
{
const
uint32_t
*
wcs2
=
wcs
+
1
;
if
(
*
wcs
==
wc
)
return
(
uint32_t
*
)
wcs
;
if
(
*
wcs
==
L'\0'
)
return
NULL
;
do
{
wcs
+=
2
;
if
(
*
wcs2
==
wc
)
return
(
uint32_t
*
)
wcs2
;
if
(
*
wcs2
==
L'\0'
)
return
NULL
;
wcs2
+=
2
;
if
(
*
wcs
==
wc
)
return
(
uint32_t
*
)
wcs
;
if
(
*
wcs
==
L'\0'
)
return
NULL
;
wcs
+=
2
;
if
(
*
wcs2
==
wc
)
return
(
uint32_t
*
)
wcs2
;
if
(
*
wcs2
==
L'\0'
)
return
NULL
;
wcs2
+=
2
;
if
(
*
wcs
==
wc
)
return
(
uint32_t
*
)
wcs
;
if
(
*
wcs
==
L'\0'
)
return
NULL
;
wcs
+=
2
;
if
(
*
wcs2
==
wc
)
return
(
uint32_t
*
)
wcs2
;
if
(
*
wcs2
==
L'\0'
)
return
NULL
;
wcs2
+=
2
;
if
(
*
wcs
==
wc
)
return
(
uint32_t
*
)
wcs
;
if
(
*
wcs
==
L'\0'
)
return
NULL
;
wcs
+=
2
;
if
(
*
wcs2
==
wc
)
return
(
uint32_t
*
)
wcs2
;
if
(
*
wcs2
==
L'\0'
)
return
NULL
;
wcs2
+=
2
;
if
(
*
wcs
==
wc
)
return
(
uint32_t
*
)
wcs
;
}
while
(
*
wcs
!=
L'\0'
);
return
NULL
;
}
static
size_t
taosWcscspn
(
const
uint32_t
*
wcs
,
const
uint32_t
*
reject
)
{
size_t
count
=
0
;
while
(
*
wcs
!=
L'\0'
)
if
(
taosWcschr
(
reject
,
*
wcs
++
)
==
NULL
)
++
count
;
else
return
count
;
return
count
;
}
int
WCSPatternMatch
(
const
uint32_t
*
patterStr
,
const
uint32_t
*
str
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
)
{
uint32_t
c
,
c1
;
uint32_t
matchOne
=
(
uint32_t
)
L'_'
;
// "_"
uint32_t
matchAll
=
(
uint32_t
)
L'%'
;
// "%"
int32_t
i
=
0
;
int32_t
j
=
0
;
while
((
c
=
patterStr
[
i
++
])
!=
0
)
{
if
(
c
==
matchAll
)
{
/* Match "%" */
while
((
c
=
patterStr
[
i
++
])
==
matchAll
||
c
==
matchOne
)
{
if
(
c
==
matchOne
&&
(
j
>=
size
||
str
[
j
++
]
==
0
))
{
return
TSDB_PATTERN_NOWILDCARDMATCH
;
}
}
if
(
c
==
0
)
{
return
TSDB_PATTERN_MATCH
;
}
wchar
_t
accept
[
3
]
=
{
towupper
(
c
),
towlower
(
c
),
0
};
uint32
_t
accept
[
3
]
=
{
towupper
(
c
),
towlower
(
c
),
0
};
while
(
1
)
{
size_t
n
=
w
cscspn
(
str
,
accept
);
size_t
n
=
taosW
cscspn
(
str
,
accept
);
str
+=
n
;
if
(
str
[
0
]
==
0
||
(
n
>=
size
))
{
...
...
@@ -465,7 +530,7 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
memcpy
(
pattern
,
varDataVal
(
pRight
),
varDataLen
(
pRight
));
memcpy
(
str
,
varDataVal
(
pLeft
),
size
*
sizeof
(
wchar_t
));
int32_t
ret
=
WCSPatternMatch
(
pattern
,
str
,
size
,
&
pInfo
);
int32_t
ret
=
WCSPatternMatch
(
(
uint32_t
*
)
pattern
,
(
uint32_t
*
)
str
,
size
,
&
pInfo
);
free
(
pattern
);
free
(
str
);
...
...
tests/pytest/query/queryLike.py
浏览文件 @
4f8f083a
...
...
@@ -161,6 +161,17 @@ class TDTestCase:
tdSql
.
query
(
"select * from st where tagg like 'tag\_\__\_';"
)
tdSql
.
checkData
(
0
,
0
,
"tag__a_"
)
tdSql
.
execute
(
"create table stb(ts timestamp, c0 int) tags(t0 nchar(64))"
)
tdSql
.
execute
(
"insert into tb1 using stb tags('测试ABCabc') values(now, 1)"
)
tdSql
.
query
(
"select * from tb1 where t0 like '%试AB%'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb1 where t0 like '测试AB%'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb1 where t0 like '%ABCabc'"
)
tdSql
.
checkRows
(
1
)
os
.
system
(
"rm -rf ./*.py.sql"
)
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录