Merge pull request #27340 from taosdata/fix/TD-31565-3.0

fix: report error when the ttl value is too large
This commit is contained in:
Hongze Cheng 2024-08-22 09:14:14 +08:00 committed by GitHub
commit 51b589f270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 19 deletions

View File

@ -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};

View File

@ -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)