This commit is contained in:
Hongze Cheng 2021-12-28 13:58:53 +08:00
parent 8f9329eaca
commit 483809b3e8
4 changed files with 38 additions and 1 deletions

View File

@ -18,8 +18,8 @@
#include "mallocator.h"
#include "os.h"
#include "trow.h"
#include "tmsg.h"
#include "trow.h"
#ifdef __cplusplus
extern "C" {
@ -47,6 +47,9 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);
int metaDropTable(SMeta *pMeta, tb_uid_t uid);
int metaCommit(SMeta *pMeta);
// For Query
int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg);
// Options
void metaOptionsInit(SMetaCfg *pMetaCfg);
void metaOptionsClear(SMetaCfg *pMetaCfg);

View File

@ -35,6 +35,8 @@ typedef int8_t td_mode_flag_t;
#define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNCLEARD, TD_MOD_CLEARD)
#define TD_IS_NULL(PTR) ((PTR) == NULL)
#ifdef __cplusplus
}
#endif

View File

@ -32,6 +32,22 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
STableInfoMsg *pReq = (STableInfoMsg *)(pMsg->pCont);
STableMetaMsg *pRspMsg;
int ret;
if (metaGetTableInfo(pVnode->pMeta, pReq->tableFname, &pRspMsg) < 0) {
return -1;
}
*pRsp = malloc(sizeof(SRpcMsg));
if (TD_IS_NULL(*pRsp)) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
free(pMsg);
return -1;
}
// TODO
(*pRsp)->pCont = pRspMsg;
return 0;
}

View File

@ -428,4 +428,20 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
} else if (pTbCfg->type == META_CHILD_TABLE) {
tfree(pTbCfg->ctbCfg.pTag);
}
}
/* ------------------------ FOR QUERY ------------------------ */
int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg) {
DBT key = {0};
DBT value = {0};
SMetaDB *pMetaDB = pMeta->pDB;
key.data = tbname;
key.size = strlen(tbname) + 1;
pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0);
// TODO: construct the message body
return 0;
}