From f1391553a22e3657baa59105c8d9679f72a24824 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 30 Nov 2022 10:21:26 +0800 Subject: [PATCH] feat(mnode): support show cluster status --- src/mnode/src/mnodeVgroup.c | 8 +++++++- src/query/src/qTableMeta.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index fb2f9fbb24..c0ab75cadb 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -800,6 +800,11 @@ static int32_t mnodeGetStatusMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p strcpy(pSchema[0].name, "status"); pSchema[0].bytes = htons(pShow->bytes[0]); + pMeta->numOfColumns = htons(1); + pShow->numOfColumns = 1; + pShow->rowSize = sizeof(int32_t); + pShow->offset[0] = 0; + return 0; } @@ -807,6 +812,7 @@ static int32_t mnodeRetrieveStatus(SShowObj *pShow, char *data, int32_t rows, vo SVgObj *pVgroup = NULL; int32_t nAvailble = 0; int32_t nUnAvailble = 0; + int32_t numOfRows = 0; // get status while (numOfRows < rows) { @@ -828,7 +834,7 @@ static int32_t mnodeRetrieveStatus(SShowObj *pShow, char *data, int32_t rows, vo // check master bool master = false; - for (int32_t i = 0; i < pShow->maxReplica; ++i) { + for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { if (pVgroup->vnodeGid[i].role == TAOS_SYNC_ROLE_MASTER) { master = true; break; diff --git a/src/query/src/qTableMeta.c b/src/query/src/qTableMeta.c index f786f4438c..6b459b1434 100644 --- a/src/query/src/qTableMeta.c +++ b/src/query/src/qTableMeta.c @@ -72,7 +72,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) { } STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { - assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2); + //assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2); int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema); STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + schemaSize); -- GitLab