Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bf15479f
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看板
未验证
提交
bf15479f
编写于
10月 29, 2021
作者:
D
dapan1121
提交者:
GitHub
10月 29, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8441 from taosdata/feature/TD-10708
Feature/td 10708 regex match support for nchar
上级
caf902e9
d9ff802e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
17 deletion
+61
-17
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+0
-7
src/query/src/qFilter.c
src/query/src/qFilter.c
+29
-3
tests/pytest/query/queryRegex.py
tests/pytest/query/queryRegex.py
+32
-7
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
bf15479f
...
...
@@ -4523,10 +4523,8 @@ static int32_t validateLikeExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t
// check for match expression
static
int32_t
validateMatchExpr
(
tSqlExpr
*
pExpr
,
STableMeta
*
pTableMeta
,
int32_t
index
,
char
*
msgBuf
)
{
const
char
*
msg1
=
"regular expression string should be less than %d characters"
;
const
char
*
msg2
=
"illegal column type for match/nmatch"
;
const
char
*
msg3
=
"invalid regular expression"
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pExpr
->
tokenId
==
TK_MATCH
||
pExpr
->
tokenId
==
TK_NMATCH
)
{
...
...
@@ -4536,11 +4534,6 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
return
invalidOperationMsg
(
msgBuf
,
tmp
);
}
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
if
((
!
isTablenameToken
(
&
pLeft
->
columnName
))
&&
(
pSchema
[
index
].
type
!=
TSDB_DATA_TYPE_BINARY
))
{
return
invalidOperationMsg
(
msgBuf
,
msg2
);
}
if
(
!
(
pRight
->
type
==
SQL_NODE_VALUE
&&
pRight
->
value
.
nType
==
TSDB_DATA_TYPE_BINARY
))
{
return
invalidOperationMsg
(
msgBuf
,
msg3
);
}
...
...
src/query/src/qFilter.c
浏览文件 @
bf15479f
...
...
@@ -1841,6 +1841,15 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
qError
(
"dump value to type[%d] failed"
,
type
);
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
// match/nmatch for nchar type need convert from ucs4 to mbs
if
(
type
==
TSDB_DATA_TYPE_NCHAR
&&
(
unit
->
compare
.
optr
==
TSDB_RELATION_MATCH
||
unit
->
compare
.
optr
==
TSDB_RELATION_NMATCH
)){
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
len
=
taosUcs4ToMbs
(
varDataVal
(
fi
->
data
),
varDataLen
(
fi
->
data
),
varDataVal
(
newValData
));
varDataSetLen
(
newValData
,
len
);
varDataCopy
(
fi
->
data
,
newValData
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2960,9 +2969,18 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
all
=
false
;
continue
;
}
// match/nmatch for nchar type need convert from ucs4 to mbs
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_MATCH
||
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_NMATCH
)){
char
*
newColData
=
calloc
(
info
->
cunits
[
uidx
].
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int
len
=
taosUcs4ToMbs
(
varDataVal
(
colData
),
varDataLen
(
colData
),
varDataVal
(
newColData
));
varDataSetLen
(
newColData
,
len
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
newColData
,
info
->
cunits
[
uidx
].
valData
);
tfree
(
newColData
);
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
}
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
}
...
...
@@ -3009,7 +3027,15 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
}
else
if
(
cunit
->
rfunc
>=
0
)
{
(
*
p
)[
i
]
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
colData
,
colData
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]);
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION_NMATCH
)){
char
*
newColData
=
calloc
(
cunit
->
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int
len
=
taosUcs4ToMbs
(
varDataVal
(
colData
),
varDataLen
(
colData
),
varDataVal
(
newColData
));
varDataSetLen
(
newColData
,
len
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
cunit
->
valData
);
tfree
(
newColData
);
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
}
//FILTER_UNIT_SET_R(info, uidx, p[i]);
...
...
tests/pytest/query/queryRegex.py
浏览文件 @
bf15479f
...
...
@@ -29,18 +29,18 @@ class TDTestCase:
print
(
"==============step1"
)
##2021-09-17 For jira: https://jira.taosdata.com:18080/browse/TD-6585
tdSql
.
execute
(
"create stable if not exists stb_test(ts timestamp,c0 binary(32),c1 int
) tags(t0 binary(32
))"
"create stable if not exists stb_test(ts timestamp,c0 binary(32),c1 int
,c2 nchar(50)) tags(t0 binary(32),t1 nchar(50
))"
)
tdSql
.
execute
(
'create table if not exists stb_1 using stb_test tags("abcdefgasdfg12346")'
'create table if not exists stb_1 using stb_test tags("abcdefgasdfg12346"
,"涛思数据"
)'
)
tdLog
.
info
(
'insert into stb_1 values("2021-09-13 10:00:00.001","abcefdasdqwerxasdazx12345",15'
)
tdLog
.
info
(
'insert into stb_1 values("2021-09-13 10:00:00.001","abcefdasdqwerxasdazx12345",15
,"引擎一组"
'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.002","abcefdasdqwerxasdazx12345",15)'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.003","aaaaafffwwqqxzz",16)'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.004","fffwwqqxzz",17)'
)
tdSql
.
execute
(
'insert into stb_1 values("2020-10-13 10:00:00.001","abcd
\\
\efgh",100)'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.002","abcefdasdqwerxasdazx12345",15
,"引擎一组一号"
)'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.003","aaaaafffwwqqxzz",16
,"引擎一组二号"
)'
)
tdSql
.
execute
(
'insert into stb_1 values("2021-09-13 10:00:00.004","fffwwqqxzz",17
,"涛涛思思"
)'
)
tdSql
.
execute
(
'insert into stb_1 values("2020-10-13 10:00:00.001","abcd
\\
\efgh",100
,"思涛思"
)'
)
tdSql
.
query
(
'select * from stb_test where tbname match "asd"'
)
tdSql
.
checkRows
(
0
)
...
...
@@ -98,6 +98,31 @@ class TDTestCase:
tdSql
.
query
(
"select * from stb_1 where c0 nmatch '
\\\\
'"
)
tdSql
.
checkRows
(
3
)
#2021-10-20 for https://jira.taosdata.com:18080/browse/TD-10708
tdSql
.
query
(
'select * from stb_1 where c2 match "^涛"'
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
'select * from stb_1 where c2 nmatch "^涛"'
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
'select * from stb_1 where c2 match "号$"'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select * from stb_1 where c2 nmatch "号$"'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select * from stb_1 where c2 match "涛+思"'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select * from stb_1 where c2 nmatch "涛+思"'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select * from stb_1 where c2 match "涛*思"'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select * from stb_1 where c2 nmatch "涛*思"'
)
tdSql
.
checkRows
(
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录