[1361]
This commit is contained in:
parent
961a6c15ff
commit
6e35d6c478
1041
src/client/src/sql.c
1041
src/client/src/sql.c
File diff suppressed because it is too large
Load Diff
|
@ -2532,15 +2532,29 @@ 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
|
||||
SSQLToken* likeToken = &pInfo->pDCLInfo->a[1];
|
||||
|
||||
strncpy(pCmd->payload, likeToken->z, likeToken->n);
|
||||
pCmd->payloadLen = strdequote(pCmd->payload);
|
||||
|
||||
if (pCmd->payloadLen > TSDB_METER_NAME_LEN) {
|
||||
return invalidSqlErrMsg(pCmd, msg2);
|
||||
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);
|
||||
pCmd->payloadLen = strdequote(pCmd->payload);
|
||||
|
||||
if (pCmd->payloadLen > TSDB_METER_NAME_LEN) {
|
||||
return invalidSqlErrMsg(pCmd, msg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -237,11 +237,25 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
|||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
int maxReplica = 0;
|
||||
SVgObj *pVgroup = pDb->pHead;
|
||||
while (pVgroup != NULL) {
|
||||
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;
|
||||
pVgroup = pVgroup->next;
|
||||
} 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) {
|
||||
|
@ -276,10 +290,16 @@ 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->numOfRows = pDb->numOfVgroups;
|
||||
pShow->pNode = pDb->pHead;
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
|
||||
if (NULL == pMeter) {
|
||||
pShow->numOfRows = pDb->numOfVgroups;
|
||||
pShow->pNode = pDb->pHead;
|
||||
} else {
|
||||
pShow->numOfRows = 1;
|
||||
pShow->pNode = pVgroup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue