[TD-5594]<fix>:calculate tag index in table meta when modify tag type

This commit is contained in:
shenglian zhou 2021-07-28 16:59:04 +08:00
parent 1d3df4a966
commit bb2b2ec9f4
2 changed files with 9 additions and 4 deletions

View File

@ -6078,10 +6078,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
int16_t numOfTags = tscGetNumOfTags(pTableMetaInfo->pTableMeta);
int16_t i;
int32_t numOfCols = tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
int32_t tagIndex = columnIndex.columnIndex - numOfCols;
assert(tagIndex>=0);
uint32_t nLen = 0;
for (i = 0; i < numOfTags; ++i) {
nLen += (i != columnIndex.columnIndex) ? pSchema[i].bytes : pItem->bytes;
for (int i = 0; i < numOfTags; ++i) {
nLen += (i != tagIndex) ? pSchema[i].bytes : pItem->bytes;
}
if (nLen >= TSDB_MAX_TAGS_LEN) {
return invalidOperationMsg(pMsg, msg24);

View File

@ -35,6 +35,9 @@ sql alter table tb1 set tag name = ""
sql alter table tb1 set tag name = "shenzhen"
sql alter table tb1 set tag len = 379
# case TD-5594
sql create stable st5520(ts timestamp, f int) tags(t0 bool, t1 nchar(4093), t2 nchar(1))
sql_error alter stable st5520 modify tag t2 nchar(2);
# test end
sql drop database $db