diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 278a2bb7478c3bae3039e7343c5e8fef2b1f341f..d7d43cf453a7d265c513a40c6c805e817e810f55 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -111,11 +111,13 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe int32_t code = 0; dTrace("pVnode:%p vgId:%d, table:%s, start to create", pVnode, pVnode->vgId, pTable->tableId); - int16_t numOfColumns = htons(pTable->numOfColumns); - int16_t numOfTags = htons(pTable->numOfTags); - int32_t sid = htonl(pTable->sid); - uint64_t uid = htobe64(pTable->uid); - SSchema *pSchema = (SSchema *) pTable->data; + int16_t numOfColumns = htons(pTable->numOfColumns); + int16_t numOfTags = htons(pTable->numOfTags); + int32_t sid = htonl(pTable->sid); + uint64_t uid = htobe64(pTable->uid); + SSchema * pSchema = (SSchema *)pTable->data; + STSchema *pDestTagSchema = NULL; + SDataRow dataRow = NULL; int32_t totalCols = numOfColumns + numOfTags; @@ -130,7 +132,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe tsdbTableSetName(&tCfg, pTable->tableId, false); if (numOfTags != 0) { - STSchema *pDestTagSchema = tdNewSchema(numOfTags); + pDestTagSchema = tdNewSchema(numOfTags); for (int i = numOfColumns; i < totalCols; i++) { tdSchemaAddCol(pDestTagSchema, pSchema[i].type, htons(pSchema[i].colId), htons(pSchema[i].bytes)); } @@ -139,7 +141,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe char *pTagData = pTable->data + totalCols * sizeof(SSchema); int accumBytes = 0; - SDataRow dataRow = tdNewDataRowFromSchema(pDestTagSchema); + dataRow = tdNewDataRowFromSchema(pDestTagSchema); for (int i = 0; i < numOfTags; i++) { STColumn *pTCol = schemaColAt(pDestTagSchema, i); @@ -150,6 +152,8 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe } code = tsdbCreateTable(pVnode->tsdb, &tCfg); + tdFreeDataRow(dataRow); + tfree(pDestTagSchema); tfree(pDestSchema); dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code);