diff --git a/examples/c/tmq.c b/examples/c/tmq.c index f421f344a291079720cab62fa41855b54bd0e6c5..c11423735345ae0c8d745923e7b981f3e726748b 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -97,14 +97,14 @@ int32_t init_env() { taos_free_result(pRes); pRes = - taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int)"); + taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)"); if (taos_errno(pRes) != 0) { printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000)"); + pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)"); if (taos_errno(pRes) != 0) { printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes)); return -1; @@ -118,14 +118,14 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct1 using st1 tags(2000)"); + pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct2 using st1 tags(NULL)"); + pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes)); return -1; @@ -139,7 +139,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct3 using st1 tags(3000)"); + pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index d37b8ce1cae922cfa491ad9aabbe7b01732a3308..6f54472dbb91fd179f8995a817f8ed3dff2108ee 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -97,7 +97,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); 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, const char* colName); +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf); // STRUCT ================= struct STColumn { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e157c4cc1b40c237065c4d9855c5302753451be7..5e7e045b78c5df73e785b501393b59454b4aaa72 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1968,8 +1968,9 @@ typedef struct SVCreateTbReq { int8_t type; union { struct { - char* name; + char* name; // super table name tb_uid_t suid; + SArray* tagName; uint8_t* pTag; } ctb; struct { @@ -1987,6 +1988,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) { if (req->type == TSDB_CHILD_TABLE) { taosMemoryFreeClear(req->ctb.pTag); taosMemoryFreeClear(req->ctb.name); + taosArrayDestroy(req->ctb.tagName); } else if (req->type == TSDB_NORMAL_TABLE) { taosMemoryFreeClear(req->ntb.schemaRow.pSchema); } diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 649584a9a13de5a28bfba9141428a035948a6e0a..c5cf6eecdf467c5704a7eadce6d53ad68ec90a1b 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2074,7 +2074,7 @@ static char *processAlterStb(SMqMetaRsp *metaRsp){ return string; } -static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t id){ +static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* tagName, int64_t id){ char* string = NULL; SArray* pTagVals = NULL; cJSON* json = cJSON_CreateObject(); @@ -2112,8 +2112,9 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); STagVal* pTagVal = taosArrayGet(pTagVals, 0); -// cJSON* tname = cJSON_CreateString(pTagVal->colName); -// cJSON_AddItemToObject(tag, "name", tname); + char* ptname = taosArrayGet(tagName, 0); + cJSON* tname = cJSON_CreateString(ptname); + cJSON_AddItemToObject(tag, "name", tname); // cJSON* cid_ = cJSON_CreateString(""); // cJSON_AddItemToObject(tag, "cid", cid_); cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON); @@ -2130,8 +2131,11 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); - cJSON* cid = cJSON_CreateNumber(pTagVal->cid); - cJSON_AddItemToObject(tag, "cid", cid); + char* ptname = taosArrayGet(tagName, i); + cJSON* tname = cJSON_CreateString(ptname); + cJSON_AddItemToObject(tag, "name", tname); +// cJSON* cid = cJSON_CreateNumber(pTagVal->cid); +// cJSON_AddItemToObject(tag, "cid", cid); cJSON* ttype = cJSON_CreateNumber(pTagVal->type); cJSON_AddItemToObject(tag, "type", ttype); @@ -2175,7 +2179,7 @@ static char *processCreateTable(SMqMetaRsp *metaRsp){ for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; if(pCreateReq->type == TSDB_CHILD_TABLE){ - string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, pCreateReq->uid); + string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, pCreateReq->ctb.tagName, pCreateReq->uid); }else if(pCreateReq->type == TSDB_NORMAL_TABLE){ string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 7245a62eb269313247c3c00af37225869ffc7ba2..8901014600c31b0ffdbcc3146ebad29dc149b630 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4943,6 +4943,12 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) { if (tEncodeCStr(pCoder, pReq->ctb.name) < 0) return -1; if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1; if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1; + int32_t len = taosArrayGetSize(pReq->ctb.tagName); + if (tEncodeI32(pCoder, len) < 0) return -1; + for (int32_t i = 0; i < len; i++){ + char* name = taosArrayGet(pReq->ctb.tagName, i); + if (tEncodeCStr(pCoder, name) < 0) return -1; + } } else if (pReq->type == TSDB_NORMAL_TABLE) { if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { @@ -4973,6 +4979,15 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { if (tDecodeCStr(pCoder, &pReq->ctb.name) < 0) return -1; if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1; + int32_t len = 0; + if (tDecodeI32(pCoder, &len) < 0) return -1; + pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); + if(pReq->ctb.tagName == NULL) return -1; + for (int32_t i = 0; i < len; i++){ + char *name = NULL; + if (tDecodeCStr(pCoder, &name) < 0) return -1; + taosArrayPush(pReq->ctb.tagName, name); + } } else if (pReq->type == TSDB_NORMAL_TABLE) { if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index 1294f0cff3446dca7fb7dcdfc6d293d947d13852..be56d901de35cee34c41fe7c9b902ef43a65e38b 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -163,6 +163,7 @@ typedef struct SSdbRow { ESdbType type; ESdbStatus status; int32_t refCount; + int64_t forAlign; char pObj[]; } SSdbRow; diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 9bb55cf663cc14aeae75b133720051c4f3b9135c..46a8ffcc6ceccaa8967507a731e016ade2c3dbd8 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -732,12 +732,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* return TSDB_CODE_SUCCESS; } -static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname) { +static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, SArray* tagName) { pTbReq->type = TD_CHILD_TABLE; pTbReq->name = strdup(tname); pTbReq->ctb.suid = suid; if(sname) pTbReq->ctb.name = strdup(sname); pTbReq->ctb.pTag = (uint8_t*)pTag; + pTbReq->ctb.tagName = taosArrayDup(tagName); pTbReq->commentLen = -1; return; @@ -936,6 +937,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16 static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint8_t precision, const char* tName) { int32_t code = TSDB_CODE_SUCCESS; SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal)); + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); SToken sToken; bool isParseBindParam = false; bool isJson = false; @@ -965,6 +967,10 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint taosMemoryFree(tmpTokenBuf); goto end; } + + if (!isNullStr(&sToken)) { + taosArrayPush(tagName, pTagSchema->name); + } if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (sToken.n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { code = buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", sToken.z); @@ -974,7 +980,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint if (isNullStr(&sToken)) { code = tTagNew(pTagVals, 1, true, &pTag); } else { - code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg, pTagSchema->name); + code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg); } taosMemoryFree(tmpTokenBuf); if (code != TSDB_CODE_SUCCESS) { @@ -1004,7 +1010,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint goto end; } - buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName); + buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName); end: for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { @@ -1014,6 +1020,7 @@ end: } } taosArrayDestroy(pTagVals); + taosArrayDestroy(tagName); return code; } @@ -1798,6 +1805,11 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch return buildInvalidOperationMsg(&pBuf, "out of memory"); } + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!tagName) { + return buildInvalidOperationMsg(&pBuf, "out of memory"); + } + int32_t code = TSDB_CODE_SUCCESS; SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); @@ -1814,6 +1826,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch if (IS_VAR_DATA_TYPE(pTagSchema->type)) { colLen = bind[c].length[0]; } + taosArrayPush(tagName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer); @@ -1823,7 +1836,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch isJson = true; char* tmp = taosMemoryCalloc(1, colLen + 1); memcpy(tmp, bind[c].buffer, colLen); - code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf, pTagSchema->name); + code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); taosMemoryFree(tmp); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -1867,7 +1880,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch } SVCreateTbReq tbReq = {0}; - buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName); + buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName); code = buildCreateTbMsg(pDataBlock, &tbReq); tdDestroySVCreateTbReq(&tbReq); @@ -1879,6 +1892,7 @@ end: } } taosArrayDestroy(pTagArray); + taosArrayDestroy(tagName); return code; } @@ -2219,17 +2233,22 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS * @param msg * @return int32_t */ -static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SMsgBuf* msg) { +static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName, SMsgBuf* msg) { SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); if (!pTagArray) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } + *tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!*tagName) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } int32_t code = TSDB_CODE_SUCCESS; for (int i = 0; i < tags->numOfBound; ++i) { SSchema* pTagSchema = &pSchema[tags->boundColumns[i]]; SSmlKv* kv = taosArrayGetP(cols, i); + taosArrayPush(*tagName, pTagSchema->name); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; // strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { @@ -2288,12 +2307,16 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols return ret; } STag* pTag = NULL; - ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &pBuf); + SArray* tagName = NULL; + ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &tagName, &pBuf); if (ret != TSDB_CODE_SUCCESS) { + taosArrayDestroy(tagName); return ret; } - buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL); + buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName); + taosArrayDestroy(tagName); + smlHandle->tableExecHandle.createTblReq.ctb.name = taosMemoryMalloc(sTableNameLen + 1); memcpy(smlHandle->tableExecHandle.createTblReq.ctb.name, sTableName, sTableNameLen); smlHandle->tableExecHandle.createTblReq.ctb.name[sTableNameLen] = 0; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index f822945ef529077df77f1174a3f65dbf7baa929e..ffacafb504ee6691ad0e09b457731529c96cc012 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5263,6 +5263,8 @@ static void destroyCreateTbReqBatch(void* data) { taosMemoryFreeClear(pTableReq->ntb.schemaRow.pSchema); } else if (pTableReq->type == TSDB_CHILD_TABLE) { taosMemoryFreeClear(pTableReq->ctb.pTag); + taosMemoryFreeClear(pTableReq->ctb.name); + taosArrayDestroy(pTableReq->ctb.tagName); } } @@ -5334,7 +5336,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { } static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt, - const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo) { + const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo, SArray* tagName) { // char dbFName[TSDB_DB_FNAME_LEN] = {0}; // SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; // strcpy(name.dbname, pStmt->dbName); @@ -5353,6 +5355,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S req.ctb.suid = suid; req.ctb.name = strdup(sTableNmae); req.ctb.pTag = (uint8_t*)pTag; + req.ctb.tagName = taosArrayDup(tagName); if (pStmt->ignoreExists) { req.flags |= TD_CREATE_IF_NOT_EXISTS; } @@ -5437,7 +5440,7 @@ static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SVa return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); } - return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf, pTagSchema->name); + return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); } static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { @@ -5457,7 +5460,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S } static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - STag** ppTag) { + STag** ppTag, SArray* tagName) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { @@ -5488,8 +5491,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla if (pSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag); + taosArrayPush(tagName, pCol->colName); } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray); + taosArrayPush(tagName, pCol->colName); } } if (TSDB_CODE_SUCCESS == code) { @@ -5510,7 +5515,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla } static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - STag** ppTag) { + STag** ppTag, SArray* tagName) { if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } @@ -5535,6 +5540,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag); + taosArrayPush(tagName, pTagSchema->name); } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; @@ -5546,6 +5552,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau memcpy(&val.i64, tmpVal, pTagSchema->bytes); } taosArrayPush(pTagArray, &val); + taosArrayPush(tagName, pTagSchema->name); } } if (TSDB_CODE_SUCCESS == code) { @@ -5581,12 +5588,13 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla } STag* pTag = NULL; + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); if (TSDB_CODE_SUCCESS == code) { if (NULL != pStmt->pSpecificTags) { - code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag); + code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName); } else { - code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag); + code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName); } } @@ -5595,9 +5603,10 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info); + addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info, tagName); } + taosArrayDestroy(tagName); taosMemoryFreeClear(pSuperTableMeta); return code; } @@ -5823,7 +5832,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS int32_t code = TSDB_CODE_SUCCESS; STag* pTag = NULL; do { - code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf, pReq->tagName); + code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf); if (TSDB_CODE_SUCCESS != code) { break; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index b6ebb0de22acd0858873210b5d2bd5cdb817d647..69cc95a7269a79c6fa8867727e61745fa718fb7f 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -341,7 +341,7 @@ static bool isValidateTag(char* input) { return true; } -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf, const char* colName) { +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf) { int32_t retCode = TSDB_CODE_SUCCESS; cJSON* root = NULL; SHashObj* keyHash = NULL; diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index dd0a60dced33875d277b10fbdb49f5ab02102622..df5df127f066beef7a64b40f95dc0909ed6d58a3 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1150,7 +1150,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu } memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; - if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL, "")){ + if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){ tTagNew(pTagVals, 1, true, &pTag); } } diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 6663fc3cc48044c532c91fe28ea85552993ed10e..9b40f0a4659ee9a8a85131c9daf017b8c3b17ce2 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -1114,7 +1114,7 @@ TEST(columnTest, json_column_arith_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL, ""); + parseJsontoTagData(rightv, tags, &row, NULL); const int32_t len = 8; EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, @@ -1262,7 +1262,7 @@ TEST(columnTest, json_column_logic_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL, ""); + parseJsontoTagData(rightv, tags, &row, NULL); const int32_t len0 = 6; const int32_t len = 9;