fix:[TD-31017]process return value in clientRawBlockWrite.c

This commit is contained in:
wangmm0220 2024-07-19 14:49:25 +08:00
parent 5957b2c19a
commit 6b9c00cb9b
10 changed files with 587 additions and 667 deletions

View File

@ -334,7 +334,7 @@ SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* nam
void destroyQueryExecRes(SExecResult* pRes);
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
char* parseTagDatatoJson(void* p);
void parseTagDatatoJson(void* p, char** jsonStr);
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);

View File

@ -55,7 +55,7 @@ typedef enum { M2C = 0, C2M } ConvType;
#define tstrncpy(dst, src, size) \
do { \
strncpy((dst), (src), (size)); \
(void)strncpy((dst), (src), (size)); \
(dst)[(size)-1] = 0; \
} while (0)

View File

@ -2007,7 +2007,8 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
varDataSetLen(dst, strlen(varDataVal(dst)));
} else if (tTagIsJson(data)) {
char* jsonString = parseTagDatatoJson(data);
char* jsonString = NULL;
parseTagDatatoJson(data, &jsonString);
STR_TO_VARSTR(dst, jsonString);
taosMemoryFree(jsonString);
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"

File diff suppressed because it is too large Load Diff

View File

@ -10820,7 +10820,9 @@ int32_t tDecodeMqBatchMetaRsp(SDecoder *pDecoder, SMqBatchMetaRsp *pRsp) {
if (tDecodeI32(pDecoder, &size) < 0) return -1;
if (size > 0) {
pRsp->batchMetaReq = taosArrayInit(size, POINTER_BYTES);
if (!pRsp->batchMetaReq) return -1;
pRsp->batchMetaLen = taosArrayInit(size, sizeof(int32_t));
if (!pRsp->batchMetaLen) return -1;
for (int32_t i = 0; i < size; i++) {
void *pCreate = NULL;
uint64_t len = 0;

View File

@ -448,7 +448,8 @@ int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
}
char* pJson = parseTagDatatoJson(pTag);
char* pJson = NULL;
parseTagDatatoJson(pTag, &pJson);
STagVal tagVal;
tagVal.cid = 0;
tagVal.type = TSDB_DATA_TYPE_JSON;

View File

@ -1772,7 +1772,8 @@ int32_t ctgHandleGetTbTagRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
}
char* pJson = parseTagDatatoJson(pTag);
char* pJson = NULL;
parseTagDatatoJson(pTag, &pJson);
STagVal tagVal;
tagVal.cid = 0;
tagVal.type = TSDB_DATA_TYPE_JSON;

View File

@ -503,11 +503,10 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
}
if (tTagIsJson(pTag)) {
char* pJson = parseTagDatatoJson(pTag);
if (pJson) {
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
taosMemoryFree(pJson);
}
char* pJson = NULL;
parseTagDatatoJson(pTag, &pJson);
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
taosMemoryFree(pJson);
return TSDB_CODE_SUCCESS;
}

View File

@ -966,7 +966,8 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
char* tagVarChar = NULL;
if (tagData != NULL) {
if (tagType == TSDB_DATA_TYPE_JSON) {
char* tagJson = parseTagDatatoJson(tagData);
char* tagJson = NULL;
parseTagDatatoJson(tagData, &tagJson);
tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE);
memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson));
varDataSetLen(tagVarChar, strlen(tagJson));

View File

@ -415,7 +415,7 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t
return TSDB_CODE_SUCCESS;
}
char* parseTagDatatoJson(void* p) {
void parseTagDatatoJson(void* p, char** jsonStr) {
char* string = NULL;
SArray* pTagVals = NULL;
cJSON* json = NULL;
@ -434,6 +434,9 @@ char* parseTagDatatoJson(void* p) {
}
for (int j = 0; j < nCols; ++j) {
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
if (pTagVal == NULL) {
continue;
}
// json key encode by binary
tstrncpy(tagJsonKey, pTagVal->pKey, sizeof(tagJsonKey));
// json value
@ -443,11 +446,16 @@ char* parseTagDatatoJson(void* p) {
if (value == NULL) {
goto end;
}
cJSON_AddItemToObject(json, tagJsonKey, value);
if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_NCHAR) {
cJSON* value = NULL;
if (pTagVal->nData > 0) {
char* tagJsonValue = taosMemoryCalloc(pTagVal->nData, 1);
if (tagJsonValue == NULL) {
goto end;
}
int32_t length = taosUcs4ToMbs((TdUcs4*)pTagVal->pData, pTagVal->nData, tagJsonValue);
if (length < 0) {
qError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
@ -462,25 +470,34 @@ char* parseTagDatatoJson(void* p) {
}
} else if (pTagVal->nData == 0) {
value = cJSON_CreateString("");
if (value == NULL) {
goto end;
}
} else {
goto end;
}
cJSON_AddItemToObject(json, tagJsonKey, value);
if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
double jsonVd = *(double*)(&pTagVal->i64);
cJSON* value = cJSON_CreateNumber(jsonVd);
if (value == NULL) {
goto end;
}
cJSON_AddItemToObject(json, tagJsonKey, value);
if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_BOOL) {
char jsonVd = *(char*)(&pTagVal->i64);
cJSON* value = cJSON_CreateBool(jsonVd);
if (value == NULL) {
goto end;
}
cJSON_AddItemToObject(json, tagJsonKey, value);
if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else {
goto end;
}
@ -492,7 +509,7 @@ end:
if (string == NULL) {
string = taosStrdup(TSDB_DATA_NULL_STR_L);
}
return string;
*jsonStr = string;
}
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {