提交 80725235 编写于 作者: wmmhello's avatar wmmhello

refactor: add json tag function for sql parser

上级 93cbee69
...@@ -738,7 +738,7 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi ...@@ -738,7 +738,7 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi
} }
varDataSetLen(pa->buf, output); varDataSetLen(pa->buf, output);
tdAddColToKVRow(pa->builder, colId, varDataTLen(pa->buf)); tdAddColToKVRow(pa->builder, colId, pa->buf, varDataTLen(pa->buf));
} else { } else {
tdAddColToKVRow(pa->builder, colId, value, TYPE_BYTES[type]); tdAddColToKVRow(pa->builder, colId, value, TYPE_BYTES[type]);
} }
......
...@@ -242,6 +242,7 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) { ...@@ -242,6 +242,7 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) {
j++; j++;
} }
dst[j] = '\0'; dst[j] = '\0';
strtrim(dst);
return j; return j;
} }
...@@ -259,7 +260,7 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p ...@@ -259,7 +260,7 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p
uint8_t jsonNULL = TSDB_JSON_NULL; uint8_t jsonNULL = TSDB_JSON_NULL;
int jsonIndex = startColId + 1; int jsonIndex = startColId + 1;
tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonKeyNULL, CHAR_BYTES); // add json null type tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonKeyNULL, CHAR_BYTES); // add json null type
if (!json || strtrim(json) == 0 || strncasecmp(json, "null", 4) == 0){ if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0){
tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonNULL, CHAR_BYTES); // add json null value tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonNULL, CHAR_BYTES); // add json null value
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -281,13 +282,13 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p ...@@ -281,13 +282,13 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p
cJSON* item = cJSON_GetArrayItem(root, i); cJSON* item = cJSON_GetArrayItem(root, i);
if (!item) { if (!item) {
qError("json inner error:%d", i); qError("json inner error:%d", i);
return buildSyntaxErrMsg(pMsgBuf, "json inner error", json); retCode = buildSyntaxErrMsg(pMsgBuf, "json inner error", json);
goto end; goto end;
} }
char *jsonKey = item->string; char *jsonKey = item->string;
if(!isValidateTag(jsonKey)){ if(!isValidateTag(jsonKey)){
retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey); retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey);
goto end; goto end;
} }
// if(strlen(jsonKey) > TSDB_MAX_JSON_KEY_LEN){ // if(strlen(jsonKey) > TSDB_MAX_JSON_KEY_LEN){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册