Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b298cb83
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
b298cb83
编写于
3月 22, 2023
作者:
D
dapan1121
提交者:
GitHub
3月 22, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20565 from taosdata/szhou/fix-ts2936
enhance: add max query time range limit to taosc
上级
d37c1fc5
257353e2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
109 addition
and
4 deletion
+109
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+20
-0
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+14
-0
src/inc/taoserror.h
src/inc/taoserror.h
+1
-1
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
src/util/src/terror.c
src/util/src/terror.c
+1
-0
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/script/general/parser/max_query_time_range.sim
tests/script/general/parser/max_query_time_range.sim
+64
-0
tests/script/test.sh
tests/script/test.sh
+6
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
b298cb83
...
@@ -6632,6 +6632,19 @@ _ret:
...
@@ -6632,6 +6632,19 @@ _ret:
return
ret
;
return
ret
;
}
}
static
int32_t
validateMaxQueryTimeRange
(
SSqlObj
*
pSql
,
SQueryInfo
*
pQueryInfo
)
{
if
(
tsMaxQueryTimeRange
<
0
)
{
return
TSDB_CODE_SUCCESS
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int64_t
maxTimeRange
=
convertTimePrecision
(
tsMaxQueryTimeRange
*
1000
,
TSDB_TIME_PRECISION_MILLI
,
tinfo
.
precision
);
uint64_t
queryTimeRange
=
pQueryInfo
->
window
.
ekey
-
pQueryInfo
->
window
.
skey
;
if
(
queryTimeRange
>
(
maxTimeRange
-
1
))
{
return
TSDB_CODE_TSC_EXCEED_QUERY_TIME_RANGE
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
validateWhereNode
(
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pExpr
,
SSqlObj
*
pSql
,
bool
joinQuery
,
bool
delData
)
{
int32_t
validateWhereNode
(
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pExpr
,
SSqlObj
*
pSql
,
bool
joinQuery
,
bool
delData
)
{
...
@@ -10692,6 +10705,10 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
...
@@ -10692,6 +10705,10 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
if
((
code
=
validateRangeNode
(
pSql
,
pQueryInfo
,
pSqlNode
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
validateRangeNode
(
pSql
,
pQueryInfo
,
pSqlNode
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
if
((
code
=
validateMaxQueryTimeRange
(
pSql
,
pQueryInfo
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
else
{
}
else
{
pQueryInfo
->
command
=
TSDB_SQL_SELECT
;
pQueryInfo
->
command
=
TSDB_SQL_SELECT
;
...
@@ -10846,6 +10863,9 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
...
@@ -10846,6 +10863,9 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
return
code
;
return
code
;
}
}
if
((
code
=
validateMaxQueryTimeRange
(
pSql
,
pQueryInfo
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
{
// set the query info
{
// set the query info
...
...
src/common/inc/tglobal.h
浏览文件 @
b298cb83
...
@@ -96,6 +96,7 @@ extern int64_t tsMaxRetentWindow;
...
@@ -96,6 +96,7 @@ extern int64_t tsMaxRetentWindow;
extern
bool
tsWriteBatchThreadLocal
;
extern
bool
tsWriteBatchThreadLocal
;
extern
int32_t
tsWriteBatchSize
;
extern
int32_t
tsWriteBatchSize
;
extern
int32_t
tsWriteBatchTimeout
;
extern
int32_t
tsWriteBatchTimeout
;
extern
int32_t
tsMaxQueryTimeRange
;
// db parameters in client
// db parameters in client
extern
int32_t
tsCacheBlockSize
;
extern
int32_t
tsCacheBlockSize
;
...
...
src/common/src/tglobal.c
浏览文件 @
b298cb83
...
@@ -135,6 +135,10 @@ bool tsWriteBatchThreadLocal = false; // if thread local enable, each thre
...
@@ -135,6 +135,10 @@ bool tsWriteBatchThreadLocal = false; // if thread local enable, each thre
int32_t
tsWriteBatchSize
=
0
;
// suggest: 64 - 512, default 0, 0 means disable batching.
int32_t
tsWriteBatchSize
=
0
;
// suggest: 64 - 512, default 0, 0 means disable batching.
int32_t
tsWriteBatchTimeout
=
10
;
// suggest: 2 - 100 (unit: milliseconds)
int32_t
tsWriteBatchTimeout
=
10
;
// suggest: 2 - 100 (unit: milliseconds)
// max query time range in seconds
// if less than zero, no limits on query time range
int32_t
tsMaxQueryTimeRange
=
-
1
;
// the maximum allowed query buffer size during query processing for each data node.
// the maximum allowed query buffer size during query processing for each data node.
// -1 no limit (default)
// -1 no limit (default)
// 0 no query allowed, queries are disabled
// 0 no query allowed, queries are disabled
...
@@ -1923,6 +1927,16 @@ static void doInitGlobalConfig(void) {
...
@@ -1923,6 +1927,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"maxQueryTimeRange"
;
cfg
.
ptr
=
&
tsMaxQueryTimeRange
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
-
1
;
cfg
.
maxValue
=
(
float
)
INT32_MAX
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
assert
(
tsGlobalConfigNum
==
TSDB_CFG_MAX_NUM
);
assert
(
tsGlobalConfigNum
==
TSDB_CFG_MAX_NUM
);
#else
#else
// if TD_TSZ macro define, have 5 count configs, so must add 5
// if TD_TSZ macro define, have 5 count configs, so must add 5
...
...
src/inc/taoserror.h
浏览文件 @
b298cb83
...
@@ -121,7 +121,7 @@ int32_t* taosGetErrno();
...
@@ -121,7 +121,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_TOO_MANY_SML_LINES TAOS_DEF_ERROR_CODE(0, 0x0229) //"too many lines in batch")
#define TSDB_CODE_TSC_TOO_MANY_SML_LINES TAOS_DEF_ERROR_CODE(0, 0x0229) //"too many lines in batch")
#define TSDB_CODE_TSC_SEND_DATA_FAILED TAOS_DEF_ERROR_CODE(0, 0x0230) //"Client send request data error"
#define TSDB_CODE_TSC_SEND_DATA_FAILED TAOS_DEF_ERROR_CODE(0, 0x0230) //"Client send request data error"
#define TSDB_CODE_TSC_EXCEED_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x0231) //"Columns total length exceeds row bytes
#define TSDB_CODE_TSC_EXCEED_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x0231) //"Columns total length exceeds row bytes
#define TSDB_CODE_TSC_EXCEED_QUERY_TIME_RANGE TAOS_DEF_ERROR_CODE(0, 0x0232) //"Query time range exceeds max query time range"
// mnode
// mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed"
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed"
#define TSDB_CODE_MND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0301) //"Message is progressing"
#define TSDB_CODE_MND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0301) //"Message is progressing"
...
...
src/util/inc/tconfig.h
浏览文件 @
b298cb83
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define TSDB_CFG_MAX_NUM 14
2
#define TSDB_CFG_MAX_NUM 14
3
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
#define TSDB_CFG_VALUE_LEN 41
...
...
src/util/src/terror.c
浏览文件 @
b298cb83
...
@@ -128,6 +128,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_RES_TOO_MANY, "Result set too large
...
@@ -128,6 +128,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_RES_TOO_MANY, "Result set too large
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_TOO_MANY_SML_LINES
,
"Too many lines in batch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_TOO_MANY_SML_LINES
,
"Too many lines in batch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_SEND_DATA_FAILED
,
"Client send request data failed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_SEND_DATA_FAILED
,
"Client send request data failed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_EXCEED_ROW_BYTES
,
"Columns total length exceeds row bytes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_EXCEED_ROW_BYTES
,
"Columns total length exceeds row bytes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_EXCEED_QUERY_TIME_RANGE
,
"Query time range exceeds max query time range"
)
// mnode
// mnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
"Message not processed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
"Message not processed"
)
...
...
tests/parallel_test/cases.task
浏览文件 @
b298cb83
...
@@ -573,6 +573,7 @@
...
@@ -573,6 +573,7 @@
10,,script,./test.sh -f general/compute/scalar_pow.sim
10,,script,./test.sh -f general/compute/scalar_pow.sim
9,,docs-examples-test,./test_go.sh
9,,docs-examples-test,./test_go.sh
9,,script,./test.sh -f general/parser/alter1.sim
9,,script,./test.sh -f general/parser/alter1.sim
9,,script,./test.sh -c maxQueryTimeRange=3 -f general/parser/max_query_time_range.sim
9,,script,./test.sh -f general/db/delete.sim
9,,script,./test.sh -f general/db/delete.sim
9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py
9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py
9,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py
9,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py
...
...
tests/script/general/parser/max_query_time_range.sim
0 → 100644
浏览文件 @
b298cb83
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 200
sql connect
print =============== step1
print ====maxQueryTimeRange is set to 3S
$db = querytimerange
$ts = 1679399468000
sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table t (ts timestamp, f int)
sql insert into t values ( $ts , 1)( $ts + 1s , 2)( $ts + 2s , 3)( $ts + 3s, 4)( $ts + 4s, 5)
sql select * from t where ts >= $ts and ts <= $ts + 2999
sql select * from t where ts >= $ts and ts <= $ts + 2999 order by ts desc
sql select * from t where ts > $ts and ts <= $ts + 3000
sql select * from t where ts > $ts and ts <= $ts + 3000 order by ts desc
sql select * from t where ts > $ts and ts < $ts + 2999
sql select * from t where ts > $ts and ts < $ts + 2999 order by ts desc
sql select * from t where ts > $ts and ts <= $ts + 2999
sql select * from t where ts > $ts and ts <= $ts + 2999 order by ts desc
sql select * from t where ts >= $ts and ts < $ts + 2999
sql select * from t where ts >= $ts and ts < $ts + 2999 order by ts desc
sql select * from t where ts > $ts and ts < $ts + 2000
sql select * from t where ts = $ts + 200
sql select * from t where ts = $ts
sql select * from t where ts > $ts and ts <= $ts + 3000
sql select * from (select * from t where ts > $ts and ts <= $ts + 3000) where ts = $ts + 200
sql_error select * from t
sql_error select * from t order by ts desc
sql_error select * from t where ts > $ts
sql_error select * from t where ts > $ts order by ts desc
sql_error select * from t where ts < $ts
sql_error select * from t where ts < $ts order by ts desc
sql_error select * from t where ts >= $ts and ts <= $ts + 3000
sql_error select * from t where ts >= $ts and ts <= $ts + 3000 order by ts desc
sql_error select * from t where ts >= $ts and ts <= $ts + 4000
sql_error select * from t where ts >= $ts and ts <= $ts + 4000 order by ts desc
sql_error select * from ( select * from t ) where ts >= $ts and ts <= $ts + 2000
sql_error select * from ( select * from t ) where ts >= $ts and ts <= $ts + 2000 oder by ts desc
sql_error select * from ( select * from t order by ts desc) where ts >= $ts and ts <= $ts + 2000 oder by ts desc
sql_error select * from ( select * from t where ts > $ts and ts < $ts + 2999) where ts > $ts
sql_error select * from ( select * from t where ts > $ts and ts < $ts + 4000) where ts > $ts
print =============== clear
#sql drop database $db
#sql show databases
#if $rows != 0 then
# return -1
#endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/test.sh
浏览文件 @
b298cb83
...
@@ -16,12 +16,15 @@ VALGRIND=0
...
@@ -16,12 +16,15 @@ VALGRIND=0
UNIQUE
=
0
UNIQUE
=
0
UNAME_BIN
=
`
which
uname
`
UNAME_BIN
=
`
which
uname
`
OS_TYPE
=
`
$UNAME_BIN
`
OS_TYPE
=
`
$UNAME_BIN
`
while
getopts
"f:avu"
arg
while
getopts
"f:
c:
avu"
arg
do
do
case
$arg
in
case
$arg
in
f
)
f
)
FILE_NAME
=
$OPTARG
FILE_NAME
=
$OPTARG
;;
;;
c
)
CFG_STR
=
$OPTARG
;;
a
)
a
)
ASYNC
=
1
ASYNC
=
1
;;
;;
...
@@ -108,7 +111,7 @@ touch -f $TAOS_CFG
...
@@ -108,7 +111,7 @@ touch -f $TAOS_CFG
TAOS_FLAG
=
$PRG_DIR
/flag
TAOS_FLAG
=
$PRG_DIR
/flag
HOSTNAME
=
`
hostname
-f
`
HOSTNAME
=
`
hostname
-f
`
CFG_ADD
=
`
echo
$CFG_STR
|
tr
=
' '
`
echo
" "
>>
$TAOS_CFG
echo
" "
>>
$TAOS_CFG
echo
"firstEp
${
HOSTNAME
}
:7100"
>>
$TAOS_CFG
echo
"firstEp
${
HOSTNAME
}
:7100"
>>
$TAOS_CFG
echo
"secondEp
${
HOSTNAME
}
:7200"
>>
$TAOS_CFG
echo
"secondEp
${
HOSTNAME
}
:7200"
>>
$TAOS_CFG
...
@@ -126,6 +129,7 @@ echo "wal 0" >> $TAOS_CFG
...
@@ -126,6 +129,7 @@ echo "wal 0" >> $TAOS_CFG
echo
"asyncLog 0"
>>
$TAOS_CFG
echo
"asyncLog 0"
>>
$TAOS_CFG
echo
"locale en_US.UTF-8"
>>
$TAOS_CFG
echo
"locale en_US.UTF-8"
>>
$TAOS_CFG
echo
"enableCoreFile 1"
>>
$TAOS_CFG
echo
"enableCoreFile 1"
>>
$TAOS_CFG
echo
$CFG_ADD
>>
$TAOS_CFG
echo
" "
>>
$TAOS_CFG
echo
" "
>>
$TAOS_CFG
ulimit
-n
600000
ulimit
-n
600000
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录