diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index dafdb0fb00695847c1355f12085297ed8bb1f1fa..b076cf0eb06c2b4f5f1342815df270b813728ed2 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -116,7 +116,7 @@ static const SInfosTableSchema userUsersSchema[] = {{.name = "name", . {.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, }; static const SInfosTableSchema vgroupsSchema[] = {{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "db_name", .bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, {.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 8e9ce1d7380ce2323982f0f5d7c5a1b07fee77a9..35d1cf4515c4fda76bbb003b2eca3481109a4a0b 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1576,7 +1576,10 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 sdbRelease(pSdb, pStb); } - mndReleaseDb(pMnode, pDb); + if (pDb != NULL) { + mndReleaseDb(pMnode, pDb); + } + pShow->numOfReads += numOfRows; mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); return numOfRows; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index f7b177f170daa28f499d7b8a8d9fd22fcc98562c..4f67d3b776768b97e03239925ecde3c030544f20 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -559,41 +559,72 @@ static int32_t mndRetrieveVgroups(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t cols = 0; char *pWrite; - SDbObj *pDb = mndAcquireDb(pMnode, pShow->db); - if (pDb == NULL) return 0; + SDbObj *pDb = NULL; + if (strlen(pShow->db) > 0) { + pDb = mndAcquireDb(pMnode, pShow->db); + if (pDb == NULL) { + return 0; + } + } while (numOfRows < rows) { pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup); if (pShow->pIter == NULL) break; - if (pVgroup->dbUid == pDb->uid) { - cols = 0; + if (pDb != NULL && pVgroup->dbUid != pDb->uid) { + continue; + } + + cols = 0; + +// mndGetVgroupMaxReplica(pMnode, pShow->db, &pShow->replica, &pShow->numOfRows); + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->vgId; + cols++; + + SName name = {0}; + char db[TSDB_DB_NAME_LEN] = {0}; + tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT|T_NAME_DB); + tNameGetDbName(&name, db); + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, db); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->numOfTables; + cols++; + //status + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, "ready"); // TODO + cols++; + + //onlines + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->replica; + cols++; + + + for (int32_t i = 0; i < pVgroup->replica; ++i) { pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pVgroup->vgId; + *(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId; cols++; + const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pVgroup->numOfTables; + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]); cols++; - - for (int32_t i = 0; i < pShow->replica; ++i) { - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId; - cols++; - - const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]); - cols++; - } - numOfRows++; } + numOfRows++; sdbRelease(pSdb, pVgroup); } - mndReleaseDb(pMnode, pDb); + if (pDb != NULL) { + mndReleaseDb(pMnode, pDb); + } + mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows;