提交 6e35d6c4 编写于 作者: L lihui

[1361]

上级 961a6c15
此差异已折叠。
......@@ -2532,8 +2532,21 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return ret;
}
if (type != SHOW_VGROUPS && pInfo->pDCLInfo->nTokens == 2) {
// set the like conds for show tables
if (pInfo->pDCLInfo->nTokens == 2) {
if (type == SHOW_VGROUPS) {
// set the table name for show vgroups
SSQLToken* meterId = &pInfo->pDCLInfo->a[1];
if (0 == pDbPrefixToken->n) {
SSQLToken db = {0};
getCurrentDBName(pSql, &db);
pDbPrefixToken = &db;
}
ret = setObjFullName(pCmd->payload, NULL, pDbPrefixToken, meterId, &(pCmd->payloadLen));
if (ret != TSDB_CODE_SUCCESS) {
return ret;
}
} else {
// set the like conds for show tables/stables
SSQLToken* likeToken = &pInfo->pDCLInfo->a[1];
strncpy(pCmd->payload, likeToken->z, likeToken->n);
......@@ -2544,6 +2557,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
}
}
} else if (type == SHOW_VNODES) {
if (NULL == pInfo->pDCLInfo) {
return invalidSqlErrMsg(pCmd, "No specified ip of dnode");
......
......@@ -2191,7 +2191,8 @@ int tscBuildShowMsg(SSqlObj *pSql) {
pShowMsg = (SShowMsg *)pMsg;
pShowMsg->type = pCmd->showType;
if ((pShowMsg->type == TSDB_MGMT_TABLE_TABLE || pShowMsg->type == TSDB_MGMT_TABLE_METRIC || pShowMsg->type == TSDB_MGMT_TABLE_VNODES ) && pCmd->payloadLen != 0) {
if ((pShowMsg->type == TSDB_MGMT_TABLE_TABLE || pShowMsg->type == TSDB_MGMT_TABLE_METRIC || pShowMsg->type == TSDB_MGMT_TABLE_VNODES || pShowMsg->type == TSDB_MGMT_TABLE_VGROUP)
&& pCmd->payloadLen != 0) {
// only show tables support wildcard query
pShowMsg->payloadLen = htons(pCmd->payloadLen);
memcpy(pShowMsg->payload, payload, pCmd->payloadLen);
......
......@@ -108,6 +108,12 @@ cmd ::= SHOW dbPrefix(X) VGROUPS. {
setDCLSQLElems(pInfo, SHOW_VGROUPS, 1, &token);
}
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
SSQLToken token;
setDBName(&token, &X);
setDCLSQLElems(pInfo, SHOW_VGROUPS, 2, &token, &Y);
}
//drop configure for tables
cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
X.n += Z.n;
......
......@@ -238,11 +238,25 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
cols++;
int maxReplica = 0;
SVgObj *pVgroup = NULL;
STabObj *pMeter = NULL;
if (pShow->payloadLen > 0 ) {
pMeter = mgmtGetMeter(pShow->payload);
if (NULL == pMeter) {
return TSDB_CODE_INVALID_METER_ID;
}
pVgroup = mgmtGetVgroup(pMeter->gid.vgId);
if (NULL == pVgroup) return TSDB_CODE_INVALID_METER_ID;
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
} else {
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
pVgroup = pVgroup->next;
}
}
for (int i = 0; i < maxReplica; ++i) {
pShow->bytes[cols] = 16;
......@@ -276,9 +290,15 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow->offset[0] = 0;
for (int i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
if (NULL == pMeter) {
pShow->numOfRows = pDb->numOfVgroups;
pShow->pNode = pDb->pHead;
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
} else {
pShow->numOfRows = 1;
pShow->pNode = pVgroup;
}
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册