mndGrant.c 4.4 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#define _DEFAULT_SOURCE
wafwerar's avatar
wafwerar 已提交
17
#include "mndGrant.h"
wafwerar's avatar
wafwerar 已提交
18
#include "mndShow.h"
wafwerar's avatar
wafwerar 已提交
19

wafwerar's avatar
wafwerar 已提交
20
#ifndef _GRANT
21 22 23 24 25 26 27 28 29 30 31 32

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";
S
Shengliang Guan 已提交
33
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
34 35 36 37 38
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
39
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
40 41 42 43 44
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "false";
S
Shengliang Guan 已提交
45
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
46 47 48 49 50
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
51
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
52 53 54 55 56
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
57
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
58 59 60 61 62
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
63
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
64 65 66 67 68
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
69
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
70 71 72 73 74
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
75
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
76 77 78 79 80
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
81
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
82 83 84 85 86
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
87
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
88 89 90 91 92
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
93
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
94 95 96 97 98
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
99
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
100 101 102 103 104
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
105
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
106 107 108 109 110
    colDataAppend(pColInfo, numOfRows, tmp, false);

    cols++;
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    src = "unlimited";
S
Shengliang Guan 已提交
111
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
112 113 114 115 116 117 118 119
    colDataAppend(pColInfo, numOfRows, tmp, false);

    numOfRows++;
  }

  pShow->numOfRows += numOfRows;
  return numOfRows;
}
wafwerar's avatar
wafwerar 已提交
120

C
Cary Xu 已提交
121 122
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }

wafwerar's avatar
wafwerar 已提交
123
int32_t mndInitGrant(SMnode *pMnode) {
124
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
C
Cary Xu 已提交
125
  mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
126
  return 0;
wafwerar's avatar
wafwerar 已提交
127
}
128

wafwerar's avatar
wafwerar 已提交
129
void    mndCleanupGrant() {}
wafwerar's avatar
wafwerar 已提交
130
void    grantParseParameter() { mError("can't parsed parameter k"); }
C
Cary Xu 已提交
131
void    grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
wafwerar's avatar
wafwerar 已提交
132 133
void    grantAdd(EGrantType grant, uint64_t value) {}
void    grantRestore(EGrantType grant, uint64_t value) {}
C
Cary Xu 已提交
134
int32_t dmProcessGrantReq(SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
wafwerar's avatar
wafwerar 已提交
135

136 137
#endif

138
void mndGenerateMachineCode() { grantParseParameter(); }