• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4808

16 Oct 2025 11:40AM UTC coverage: 57.938% (-0.6%) from 58.524%
#4808

push

travis-ci

web-flow
fix(tref): increase TSDB_REF_OBJECTS from 100 to 2000 for improved reference handling (#33281)

137662 of 303532 branches covered (45.35%)

Branch coverage included in aggregate %.

209234 of 295200 relevant lines covered (70.88%)

4035326.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

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

16
#define _DEFAULT_SOURCE
17
#include "mndGrant.h"
18
#include "mndShow.h"
19

20
#ifndef _GRANT
21

22
#define GRANT_ITEM_SHOW(display)                               \
23
  do {                                                         \
24
    if ((++cols) >= nCols) goto _end;                          \
25
    if ((pColInfo = taosArrayGet(pBlock->pDataBlock, cols))) { \
26
      src = (display);                                         \
27
      STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);                \
28
      COL_DATA_SET_VAL_GOTO(tmp, false, NULL, NULL, _exit);    \
29
    }                                                          \
30
  } while (0)
31

32
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
33
  SMnode *pMnode = pReq->info.node;
34
  SSdb   *pSdb = pMnode->pSdb;
35
  int32_t numOfRows = 0;
36
  int32_t cols = 0;
37
  int32_t code = 0;
38
  int32_t lino = 0;
39
  char    tmp[32];
40
  int32_t nCols = taosArrayGetSize(pBlock->pDataBlock);
41

42
  if (pShow->numOfRows < 1) {
43
    cols = 0;
44
    SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
45
    const char      *src = TD_PRODUCT_NAME;
46
    STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
47
    COL_DATA_SET_VAL_GOTO(tmp, false, NULL, NULL, _exit);
48

49
    GRANT_ITEM_SHOW("unlimited");
50
    GRANT_ITEM_SHOW("limited");
51
    GRANT_ITEM_SHOW("false");
52
    GRANT_ITEM_SHOW("ungranted");
53

54
    for (int32_t i = 0; i < nCols - 5; ++i) {
55
      GRANT_ITEM_SHOW("unlimited");
56
    }
57
  _end:
58
    ++numOfRows;
59
  }
60

61
  pShow->numOfRows += numOfRows;
62
_exit:
63
  if (code != 0) {
64
    mError("failed to retrieve grant at line %d since %s", lino, tstrerror(code));
65
    TAOS_RETURN(code);
66
  }
67
  return numOfRows;
68
}
69

70
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
71
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
72
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
73
static int32_t mndRetrieveEncryptions(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
74

75
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
76

77
int32_t mndInitGrant(SMnode *pMnode) {
78
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
79
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
80
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
81
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
82
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ENCRYPTIONS, mndRetrieveEncryptions);
83
  mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
84
  return 0;
85
}
86

87
void    mndCleanupGrant() {}
88
void    grantParseParameter() { mError("can't parsed parameter k"); }
89
void    grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
90
void    grantAdd(EGrantType grant, uint64_t value) {}
91
void    grantRestore(EGrantType grant, uint64_t value) {}
92
int64_t grantRemain(EGrantType grant) { return 0; }
93
int32_t tGetMachineId(char **result) {
94
  *result = NULL;
95
  return 0;
96
}
97
bool    grantCheckDualReplicaDnodes(void *pMnode) { return false; }
98
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
99
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
100
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
101
#endif
102

103
void mndGenerateMachineCode() { grantParseParameter(); }
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc