提交 b404f022 编写于 作者: wmmhello's avatar wmmhello

TD-6129<feature> add json type check

上级 cd8c5c66
......@@ -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);
......
......@@ -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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册