diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e7a821ddf4643e78ae521eaf534ee8881a8974c4..dbfb042b108c62e22855712226a9e484fa7a72ae 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6623,6 +6623,13 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } + int32_t blocks = ntohl(pCreate->totalBlocks); + if (blocks != -1 && (blocks < TSDB_MIN_TOTAL_BLOCKS || blocks > TSDB_MAX_TOTAL_BLOCKS)) { + snprintf(msg, tListLen(msg), "invalid db option totalBlocks: %d valid range: [%d, %d]", blocks, + TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); + } + if (pCreate->quorum != -1 && (pCreate->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCreate->quorum > TSDB_MAX_DB_QUORUM_OPTION)) { snprintf(msg, tListLen(msg), "invalid db option quorum: %d valid range: [%d, %d]", pCreate->quorum, diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index c3bb23855fceb877c1ed39c01524231d27edb4f4..bd68ddd859142b0904b92b2b8116b328d158cb83 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -177,7 +177,7 @@ sql alter database db blocks 20 sql alter database db blocks 10 sql_error alter database db blocks 2 sql_error alter database db blocks 1 -sql alter database db blocks 0 +sql_error alter database db blocks 0 sql_error alter database db blocks -1 sql_error alter database db blocks 10001 diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 2b4cce5e64bf7076eeb2f0f0e3c1dfbaa224b116..63cae8dffd24d9c292166ed0892a2416805131b2 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -455,7 +455,7 @@ sql alter database db blocks 20 sql alter database db blocks 10 sql_error alter database db blocks 2 sql_error alter database db blocks 1 -sql alter database db blocks 0 +sql_error alter database db blocks 0 sql_error alter database db blocks -1 sql_error alter database db blocks 10001