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); void destroyQueryExecRes(SExecResult* pRes);
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len); 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); int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType); void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst); int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);

View File

@ -55,7 +55,7 @@ typedef enum { M2C = 0, C2M } ConvType;
#define tstrncpy(dst, src, size) \ #define tstrncpy(dst, src, size) \
do { \ do { \
strncpy((dst), (src), (size)); \ (void)strncpy((dst), (src), (size)); \
(dst)[(size)-1] = 0; \ (dst)[(size)-1] = 0; \
} while (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); sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
varDataSetLen(dst, strlen(varDataVal(dst))); varDataSetLen(dst, strlen(varDataVal(dst)));
} else if (tTagIsJson(data)) { } else if (tTagIsJson(data)) {
char* jsonString = parseTagDatatoJson(data); char* jsonString = NULL;
parseTagDatatoJson(data, &jsonString);
STR_TO_VARSTR(dst, jsonString); STR_TO_VARSTR(dst, jsonString);
taosMemoryFree(jsonString); taosMemoryFree(jsonString);
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value" } 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 (tDecodeI32(pDecoder, &size) < 0) return -1;
if (size > 0) { if (size > 0) {
pRsp->batchMetaReq = taosArrayInit(size, POINTER_BYTES); pRsp->batchMetaReq = taosArrayInit(size, POINTER_BYTES);
if (!pRsp->batchMetaReq) return -1;
pRsp->batchMetaLen = taosArrayInit(size, sizeof(int32_t)); pRsp->batchMetaLen = taosArrayInit(size, sizeof(int32_t));
if (!pRsp->batchMetaLen) return -1;
for (int32_t i = 0; i < size; i++) { for (int32_t i = 0; i < size; i++) {
void *pCreate = NULL; void *pCreate = NULL;
uint64_t len = 0; 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); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
} }
char* pJson = parseTagDatatoJson(pTag); char* pJson = NULL;
parseTagDatatoJson(pTag, &pJson);
STagVal tagVal; STagVal tagVal;
tagVal.cid = 0; tagVal.cid = 0;
tagVal.type = TSDB_DATA_TYPE_JSON; 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); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
} }
char* pJson = parseTagDatatoJson(pTag); char* pJson = NULL;
parseTagDatatoJson(pTag, &pJson);
STagVal tagVal; STagVal tagVal;
tagVal.cid = 0; tagVal.cid = 0;
tagVal.type = TSDB_DATA_TYPE_JSON; 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)) { if (tTagIsJson(pTag)) {
char* pJson = parseTagDatatoJson(pTag); char* pJson = NULL;
if (pJson) { parseTagDatatoJson(pTag, &pJson);
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson); *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
taosMemoryFree(pJson); taosMemoryFree(pJson);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -966,7 +966,8 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
char* tagVarChar = NULL; char* tagVarChar = NULL;
if (tagData != NULL) { if (tagData != NULL) {
if (tagType == TSDB_DATA_TYPE_JSON) { if (tagType == TSDB_DATA_TYPE_JSON) {
char* tagJson = parseTagDatatoJson(tagData); char* tagJson = NULL;
parseTagDatatoJson(tagData, &tagJson);
tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE); tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE);
memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson)); memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson));
varDataSetLen(tagVarChar, 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; return TSDB_CODE_SUCCESS;
} }
char* parseTagDatatoJson(void* p) { void parseTagDatatoJson(void* p, char** jsonStr) {
char* string = NULL; char* string = NULL;
SArray* pTagVals = NULL; SArray* pTagVals = NULL;
cJSON* json = NULL; cJSON* json = NULL;
@ -434,6 +434,9 @@ char* parseTagDatatoJson(void* p) {
} }
for (int j = 0; j < nCols; ++j) { for (int j = 0; j < nCols; ++j) {
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j); STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
if (pTagVal == NULL) {
continue;
}
// json key encode by binary // json key encode by binary
tstrncpy(tagJsonKey, pTagVal->pKey, sizeof(tagJsonKey)); tstrncpy(tagJsonKey, pTagVal->pKey, sizeof(tagJsonKey));
// json value // json value
@ -443,11 +446,16 @@ char* parseTagDatatoJson(void* p) {
if (value == NULL) { if (value == NULL) {
goto end; goto end;
} }
cJSON_AddItemToObject(json, tagJsonKey, value); if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_NCHAR) { } else if (type == TSDB_DATA_TYPE_NCHAR) {
cJSON* value = NULL; cJSON* value = NULL;
if (pTagVal->nData > 0) { if (pTagVal->nData > 0) {
char* tagJsonValue = taosMemoryCalloc(pTagVal->nData, 1); char* tagJsonValue = taosMemoryCalloc(pTagVal->nData, 1);
if (tagJsonValue == NULL) {
goto end;
}
int32_t length = taosUcs4ToMbs((TdUcs4*)pTagVal->pData, pTagVal->nData, tagJsonValue); int32_t length = taosUcs4ToMbs((TdUcs4*)pTagVal->pData, pTagVal->nData, tagJsonValue);
if (length < 0) { if (length < 0) {
qError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, 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) { } else if (pTagVal->nData == 0) {
value = cJSON_CreateString(""); value = cJSON_CreateString("");
if (value == NULL) {
goto end;
}
} else { } else {
goto end; goto end;
} }
cJSON_AddItemToObject(json, tagJsonKey, value); if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_DOUBLE) { } else if (type == TSDB_DATA_TYPE_DOUBLE) {
double jsonVd = *(double*)(&pTagVal->i64); double jsonVd = *(double*)(&pTagVal->i64);
cJSON* value = cJSON_CreateNumber(jsonVd); cJSON* value = cJSON_CreateNumber(jsonVd);
if (value == NULL) { if (value == NULL) {
goto end; goto end;
} }
cJSON_AddItemToObject(json, tagJsonKey, value); if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else if (type == TSDB_DATA_TYPE_BOOL) { } else if (type == TSDB_DATA_TYPE_BOOL) {
char jsonVd = *(char*)(&pTagVal->i64); char jsonVd = *(char*)(&pTagVal->i64);
cJSON* value = cJSON_CreateBool(jsonVd); cJSON* value = cJSON_CreateBool(jsonVd);
if (value == NULL) { if (value == NULL) {
goto end; goto end;
} }
cJSON_AddItemToObject(json, tagJsonKey, value); if(!cJSON_AddItemToObject(json, tagJsonKey, value)){
goto end;
}
} else { } else {
goto end; goto end;
} }
@ -492,7 +509,7 @@ end:
if (string == NULL) { if (string == NULL) {
string = taosStrdup(TSDB_DATA_NULL_STR_L); string = taosStrdup(TSDB_DATA_NULL_STR_L);
} }
return string; *jsonStr = string;
} }
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) { int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {