Merge pull request #24298 from taosdata/fix/TD-28078-3.0
fix: check in client when create index
This commit is contained in:
commit
f6c366ec53
|
@ -6930,11 +6930,37 @@ static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateInde
|
|||
}
|
||||
|
||||
static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
int32_t code = 0;
|
||||
SName name;
|
||||
STableMeta* pMeta = NULL;
|
||||
|
||||
code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), &pMeta, false);
|
||||
if (code) {
|
||||
taosMemoryFree(pMeta);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (LIST_LENGTH(pStmt->pCols) != 1) {
|
||||
taosMemoryFree(pMeta);
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAGS_NUM, "Only one tag is allowed");
|
||||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pStmt->pCols) {
|
||||
const SSchema* pSchema = getTagSchema(pMeta, ((SColumnNode*)pNode)->colName);
|
||||
if (!pSchema) {
|
||||
taosMemoryFree(pMeta);
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pNode)->colName);
|
||||
}
|
||||
}
|
||||
|
||||
SCreateTagIndexReq createTagIdxReq = {0};
|
||||
int32_t code = buildCreateTagIndexReq(pCxt, pStmt, &createTagIdxReq);
|
||||
code = buildCreateTagIndexReq(pCxt, pStmt, &createTagIdxReq);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_INDEX, (FSerializeFunc)tSerializeSCreateTagIdxReq, &createTagIdxReq);
|
||||
}
|
||||
_exit:
|
||||
taosMemoryFree(pMeta);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue