Merge pull request #28962 from taosdata/fix/TD-33058
update test case and remove invalid code
This commit is contained in:
commit
7b6c19d4d6
|
@ -755,9 +755,9 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* colValue = cJSON_CreateString(buf);
|
cJSON* colValue = cJSON_CreateString(buf);
|
||||||
|
taosMemoryFree(buf);
|
||||||
RAW_NULL_CHECK(colValue);
|
RAW_NULL_CHECK(colValue);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValue", colValue));
|
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValue", colValue));
|
||||||
taosMemoryFree(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
||||||
|
@ -804,9 +804,9 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
cJSON* colValue = cJSON_CreateString(buf);
|
cJSON* colValue = cJSON_CreateString(buf);
|
||||||
|
taosMemoryFree(buf);
|
||||||
RAW_NULL_CHECK(colValue);
|
RAW_NULL_CHECK(colValue);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colValue", colValue));
|
RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colValue", colValue));
|
||||||
taosMemoryFree(buf);
|
|
||||||
}
|
}
|
||||||
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
||||||
RAW_NULL_CHECK(isNullCJson);
|
RAW_NULL_CHECK(isNullCJson);
|
||||||
|
|
|
@ -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);
|
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};
|
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||||
if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) {
|
((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);
|
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};
|
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||||
if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) {
|
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) {
|
||||||
|
|
|
@ -2547,6 +2547,7 @@ SNode* createAlterSingleTagColumnNode(SAstCreateContext* pCtx, SToken* pTagName,
|
||||||
pCtx->errCode = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT, (SNode**)&pStmt);
|
pCtx->errCode = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT, (SNode**)&pStmt);
|
||||||
CHECK_MAKE_NODE(pStmt);
|
CHECK_MAKE_NODE(pStmt);
|
||||||
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||||
|
CHECK_NAME(checkColumnName(pCtx, pTagName));
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pTagName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pTagName);
|
||||||
pStmt->pVal = (SValueNode*)pVal;
|
pStmt->pVal = (SValueNode*)pVal;
|
||||||
pStmt->pNodeListTagValue = NULL;
|
pStmt->pNodeListTagValue = NULL;
|
||||||
|
|
|
@ -34,14 +34,33 @@ sql create table $ntable (ts timestamp, f int)
|
||||||
|
|
||||||
sql insert into $tb values(now, 1)
|
sql insert into $tb values(now, 1)
|
||||||
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
|
# invalid sql
|
||||||
sql_error alter table $tbj set tag tagCol1=1,tagCol1 = 2 # dumplicate tag name
|
sql_error alter table $mt set tag tgcol1 = 1,
|
||||||
sql_error alter table $tbj set tag tagCol1=1,tagCol1 = 2 # not exist tag
|
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"
|
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="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"
|
|
||||||
|
# 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 alter table $tbj set tag tagCol1 = 100, tagCol2 = 100
|
||||||
|
|
||||||
sql select * from $mt where tagCol2 = 100
|
sql select * from $mt where tagCol2 = 100
|
||||||
|
@ -180,12 +199,14 @@ if $rows != 1 then
|
||||||
endi
|
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 $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 tagCol7
|
||||||
sql alter table $mt drop tag tagCol3
|
sql alter table $mt drop tag tagCol3
|
||||||
|
|
||||||
sql alter table $mt add tag tagCol8 int
|
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_error alter table $tbj set tag tagCol1=true,tagCol2=-10,tagcol3=-100, tagcol4=-1000,tagcol5=NULL,tagCol6=NULL,tagCol7=NULL
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue