diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index ac5b4f2ec2073c4d903cbd72aa1c149b81543588..4249155eab6284c54f206dfa4d2a8e82fb1be895 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -307,6 +307,7 @@ typedef struct { char * data; TAOS_ROW tsrow; TAOS_ROW urow; + bool dataConverted; int32_t* length; // length for each field for current row char ** buffer; // Buffer used to put multibytes encoded using unicode (wchar_t) SColumnIndex* pColumnIndex; @@ -439,7 +440,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo *pQueryInfo); void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo); int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo); -void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo); +void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo, bool converted); void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar); void handleDownstreamOperator(SSqlObj** pSqlList, int32_t numOfUpstream, SQueryInfo* px, SSqlObj* pParent); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 4dd252b692abcf62ad210a88c86f94a689caa84b..c2202f1e67a1ecda9dd873d288953b54911fc931 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1892,7 +1892,7 @@ static int tscLocalResultCommonBuilder(SSqlObj *pSql, int32_t numOfRes) { return pRes->code; } - tscSetResRawPtr(pRes, pQueryInfo); + tscSetResRawPtr(pRes, pQueryInfo, pRes->dataConverted); } else { tscResetForNextRetrieve(pRes); } @@ -2807,7 +2807,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_QUERY) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE))) { - tscSetResRawPtr(pRes, pQueryInfo); + tscSetResRawPtr(pRes, pQueryInfo, pRes->dataConverted); } if (pSql->pSubscription != NULL) { diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index a8cd56204ef6af812ac4e27c610a3565a79827d1..925ad3306a312a487cc5dfd45364e1394e8f1462 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3448,6 +3448,8 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { char* pData = getResultBlockPosition(pCmd1, pRes1, pIndex->columnIndex, &bytes); memcpy(data, pData, bytes * numOfRes); + pRes->dataConverted = pRes1->dataConverted; + data += bytes * numOfRes; } @@ -3473,7 +3475,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { doArithmeticCalculate(pQueryInfo, pFilePage, rowSize, finalRowSize); pRes->data = pFilePage->data; - tscSetResRawPtr(pRes, pQueryInfo); + tscSetResRawPtr(pRes, pQueryInfo, pRes->dataConverted); } void tscBuildResFromSubqueries(SSqlObj *pSql) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 21e67e56e87da03afd400bea6321358541425667..1b4dff4b1b5a9c0b8053ed3f6289676c87ab0289 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -690,9 +690,13 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); } + + if (convertNchar) { + pRes->dataConverted = true; + } } -void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) { +void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo, bool converted) { assert(pRes->numOfCols > 0); if (pRes->numOfRows == 0) { return; @@ -705,7 +709,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) { pRes->length[i] = pInfo->field.bytes; offset += pInfo->field.bytes; - setResRawPtrImpl(pRes, pInfo, i, true); + setResRawPtrImpl(pRes, pInfo, i, converted ? false : true); } } @@ -3424,6 +3428,7 @@ void tscResetForNextRetrieve(SSqlRes* pRes) { pRes->row = 0; pRes->numOfRows = 0; + pRes->dataConverted = false; } void tscInitResForMerge(SSqlRes* pRes) {