From a6a38058dd290aaf34d400221d91d4f6bd22142d Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 13 Sep 2022 16:39:27 +0800 Subject: [PATCH] fix: support ttl in create table automatic --- source/libs/parser/src/parInsert.c | 4 ++-- tests/system-test/2-query/ttl_comment.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 74bc68f89e..06e19b98cd 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1129,7 +1129,7 @@ static int32_t parseTableOptions(SInsertParseContext* pCxt) { NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); if (TK_TTL == sToken.type) { pCxt->pSql += index; - NEXT_TOKEN(pCxt->pSql, sToken); + NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken); if (TK_NK_INTEGER != sToken.type) { return buildSyntaxErrMsg(&pCxt->msg, "Invalid option ttl", sToken.z); } @@ -1745,7 +1745,7 @@ static int32_t skipTableOptions(SInsertParseSyntaxCxt* pCxt) { NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); if (TK_TTL == sToken.type || TK_COMMENT == sToken.type) { pCxt->pSql += index; - NEXT_TOKEN(pCxt->pSql, sToken); + NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken); } else { break; } diff --git a/tests/system-test/2-query/ttl_comment.py b/tests/system-test/2-query/ttl_comment.py index c26393158c..187df2e2d3 100644 --- a/tests/system-test/2-query/ttl_comment.py +++ b/tests/system-test/2-query/ttl_comment.py @@ -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_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_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.checkData(0, 0, 'child_table1') @@ -160,6 +161,11 @@ class TDTestCase: tdSql.checkData(0, 7, 0) 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.query("select * from information_schema.ins_tables where table_name like 'child_table1'") -- GitLab