From a774d3b428dc277a3960981f609b5a0285f7d731 Mon Sep 17 00:00:00 2001 From: Pengrongkun Date: Sat, 16 Nov 2024 09:27:52 +0800 Subject: [PATCH] fix some review problem --- include/common/tdataformat.h | 2 +- source/libs/parser/src/parInsertStmt.c | 28 ++------------------------ source/libs/parser/src/parUtil.c | 12 ++++++----- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 4d289b6780..c0b899b6aa 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -155,7 +155,7 @@ int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove int32_t parseJsontoTagData(const char *json, SArray *pTagVals, STag **ppTag, void *pMsgBuf); -int32_t parseGeotoTagData(const char *g, SArray *pTagVals, SSchema *pTagSchema, unsigned char *output); +int32_t parseGeotoTagData(const char *g, SArray *pTagVals, SSchema *pTagSchema); // SColData ================================ typedef struct { diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index 819f47180f..8715d1d3ec 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -189,19 +189,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch goto end; } } else if (pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) { - char* tmp = taosMemoryCalloc(1, colLen); - if (!tmp) { - code = terrno; - goto end; - } - memcpy(tmp, bind[c].buffer, colLen); - unsigned char* out = NULL; - code = parseGeotoTagData(tmp, pTagArray, pTagSchema, out); - taosMemoryFree(tmp); - if (code != TSDB_CODE_SUCCESS) { - geosFreeBuffer(out); - goto end; - } + code = parseGeotoTagData(bind[c].buffer, pTagArray, pTagSchema); } else { STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; // strcpy(val.colName, pTagSchema->name); @@ -590,19 +578,7 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c goto end; } } else if (pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) { - char* tmp = taosMemoryCalloc(1, colLen); - if (!tmp) { - code = terrno; - goto end; - } - memcpy(tmp, bind[c].buffer, colLen); - unsigned char* out = NULL; - code = parseGeotoTagData(tmp, pTagArray, pTagSchema, out); - taosMemoryFree(tmp); - if (code != TSDB_CODE_SUCCESS) { - geosFreeBuffer(out); - goto end; - } + code = parseGeotoTagData(bind[c].buffer, pTagArray, pTagSchema); } else { STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; // strcpy(val.colName, pTagSchema->name); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index fc6ed0d7b0..33b36c98fb 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -519,13 +519,14 @@ end: return retCode; } -int32_t parseGeotoTagData(const char* g, SArray* pTagVals, SSchema* pTagSchema, unsigned char* output) { - int32_t code = 0; - size_t size = 0; - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; +int32_t parseGeotoTagData(const char* g, SArray* pTagVals, SSchema* pTagSchema) { + int32_t code = 0; + size_t size = 0; + unsigned char* output = NULL; + STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; code = initCtxGeomFromText(); if (code != TSDB_CODE_SUCCESS) { - goto end; + return code; } code = doGeomFromText(g, &output, &size); if (code != TSDB_CODE_SUCCESS) { @@ -541,6 +542,7 @@ int32_t parseGeotoTagData(const char* g, SArray* pTagVals, SSchema* pTagSchema, if (NULL == taosArrayPush(pTagVals, &val)) { code = terrno; + geosFreeBuffer(output); goto end; }