diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 1776cc9a0566756ae18befbaf2c03adf5d68c79e..2f88a05c5ae1d57afcdd086fc9c0fcdcce8f7f6c 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -699,7 +699,7 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo if (isNull(p, TSDB_DATA_TYPE_NCHAR) && pInfo->field.type == TSDB_DATA_TYPE_NCHAR) { memcpy(dst, p, varDataTLen(p)); - } else if(isNull(p, TSDB_DATA_TYPE_JSON && pInfo->field.type == TSDB_DATA_TYPE_JSON)) { + } else if(isNull(p, TSDB_DATA_TYPE_JSON) && pInfo->field.type == TSDB_DATA_TYPE_JSON) { memcpy(dst, p, varDataTLen(p)); }else if (varDataLen(p) > 0) { int32_t length = taosUcs4ToMbs(varDataVal(p), varDataLen(p), varDataVal(dst)); @@ -5158,11 +5158,12 @@ void getJsonTagValueElment(STable* data, char* key, int32_t keyLen, char* dst, i return; } - char out[TSDB_MAX_TAGS_LEN] = {0}; + char out[20] = {0}; char* realData = POINTER_SHIFT(result, CHAR_BYTES); if(*(char*)result == TSDB_DATA_TYPE_NCHAR) { - assert(varDataTLen(result) <= TSDB_MAX_TAGS_LEN); - varDataCopy(out, result); + assert(varDataTLen(realData) <= bytes); + varDataCopy(dst, realData); + return; }else if (*(char*)result == TSDB_DATA_TYPE_DOUBLE) { double jsonVd = *(double*)(realData); sprintf(varDataVal(out), "%.9lf", jsonVd); diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index 72528e2d6885ae25cb352ea28d6bf839ab57fa9b..79e4168792c5ff12e9e886d6a182019cc88f6cfa 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -176,19 +176,19 @@ class TDTestCase: tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_5 using db_json_tag_test.jsons1 tags('\t')") tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_6 using db_json_tag_test.jsons1 tags('')") tdSql.query("select jtag from db_json_tag_test.jsons1_6") - tdSql.checkData(0, 0, "") + tdSql.checkData(0, 0, None) tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_7 using db_json_tag_test.jsons1 tags('{}')") tdSql.query("select jtag from db_json_tag_test.jsons1_7") - tdSql.checkData(0, 0, "") + tdSql.checkData(0, 0, None) tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_8 using db_json_tag_test.jsons1 tags('null')") tdSql.query("select jtag from db_json_tag_test.jsons1_8") - tdSql.checkData(0, 0, "") + tdSql.checkData(0, 0, None) tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_9 using db_json_tag_test.jsons1 tags('{\"\":4, \"time\":null}')") tdSql.query("select jtag from db_json_tag_test.jsons1_9") - tdSql.checkData(0, 0, "") + tdSql.checkData(0, 0, None) tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_10 using db_json_tag_test.jsons1 tags('{\"k1\":\"\",\"k1\":\"v1\",\"k2\":true,\"k3\":false,\"k4\":55}')") tdSql.query("select jtag from db_json_tag_test.jsons1_10")