未验证 提交 d3dcd67e 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #16805 from taosdata/feature/TD-18765

fix:<TD-18765> support ttl in create table automatic
...@@ -1129,7 +1129,7 @@ static int32_t parseTableOptions(SInsertParseContext* pCxt) { ...@@ -1129,7 +1129,7 @@ static int32_t parseTableOptions(SInsertParseContext* pCxt) {
NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index);
if (TK_TTL == sToken.type) { if (TK_TTL == sToken.type) {
pCxt->pSql += index; pCxt->pSql += index;
NEXT_TOKEN(pCxt->pSql, sToken); NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
if (TK_NK_INTEGER != sToken.type) { if (TK_NK_INTEGER != sToken.type) {
return buildSyntaxErrMsg(&pCxt->msg, "Invalid option ttl", sToken.z); return buildSyntaxErrMsg(&pCxt->msg, "Invalid option ttl", sToken.z);
} }
...@@ -1745,7 +1745,7 @@ static int32_t skipTableOptions(SInsertParseSyntaxCxt* pCxt) { ...@@ -1745,7 +1745,7 @@ static int32_t skipTableOptions(SInsertParseSyntaxCxt* pCxt) {
NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index);
if (TK_TTL == sToken.type || TK_COMMENT == sToken.type) { if (TK_TTL == sToken.type || TK_COMMENT == sToken.type) {
pCxt->pSql += index; pCxt->pSql += index;
NEXT_TOKEN(pCxt->pSql, sToken); NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
} else { } else {
break; break;
} }
......
...@@ -137,7 +137,8 @@ class TDTestCase: ...@@ -137,7 +137,8 @@ class TDTestCase:
tdSql.execute(f"create table {dbname}.child_table2 using {dbname}.super_table1 tags(1) comment ''") tdSql.execute(f"create table {dbname}.child_table2 using {dbname}.super_table1 tags(1) comment ''")
tdSql.execute(f"create table {dbname}.child_table3 using {dbname}.super_table1 tags(1) comment 'child'") tdSql.execute(f"create table {dbname}.child_table3 using {dbname}.super_table1 tags(1) comment 'child'")
tdSql.execute(f"insert into {dbname}.child_table4 using {dbname}.super_table1 tags(1) values(now, 1)") tdSql.execute(f"insert into {dbname}.child_table4 using {dbname}.super_table1 tags(1) values(now, 1)")
tdSql.execute(f"insert into {dbname}.child_table5 using {dbname}.super_table1 tags(1) ttl 23 comment '' values(now, 1)")
tdSql.error(f"insert into {dbname}.child_table6 using {dbname}.super_table1 tags(1) ttl -23 comment '' values(now, 1)")
tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'")
tdSql.checkData(0, 0, 'child_table1') tdSql.checkData(0, 0, 'child_table1')
...@@ -160,6 +161,11 @@ class TDTestCase: ...@@ -160,6 +161,11 @@ class TDTestCase:
tdSql.checkData(0, 7, 0) tdSql.checkData(0, 7, 0)
tdSql.checkData(0, 8, None) tdSql.checkData(0, 8, None)
tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table5'")
tdSql.checkData(0, 0, 'child_table5')
tdSql.checkData(0, 7, 23)
tdSql.checkData(0, 8, '')
tdSql.execute(f"alter table {dbname}.child_table1 comment 'nihao'") tdSql.execute(f"alter table {dbname}.child_table1 comment 'nihao'")
tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册