more work
This commit is contained in:
parent
846acadf04
commit
74900ff04e
|
@ -48,7 +48,7 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
|
||||||
int metaCommit(SMeta *pMeta);
|
int metaCommit(SMeta *pMeta);
|
||||||
|
|
||||||
// For Query
|
// For Query
|
||||||
int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg);
|
int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
void metaOptionsInit(SMetaCfg *pMetaCfg);
|
void metaOptionsInit(SMetaCfg *pMetaCfg);
|
||||||
|
|
|
@ -431,17 +431,79 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------ FOR QUERY ------------------------ */
|
/* ------------------------ FOR QUERY ------------------------ */
|
||||||
int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg) {
|
int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) {
|
||||||
DBT key = {0};
|
DBT key = {0};
|
||||||
DBT value = {0};
|
DBT value = {0};
|
||||||
SMetaDB * pMetaDB = pMeta->pDB;
|
SMetaDB * pMetaDB = pMeta->pDB;
|
||||||
|
int ret;
|
||||||
|
STbCfg tbCfg;
|
||||||
|
SSchemaKey schemaKey;
|
||||||
|
DBT key1 = {0};
|
||||||
|
DBT value1 = {0};
|
||||||
|
uint32_t ncols;
|
||||||
|
void * pBuf;
|
||||||
|
int tlen;
|
||||||
|
STableMetaMsg *pMsg;
|
||||||
|
|
||||||
key.data = tbname;
|
key.data = tbname;
|
||||||
key.size = strlen(tbname) + 1;
|
key.size = strlen(tbname) + 1;
|
||||||
|
|
||||||
pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0);
|
ret = pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: construct the message body
|
metaDecodeTbInfo(value.data, &tbCfg);
|
||||||
|
|
||||||
|
switch (tbCfg.type) {
|
||||||
|
case META_SUPER_TABLE:
|
||||||
|
schemaKey.uid = tbCfg.stbCfg.suid;
|
||||||
|
schemaKey.sver = 0;
|
||||||
|
|
||||||
|
key1.data = &schemaKey;
|
||||||
|
key1.size = sizeof(schemaKey);
|
||||||
|
|
||||||
|
ret = pMetaDB->pSchemaDB->get(pMetaDB->pSchemaDB, &key1, &value1, NULL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pBuf = value1.data;
|
||||||
|
pBuf = taosDecodeFixedU32(pBuf, &ncols);
|
||||||
|
|
||||||
|
tlen = sizeof(STableMetaMsg) + (tbCfg.stbCfg.nTagCols + ncols) * sizeof(SSchema);
|
||||||
|
pMsg = calloc(1, tlen);
|
||||||
|
if (pMsg == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(pMsg->tbFname, tbCfg.name);
|
||||||
|
pMsg->numOfTags = tbCfg.stbCfg.nTagCols;
|
||||||
|
pMsg->numOfColumns = ncols;
|
||||||
|
pMsg->tableType = tbCfg.type;
|
||||||
|
pMsg->sversion = 0;
|
||||||
|
pMsg->tversion = 0;
|
||||||
|
pMsg->suid = tbCfg.stbCfg.suid;
|
||||||
|
pMsg->tuid = tbCfg.stbCfg.suid;
|
||||||
|
for (size_t i = 0; i < tbCfg.stbCfg.nTagCols; i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case META_CHILD_TABLE:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
case META_NORMAL_TABLE:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppMsg = pMsg;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue