From 5e4f374c2bf4958e5d2e5d98d1ca34336616ee38 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 21 Mar 2023 07:05:48 -0800 Subject: [PATCH] fix: add test cases --- src/client/src/tscSQLParser.c | 3 +- src/common/src/tglobal.c | 4 +- tests/parallel_test/cases.task | 1 + .../general/parser/max_query_time_range.sim | 51 +++++++++++++++++++ tests/script/test.sh | 6 ++- 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 tests/script/general/parser/max_query_time_range.sim diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index ec681c791a..1bd592341e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6612,7 +6612,8 @@ static int32_t validateMaxQueryTimeRange(SSqlObj* pSql, SQueryInfo* pQueryInfo) STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); int64_t maxTimeRange = convertTimePrecision(tsMaxQueryTimeRange * 1000, TSDB_TIME_PRECISION_MILLI, tinfo.precision); - if (pQueryInfo->window.ekey - pQueryInfo->window.skey > maxTimeRange) { + uint64_t queryTimeRange = pQueryInfo->window.ekey - pQueryInfo->window.skey; + if (queryTimeRange > maxTimeRange) { return TSDB_CODE_TSC_EXCEED_QUERY_TIME_RANGE; } return TSDB_CODE_SUCCESS; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 0f4adb6b51..9a746a2b59 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -135,8 +135,8 @@ bool tsWriteBatchThreadLocal = false; // if thread local enable, each thre int32_t tsWriteBatchSize = 0; // suggest: 64 - 512, default 0, 0 means disable batching. int32_t tsWriteBatchTimeout = 10; // suggest: 2 - 100 (unit: milliseconds) -// max query time range -// if less than zero, no limits +// 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. diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a13f77d43b..f903c82988 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -573,6 +573,7 @@ 10,,script,./test.sh -f general/compute/scalar_pow.sim 9,,docs-examples-test,./test_go.sh 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,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py 9,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py diff --git a/tests/script/general/parser/max_query_time_range.sim b/tests/script/general/parser/max_query_time_range.sim new file mode 100644 index 0000000000..0a7be90a34 --- /dev/null +++ b/tests/script/general/parser/max_query_time_range.sim @@ -0,0 +1,51 @@ +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 2000 +sql connect + +print =============== step1 +$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 + 3000 +sql select * from t where ts > $ts and ts <= $ts + 3001 +sql select * from t where ts > $ts and ts < $ts + 3000 +sql select * from t where ts > $ts and ts <= $ts + 3000 +sql select * from t where ts >= $ts and ts < $ts + 3000 +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 + 3001 +sql select * from (select * from t where ts > $ts and ts <= $ts + 3001) where ts = $ts + 200 + +sql_error select * from t +sql_error select * from t where ts > $ts +sql_error select * from t where ts < $ts + +sql_error select * from t where ts >= $ts and ts <= $ts + 3001 +sql_error select * from t where ts >= $ts and ts <= $ts + 4000 + +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 + 3000) 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 diff --git a/tests/script/test.sh b/tests/script/test.sh index f2dc578987..5a6d289721 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -16,12 +16,15 @@ VALGRIND=0 UNIQUE=0 UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` -while getopts "f:avu" arg +while getopts "f:c:avu" arg do case $arg in f) FILE_NAME=$OPTARG ;; + c) + CFG_STR=$OPTARG + ;; a) ASYNC=1 ;; @@ -126,6 +129,7 @@ echo "wal 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG echo "enableCoreFile 1" >> $TAOS_CFG +echo $CFG_STR >> $TAOS_CFG echo " " >> $TAOS_CFG ulimit -n 600000 -- GitLab