From 92146c510adf2fb4f149b62dc1d1396b2bf71fd3 Mon Sep 17 00:00:00 2001 From: kailixu Date: Wed, 25 Sep 2024 09:22:56 +0800 Subject: [PATCH 1/3] fix: unify the error code when drop stable --- source/libs/parser/src/parTranslater.c | 9 +++++--- tests/system-test/1-insert/drop.py | 29 +++++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 798793bf55..3781479f36 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -14705,7 +14705,7 @@ static int32_t rewriteDropSuperTablewithOpt(STranslateContext* pCxt, SQuery* pQu break; } if (!isdigit(pStmt->tableName[i])) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, "Table does not exist: `%s`.`%s`", + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, "STable not exist: `%s`.`%s`", pStmt->dbName, pStmt->tableName); } } @@ -14715,8 +14715,11 @@ static int32_t rewriteDropSuperTablewithOpt(STranslateContext* pCxt, SQuery* pQu toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); code = getTargetName(pCxt, &name, pTableName); if (TSDB_CODE_SUCCESS != code) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "%s: db:`%s`, tbuid:`%s`", tstrerror(code), pStmt->dbName, - pStmt->tableName); + return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "%s: db:`%s`, tbuid:`%s`", + (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST) + ? "STable not exist" + : tstrerror(code), + pStmt->dbName, pStmt->tableName); } tstrncpy(pStmt->tableName, pTableName, TSDB_TABLE_NAME_LEN); // rewrite table uid to table name diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index 7e41aad4a8..e28b24b5ca 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -147,13 +147,28 @@ class TDTestCase: if i == 0: dropTable = f'drop table with `{stb_result[1]}`.`{stb_result[10]}`,' dropStable = f'drop stable with `{stb_result[1]}`.`{stb_result[10]}`,' + dropTableWithSpace = f'drop table with `{stb_result[1]}`.`{stb_result[10]} `,' + dropStableWithSpace = f'drop stable with `{stb_result[1]}`.` {stb_result[10]}`,' + dropStableNotExist = f'drop stable with `{stb_result[1]}`.`{stb_result[10]}_notexist`,' + tdLog.info(dropTableWithSpace[:-1]) + tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) + tdLog.info(dropStableWithSpace[:-1]) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) + tdLog.info(dropStableNotExist[:-1]) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) else: dropTable += f'`{stb_result[1]}`.`{stb_result[10]}`,' dropStable += f'`{stb_result[1]}`.`{stb_result[10]}`,' tdLog.info(dropTable[:-1]) tdLog.info(dropStable[:-1]) - tdSql.error(dropTable[:-1]) - tdSql.error(dropStable[:-1]) + tdSql.error(dropTable[:-1], expectErrInfo="Cannot drop super table in batch") + tdSql.error(dropStable[:-1], expectErrInfo="syntax error", fullMatched=False) + dropTableWithSpace += f'`{stb_result[1]}`.` {stb_result[10]}`,' + dropStableWithSpace += f'`{stb_result[1]}`.`{stb_result[10]} `,' + tdLog.info(dropTableWithSpace[:-1]) + tdLog.info(dropStableWithSpace[:-1]) + tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="syntax error", fullMatched=False) i += 1 i = 0 for stb_result in result: @@ -172,9 +187,9 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"') tdSql.checkRows(8) - tdSql.error(f'drop stable with information_schema.`ins_tables`;') - tdSql.error(f'drop stable with performance_schema.`perf_connections`;') - self.drop_table_check_end() + tdSql.error(f'drop stable with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + tdSql.error(f'drop stable with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + self.drop_table_check_end() def drop_table_with_check(self): self.drop_table_check_init() tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"') @@ -196,8 +211,8 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_stables where db_name like "dbtest_%"') tdSql.checkRows(2) - tdSql.error(f'drop table with information_schema.`ins_tables`;') - tdSql.error(f'drop table with performance_schema.`perf_connections`;') + tdSql.error(f'drop table with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + tdSql.error(f'drop table with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) self.drop_table_check_end() def drop_table_with_check_tsma(self): tdSql.execute(f'create database if not exists {self.dbname} {self.vgroups_opt}') From c2c3be3aa6c6c65a3dca202592bb972ab14f3542 Mon Sep 17 00:00:00 2001 From: kailixu Date: Wed, 25 Sep 2024 09:40:26 +0800 Subject: [PATCH 2/3] enh: test case optimization --- tests/system-test/1-insert/drop.py | 47 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index 6d674c5ad5..7ff48e8d40 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -54,6 +54,7 @@ class TDTestCase: self.ctb_names = [ f'ctb0', 'ctb1', f'aa\u00bf\u200bctb0', f'aa\u00bf\u200bctb1'] self.ntb_names = [ f'ntb0', f'aa\u00bf\u200bntb0', f'ntb1', f'aa\u00bf\u200bntb1'] self.vgroups_opt = f'vgroups 4' + self.err_dup_cnt = 5 def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) for i in range(row_num): @@ -150,25 +151,31 @@ class TDTestCase: dropTableWithSpace = f'drop table with `{stb_result[1]}`.`{stb_result[10]} `,' dropStableWithSpace = f'drop stable with `{stb_result[1]}`.` {stb_result[10]}`,' dropStableNotExist = f'drop stable with `{stb_result[1]}`.`{stb_result[10]}_notexist`,' - tdLog.info(dropTableWithSpace[:-1]) - tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) - tdLog.info(dropStableWithSpace[:-1]) - tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) - tdLog.info(dropStableNotExist[:-1]) - tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) + k = 0 + for k in range(self.err_dup_cnt): + tdLog.info(dropTableWithSpace[:-1]) + tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) + tdLog.info(dropStableWithSpace[:-1]) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) + tdLog.info(dropStableNotExist[:-1]) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="STable not exist", fullMatched=False) else: dropTable += f'`{stb_result[1]}`.`{stb_result[10]}`,' dropStable += f'`{stb_result[1]}`.`{stb_result[10]}`,' - tdLog.info(dropTable[:-1]) - tdLog.info(dropStable[:-1]) - tdSql.error(dropTable[:-1], expectErrInfo="Cannot drop super table in batch") - tdSql.error(dropStable[:-1], expectErrInfo="syntax error", fullMatched=False) + k = 0 + for k in range(self.err_dup_cnt): + tdLog.info(dropTable[:-1]) + tdLog.info(dropStable[:-1]) + tdSql.error(dropTable[:-1], expectErrInfo="Cannot drop super table in batch") + tdSql.error(dropStable[:-1], expectErrInfo="syntax error", fullMatched=False) dropTableWithSpace += f'`{stb_result[1]}`.` {stb_result[10]}`,' dropStableWithSpace += f'`{stb_result[1]}`.`{stb_result[10]} `,' - tdLog.info(dropTableWithSpace[:-1]) - tdLog.info(dropStableWithSpace[:-1]) - tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) - tdSql.error(dropStableWithSpace[:-1], expectErrInfo="syntax error", fullMatched=False) + k = 0 + for k in range(self.err_dup_cnt): + tdLog.info(dropTableWithSpace[:-1]) + tdLog.info(dropStableWithSpace[:-1]) + tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) + tdSql.error(dropStableWithSpace[:-1], expectErrInfo="syntax error", fullMatched=False) i += 1 i = 0 for stb_result in result: @@ -187,8 +194,10 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"') tdSql.checkRows(8) - tdSql.error(f'drop stable with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) - tdSql.error(f'drop stable with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + k = 0 + for k in range(self.err_dup_cnt): + tdSql.error(f'drop stable with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + tdSql.error(f'drop stable with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) self.drop_table_check_end() def drop_table_with_check(self): self.drop_table_check_init() @@ -211,8 +220,10 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_stables where db_name like "dbtest_%"') tdSql.checkRows(2) - tdSql.error(f'drop table with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) - tdSql.error(f'drop table with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + k = 0 + for k in range(self.err_dup_cnt): + tdSql.error(f'drop table with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + tdSql.error(f'drop table with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) self.drop_table_check_end() def drop_table_with_check_tsma(self): tdSql.execute(f'create database if not exists {self.dbname} {self.vgroups_opt}') From 234b95fcd6259fa9d0ee4efefcf7ff5db913baaf Mon Sep 17 00:00:00 2001 From: kailixu Date: Wed, 25 Sep 2024 09:51:27 +0800 Subject: [PATCH 3/3] enh: test case optimization --- tests/system-test/1-insert/drop.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index 7ff48e8d40..ad9f6c9be6 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -151,8 +151,7 @@ class TDTestCase: dropTableWithSpace = f'drop table with `{stb_result[1]}`.`{stb_result[10]} `,' dropStableWithSpace = f'drop stable with `{stb_result[1]}`.` {stb_result[10]}`,' dropStableNotExist = f'drop stable with `{stb_result[1]}`.`{stb_result[10]}_notexist`,' - k = 0 - for k in range(self.err_dup_cnt): + for _ in range(self.err_dup_cnt): tdLog.info(dropTableWithSpace[:-1]) tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) tdLog.info(dropStableWithSpace[:-1]) @@ -162,16 +161,14 @@ class TDTestCase: else: dropTable += f'`{stb_result[1]}`.`{stb_result[10]}`,' dropStable += f'`{stb_result[1]}`.`{stb_result[10]}`,' - k = 0 - for k in range(self.err_dup_cnt): + for _ in range(self.err_dup_cnt): tdLog.info(dropTable[:-1]) tdLog.info(dropStable[:-1]) tdSql.error(dropTable[:-1], expectErrInfo="Cannot drop super table in batch") tdSql.error(dropStable[:-1], expectErrInfo="syntax error", fullMatched=False) dropTableWithSpace += f'`{stb_result[1]}`.` {stb_result[10]}`,' dropStableWithSpace += f'`{stb_result[1]}`.`{stb_result[10]} `,' - k = 0 - for k in range(self.err_dup_cnt): + for _ in range(self.err_dup_cnt): tdLog.info(dropTableWithSpace[:-1]) tdLog.info(dropStableWithSpace[:-1]) tdSql.error(dropTableWithSpace[:-1], expectErrInfo="Table does not exist", fullMatched=False) @@ -194,8 +191,7 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"') tdSql.checkRows(8) - k = 0 - for k in range(self.err_dup_cnt): + for _ in range(self.err_dup_cnt): tdSql.error(f'drop stable with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) tdSql.error(f'drop stable with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) self.drop_table_check_end() @@ -220,8 +216,7 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query(f'select * from information_schema.ins_stables where db_name like "dbtest_%"') tdSql.checkRows(2) - k = 0 - for k in range(self.err_dup_cnt): + for _ in range(self.err_dup_cnt): tdSql.error(f'drop table with information_schema.`ins_tables`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) tdSql.error(f'drop table with performance_schema.`perf_connections`;', expectErrInfo="Cannot drop table of system database", fullMatched=False) self.drop_table_check_end()