Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
75fdd8b8
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看板
未验证
提交
75fdd8b8
编写于
8月 10, 2021
作者:
D
dapan1121
提交者:
GitHub
8月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7252 from taosdata/fix/TD-5578
[TD-5578]<fix> add show like wild cards max length
上级
0d51e50b
dd2c83fc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
238 addition
and
3 deletion
+238
-3
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-3
tests/pytest/query/queryWildcardLength.py
tests/pytest/query/queryWildcardLength.py
+217
-0
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+16
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
75fdd8b8
...
@@ -3222,7 +3222,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -3222,7 +3222,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd
->
command
=
TSDB_SQL_SHOW
;
pCmd
->
command
=
TSDB_SQL_SHOW
;
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg2
=
"
pattern filter string too long
"
;
const
char
*
msg2
=
"
wildcard string should be less than %d characters
"
;
const
char
*
msg3
=
"database name too long"
;
const
char
*
msg3
=
"database name too long"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
...
@@ -3265,8 +3265,10 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -3265,8 +3265,10 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
if
(
!
tscValidateTableNameLength
(
pCmd
->
payloadLen
))
{
if
(
pPattern
->
n
>
tsMaxWildCardsLen
){
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
char
tmp
[
64
]
=
{
0
};
sprintf
(
tmp
,
msg2
,
tsMaxWildCardsLen
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
tmp
);
}
}
}
}
}
else
if
(
showType
==
TSDB_MGMT_TABLE_VNODES
)
{
}
else
if
(
showType
==
TSDB_MGMT_TABLE_VNODES
)
{
...
...
tests/pytest/query/queryWildcardLength.py
0 → 100644
浏览文件 @
75fdd8b8
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from
copy
import
deepcopy
import
string
import
random
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
cleanTb
(
self
):
query_sql
=
"show stables"
res_row_list
=
tdSql
.
query
(
query_sql
,
True
)
stb_list
=
map
(
lambda
x
:
x
[
0
],
res_row_list
)
for
stb
in
stb_list
:
tdSql
.
execute
(
f
'drop table if exists
{
stb
}
'
)
query_sql
=
"show tables"
res_row_list
=
tdSql
.
query
(
query_sql
,
True
)
tb_list
=
map
(
lambda
x
:
x
[
0
],
res_row_list
)
for
tb
in
tb_list
:
tdSql
.
execute
(
f
'drop table if exists
{
tb
}
'
)
def
getLongWildcardStr
(
self
,
len
=
None
):
"""
generate long wildcard str
"""
maxWildCardsLength
=
int
(
tdSql
.
getVariable
(
'maxWildCardsLength'
)[
0
])
if
len
:
chars
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
.
lower
())
for
i
in
range
(
len
))
else
:
chars
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
.
lower
())
for
i
in
range
(
maxWildCardsLength
+
1
))
return
chars
def
genTableName
(
self
):
'''
generate table name
hp_name--->'%str'
lp_name--->'str%'
ul_name--->'st_r'
'''
table_name
=
self
.
getLongWildcardStr
()
table_name_list
=
list
(
table_name
)
table_name_list
.
pop
(
-
1
)
if
len
(
table_name_list
)
>
1
:
lp_name
=
deepcopy
(
table_name_list
)
lp_name
[
-
1
]
=
'%'
lp_name
=
''
.
join
(
lp_name
)
ul_name
=
list
(
lp_name
)
ul_name
[
int
(
len
(
ul_name
)
/
2
)]
=
'_'
ul_name
=
''
.
join
(
ul_name
)
table_name_list
=
list
(
table_name
)
hp_name
=
deepcopy
(
table_name_list
)
hp_name
.
pop
(
1
)
hp_name
[
0
]
=
'%'
hp_name
=
''
.
join
(
hp_name
)
else
:
hp_name
=
'%'
lp_name
=
'%'
ul_name
=
'_'
return
table_name
,
hp_name
,
lp_name
,
ul_name
def
checkRegularTableWildcardLength
(
self
):
'''
check regular table wildcard length with % and _
'''
self
.
cleanTb
()
table_name
,
hp_name
,
lp_name
,
ul_name
=
self
.
genTableName
()
tdSql
.
execute
(
f
"CREATE TABLE
{
table_name
}
(ts timestamp, a1 int)"
)
sql_list
=
[
f
'show tables like "
{
hp_name
}
"'
,
f
'show tables like "
{
lp_name
}
"'
,
f
'show tables like "
{
ul_name
}
"'
]
for
sql
in
sql_list
:
tdSql
.
query
(
sql
)
if
len
(
table_name
)
>=
1
:
tdSql
.
checkRows
(
1
)
else
:
tdSql
.
error
(
sql
)
exceed_sql_list
=
[
f
'show tables like "%
{
hp_name
}
"'
,
f
'show tables like "
{
lp_name
}
%"'
,
f
'show tables like "
{
ul_name
}
%"'
]
for
sql
in
exceed_sql_list
:
tdSql
.
error
(
sql
)
def
checkSuperTableWildcardLength
(
self
):
'''
check super table wildcard length with % and _
'''
self
.
cleanTb
()
table_name
,
hp_name
,
lp_name
,
ul_name
=
self
.
genTableName
()
tdSql
.
execute
(
f
"CREATE TABLE
{
table_name
}
(ts timestamp, c1 int) tags (t1 int)"
)
sql_list
=
[
f
'show stables like "
{
hp_name
}
"'
,
f
'show stables like "
{
lp_name
}
"'
,
f
'show stables like "
{
ul_name
}
"'
]
for
sql
in
sql_list
:
tdSql
.
query
(
sql
)
if
len
(
table_name
)
>=
1
:
tdSql
.
checkRows
(
1
)
else
:
tdSql
.
error
(
sql
)
exceed_sql_list
=
[
f
'show stables like "%
{
hp_name
}
"'
,
f
'show stables like "
{
lp_name
}
%"'
,
f
'show stables like "
{
ul_name
}
%"'
]
for
sql
in
exceed_sql_list
:
tdSql
.
error
(
sql
)
def
checkRegularWildcardSelectLength
(
self
):
'''
check regular table wildcard select length with % and _
'''
self
.
cleanTb
()
table_name
,
hp_name
,
lp_name
,
ul_name
=
self
.
genTableName
()
tdSql
.
execute
(
f
"CREATE TABLE
{
table_name
}
(ts timestamp, bi1 binary(200), nc1 nchar(200))"
)
tdSql
.
execute
(
f
'insert into
{
table_name
}
values (now, "
{
table_name
}
", "
{
table_name
}
")'
)
sql_list
=
[
f
'select * from
{
table_name
}
where bi1 like "
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
lp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
ul_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
lp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
ul_name
}
"'
]
for
sql
in
sql_list
:
tdSql
.
query
(
sql
)
if
len
(
table_name
)
>=
1
:
tdSql
.
checkRows
(
1
)
else
:
tdSql
.
error
(
sql
)
exceed_sql_list
=
[
f
'select * from
{
table_name
}
where bi1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
ul_name
}
%"'
,
f
'select * from
{
table_name
}
where nc1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
ul_name
}
%"'
]
for
sql
in
exceed_sql_list
:
tdSql
.
error
(
sql
)
def
checkStbWildcardSelectLength
(
self
):
'''
check stb wildcard select length with % and _
'''
self
.
cleanTb
()
table_name
,
hp_name
,
lp_name
,
ul_name
=
self
.
genTableName
()
tdSql
.
execute
(
f
'CREATE TABLE
{
table_name
}
(ts timestamp, bi1 binary(200), nc1 nchar(200)) tags (si1 binary(200), sc1 nchar(200))'
)
tdSql
.
execute
(
f
'create table
{
table_name
}
_sub1 using
{
table_name
}
tags ("
{
table_name
}
", "
{
table_name
}
")'
)
tdSql
.
execute
(
f
'insert into
{
table_name
}
_sub1 values (now, "
{
table_name
}
", "
{
table_name
}
");'
)
# TODO sc1 leave a bug ---> TD-5918
# sql_list = [f'select * from {table_name} where bi1 like "{hp_name}"',
# f'select * from {table_name} where bi1 like "{lp_name}"',
# f'select * from {table_name} where bi1 like "{ul_name}"',
# f'select * from {table_name} where nc1 like "{hp_name}"',
# f'select * from {table_name} where nc1 like "{lp_name}"',
# f'select * from {table_name} where nc1 like "{ul_name}"',
# f'select * from {table_name} where si1 like "{hp_name}"',
# f'select * from {table_name} where si1 like "{lp_name}"',
# f'select * from {table_name} where si1 like "{ul_name}"',
# f'select * from {table_name} where sc1 like "{hp_name}"',
# f'select * from {table_name} where sc1 like "{lp_name}"',
# f'select * from {table_name} where sc1 like "{ul_name}"']
sql_list
=
[
f
'select * from
{
table_name
}
where bi1 like "
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
lp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
ul_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
lp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
ul_name
}
"'
,
f
'select * from
{
table_name
}
where si1 like "
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where si1 like "
{
lp_name
}
"'
,
f
'select * from
{
table_name
}
where si1 like "
{
ul_name
}
"'
]
for
sql
in
sql_list
:
tdSql
.
query
(
sql
)
if
len
(
table_name
)
>=
1
:
tdSql
.
checkRows
(
1
)
else
:
tdSql
.
error
(
sql
)
exceed_sql_list
=
[
f
'select * from
{
table_name
}
where bi1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where bi1 like "
{
ul_name
}
%"'
,
f
'select * from
{
table_name
}
where nc1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where nc1 like "
{
ul_name
}
%"'
,
f
'select * from
{
table_name
}
where si1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where si1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where si1 like "
{
ul_name
}
%"'
,
f
'select * from
{
table_name
}
where sc1 like "%
{
hp_name
}
"'
,
f
'select * from
{
table_name
}
where sc1 like "
{
lp_name
}
%"'
,
f
'select * from
{
table_name
}
where sc1 like "
{
ul_name
}
%"'
]
for
sql
in
exceed_sql_list
:
tdSql
.
error
(
sql
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
checkRegularTableWildcardLength
()
self
.
checkSuperTableWildcardLength
()
self
.
checkRegularWildcardSelectLength
()
self
.
checkStbWildcardSelectLength
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/util/sql.py
浏览文件 @
75fdd8b8
...
@@ -81,6 +81,22 @@ class TDSql:
...
@@ -81,6 +81,22 @@ class TDSql:
return
self
.
queryResult
return
self
.
queryResult
return
self
.
queryRows
return
self
.
queryRows
def
getVariable
(
self
,
search_attr
):
'''
get variable of search_attr access "show variables"
'''
try
:
sql
=
'show variables'
param_list
=
self
.
query
(
sql
,
row_tag
=
True
)
for
param
in
param_list
:
if
param
[
0
]
==
search_attr
:
return
param
[
1
],
param_list
except
Exception
as
e
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
sql
,
repr
(
e
))
tdLog
.
notice
(
"%s(%d) failed: sql:%s, %s"
%
args
)
raise
Exception
(
repr
(
e
))
def
getColNameList
(
self
,
sql
,
col_tag
=
None
):
def
getColNameList
(
self
,
sql
,
col_tag
=
None
):
self
.
sql
=
sql
self
.
sql
=
sql
try
:
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录