From 0d9e8ae76dacfd1220d9ebe9e92bc3357b7bd720 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 15 Oct 2021 16:04:45 +0800 Subject: [PATCH] [TD-10639]: allow OpenTSDB telnet line protocol metric value contain space inside double quote for string types --- src/client/src/tscParseOpenTSDB.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index a079198be3..a6c1acfc35 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -138,21 +138,41 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch const char *start, *cur; int32_t ret = TSDB_CODE_SUCCESS; int len = 0; + bool searchQuote = false; char key[] = OTD_METRIC_VALUE_COLUMN_NAME; char *value = NULL; start = cur = *index; + //if metric value is string + if (*cur == '"') { + searchQuote = true; + cur += 1; + len += 1; + } else if (*cur == 'L' && *(cur + 1) == '"') { + searchQuote = true; + cur += 2; + len += 2; + } + while(*cur != '\0') { if (*cur == ' ') { - if (*cur == ' ') { - if (*(cur + 1) != ' ') { - break; + if (searchQuote == true) { + if (*(cur - 1) == '"' && len != 1 && len != 2) { + searchQuote = false; } else { cur++; + len++; continue; } } + + if (*(cur + 1) != ' ') { + break; + } else { + cur++; + continue; + } } cur++; len++; -- GitLab