提交 7d8887a4 编写于 作者: X xywang

[TS-1289]<fix>: fixed show create stable error if tag type was json

上级 87e8dd9e
...@@ -375,6 +375,8 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { ...@@ -375,6 +375,8 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
|| fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_BINARY
|| fields[i].type == TSDB_DATA_TYPE_TIMESTAMP) && 0 == ret) { || fields[i].type == TSDB_DATA_TYPE_TIMESTAMP) && 0 == ret) {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "\"%s\",", buf); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "\"%s\",", buf);
} else if (fields[i].type == TSDB_DATA_TYPE_JSON) {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "'%s,", buf);
} else { } else {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf);
} }
...@@ -382,7 +384,11 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { ...@@ -382,7 +384,11 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
free(buf); free(buf);
if (i == num_fields - 1) { if (i == num_fields - 1) {
sprintf(result + strlen(result) - 1, "%s", ")"); if (fields[i].type == TSDB_DATA_TYPE_JSON) {
sprintf(result + strlen(result) - 1, "%s'", ")");
} else {
sprintf(result + strlen(result) - 1, "%s", ")");
}
} }
} }
......
...@@ -4533,21 +4533,13 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { ...@@ -4533,21 +4533,13 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) {
return; return;
} }
char *p = NULL;
char* str = malloc(strlen(json) + 3);
if (str) {
snprintf(str, len + 3, "'%s'", json);
}
p = str ? str : json;
int32_t length = 0; int32_t length = 0;
if(!taosMbsToUcs4(p, strlen(p), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){ if(!taosMbsToUcs4(json, strlen(json), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){
tsdbError("getJsonTagValueAll mbstoucs4 error! length:%d", length); tsdbError("getJsonTagValueAll mbstoucs4 error! length:%d", length);
} }
varDataSetLen(tagData, length); varDataSetLen(tagData, length);
assert(varDataTLen(tagData) <= bytes); assert(varDataTLen(tagData) <= bytes);
tfree(json); tfree(json);
tfree(str);
} }
char* parseTagDatatoJson(void *p){ char* parseTagDatatoJson(void *p){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册