From c63a7e39797be965843efb56faa5234bf952603d Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Mar 2024 10:52:54 +0800 Subject: [PATCH] feat:add paras for schemaless interface --- source/client/inc/clientSml.h | 2 +- source/client/src/clientSml.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/source/client/inc/clientSml.h b/source/client/inc/clientSml.h index 85c180da5a..5a2fbd45b4 100644 --- a/source/client/inc/clientSml.h +++ b/source/client/inc/clientSml.h @@ -222,7 +222,7 @@ bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg); int64_t smlGetTimeValue(const char *value, int32_t len, uint8_t fromPrecision, uint8_t toPrecision); SSmlTableInfo* smlBuildTableInfo(int numRows, const char* measure, int32_t measureLen); SSmlSTableMeta* smlBuildSTableMeta(bool isDataFormat); -int32_t smlSetCTableName(SSmlTableInfo *oneTable); +int32_t smlSetCTableName(SSmlTableInfo *oneTable, char *tbnameKey); void getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tinfo); STableMeta* smlGetMeta(SSmlHandle *info, const void* measure, int32_t measureLen); int32_t is_same_child_table_telnet(const void *a, const void *b); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 950f9d13d0..e1ca9e5d3e 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -349,7 +349,7 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements){ if (kv->valueEscaped) kv->value = NULL; } - smlSetCTableName(tinfo); + smlSetCTableName(tinfo, info->tbnameKey); getTableUid(info, elements, tinfo); if (info->dataFormat) { info->currSTableMeta->uid = tinfo->uid; @@ -418,10 +418,10 @@ int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs){ return TSDB_CODE_SUCCESS; } -static int32_t smlParseTableName(SArray *tags, char *childTableName) { +static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnameKey) { bool autoChildName = false; size_t delimiter = strlen(tsSmlAutoChildTableNameDelimiter); - if(delimiter > 0){ + if(delimiter > 0 && tbnameKey == NULL){ size_t totalNameLen = delimiter * (taosArrayGetSize(tags) - 1); for (int i = 0; i < taosArrayGetSize(tags); i++) { SSmlKv *tag = (SSmlKv *)taosArrayGet(tags, i); @@ -444,13 +444,16 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName) { smlStrReplace(childTableName, strlen(childTableName)); } }else{ - size_t childTableNameLen = strlen(tsSmlChildTableName); + if (tbnameKey == NULL){ + tbnameKey = tsSmlChildTableName; + } + size_t childTableNameLen = strlen(tbnameKey); if (childTableNameLen <= 0) return TSDB_CODE_SUCCESS; for (int i = 0; i < taosArrayGetSize(tags); i++) { SSmlKv *tag = (SSmlKv *)taosArrayGet(tags, i); // handle child table name - if (childTableNameLen == tag->keyLen && strncmp(tag->key, tsSmlChildTableName, tag->keyLen) == 0) { + if (childTableNameLen == tag->keyLen && strncmp(tag->key, tbnameKey, tag->keyLen) == 0) { memset(childTableName, 0, TSDB_TABLE_NAME_LEN); strncpy(childTableName, tag->value, (tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN)); if(tsSmlDot2Underline){ @@ -465,8 +468,8 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName) { return TSDB_CODE_SUCCESS; } -int32_t smlSetCTableName(SSmlTableInfo *oneTable) { - smlParseTableName(oneTable->tags, oneTable->childTableName); +int32_t smlSetCTableName(SSmlTableInfo *oneTable, char *tbnameKey) { + smlParseTableName(oneTable->tags, oneTable->childTableName, tbnameKey); if (strlen(oneTable->childTableName) == 0) { SArray *dst = taosArrayDup(oneTable->tags, NULL);