Merge pull request #28962 from taosdata/fix/TD-33058

update test case and remove invalid code
This commit is contained in:
Shengliang Guan 2024-11-28 17:55:22 +08:00 committed by GitHub
commit 7b6c19d4d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 20 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -2547,6 +2547,7 @@ SNode* createAlterSingleTagColumnNode(SAstCreateContext* pCtx, SToken* pTagName,
pCtx->errCode = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT, (SNode**)&pStmt);
CHECK_MAKE_NODE(pStmt);
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
CHECK_NAME(checkColumnName(pCtx, pTagName));
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pTagName);
pStmt->pVal = (SValueNode*)pVal;
pStmt->pNodeListTagValue = NULL;

View File

@ -34,15 +34,34 @@ 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
sql_error alter table $tbj set tag tagCol5="xxxx"
sql alter table $tbj set tag tagCol1 = 100, tagCol2 = 100
# invalid data type
# escape
sql_error alter table $tbj set tag `tagCol1`=true
sql_error alter table $tbj set tag `tagCol1`=true,`tagCol2`=1,`tagNotExist`=10
sql_error alter table $tbj set tag `tagCol1`=true,`tagCol2`=1,tagcol1=true
sql alter table $tbj set tag tagCol1 = 100, tagCol2 = 100
sql select * from $mt where tagCol2 = 100
if $rows != 0 then
@ -180,14 +199,16 @@ if $rows != 1 then
endi
sql 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 `tagcol1`=true,`tagcol2`=-10,`tagcol3`=-100, `tagcol4`=-1000,`tagcol5`=NULL,`tagcol6`=NULL,`tagcol7`=NULL
sql alter table $mt drop tag tagCol7
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