fix another bug

This commit is contained in:
Hongze Cheng 2022-03-29 08:10:02 +00:00
parent 4552f9ba2f
commit 22d43247a9
1 changed files with 8 additions and 2 deletions

View File

@ -320,6 +320,8 @@ STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) { STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
void *pKey; void *pKey;
void *pVal; void *pVal;
void *ppKey;
int pkLen;
int kLen; int kLen;
int vLen; int vLen;
int ret; int ret;
@ -327,12 +329,16 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
pKey = tbname; pKey = tbname;
kLen = strlen(tbname) + 1; kLen = strlen(tbname) + 1;
pVal = NULL; pVal = NULL;
ret = tdbDbGet(pMeta->pDB->pNameIdx, pKey, kLen, &pVal, &vLen); ppKey = NULL;
ret = tdbDbPGet(pMeta->pDB->pNameIdx, pKey, kLen, &ppKey, &pkLen, &pVal, &vLen);
if (ret < 0) { if (ret < 0) {
return NULL; return NULL;
} }
*uid = *(tb_uid_t *)POINTER_SHIFT(pVal, kLen); ASSERT(pkLen == kLen + sizeof(uid));
*uid = *(tb_uid_t *)POINTER_SHIFT(ppKey, kLen);
TDB_FREE(ppKey);
TDB_FREE(pVal); TDB_FREE(pVal);
return metaGetTbInfoByUid(pMeta, *uid); return metaGetTbInfoByUid(pMeta, *uid);