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

static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
  int32_t numOfRows = 0;
  int32_t cols = 0;
  char    tmp[32];

  if (pShow->numOfRows < 1) {
    cols = 0;
    SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
    const char      *src = "community";
S
Shengliang Guan 已提交
31
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
32 33 34 35 36
    colDataAppend(pColInfo, numOfRows, tmp, false);

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

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

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

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

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

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

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

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

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

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

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

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

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

    numOfRows++;
  }

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

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

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

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

134 135
#endif

136
void mndGenerateMachineCode() { grantParseParameter(); }