提交 8d38ce5a 编写于 作者: S Shengliang Guan

enh: enable show grants in community version

上级 9d070b3d
...@@ -175,7 +175,7 @@ static const SSysDbTableSchema userUsersSchema[] = { ...@@ -175,7 +175,7 @@ static const SSysDbTableSchema userUsersSchema[] = {
}; };
static const SSysDbTableSchema grantsSchema[] = { static const SSysDbTableSchema grantsSchema[] = {
{.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
"C" { "C" {
#endif #endif
#include "mndInt.h"
typedef enum { typedef enum {
TSDB_GRANT_ALL, TSDB_GRANT_ALL,
TSDB_GRANT_TIME, TSDB_GRANT_TIME,
......
...@@ -14,19 +14,115 @@ ...@@ -14,19 +14,115 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "mndGrant.h" #include "mndGrant.h"
#include "mndInt.h"
#include "mndShow.h" #include "mndShow.h"
#ifndef _GRANT #ifndef _GRANT
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { return 0; }
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
int32_t numOfRows = 0;
char *pWrite;
int32_t cols = 0;
char tmp[32];
char tmp1[32];
if (pShow->numOfRows < 1) {
cols = 0;
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
const char *src = "community";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "false";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src));
colDataAppend(pColInfo, numOfRows, tmp, false);
numOfRows++;
}
pShow->numOfRows += numOfRows;
return numOfRows;
}
int32_t mndInitGrant(SMnode *pMnode) { int32_t mndInitGrant(SMnode *pMnode) {
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
return TSDB_CODE_SUCCESS; return 0;
} }
void mndCleanupGrant() {} void mndCleanupGrant() {}
void grantParseParameter() { mError("can't parsed parameter k"); } void grantParseParameter() { mError("can't parsed parameter k"); }
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; } int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
......
...@@ -886,7 +886,9 @@ void shellGetGrantInfo() { ...@@ -886,7 +886,9 @@ void shellGetGrantInfo() {
memcpy(expiretime, row[1], fields[1].bytes); memcpy(expiretime, row[1], fields[1].bytes);
memcpy(expired, row[2], fields[2].bytes); memcpy(expired, row[2], fields[2].bytes);
if (strcmp(expiretime, "unlimited") == 0) { if (strcmp(serverVersion, "community") == 0) {
fprintf(stdout, "Server is Community Edition.\n");
} else if (strcmp(expiretime, "unlimited") == 0) {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\n", serverVersion, sinfo); fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\n", serverVersion, sinfo);
} else { } else {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\n", serverVersion, sinfo, expiretime); fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\n", serverVersion, sinfo, expiretime);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册