Merge pull request #7060 from taosdata/hotfix/td-5594
[TD-5594]<fix>:calculate tag index in table meta when modify tag type
This commit is contained in:
commit
c1650bd06f
|
@ -6078,10 +6078,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
||||||
int16_t numOfTags = tscGetNumOfTags(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;
|
uint32_t nLen = 0;
|
||||||
for (i = 0; i < numOfTags; ++i) {
|
for (int i = 0; i < numOfTags; ++i) {
|
||||||
nLen += (i != columnIndex.columnIndex) ? pSchema[i].bytes : pItem->bytes;
|
nLen += (i != tagIndex) ? pSchema[i].bytes : pItem->bytes;
|
||||||
}
|
}
|
||||||
if (nLen >= TSDB_MAX_TAGS_LEN) {
|
if (nLen >= TSDB_MAX_TAGS_LEN) {
|
||||||
return invalidOperationMsg(pMsg, msg24);
|
return invalidOperationMsg(pMsg, msg24);
|
||||||
|
|
|
@ -35,7 +35,10 @@ sql alter table tb1 set tag name = ""
|
||||||
sql alter table tb1 set tag name = "shenzhen"
|
sql alter table tb1 set tag name = "shenzhen"
|
||||||
sql alter table tb1 set tag len = 379
|
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
|
# test end
|
||||||
sql drop database $db
|
sql drop database $db
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
Loading…
Reference in New Issue