diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index cd7904928119617fbf462a82e86447c40fba464b..8231c8b2996ebcaa0b153bd3123cfcec23561591 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2844,15 +2844,11 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool tNameExtractFullName(&pTableMetaInfo->name, name); size_t len = strlen(name); + if (pTableMetaInfo->tableMetaCapacity != 0) { + memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity); + } taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity); - // TODO resize the tableMeta - //assert(size < 80 * TSDB_MAX_COLUMNS); - //if (!pSql->pBuf) { - // if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { - // return TSDB_CODE_TSC_OUT_OF_MEMORY; - // } - //} STableMeta* pMeta = pTableMetaInfo->pTableMeta; if (pMeta && pMeta->id.uid > 0) { // in case of child table, here only get the diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index cf5f0b2d12b5380c5b1e33356b9979fce0e52e49..8a2fafe3e30319f4780040a4eaff210ec9b526e4 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4460,17 +4460,19 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name, // tableMeta exists, build child table meta according to the super table meta // the uid need to be checked in addition to the general name of the super table. if (p && p->id.uid > 0 && pChild->suid == p->id.uid) { - pChild->sversion = p->sversion; - pChild->tversion = p->tversion; - memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo)); - int32_t totalBytes = (pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags) * sizeof(SSchema); + int32_t totalBytes = (p->tableInfo.numOfColumns + p->tableInfo.numOfTags) * sizeof(SSchema); int32_t tableMetaSize = sizeof(STableMeta) + totalBytes; if (*tableMetaCapacity < tableMetaSize) { pChild = realloc(pChild, tableMetaSize); *tableMetaCapacity = (size_t)tableMetaSize; } + + pChild->sversion = p->sversion; + pChild->tversion = p->tversion; + memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo)); memcpy(pChild->schema, p->schema, totalBytes); + *ppChild = pChild; tfree(p); return TSDB_CODE_SUCCESS;