From 81d8b9b98b3775848c6398e136c260125f43fa3b Mon Sep 17 00:00:00 2001 From: kailixu Date: Fri, 5 Jan 2024 00:35:29 +0800 Subject: [PATCH] test: add test case for create index --- source/libs/parser/src/parTranslater.c | 11 ++++------- tests/system-test/0-others/tag_index_basic.py | 8 ++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 40b869d2b7..c51e96d1b6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6930,10 +6930,11 @@ static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateInde } static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + int32_t code = 0; SName name; STableMeta* pMeta = NULL; - int32_t code = - getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), &pMeta, false); + + code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), &pMeta, false); if (code) { taosMemoryFree(pMeta); return code; @@ -6955,10 +6956,6 @@ static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexS taosMemoryFree(pMeta); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pNode)->colName); } - if (IS_IDX_ON(pSchema)) { - code = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST; - goto _exit; - } } SCreateTagIndexReq createTagIdxReq = {0}; @@ -6966,7 +6963,7 @@ static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexS if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_INDEX, (FSerializeFunc)tSerializeSCreateTagIdxReq, &createTagIdxReq); } -_exit: +_exit: taosMemoryFree(pMeta); return code; } diff --git a/tests/system-test/0-others/tag_index_basic.py b/tests/system-test/0-others/tag_index_basic.py index c1e1d521d2..a55508e229 100644 --- a/tests/system-test/0-others/tag_index_basic.py +++ b/tests/system-test/0-others/tag_index_basic.py @@ -88,6 +88,13 @@ class TDTestCase: tdLog.info(f" create {count} child tables ok.") + def create_tagidx_check(self, stbname): + err_dict = {"NULL","",",","\"","\"\"","undef","t1,t2","t12,t12"} + for errs in err_dict: + sql = (f'create index idx_err_check on {stbname} (%s)'% (errs)) + tdLog.info(f' sql={sql}') + tdSql.error(f'{sql}') + tdLog.info(f' create tagidx check ok.') # create stable and child tables def create_tagidx(self, stbname): @@ -231,6 +238,7 @@ class TDTestCase: count = 1000 # do self.create_table(stable, tbname, count) + self.create_tagidx_check(stable) self.create_tagidx(stable) self.insert_data(tbname) self.show_tagidx(stable)