Merge pull request #7558 from taosdata/fix/TD-6308
[TD-6308]<fix> partial loaded table meta cause unexpected result
This commit is contained in:
commit
976fbda9d6
|
@ -8485,7 +8485,10 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
|
|
||||||
taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&pTableMeta, &tableMetaCapacity);
|
if (NULL == taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&pTableMeta, &tableMetaCapacity)) {
|
||||||
|
// not found
|
||||||
|
tfree(pTableMeta);
|
||||||
|
}
|
||||||
|
|
||||||
if (pTableMeta && pTableMeta->id.uid > 0) {
|
if (pTableMeta && pTableMeta->id.uid > 0) {
|
||||||
tscDebug("0x%"PRIx64" retrieve table meta %s from local buf", pSql->self, name);
|
tscDebug("0x%"PRIx64" retrieve table meta %s from local buf", pSql->self, name);
|
||||||
|
|
|
@ -2951,7 +2951,9 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool
|
||||||
if (pTableMetaInfo->tableMetaCapacity != 0 && pTableMetaInfo->pTableMeta != NULL) {
|
if (pTableMetaInfo->tableMetaCapacity != 0 && pTableMetaInfo->pTableMeta != NULL) {
|
||||||
memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity);
|
memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity);
|
||||||
}
|
}
|
||||||
taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity);
|
if (NULL == taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity)) {
|
||||||
|
tfree(pTableMetaInfo->pTableMeta);
|
||||||
|
}
|
||||||
|
|
||||||
STableMeta* pMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pMeta = pTableMetaInfo->pTableMeta;
|
||||||
STableMeta* pSTMeta = (STableMeta *)(pSql->pBuf);
|
STableMeta* pSTMeta = (STableMeta *)(pSql->pBuf);
|
||||||
|
|
|
@ -4504,25 +4504,24 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name,
|
||||||
STableMeta* pChild = *ppChild;
|
STableMeta* pChild = *ppChild;
|
||||||
|
|
||||||
size_t sz = (p != NULL) ? tscGetTableMetaSize(p) : 0; //ppSTableBuf actually capacity may larger than sz, dont care
|
size_t sz = (p != NULL) ? tscGetTableMetaSize(p) : 0; //ppSTableBuf actually capacity may larger than sz, dont care
|
||||||
if (p != NULL && sz != 0) {
|
if (sz != 0) {
|
||||||
memset((char *)p, 0, sz);
|
memset((char *)p, 0, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta* pChild1;
|
if (NULL == taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz)) {
|
||||||
|
tfree(p);
|
||||||
taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz);
|
} else {
|
||||||
*ppSTable = p;
|
*ppSTable = p;
|
||||||
|
}
|
||||||
|
|
||||||
// tableMeta exists, build child table meta according to the super table meta
|
// 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.
|
// 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) {
|
if (p && p->id.uid > 0 && pChild->suid == p->id.uid) {
|
||||||
|
|
||||||
int32_t totalBytes = (p->tableInfo.numOfColumns + p->tableInfo.numOfTags) * sizeof(SSchema);
|
int32_t totalBytes = (p->tableInfo.numOfColumns + p->tableInfo.numOfTags) * sizeof(SSchema);
|
||||||
int32_t tableMetaSize = sizeof(STableMeta) + totalBytes;
|
int32_t tableMetaSize = sizeof(STableMeta) + totalBytes;
|
||||||
if (*tableMetaCapacity < tableMetaSize) {
|
if (*tableMetaCapacity < tableMetaSize) {
|
||||||
pChild1 = realloc(pChild, tableMetaSize);
|
STableMeta* pChild1 = realloc(pChild, tableMetaSize);
|
||||||
if(pChild1 == NULL)
|
if(pChild1 == NULL) return -1;
|
||||||
return -1;
|
|
||||||
pChild = pChild1;
|
pChild = pChild1;
|
||||||
*tableMetaCapacity = (size_t)tableMetaSize;
|
*tableMetaCapacity = (size_t)tableMetaSize;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue