From 95a1005e1f53b8c0efdf05f7c06b639a9ccda0d4 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 28 Nov 2024 15:09:20 +0800 Subject: [PATCH] update test case and remove invalid code --- source/client/src/clientRawBlockWrite.c | 4 +-- source/dnode/vnode/src/meta/metaTable.c | 10 -------- tests/script/tsim/tag/change_multi_tag.sim | 30 +++++++++++++++++----- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index 6331224c3a..3a23d38375 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -755,9 +755,9 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) { } cJSON* colValue = cJSON_CreateString(buf); + taosMemoryFree(buf); RAW_NULL_CHECK(colValue); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValue", colValue)); - taosMemoryFree(buf); } cJSON* isNullCJson = cJSON_CreateBool(isNull); @@ -804,9 +804,9 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) { goto end; } cJSON* colValue = cJSON_CreateString(buf); + taosMemoryFree(buf); RAW_NULL_CHECK(colValue); RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colValue", colValue)); - taosMemoryFree(buf); } cJSON* isNullCJson = cJSON_CreateBool(isNull); RAW_NULL_CHECK(isNullCJson); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 8256b5e402..65e520bb4a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -2215,11 +2215,6 @@ static int metaUpdateTableMultiTagVal(SMeta *pMeta, int64_t version, SVAlterTbRe metaError("meta/table: failed to update tag idx:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid); } - if (NULL == ctbEntry.ctbEntry.pTags) { - metaError("meta/table: null tags, update tag val failed."); - goto _err; - } - SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid}; if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) { @@ -2454,11 +2449,6 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA metaError("meta/table: failed to update tag idx:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid); } - if (NULL == ctbEntry.ctbEntry.pTags) { - metaError("meta/table: null tags, update tag val failed."); - goto _err; - } - SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid}; if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) { diff --git a/tests/script/tsim/tag/change_multi_tag.sim b/tests/script/tsim/tag/change_multi_tag.sim index 30ae1c653a..5bd8cba916 100644 --- a/tests/script/tsim/tag/change_multi_tag.sim +++ b/tests/script/tsim/tag/change_multi_tag.sim @@ -34,15 +34,30 @@ sql create table $ntable (ts timestamp, f int) sql insert into $tb values(now, 1) sql insert into $tb values(now, 1) -sql_error alter table $mt set tag tgcol1 = 1,tagcol2 = 2, tag3 = 4 # set tag value on supertable -sql_error alter table $ntable set tag f = 10 # set normal table value -sql_error alter table $tbj set tag tagCol1=1,tagCol1 = 2 # dumplicate tag name -sql_error alter table $tbj set tag tagCol1=1,tagCol1 = 2 # not exist tag + +# invalid sql +sql_error alter table $mt set tag tgcol1 = 1, +sql_error alter table $mt set tag , +sql_error alter table $mt set tag tgcol1=10,tagcol2= +#set tag value on supertable +sql_error alter table $mt set tag tgcol1 = 1,tagcol2 = 2, tag3 = 4 +#set normal table value +sql_error alter table $ntable set tag f = 10 +# duplicate tag name +sql_error alter table $tbj set tag tagCol1=1,tagCol1 = 2 +sql_error alter table $tbj set tag tagCol1=1,tagCol5=10, tagCol5=3 +# not exist tag +sql_error alter table $tbj set tag tagNotExist = 1,tagCol1 = 2 +sql_error alter table $tbj set tag tagCol1 = 2, tagNotExist = 1 +sql_error alter table $tbj set tagNotExist = 1 +sql_error alter table $tbj set tagNotExist = NULL, sql_error alter table $tbj set tag tagCol1 = 1, tagCol5="xxxxxxxxxxxxxxxx" +# invalid tag value sql_error alter table $tbj set tag tagCol1 = 1, tagCol5="xxxxxxxxxxxxxxxx", tagCol7="yyyyyyyyyyyyyyyyyyyyyyyyy" -sql_error alter table $tbj set tag tagCol1=1,tagCol5=10, tagCol1=3 +# invalid data type sql_error alter table $tbj set tag tagCol5="xxxx" -sql alter table $tbj set tag tagCol1 = 100, tagCol2 = 100 + +sql alter table $tbj set tag tagCol1 = 100, tagCol2 = 100 sql select * from $mt where tagCol2 = 100 if $rows != 0 then @@ -186,8 +201,9 @@ sql alter table $mt drop tag tagCol3 sql alter table $mt add tag tagCol8 int +#set not exist tag and value sql_error alter table $tbj set tag tagCol1=true,tagCol2=-10,tagcol3=-100, tagcol4=-1000,tagcol5=NULL,tagCol6=NULL,tagCol7=NULL -sql_error alter table $tbj set tag tagCol1=true,tagCol2=-10,tagcol3=-100, tagcol4=-1000,tagcol5=NULL,tagCol6=NULL,tagCol7=NULL +sql_error alter table $tbj set tag tagCol1=true,tagCol2=-10,tagcol3=-100, tagcol4=-1000,tagcol5=NULL,tagCol6=NULL,tagCol7=NULL sql alter table $tbj set tag tagCol8 = 8