From f6e19a726cc6fd2b6fe1a54f28243a2bf197d379 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Oct 2021 14:45:49 +0800 Subject: [PATCH] TD-6129 fix select * from json tag --- src/client/src/tscUtil.c | 2 ++ src/query/src/qExecutor.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 9a7d1a5c36..e0426cc2f0 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -727,12 +727,14 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo char* p = pRes->urow[i]; for (int32_t k = 0; k < pRes->numOfRows; ++k) { char* dst = pRes->buffer[i] + k * pInfo->field.bytes; + p = varDataVal(p); char* realData = p + CHAR_BYTES; if (*p == SELECT_ALL_JSON_TAG){ char* json = parseTagDatatoJson(realData, pInfo->field.type); if(json) { memcpy(varDataVal(dst), json, strlen(json)); varDataSetLen(dst, strlen(json)); + assert(varDataTLen(dst) <= pInfo->field.type); tfree(json); } }else if (*p == SELECT_ELEMENT_JSON_TAG){ diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 48d86df436..c98e287eda 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3362,6 +3362,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, tVariantCreateFromBinary(tag, val, bytes, type); memcpy(tag->pz + 1, tag->pz, bytes - 1); // move back 1 byte for select type *(tag->pz) = SELECT_ALL_JSON_TAG; + tag->nLen++; } else { tVariantCreateFromBinary(tag, val, bytes, type); -- GitLab