From 22aa4f15288edd8d621c04cd4e33eb659b5d0277 Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Tue, 20 Aug 2024 19:38:47 +0800 Subject: [PATCH 1/2] fix: report error when the ttl value is too large --- source/libs/parser/src/parAstCreater.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 2bf82ba98f..20081b7535 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1905,10 +1905,11 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType case TABLE_OPTION_TTL: { int64_t ttl = taosStr2Int64(((SToken*)pVal)->z, NULL, 10); if (ttl > INT32_MAX) { - ttl = INT32_MAX; + pCxt->errCode = TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + } else { + // ttl can not be smaller than 0, because there is a limitation in sql.y (TTL NK_INTEGER) + ((STableOptions*)pOptions)->ttl = ttl; } - // ttl can not be smaller than 0, because there is a limitation in sql.y (TTL NK_INTEGER) - ((STableOptions*)pOptions)->ttl = ttl; break; } case TABLE_OPTION_SMA: @@ -2516,7 +2517,7 @@ SNode* addCreateUserStmtWhiteList(SAstCreateContext* pCxt, SNode* pCreateUserStm return pCreateUserStmt; } -SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo, +SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo, int8_t createDb, int8_t is_import) { CHECK_PARSER_STATUS(pCxt); char password[TSDB_USET_PASSWORD_LEN + 3] = {0}; From b10aeeea87b68a13d875d96e2ece2aaf5ba2319d Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Wed, 21 Aug 2024 10:00:53 +0800 Subject: [PATCH 2/2] fix: update ttl test case --- tests/system-test/2-query/ttl_comment.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/tests/system-test/2-query/ttl_comment.py b/tests/system-test/2-query/ttl_comment.py index ba24579611..b332cd3afb 100644 --- a/tests/system-test/2-query/ttl_comment.py +++ b/tests/system-test/2-query/ttl_comment.py @@ -36,12 +36,12 @@ class TDTestCase: tdSql.error(f"create table {dbname}.ttl_table1(ts timestamp, i int) ttl 1.1") tdSql.error(f"create table {dbname}.ttl_table2(ts timestamp, i int) ttl 1e1") tdSql.error(f"create table {dbname}.ttl_table3(ts timestamp, i int) ttl -1") + tdSql.error(f"create table {dbname}.ttl_table4(ts timestamp, i int) ttl 2147483648") print("============== STEP 1 ===== test normal table") tdSql.execute(f"create table {dbname}.normal_table1(ts timestamp, i int)") tdSql.execute(f"create table {dbname}.normal_table2(ts timestamp, i int) comment '' ttl 3") - tdSql.execute(f"create table {dbname}.normal_table3(ts timestamp, i int) ttl 2100000000020 comment 'hello'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') @@ -54,12 +54,6 @@ class TDTestCase: tdSql.checkData(0, 7, 3) tdSql.checkData(0, 8, '') - - tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table3'") - tdSql.checkData(0, 0, 'normal_table3') - tdSql.checkData(0, 7, 2147483647) - tdSql.checkData(0, 8, 'hello') - tdSql.execute(f"alter table {dbname}.normal_table1 comment 'nihao'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') @@ -75,19 +69,14 @@ class TDTestCase: tdSql.checkData(0, 0, 'normal_table2') tdSql.checkData(0, 8, 'fly') - tdSql.execute(f"alter table {dbname}.normal_table3 comment 'fly'") - tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table3'") - tdSql.checkData(0, 0, 'normal_table3') - tdSql.checkData(0, 8, 'fly') - tdSql.execute(f"alter table {dbname}.normal_table1 ttl 1") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') tdSql.checkData(0, 7, 1) - tdSql.execute(f"alter table {dbname}.normal_table3 ttl 0") - tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table3'") - tdSql.checkData(0, 0, 'normal_table3') + tdSql.execute(f"alter table {dbname}.normal_table2 ttl 0") + tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table2'") + tdSql.checkData(0, 0, 'normal_table2') tdSql.checkData(0, 7, 0)