diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e0351784ff9ea1f4bb76f0ef865abb89c7518fbe..447de9de93ebffa7103c3913bd9257ac1095a410 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6031,12 +6031,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } int32_t schemaLen = sizeof(STColumn) * numOfTags; - int32_t size = 0; - if (pTagsSchema->type == TSDB_DATA_TYPE_JSON){ - size = sizeof(SUpdateTableTagValMsg) + pTagsSchema->bytes + schemaLen + TSDB_EXTRA_PAYLOAD_SIZE; - } else { - size = sizeof(SUpdateTableTagValMsg) + TSDB_MAX_TAGS_LEN + schemaLen + TSDB_EXTRA_PAYLOAD_SIZE; - } + int32_t size = = sizeof(SUpdateTableTagValMsg) + pTagsSchema->bytes + schemaLen + TSDB_EXTRA_PAYLOAD_SIZE; if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) { tscError("0x%"PRIx64" failed to malloc for alter table pMsg", pSql->self); @@ -6099,10 +6094,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } int32_t len = 0; - if (!IS_VAR_DATA_TYPE(pTagsSchema->type)) { - len = tDataTypes[pTagsSchema->type].bytes; - } else if(pTagsSchema->type == TSDB_DATA_TYPE_JSON){ + if(pTagsSchema->type == TSDB_DATA_TYPE_JSON){ len = kvRowLen(pUpdateMsg->data + schemaLen); + }else if (!IS_VAR_DATA_TYPE(pTagsSchema->type)) { + len = tDataTypes[pTagsSchema->type].bytes; } else { len = varDataTLen(pUpdateMsg->data + schemaLen); if(len > pTagsSchema->bytes) return invalidOperationMsg(pMsg, msg14); diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index 36fc03f23d97facce7dd8322053ff97bc02373ca..774a5570821ca491c4de3547c1247156cbd6dbd8 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -33,8 +33,8 @@ class TDTestCase: #tdSql.execute("create table if not exists db_json_tag_test.jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json)") #tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_1 using db_json_tag_test.jsons1 tags('{\"loc\":\"fff\",\"id\":5}')") #tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_3 using db_json_tag_test.jsons1 tags(3333)") - #tdSql.execute("insert into jsons1_2 using db_json_tag_test.jsons1 tags('{\"num\":5,\"location\":\"beijing\"}' values (now, 1, 'sss')") - #tdSql.execute("insert into jsons1_4 using db_json_tag_test.jsons1 tags(3)") + #tdSql.execute("insert into db_json_tag_test.jsons1_2 using db_json_tag_test.jsons1 tags('{\"num\":5,\"location\":\"beijing\"}' values (now, 1, 'sss')") + #tdSql.execute("insert into db_json_tag_test.jsons1_4 using db_json_tag_test.jsons1 tags(3)") print("==============step2") tdLog.info("select table")