Merge pull request #11824 from taosdata/feature/3.0_liaohj
fix(query): enable mnd to support show topics processing.
This commit is contained in:
commit
815c70c604
|
@ -252,7 +252,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
|
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
|
||||||
|
|
||||||
// mnode-infoSchema
|
// mnode-infoSchema
|
||||||
#define TSDB_CODE_MND_INVALID_INFOS_TBL TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||||
|
|
||||||
// mnode-func
|
// mnode-func
|
||||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||||
|
|
|
@ -325,7 +325,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName) + 1, &meta, sizeof(meta))) {
|
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -340,10 +340,10 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName) + 1);
|
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
|
||||||
if (NULL == pMeta) {
|
if (NULL == pMeta) {
|
||||||
mError("invalid information schema table name:%s", tbName);
|
mError("invalid information schema table name:%s", tbName);
|
||||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
|
||||||
STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
|
STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
|
||||||
if (NULL == meta) {
|
if (NULL == meta) {
|
||||||
mError("invalid performance schema table name:%s", tbName);
|
mError("invalid performance schema table name:%s", tbName);
|
||||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,8 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_QUERIES;
|
type = TSDB_MGMT_TABLE_QUERIES;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_VNODES;
|
type = TSDB_MGMT_TABLE_VNODES;
|
||||||
|
} else if (strncasecmp(name, TSDB_PERFS_TABLE_TOPICS, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_TOPICS;
|
||||||
} else {
|
} else {
|
||||||
// ASSERT(0);
|
// ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -187,11 +189,14 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retrieveReq.showId == 0) {
|
if (retrieveReq.showId == 0) {
|
||||||
STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1);
|
STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
pMeta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||||
mError("failed to process show-retrieve req:%p since %s", pShow, terrstr());
|
if (pMeta == NULL) {
|
||||||
return -1;
|
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
||||||
|
mError("failed to process show-retrieve req:%p since %s", pShow, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pShow = mndCreateShowObj(pMnode, &retrieveReq);
|
pShow = mndCreateShowObj(pMnode, &retrieveReq);
|
||||||
|
|
|
@ -520,8 +520,11 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
tstrncpy(&topicName[VARSTR_HEADER_SIZE], pTopic->name, TSDB_TOPIC_NAME_LEN);
|
|
||||||
varDataSetLen(topicName, strlen(&topicName[VARSTR_HEADER_SIZE]));
|
SName n;
|
||||||
|
tNameFromString(&n, pTopic->name, T_NAME_ACCT|T_NAME_DB);
|
||||||
|
tNameGetDbName(&n, varDataVal(topicName));
|
||||||
|
varDataSetLen(topicName, strlen(varDataVal(topicName)));
|
||||||
|
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)topicName, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)topicName, false);
|
||||||
|
@ -535,7 +538,7 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
varDataSetLen(sql, strlen(&sql[VARSTR_HEADER_SIZE]));
|
varDataSetLen(sql, strlen(&sql[VARSTR_HEADER_SIZE]));
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)sql, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)sql, false);
|
||||||
|
|
||||||
taosMemoryFree(sql);
|
// taosMemoryFree(sql);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pTopic);
|
sdbRelease(pSdb, pTopic);
|
||||||
|
|
|
@ -258,7 +258,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist")
|
||||||
|
|
||||||
// mnode-infoSchema
|
// mnode-infoSchema
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_INFOS_TBL, "Invalid information schema table name")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name")
|
||||||
|
|
||||||
|
|
||||||
// mnode-func
|
// mnode-func
|
||||||
|
|
Loading…
Reference in New Issue