From 877b6e705335ffd31865d59a684f4daf5e4fa048 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 21 Apr 2023 14:58:58 +0800 Subject: [PATCH] fix: add table_prefix/table_suffix cases --- source/libs/parser/src/parTranslater.c | 4 +- tests/parallel_test/cases.task | 1 + tests/script/tsim/db/table_prefix_suffix.sim | 182 +++++++++++++++++++ 3 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 tests/script/tsim/db/table_prefix_suffix.sim diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c0ee34d6aa..21ae3c74a2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4181,13 +4181,13 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete static int32_t checkDbTbPrefixSuffixOptions(STranslateContext* pCxt, int32_t tbPrefix, int32_t tbSuffix) { if (tbPrefix < TSDB_MIN_HASH_PREFIX || tbPrefix > TSDB_MAX_HASH_PREFIX) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, - "Invalid option table_prefix: %d valid range: [%" PRId64 ", %" PRId64 "]", tbPrefix, + "Invalid option table_prefix: %d valid range: [%d, %d]", tbPrefix, TSDB_MIN_HASH_PREFIX, TSDB_MAX_HASH_PREFIX); } if (tbSuffix < TSDB_MIN_HASH_SUFFIX || tbSuffix > TSDB_MAX_HASH_SUFFIX) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, - "Invalid option table_suffix: %d valid range: [%" PRId64 ", %" PRId64 "]", tbSuffix, + "Invalid option table_suffix: %d valid range: [%d, %d]", tbSuffix, TSDB_MIN_HASH_SUFFIX, TSDB_MAX_HASH_SUFFIX); } diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index dda4ec3e84..6e662a9a15 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -746,6 +746,7 @@ ,,y,script,./test.sh -f tsim/db/show_create_table.sim ,,y,script,./test.sh -f tsim/db/tables.sim ,,y,script,./test.sh -f tsim/db/taosdlog.sim +,,y,script,./test.sh -f tsim/db/table_prefix_suffix.sim ,,y,script,./test.sh -f tsim/dnode/balance_replica1.sim ,,y,script,./test.sh -f tsim/dnode/balance_replica3.sim ,,y,script,./test.sh -f tsim/dnode/balance1.sim diff --git a/tests/script/tsim/db/table_prefix_suffix.sim b/tests/script/tsim/db/table_prefix_suffix.sim new file mode 100644 index 0000000000..1b483d7df7 --- /dev/null +++ b/tests/script/tsim/db/table_prefix_suffix.sim @@ -0,0 +1,182 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 5 TABLE_PREFIX 1 TABLE_SUFFIX 2; +sql use db1; +sql create table atb1aa (ts timestamp, f1 int); +sql create table btb1bb (ts timestamp, f1 int); +sql create table ctb1cc (ts timestamp, f1 int); +sql create table dtb1dd (ts timestamp, f1 int); +sql create table atb2aa (ts timestamp, f1 int); +sql create table btb2bb (ts timestamp, f1 int); +sql create table ctb2cc (ts timestamp, f1 int); +sql create table dtb2dd (ts timestamp, f1 int); +sql create table etb2ee (ts timestamp, f1 int); +sql show create database db1; +sql select count(*) a from information_schema.ins_tables where db_name='db1' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db1; + +sql drop database if exists db2; +sql create database db2 vgroups 5 TABLE_PREFIX -1 TABLE_SUFFIX -2; +sql use db2; +sql create table taaa11 (ts timestamp, f1 int); +sql create table tbbb11 (ts timestamp, f1 int); +sql create table tccc11 (ts timestamp, f1 int); +sql create table tddd11 (ts timestamp, f1 int); +sql create table taaa22 (ts timestamp, f1 int); +sql create table tbbb22 (ts timestamp, f1 int); +sql create table tccc22 (ts timestamp, f1 int); +sql create table tddd22 (ts timestamp, f1 int); +sql create table teee22 (ts timestamp, f1 int); +sql show create database db2; +sql select count(*) a from information_schema.ins_tables where db_name='db2' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db2; + +sql drop database if exists db3; +sql create database db3 vgroups 5 TABLE_PREFIX -1; +sql use db3; +sql create table taaa11 (ts timestamp, f1 int); +sql create table tbbb11 (ts timestamp, f1 int); +sql create table tccc11 (ts timestamp, f1 int); +sql create table tddd11 (ts timestamp, f1 int); +sql create table zaaa22 (ts timestamp, f1 int); +sql create table zbbb22 (ts timestamp, f1 int); +sql create table zccc22 (ts timestamp, f1 int); +sql create table zddd22 (ts timestamp, f1 int); +sql create table zeee22 (ts timestamp, f1 int); +sql show create database db3; +sql select count(*) a from information_schema.ins_tables where db_name='db3' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db3; + +sql drop database if exists db4; +sql create database db4 vgroups 5 TABLE_SUFFIX -2; +sql use db4; +sql create table taaa11 (ts timestamp, f1 int); +sql create table tbbb11 (ts timestamp, f1 int); +sql create table tccc11 (ts timestamp, f1 int); +sql create table tddd11 (ts timestamp, f1 int); +sql create table zaaa22 (ts timestamp, f1 int); +sql create table zbbb22 (ts timestamp, f1 int); +sql create table zccc22 (ts timestamp, f1 int); +sql create table zddd22 (ts timestamp, f1 int); +sql create table zeee22 (ts timestamp, f1 int); +sql show create database db4; +sql select count(*) a from information_schema.ins_tables where db_name='db4' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db4; + +sql drop database if exists db5; +sql create database db5 vgroups 5 TABLE_PREFIX 1; +sql use db5; +sql create table taaa11 (ts timestamp, f1 int); +sql create table baaa11 (ts timestamp, f1 int); +sql create table caaa11 (ts timestamp, f1 int); +sql create table daaa11 (ts timestamp, f1 int); +sql create table faaa11 (ts timestamp, f1 int); +sql create table gbbb11 (ts timestamp, f1 int); +sql create table hbbb11 (ts timestamp, f1 int); +sql create table ibbb11 (ts timestamp, f1 int); +sql create table jbbb11 (ts timestamp, f1 int); +sql show create database db5; +sql select count(*) a from information_schema.ins_tables where db_name='db5' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db5; + +sql drop database if exists db6; +sql create database db6 vgroups 5 TABLE_SUFFIX 2; +sql use db6; +sql create table taaa11 (ts timestamp, f1 int); +sql create table taaa12 (ts timestamp, f1 int); +sql create table taaa13 (ts timestamp, f1 int); +sql create table taaa14 (ts timestamp, f1 int); +sql create table tbbb23 (ts timestamp, f1 int); +sql create table tbbb24 (ts timestamp, f1 int); +sql create table tbbb31 (ts timestamp, f1 int); +sql create table tbbb32 (ts timestamp, f1 int); +sql create table tbbb33 (ts timestamp, f1 int); +sql show create database db6; +sql select count(*) a from information_schema.ins_tables where db_name='db6' group by vgroup_id having(count(*) > 0) order by a; +if $rows != 2 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql drop database if exists db6; + +sql drop database if exists db7; +sql create database db7 vgroups 5 TABLE_PREFIX -100 TABLE_SUFFIX -92; +sql use db7; +sql create table taaa11 (ts timestamp, f1 int); +sql create table taaa12 (ts timestamp, f1 int); +sql create table taaa13 (ts timestamp, f1 int); +sql create table tbbb21 (ts timestamp, f1 int); +sql create table tbbb22 (ts timestamp, f1 int); +sql create table tbbb23 (ts timestamp, f1 int); +sql create table tbbb24 (ts timestamp, f1 int); +sql create table tccc31 (ts timestamp, f1 int); +sql create table tccc32 (ts timestamp, f1 int); +sql create table tccc33 (ts timestamp, f1 int); +sql create table tddd24 (ts timestamp, f1 int); +sql create table tddd31 (ts timestamp, f1 int); +sql create table tddd32 (ts timestamp, f1 int); +sql create table tddd33 (ts timestamp, f1 int); +sql show create database db7; +sql select count(*) a from information_schema.ins_tables where db_name='db7' group by vgroup_id having(count(*) > 0) order by a; +sql drop database if exists db7; + +sql_error create database db8 vgroups 5 TABLE_PREFIX -1 TABLE_SUFFIX 2; +sql_error create database db8 vgroups 5 TABLE_PREFIX 191 TABLE_SUFFIX 192; +sql_error create database db8 vgroups 5 TABLE_PREFIX -192 TABLE_SUFFIX -191; +sql_error create database db8 vgroups 5 TABLE_PREFIX 100 TABLE_SUFFIX 92; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT