提交 c978eb12 编写于 作者: S Shengliang Guan

TD-13101

上级 af9178c5
......@@ -540,35 +540,41 @@ 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;
while (numOfRows < rows) {
pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup);
if (pShow->pIter == NULL) break;
cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int32_t *)pWrite = pVgroup->vgId;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int32_t *)pWrite = pVgroup->numOfTables;
cols++;
if (pVgroup->dbUid == pDb->uid) {
cols = 0;
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;
*(int32_t *)pWrite = pVgroup->vgId;
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]);
*(int32_t *)pWrite = pVgroup->numOfTables;
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++;
}
sdbRelease(pSdb, pVgroup);
numOfRows++;
}
mndReleaseDb(pMnode, pDb);
mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
pShow->numOfReads += numOfRows;
return numOfRows;
......
......@@ -60,6 +60,7 @@ TEST_F(TfsTest, 02_AllocDisk) {
dCfg.level = 0;
dCfg.primary = 1;
taosRemoveDir(root);
taosMkDir(root);
STfs *pTfs = tfsOpen(&dCfg, 1);
ASSERT_NE(pTfs, nullptr);
......@@ -110,6 +111,7 @@ TEST_F(TfsTest, 03_Dir) {
dCfg.level = 0;
dCfg.primary = 1;
taosRemoveDir(root);
taosMkDir(root);
STfs *pTfs = tfsOpen(&dCfg, 1);
ASSERT_NE(pTfs, nullptr);
......@@ -130,7 +132,7 @@ TEST_F(TfsTest, 03_Dir) {
EXPECT_EQ(taosDirExist(ap2), 0);
char p3[] = "p3/p2/p1/p0";
char ap3[128] ={0};
char ap3[128] = {0};
snprintf(ap3, 128, "%s%s%s", root, TD_DIRSEP, p3);
EXPECT_NE(taosDirExist(ap3), 0);
EXPECT_NE(tfsMkdir(pTfs, p3), 0);
......@@ -155,4 +157,43 @@ TEST_F(TfsTest, 03_Dir) {
EXPECT_NE(taosDirExist(ap4), 0);
tfsClose(pTfs);
}
\ No newline at end of file
}
#if 0
TEST_F(TfsTest, 04_File) {
int32_t code = 0;
SDiskCfg dCfg = {0};
tstrncpy(dCfg.dir, root, TSDB_FILENAME_LEN);
dCfg.level = 0;
dCfg.primary = 1;
taosRemoveDir(root);
taosMkDir(root);
STfs *pTfs = tfsOpen(&dCfg, 1);
ASSERT_NE(pTfs, nullptr);
STfsFile file0;
STfsFile file1;
STfsFile file2;
STfsFile file3;
STfsFile file4;
SDiskID did0 = {0};
SDiskID did1 = {0};
SDiskID did2 = {0};
SDiskID did3 = {0};
SDiskID did4 = {0};
did3.id = 1;
did4.level = 1;
tfsInitFile(pTfs, &file0, did0, "fname");
tfsInitFile(pTfs, &file1, did1, "fname");
tfsInitFile(pTfs, &file2, did2, "fnamex");
tfsInitFile(pTfs, &file3, did3, "fname");
tfsInitFile(pTfs, &file4, did4, "fname");
EXPECT_TRUE(tfsIsSameFile(&file0, &file1));
EXPECT_FALSE(tfsIsSameFile(&file0, &file2));
EXPECT_FALSE(tfsIsSameFile(&file0, &file3));
EXPECT_FALSE(tfsIsSameFile(&file0, &file4));
tfsClose(pTfs);
}
#endif
\ No newline at end of file
......@@ -4,7 +4,7 @@ system sh/exec.sh -n dnode1 -s start
sql connect
print =============== create database
sql create database d1
sql create database d1 vgroups 2
sql show databases
if $rows != 1 then
return -1
......@@ -22,6 +22,21 @@ if $data03 != 0 then
return -1
endi
print =============== show vgroups1
sql use d1
sql show vgroups
if $rows != 2 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
print =============== drop database
sql drop database d1
sql show databases
......@@ -30,14 +45,68 @@ if $rows != 0 then
endi
print =============== more databases
sql create database d2
sql create database d3
sql create database d4
sql create database d2 vgroups 2
sql create database d3 vgroups 3
sql create database d4 vgroups 4
sql show databases
if $rows != 3 then
return -1
endi
print =============== show vgroups2
sql show d2.vgroups
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
print =============== show vgroups3
sql show d3.vgroups
if $rows != 3 then
return -1
endi
if $data00 != 6 then
return -1
endi
if $data10 != 7 then
return -1
endi
if $data20 != 8 then
return -1
endi
print =============== show vgroups4
sql show d4.vgroups
if $rows != 4 then
return -1
endi
if $data00 != 9 then
return -1
endi
if $data10 != 10 then
return -1
endi
if $data20 != 11 then
return -1
endi
if $data30 != 12 then
return -1
endi
print =============== drop database
sql drop database d2
sql drop database d3
......@@ -50,7 +119,7 @@ if $data00 != d4 then
return -1
endi
if $data02 != 2 then
if $data02 != 4 then
return -1
endi
......@@ -58,19 +127,12 @@ if $data03 != 0 then
return -1
endi
print =============== show vgroups
sql show databases
if $rows != 1 then
return -1
endi
print =============== show vgroups4 again
sql_error use d1
sql use d4
sql show vgroups
if $rows != 2 then
if $rows != 4 then
return -1
endi
......@@ -81,15 +143,16 @@ if $data00 != 1 then
return -1
endi
if $data02 != 2 then
if $data02 != 4 then
return -1
endi
print =============== restart
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
system sh/exec.sh -n dnode1 -s start
sql show databases
if $rows != 1 then
return -1
endi
......@@ -99,7 +162,24 @@ sql_error use d1
sql use d4
sql show vgroups
if $rows != 2 then
if $rows != 4 then
return -1
endi
sql create database d5 vgroups 5;
sql use d5
sql show vgroups
if $rows != 5 then
return -1
endi
sql show d4.vgroups
if $rows != 4 then
return -1
endi
sql show d5.vgroups
if $rows != 5 then
return -1
endi
......
......@@ -94,8 +94,8 @@ sql use $db
sql create table st (ts timestamp, i int) tags (j int)
sql create table $tb using st tags(1)
return
system sh/exec.sh -n dnode1 -s stop -x SIGINT
return
sql show tables
if $rows != 1 then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册