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

taosdata / TDengine / #4962

09 Feb 2026 01:16AM UTC coverage: 66.872% (+0.07%) from 66.798%
#4962

push

travis-ci

web-flow
docs: add support for recording STMT to CSV files (#34276)

* docs: add support for recording STMT to CSV files

* docs: update version for STMT recording feature in CSV files

205763 of 307696 relevant lines covered (66.87%)

127640448.9 hits per line

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

90.56
/source/libs/parser/src/parAstParser.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
#include "functionMgt.h"
17
#include "os.h"
18
#include "parAst.h"
19
#include "parInt.h"
20
#include "parToken.h"
21
#include "systable.h"
22
#include "tglobal.h"
23

24
typedef void* (*FMalloc)(size_t);
25
typedef void (*FFree)(void*);
26

27
extern SConfig* tsCfg;
28

29
extern void* ParseAlloc(FMalloc);
30
extern void  Parse(void*, int, SToken, void*);
31
extern void  ParseFree(void*, FFree);
32
extern void  ParseTrace(FILE*, char*);
33

34
int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues) {
277,067,073✔
35
  *pQuery = NULL;
277,067,073✔
36
  int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)pQuery);
277,069,280✔
37
  if (NULL == *pQuery) {
277,074,421✔
38
    return code;
×
39
  }
40
  (*pQuery)->pRoot = pRootNode;
277,074,945✔
41
  (*pQuery)->placeholderNum = placeholderNo;
277,072,483✔
42
  TSWAP((*pQuery)->pPlaceholderValues, *pPlaceholderValues);
277,071,659✔
43
  (*pQuery)->execStage = QUERY_EXEC_STAGE_ANALYSE;
277,055,710✔
44

45
  return TSDB_CODE_SUCCESS;
277,069,962✔
46
}
47

48
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
286,349,171✔
49
  SAstCreateContext cxt;
210,236,269✔
50
  initAstCreateContext(pParseCxt, &cxt);
286,351,592✔
51
  void* pParser = ParseAlloc((FMalloc)taosMemMalloc);
286,340,055✔
52
  if (!pParser) return terrno;
286,350,157✔
53
  int32_t i = 0;
286,350,157✔
54
  while (1) {
2,147,483,647✔
55
    SToken t0 = {0};
2,147,483,647✔
56
    if (cxt.pQueryCxt->pSql[i] == 0) {
2,147,483,647✔
57
      Parse(pParser, 0, t0, &cxt);
218,869,631✔
58
      goto abort_parse;
237,263,685✔
59
    }
60
    if (!pParseCxt->hasDupQuoteChar) {
2,147,483,647✔
61
      char dupQuoteChar = 0;
2,147,483,647✔
62
      t0.n = tGetToken((char*)&cxt.pQueryCxt->pSql[i], &t0.type, &dupQuoteChar);
2,147,483,647✔
63
      if (dupQuoteChar) pParseCxt->hasDupQuoteChar = true;
2,147,483,647✔
64
    } else {
65
      t0.n = tGetToken((char*)&cxt.pQueryCxt->pSql[i], &t0.type, NULL);
629,442✔
66
    }
67
    t0.z = (char*)(cxt.pQueryCxt->pSql + i);
2,147,483,647✔
68
    i += t0.n;
2,147,483,647✔
69

70
    switch (t0.type) {
2,147,483,647✔
71
      case TK_NK_SPACE:
2,147,483,647✔
72
      case TK_NK_COMMENT: {
73
        break;
2,147,483,647✔
74
      }
75
      case TK_NK_SEMI: {
58,559,588✔
76
        Parse(pParser, 0, t0, &cxt);
58,559,588✔
77
        goto abort_parse;
58,559,588✔
78
      }
79
      case TK_NK_ILLEGAL: {
209,956✔
80
        snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unrecognized token: \"%s\"", t0.z);
209,956✔
81
        cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
209,956✔
82
        goto abort_parse;
209,956✔
83
      }
84
      case TK_NK_OCT: {
×
85
        snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unsupported token: \"%s\"", t0.z);
×
86
        cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
×
87
        goto abort_parse;
×
88
      }
89
      default:
2,147,483,647✔
90
        // ParseTrace(stdout, "");
91
        Parse(pParser, t0.type, t0, &cxt);
2,147,483,647✔
92
        if (TSDB_CODE_SUCCESS != cxt.errCode) {
2,147,483,647✔
93
          goto abort_parse;
8,715,356✔
94
        }
95
    }
96
  }
97

98
abort_parse:
286,330,936✔
99
  ParseFree(pParser, (FFree)taosAutoMemoryFree);
286,342,744✔
100
  if (TSDB_CODE_SUCCESS == cxt.errCode) {
286,341,487✔
101
    int32_t code = buildQueryAfterParse(pQuery, cxt.pRootNode, cxt.placeholderNo, &cxt.pPlaceholderValues);
277,065,938✔
102
    if (TSDB_CODE_SUCCESS != code) {
277,058,787✔
103
      return code;
×
104
    }
105
  }
106
  taosArrayDestroy(cxt.pPlaceholderValues);
286,334,336✔
107
  return cxt.errCode;
286,333,561✔
108
}
109

110
typedef struct SCollectMetaKeyCxt {
111
  SParseContext*   pParseCxt;
112
  SParseMetaCache* pMetaCache;
113
  SNode*           pStmt;
114
  bool             collectVStbRefDbs;
115
} SCollectMetaKeyCxt;
116

117
typedef struct SCollectMetaKeyFromExprCxt {
118
  SCollectMetaKeyCxt* pComCxt;
119
  bool                hasLastRowOrLast;
120
  bool                tbnameCollect;
121
  int32_t             errCode;
122
} SCollectMetaKeyFromExprCxt;
123

124
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt);
125
static int32_t collectMetaKeyFromSetOperator(SCollectMetaKeyCxt* pCxt, SSetOperator* pStmt);
126
static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* pStmt);
127

128
static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) {
515,116,414✔
129
  switch (fmGetFuncType(pFunc->functionName)) {
515,116,414✔
130
    case FUNCTION_TYPE_LAST_ROW:
17,256,643✔
131
    case FUNCTION_TYPE_LAST:
132
      pCxt->hasLastRowOrLast = true;
17,256,643✔
133
      break;
17,256,697✔
134
    case FUNCTION_TYPE_UDF:
390,570✔
135
      pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache);
390,570✔
136
      break;
390,570✔
137
    default:
497,468,256✔
138
      break;
497,468,256✔
139
  }
140
  return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
515,115,523✔
141
}
142

143
static bool needGetTableIndex(SNode* pStmt) {
487,996,001✔
144
  return false;
487,996,001✔
145
  if (QUERY_SMA_OPTIMIZE_ENABLE == tsQuerySmaOptimize && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
146
    SSelectStmt* pSelect = (SSelectStmt*)pStmt;
147
    return (NULL != pSelect->pWindow && QUERY_NODE_INTERVAL_WINDOW == nodeType(pSelect->pWindow));
148
  }
149
  return false;
150
}
151

152
static int32_t collectMetaKeyFromInsTagsImpl(SCollectMetaKeyCxt* pCxt, SName* pName) {
1,488,776✔
153
  if (0 == pName->type) {
1,488,776✔
154
    return TSDB_CODE_SUCCESS;
1,046,340✔
155
  }
156
  if (TSDB_DB_NAME_T == pName->type) {
442,436✔
157
    return reserveDbVgInfoInCache(pName->acctId, pName->dbname, pCxt->pMetaCache);
132,906✔
158
  }
159
  return reserveTableVgroupInCacheExt(pName, pCxt->pMetaCache);
309,530✔
160
}
161

162
static int32_t collectMetaKeyFromInsTags(SCollectMetaKeyCxt* pCxt) {
1,488,776✔
163
  SSelectStmt* pSelect = (SSelectStmt*)pCxt->pStmt;
1,488,776✔
164
  SName        name = {0};
1,489,524✔
165
  int32_t      code = getVnodeSysTableTargetName(pCxt->pParseCxt->acctId, pSelect->pWhere, &name);
1,488,811✔
166
  if (TSDB_CODE_SUCCESS == code) {
1,489,559✔
167
    code = collectMetaKeyFromInsTagsImpl(pCxt, &name);
1,489,559✔
168
  }
169
  return code;
1,489,559✔
170
}
171

172
static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const char* pDb, const char* pTable,
487,994,421✔
173
                                               EPrivType privType, EPrivObjType objType) {
174
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pDb, pTable, pCxt->pMetaCache);
487,994,421✔
175
  if (TSDB_CODE_SUCCESS == code) {
487,997,135✔
176
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pDb, NULL, PRIV_DB_USE, PRIV_OBJ_DB,
487,997,625✔
177
                                  pCxt->pMetaCache);
178
  }
179
  if (TSDB_CODE_SUCCESS == code) {
487,999,034✔
180
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache);
487,999,034✔
181
  }
182
  if (TSDB_CODE_SUCCESS == code) {
487,999,019✔
183
    code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pDb, pTable, pCxt->pMetaCache);
487,999,019✔
184
  }
185
  if (TSDB_CODE_SUCCESS == code) {
487,999,048✔
186
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pDb, pTable, privType, objType,
487,999,048✔
187
                                  pCxt->pMetaCache);
188
  }
189
#ifdef TD_ENTERPRISE
190
  if (TSDB_CODE_SUCCESS == code && NULL != pCxt->pParseCxt->pEffectiveUser) {
487,998,201✔
191
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pEffectiveUser, pDb, pTable, privType,
297,822✔
192
                                  objType, pCxt->pMetaCache);
193
  }
194
#endif
195
  if (TSDB_CODE_SUCCESS == code) {
487,995,831✔
196
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache);
487,995,831✔
197
  }
198
  if (TSDB_CODE_SUCCESS == code && needGetTableIndex(pCxt->pStmt)) {
487,998,556✔
199
    code = reserveTableIndexInCache(pCxt->pParseCxt->acctId, pDb, pTable, pCxt->pMetaCache);
×
200
  }
201
  if (TSDB_CODE_SUCCESS == code && (0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES))) {
487,995,976✔
202
    code = reserveDnodeRequiredInCache(pCxt->pMetaCache);
2,580✔
203
  }
204
  if (TSDB_CODE_SUCCESS == code &&
487,995,821✔
205
      (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES) ||
487,995,821✔
206
       0 == strcmp(pTable, TSDB_INS_TABLE_COLS) || 0 == strcmp(pTable, TSDB_INS_TABLE_VC_COLS) ||
487,418,009✔
207
       0 == strcmp(pTable, TSDB_INS_DISK_USAGE) || 0 == strcmp(pTable, TSDB_INS_TABLE_FILESETS)) &&
486,505,125✔
208
      QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
1,494,816✔
209
    code = collectMetaKeyFromInsTags(pCxt);
1,489,559✔
210
  }
211
  if (TSDB_CODE_SUCCESS == code && QUERY_SMA_OPTIMIZE_ENABLE == tsQuerySmaOptimize &&
487,993,779✔
212
      QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
28,410✔
213
    code = reserveTableTSMAInfoInCache(pCxt->pParseCxt->acctId, pDb, pTable, pCxt->pMetaCache);
28,410✔
214
  }
215
  return code;
487,995,318✔
216
}
217

218
static EDealRes collectMetaKeyFromRealTable(SCollectMetaKeyFromExprCxt* pCxt, SRealTableNode* pRealTable) {
485,503,993✔
219
  pCxt->errCode = collectMetaKeyFromRealTableImpl(pCxt->pComCxt, pRealTable->table.dbName, pRealTable->table.tableName,
485,503,993✔
220
                                                  PRIV_TBL_SELECT, PRIV_OBJ_TBL);
221
  if (TSDB_CODE_SUCCESS == pCxt->errCode && pCxt->pComCxt->collectVStbRefDbs) {
485,506,413✔
222
    pCxt->errCode = reserveVStbRefDbsInCache(pCxt->pComCxt->pParseCxt->acctId, pRealTable->table.dbName,
566,328,662✔
223
                                             pRealTable->table.tableName, pCxt->pComCxt->pMetaCache);
566,328,280✔
224
  }
225
  return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
485,506,854✔
226
}
227

228
static EDealRes collectMetaKeyFromTempTable(SCollectMetaKeyFromExprCxt* pCxt, STempTableNode* pTempTable) {
30,755,155✔
229
  pCxt->errCode = collectMetaKeyFromQuery(pCxt->pComCxt, pTempTable->pSubquery);
30,755,155✔
230
  return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
30,755,155✔
231
}
232

233
static int32_t isTbnameEqCondOperator(SOperatorNode* pOperator, char** ppTableName) {
286,730,824✔
234
  if (pOperator->opType != OP_TYPE_EQUAL) {
286,730,824✔
235
    return TSDB_CODE_SUCCESS;
255,136,498✔
236
  }
237

238
  SValueNode* pValueNode = NULL;
31,595,529✔
239
  if (nodeType(pOperator->pLeft) == QUERY_NODE_FUNCTION &&
31,595,529✔
240
      0 == strcasecmp(((SFunctionNode*)(pOperator->pLeft))->functionName, "tbname") &&
3,760,883✔
241
      nodeType(pOperator->pRight) == QUERY_NODE_VALUE) {
486,100✔
242
    pValueNode = (SValueNode*)pOperator->pRight;
467,426✔
243
  } else if (nodeType(pOperator->pRight) == QUERY_NODE_FUNCTION &&
31,128,103✔
244
             0 == strcasecmp(((SFunctionNode*)(pOperator->pRight))->functionName, "tbname") &&
76,066✔
245
             nodeType(pOperator->pLeft) == QUERY_NODE_VALUE) {
1,100✔
246
    pValueNode = (SValueNode*)pOperator->pLeft;
×
247
  } else {
248
    return TSDB_CODE_SUCCESS;
31,128,103✔
249
  }
250

251
  *ppTableName = pValueNode->literal;
467,426✔
252

253
  return TSDB_CODE_SUCCESS;
467,426✔
254
}
255

256
static EDealRes collectMetaKeyFromOperator(SCollectMetaKeyFromExprCxt* pCxt, SOperatorNode* pOpNode) {
402,891,150✔
257
  if (!pCxt->tbnameCollect) {
402,891,150✔
258
    return DEAL_RES_CONTINUE;
116,160,326✔
259
  }
260

261
  char*   pTableName = NULL;
286,731,762✔
262
  int32_t code = isTbnameEqCondOperator((SOperatorNode*)pOpNode, &pTableName);
286,731,324✔
263
  if (TSDB_CODE_SUCCESS != code) return DEAL_RES_CONTINUE;
286,732,221✔
264
  if (pTableName) {
286,732,221✔
265
    SSelectStmt* pSelect = (SSelectStmt*)pCxt->pComCxt->pStmt;
467,426✔
266
    pCxt->errCode = collectMetaKeyFromRealTableImpl(pCxt->pComCxt, ((SRealTableNode*)pSelect->pFromTable)->table.dbName,
467,426✔
267
                                                    pTableName, PRIV_TBL_SELECT, PRIV_OBJ_TBL);
268
  }
269

270
  return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
286,732,221✔
271
}
272

273
static EDealRes collectMetaKeyFromExprImpl(SNode* pNode, void* pContext) {
2,147,483,647✔
274
  SCollectMetaKeyFromExprCxt* pCxt = pContext;
2,147,483,647✔
275
  switch (nodeType(pNode)) {
2,147,483,647✔
276
    case QUERY_NODE_FUNCTION:
515,116,781✔
277
      return collectMetaKeyFromFunction(pCxt, (SFunctionNode*)pNode);
515,116,781✔
278
    case QUERY_NODE_REAL_TABLE:
485,209,908✔
279
      return collectMetaKeyFromRealTable(pCxt, (SRealTableNode*)pNode);
485,209,908✔
280
    case QUERY_NODE_TEMP_TABLE:
30,754,766✔
281
      return collectMetaKeyFromTempTable(pCxt, (STempTableNode*)pNode);
30,754,766✔
282
    case QUERY_NODE_OPERATOR:
402,892,003✔
283
      return collectMetaKeyFromOperator(pCxt, (SOperatorNode*)pNode);
402,892,003✔
284
    case QUERY_NODE_SET_OPERATOR:
23,109,876✔
285
      return collectMetaKeyFromSetOperator(pCxt->pComCxt, (SSetOperator*)pNode);
23,109,876✔
286
    case QUERY_NODE_SELECT_STMT:
212,990,724✔
287
      return collectMetaKeyFromQuery(pCxt->pComCxt, pNode);
212,990,724✔
288
    default:
1,993,509,325✔
289
      break;
1,993,509,325✔
290
  }
291
  return DEAL_RES_CONTINUE;
1,993,509,325✔
292
}
293

294
static int32_t collectMetaKeyFromExprs(SCollectMetaKeyCxt* pCxt, SNodeList* pList) {
35,813,536✔
295
  SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .errCode = TSDB_CODE_SUCCESS, .tbnameCollect = false};
35,813,536✔
296
  nodesWalkExprs(pList, collectMetaKeyFromExprImpl, &cxt);
35,813,536✔
297
  return cxt.errCode;
35,813,536✔
298
}
299

300
static int32_t collectMetaKeyFromSetOperator(SCollectMetaKeyCxt* pCxt, SSetOperator* pStmt) {
35,813,536✔
301
  int32_t code = collectMetaKeyFromQuery(pCxt, pStmt->pLeft);
35,813,536✔
302
  if (TSDB_CODE_SUCCESS == code) {
35,813,536✔
303
    code = collectMetaKeyFromQuery(pCxt, pStmt->pRight);
35,813,536✔
304
  }
305
  if (TSDB_CODE_SUCCESS == code) {
35,813,536✔
306
    code = collectMetaKeyFromExprs(pCxt, pStmt->pOrderByList);
35,813,536✔
307
  }
308
  return code;
35,813,536✔
309
}
310

311
static int32_t reserveDbCfgForLastRow(SCollectMetaKeyCxt* pCxt, SNode* pTable) {
13,673,762✔
312
  if (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable)) {
13,673,762✔
313
    return TSDB_CODE_SUCCESS;
468,878✔
314
  }
315
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SRealTableNode*)pTable)->table.dbName, pCxt->pMetaCache);
13,204,869✔
316
}
317

318
static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* pStmt) {
497,255,881✔
319
  SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .hasLastRowOrLast = false, .errCode = TSDB_CODE_SUCCESS};
497,255,881✔
320
  if (pStmt->pFromTable && QUERY_NODE_REAL_TABLE == nodeType(pStmt->pFromTable)) {
497,257,293✔
321
    cxt.tbnameCollect = true;
411,119,735✔
322
    cxt.pComCxt->collectVStbRefDbs = true;
411,119,735✔
323
  }
324
  nodesWalkSelectStmt(pStmt, SQL_CLAUSE_FROM, collectMetaKeyFromExprImpl, &cxt);
497,255,587✔
325
  if (TSDB_CODE_SUCCESS == cxt.errCode && cxt.hasLastRowOrLast) {
497,256,661✔
326
    cxt.errCode = reserveDbCfgForLastRow(pCxt, pStmt->pFromTable);
13,673,736✔
327
  }
328
  return cxt.errCode;
497,256,487✔
329
}
330

331
static int32_t collectMetaKeyFromCreateDatabase(SCollectMetaKeyCxt* pCxt, SCreateDatabaseStmt* pStmt) {
1,384,437✔
332
  return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_DB_CREATE, 0,
1,384,437✔
333
                                pCxt->pMetaCache);
334
}
335

336
static int32_t collectMetaKeyFromAlterDatabase(SCollectMetaKeyCxt* pCxt, SAlterDatabaseStmt* pStmt) {
182,528✔
337
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
182,528✔
338
  if (TSDB_CODE_SUCCESS == code) {
182,528✔
339
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_CM_ALTER,
182,528✔
340
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
341
  }
342
  return code;
182,528✔
343
}
344

345
static int32_t collectMetaKeyFromDropDatabase(SCollectMetaKeyCxt* pCxt, SDropDatabaseStmt* pStmt) {
1,139,539✔
346
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
1,139,539✔
347
  if (TSDB_CODE_SUCCESS == code) {
1,139,539✔
348
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_CM_DROP,
1,139,539✔
349
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
350
  }
351
  return code;
1,139,539✔
352
}
353

354
static int32_t collectMetaKeyFromFlushDatabase(SCollectMetaKeyCxt* pCxt, SFlushDatabaseStmt* pStmt) {
1,811,455✔
355
  int32_t code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
1,811,455✔
356
  if (TSDB_CODE_SUCCESS == code) {
1,811,455✔
357
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_FLUSH,
1,811,455✔
358
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
359
  }
360
  return code;
1,811,455✔
361
}
362

363
static int32_t collectMetaKeyFromCreateTable(SCollectMetaKeyCxt* pCxt, SCreateTableStmt* pStmt) {
8,309,610✔
364
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
8,309,610✔
365
  if (TSDB_CODE_SUCCESS == code && NULL == pStmt->pTags) {
8,309,610✔
366
    code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
6,812,329✔
367
  }
368
  if (TSDB_CODE_SUCCESS == code) {
8,309,610✔
369
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
8,309,610✔
370
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
371
  }
372
  if (TSDB_CODE_SUCCESS == code) {
8,309,610✔
373
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_TBL_CREATE,
8,309,610✔
374
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
375
  }
376
  return code;
8,309,610✔
377
}
378

379
static int32_t collectMetaKeyFromCreateVTable(SCollectMetaKeyCxt* pCxt, SCreateVTableStmt* pStmt) {
160,294✔
380
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
160,294✔
381
  if (TSDB_CODE_SUCCESS == code) {
160,294✔
382
    code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
160,294✔
383
  }
384
  if (TSDB_CODE_SUCCESS == code) {
160,294✔
385
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
160,294✔
386
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
387
  }
388
  if (TSDB_CODE_SUCCESS == code) {
160,294✔
389
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_TBL_CREATE,
160,294✔
390
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
391
  }
392
  if (TSDB_CODE_SUCCESS == code) {
160,294✔
393
    SNode* pNode = NULL;
160,294✔
394
    FOREACH(pNode, pStmt->pCols) {
144,229,462✔
395
      SColumnDefNode* pCol = (SColumnDefNode*)pNode;
144,069,168✔
396
      if (NULL == pCol) {
144,069,168✔
397
        code = TSDB_CODE_PAR_INVALID_COLUMN;
×
398
        break;
×
399
      }
400
      SColumnOptions* pOptions = (SColumnOptions*)pCol->pOptions;
144,069,168✔
401
      if (pOptions && pOptions->hasRef) {
144,069,168✔
402
        code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pOptions->refDb, pOptions->refTable, pCxt->pMetaCache);
89,896,355✔
403
        if (TSDB_CODE_SUCCESS == code) {
89,896,355✔
404
          code =
405
              reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pOptions->refDb, pOptions->refTable, pCxt->pMetaCache);
89,896,355✔
406
        }
407
        if (TSDB_CODE_SUCCESS == code) {
89,896,355✔
408
          code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pOptions->refDb,
179,792,417✔
409
                                        pOptions->refTable, PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache);
89,896,355✔
410
        }
411
        if (TSDB_CODE_SUCCESS != code) {
89,896,355✔
412
          break;
×
413
        }
414
      }
415
    }
416
  }
417
  return code;
160,294✔
418
}
419

420
static int32_t collectMetaKeyFromCreateVSubTable(SCollectMetaKeyCxt* pCxt, SCreateVSubTableStmt* pStmt) {
253,748✔
421
  int32_t code = TSDB_CODE_SUCCESS;
253,748✔
422
  PAR_ERR_RET(reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache));
253,748✔
423
  // super table's meta
424
  PAR_ERR_RET(
253,748✔
425
      reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->useDbName, pStmt->useTableName, pCxt->pMetaCache));
426
  // child table's meta
427
  PAR_ERR_RET(reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache));
253,748✔
428
  // check db's write auth
429
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
253,748✔
430
                                     PRIV_OBJ_DB, pCxt->pMetaCache));
431
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
253,748✔
432
                                     PRIV_TBL_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache));
433
  // check org table's read auth
434
  SNode*     pNode = NULL;
253,748✔
435
  SNodeList* pTmpNodeList = pStmt->pSpecificColRefs ? pStmt->pSpecificColRefs : pStmt->pColRefs;
253,748✔
436
  if (NULL == pTmpNodeList) {
253,748✔
437
    // no column reference
438
    return TSDB_CODE_SUCCESS;
15,330✔
439
  }
440

441
  FOREACH(pNode, pTmpNodeList) {
55,125,122✔
442
    SColumnRefNode* pColRef = (SColumnRefNode*)pNode;
54,886,704✔
443
    if (NULL == pColRef) {
54,886,704✔
444
      code = TSDB_CODE_PAR_INVALID_COLUMN;
×
445
      break;
×
446
    }
447
    PAR_ERR_RET(
54,886,704✔
448
        reserveTableMetaInCache(pCxt->pParseCxt->acctId, pColRef->refDbName, pColRef->refTableName, pCxt->pMetaCache));
449
    PAR_ERR_RET(reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pColRef->refDbName, pColRef->refTableName,
54,886,704✔
450
                                          pCxt->pMetaCache));
451
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pColRef->refDbName,
54,886,704✔
452
                                       pColRef->refTableName, PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache));
453
  }
454
  return code;
238,418✔
455
}
456

457
static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCreateMultiTablesStmt* pStmt) {
31,749,559✔
458
  int32_t code = TSDB_CODE_SUCCESS;
31,749,559✔
459
  SNode*  pNode = NULL;
31,749,559✔
460
  FOREACH(pNode, pStmt->pSubTables) {
69,825,559✔
461
    if (pNode->type == QUERY_NODE_CREATE_SUBTABLE_CLAUSE) {
38,073,973✔
462
      SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
38,080,947✔
463
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pClause->dbName, pCxt->pMetaCache);
38,080,947✔
464
      if (TSDB_CODE_SUCCESS == code) {
38,076,498✔
465
        code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pClause->useTableName,
38,076,922✔
466
                                       pCxt->pMetaCache);
467
      }
468
      if (TSDB_CODE_SUCCESS == code) {
38,077,022✔
469
        code =
470
            reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
38,077,022✔
471
      }
472
      if (TSDB_CODE_SUCCESS == code) {
38,083,843✔
473
        code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->dbName, NULL,
38,083,843✔
474
                                      PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
475
      }
476
      if (TSDB_CODE_SUCCESS == code) {
38,079,635✔
477
        code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->dbName, NULL,
38,079,635✔
478
                                      PRIV_TBL_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
479
      }
480
    } else {
481
      SCreateSubTableFromFileClause* pClause = (SCreateSubTableFromFileClause*)pNode;
×
482
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pCxt->pMetaCache);
×
483
      if (TSDB_CODE_SUCCESS == code) {
×
484
        code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pClause->useTableName,
×
485
                                       pCxt->pMetaCache);
486
      }
487
      if (TSDB_CODE_SUCCESS == code) {
×
488
        code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->useDbName, NULL,
×
489
                                      PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
490
      }
491
      if (TSDB_CODE_SUCCESS == code) {
×
492
        code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->useDbName, NULL,
×
493
                                      PRIV_TBL_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
494
      }
495
    }
496

497
    if (TSDB_CODE_SUCCESS != code) {
38,076,000✔
498
      break;
×
499
    }
500
  }
501
  return code;
31,753,515✔
502
}
503

504
static int32_t collectMetaKeyFromCreateSubTableFromFile(SCollectMetaKeyCxt*            pCxt,
1,323✔
505
                                                        SCreateSubTableFromFileClause* pClause) {
506
  int32_t code = TSDB_CODE_SUCCESS;
1,323✔
507
  SNode*  pNode = NULL;
1,323✔
508

509
  code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pCxt->pMetaCache);
1,323✔
510
  if (TSDB_CODE_SUCCESS == code) {
1,323✔
511
    code =
512
        reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pClause->useTableName, pCxt->pMetaCache);
1,323✔
513
  }
514
  if (TSDB_CODE_SUCCESS == code) {
1,323✔
515
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->useDbName, NULL,
1,323✔
516
                                  PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
517
  }
518
  if (TSDB_CODE_SUCCESS == code) {
1,323✔
519
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->useDbName, NULL,
1,323✔
520
                                  PRIV_TBL_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
521
  }
522

523
  return code;
1,323✔
524
}
525

526
static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableStmt* pStmt) {
2,103,349✔
527
  int32_t code = TSDB_CODE_SUCCESS;
2,103,349✔
528
  SNode*  pNode = NULL;
2,103,349✔
529
  FOREACH(pNode, pStmt->pTables) {
4,320,085✔
530
    SDropTableClause* pClause = (SDropTableClause*)pNode;
2,216,736✔
531
    if (pStmt->withOpt) {
2,216,736✔
532
      code = reserveTableUidInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
145,087✔
533
      if (TSDB_CODE_SUCCESS == code) {
145,087✔
534
        code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pClause->dbName, pCxt->pMetaCache);
145,087✔
535
      }
536
    } else {
537
      code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
2,071,649✔
538
      if (TSDB_CODE_SUCCESS == code) {
2,071,649✔
539
        code =
540
            reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
2,071,649✔
541
      }
542
      if (TSDB_CODE_SUCCESS == code) {
2,071,649✔
543
        code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->dbName,
4,138,299✔
544
                                      pClause->tableName, PRIV_CM_DROP, PRIV_OBJ_TBL, pCxt->pMetaCache);
2,071,649✔
545
      }
546
    }
547
    if (TSDB_CODE_SUCCESS == code) {
2,216,736✔
548
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pClause->dbName, pCxt->pMetaCache);
2,216,736✔
549
    }
550
    if (TSDB_CODE_SUCCESS == code) {
2,216,736✔
551
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->dbName, NULL, PRIV_DB_USE,
2,216,736✔
552
                                    PRIV_OBJ_DB, pCxt->pMetaCache);
553
    }
554

555
    if (TSDB_CODE_SUCCESS != code) {
2,216,736✔
556
      break;
×
557
    }
558
  }
559
  return code;
2,103,349✔
560
}
561

562
static int32_t collectMetaKeyFromDropStable(SCollectMetaKeyCxt* pCxt, SDropSuperTableStmt* pStmt) {
87,464✔
563
  int32_t code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
87,464✔
564
                                        PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
565
  if (TSDB_CODE_SUCCESS == code) {
87,464✔
566
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
87,464✔
567
  }
568
  if (TSDB_CODE_SUCCESS == code) {
87,464✔
569
    if (pStmt->withOpt) {
87,464✔
570
      code = reserveTableUidInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
55,252✔
571
    } else {
572
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
32,212✔
573
                                    PRIV_CM_DROP, PRIV_OBJ_TBL, pCxt->pMetaCache);
574
    }
575
  }
576
  return code;
87,464✔
577
}
578

579
static int32_t collectMetaKeyFromDropVtable(SCollectMetaKeyCxt* pCxt, SDropVirtualTableStmt* pStmt) {
70,974✔
580
  int32_t code = TSDB_CODE_SUCCESS;
70,974✔
581
  if (pStmt->withOpt) {
70,974✔
582
    code = reserveTableUidInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
×
583
    if (TSDB_CODE_SUCCESS == code) {
×
584
      code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
×
585
    }
586
    if (TSDB_CODE_SUCCESS == code) {
×
587
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
×
588
    }
589
  } else {
590
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
70,974✔
591
    if (TSDB_CODE_SUCCESS == code) {
70,974✔
592
      code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
70,974✔
593
    }
594
    if (TSDB_CODE_SUCCESS == code) {
70,974✔
595
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
70,974✔
596
                                    PRIV_OBJ_DB, pCxt->pMetaCache);
597
    }
598
    if (TSDB_CODE_SUCCESS == code) {
70,974✔
599
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
70,974✔
600
                                    PRIV_CM_DROP, PRIV_OBJ_TBL, pCxt->pMetaCache);
601
    }
602
  }
603
  return code;
70,974✔
604
}
605

606
static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) {
21,044,742✔
607
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
21,044,742✔
608
  if (TSDB_CODE_SUCCESS == code && (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType ||
21,044,742✔
609
                                    TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL == pStmt->alterType)) {
21,044,742✔
610
    SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
8,174,454✔
611
    tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
8,174,454✔
612
    tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
8,174,454✔
613
    code = catalogRemoveTableRelatedMeta(pCxt->pParseCxt->pCatalog, &name);
8,174,454✔
614
  }
615
  if (TSDB_CODE_SUCCESS == code) {
21,044,742✔
616
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
21,044,742✔
617
  }
618
  if (TSDB_CODE_SUCCESS == code) {
21,044,742✔
619
    code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
21,044,742✔
620
  }
621
  if (TSDB_CODE_SUCCESS == code) {
21,044,742✔
622
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
21,044,742✔
623
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
624
  }
625
  if (TSDB_CODE_SUCCESS == code) {
21,044,742✔
626
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
21,044,742✔
627
                                  PRIV_CM_ALTER, PRIV_OBJ_TBL, pCxt->pMetaCache);
628
  }
629
  return code;
21,044,742✔
630
}
631

632
static int32_t collectMetaKeyFromAlterStable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) {
501,248✔
633
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
501,248✔
634
  if (TSDB_CODE_SUCCESS == code) {
501,248✔
635
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
501,248✔
636
  }
637
  if (TSDB_CODE_SUCCESS == code) {
501,248✔
638
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
501,248✔
639
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
640
  }
641
  if (TSDB_CODE_SUCCESS == code) {
501,248✔
642
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
501,248✔
643
                                  PRIV_CM_ALTER, PRIV_OBJ_TBL, pCxt->pMetaCache);
644
  }
645
  return code;
501,248✔
646
}
647

648
static int32_t collectMetaKeyFromAlterVtable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) {
373,842✔
649
  PAR_ERR_RET(reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache));
373,842✔
650
  if (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType ||
373,842✔
651
      TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL == pStmt->alterType) {
373,842✔
652
    SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
30,772✔
653
    tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
30,772✔
654
    tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
30,772✔
655
    PAR_ERR_RET(catalogRemoveTableRelatedMeta(pCxt->pParseCxt->pCatalog, &name));
30,772✔
656
  }
657
  PAR_ERR_RET(reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache));
373,842✔
658
  PAR_ERR_RET(reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache));
373,842✔
659
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
373,842✔
660
                                     PRIV_OBJ_DB, pCxt->pMetaCache));
661
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
373,842✔
662
                                     PRIV_CM_ALTER, PRIV_OBJ_TBL, pCxt->pMetaCache));
663
  if (pStmt->alterType == TSDB_ALTER_TABLE_ALTER_COLUMN_REF ||
373,842✔
664
      pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COLUMN_REF) {
264,499✔
665
    PAR_ERR_RET(
142,627✔
666
        reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->refDbName, pStmt->refTableName, pCxt->pMetaCache));
667
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->refDbName, NULL,
142,627✔
668
                                       PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache));
669
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->refDbName,
142,627✔
670
                                       pStmt->refTableName, PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache));
671
  }
672
  return TSDB_CODE_SUCCESS;
373,842✔
673
}
674

675
static int32_t collectMetaKeyFromUseDatabase(SCollectMetaKeyCxt* pCxt, SUseDatabaseStmt* pStmt) {
2,208,616✔
676
  int32_t code = reserveDbVgVersionInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
2,208,616✔
677
  if (TSDB_CODE_SUCCESS == code) {
2,208,301✔
678
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
2,208,884✔
679
  }
680
  if (TSDB_CODE_SUCCESS == code) {
2,209,261✔
681
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
2,209,261✔
682
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
683
  }
684
  return code;
2,208,678✔
685
}
686

687
static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIndexStmt* pStmt) {
11,848✔
688
  int32_t code = TSDB_CODE_SUCCESS;
11,848✔
689
  if (INDEX_TYPE_SMA == pStmt->indexType || INDEX_TYPE_NORMAL == pStmt->indexType) {
11,848✔
690
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
11,848✔
691
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
692
      code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
11,848✔
693
    }
694
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
695
      code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
11,848✔
696
    }
697
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
698
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
11,848✔
699
    }
700
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
701
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
11,848✔
702
                                    PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache);
703
    }
704
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
705
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
11,848✔
706
                                    PRIV_IDX_CREATE, PRIV_OBJ_TBL, pCxt->pMetaCache);
707
    }
708
    if (TSDB_CODE_SUCCESS == code) {
11,848✔
709
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
11,848✔
710
                                    PRIV_OBJ_DB, pCxt->pMetaCache);
711
    }
712
  }
713
  return code;
11,848✔
714
}
715

716
static int32_t collectMetaKeyFromDropIndex(SCollectMetaKeyCxt* pCxt, SDropIndexStmt* pStmt) {
3,399✔
717
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->indexDbName, pCxt->pMetaCache);
3,399✔
718
  if (TSDB_CODE_SUCCESS == code) {
3,399✔
719
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->indexDbName, NULL,
3,399✔
720
                                  PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
721
  }
722
  if (TSDB_CODE_SUCCESS == code) {
3,399✔
723
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->indexDbName, pStmt->indexName,
3,399✔
724
                                  PRIV_CM_DROP, PRIV_OBJ_IDX, pCxt->pMetaCache);
725
  }
726
  return code;
3,399✔
727
}
728

729
static int32_t collectMetaKeyFromCreateTopic(SCollectMetaKeyCxt* pCxt, SCreateTopicStmt* pStmt) {
173,679✔
730
  int32_t code = 0;
173,679✔
731
  if (NULL != pStmt->pQuery) {
173,679✔
732
    code = collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
136,108✔
733
  }
734
  if (NULL != pStmt->pWhere) {
173,679✔
735
    code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->subDbName, pStmt->subSTbName, PRIV_TBL_SELECT, PRIV_OBJ_TBL);
7,586✔
736
  }
737
  if (pStmt->subDbName[0] != '\0') {
173,679✔
738
    if (TSDB_CODE_SUCCESS == code) {
37,571✔
739
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->subDbName, pCxt->pMetaCache);
37,571✔
740
    }
741
    if (TSDB_CODE_SUCCESS == code) {
37,571✔
742
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->subDbName, NULL,
37,571✔
743
                                    PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
744
    }
745
    if (TSDB_CODE_SUCCESS == code) {
37,571✔
746
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->subDbName, NULL,
37,571✔
747
                                    PRIV_TOPIC_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
748
    }
749
  }
750
  return code;
173,679✔
751
}
752

753
static int32_t collectMetaKeyFromExplain(SCollectMetaKeyCxt* pCxt, SExplainStmt* pStmt) {
69,972,579✔
754
  return collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
69,972,579✔
755
}
756

757
static int32_t collectMetaKeyFromDescribe(SCollectMetaKeyCxt* pCxt, SDescribeStmt* pStmt) {
516,523✔
758
  SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
516,523✔
759
  tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
516,523✔
760
  tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
516,523✔
761
  int32_t code = catalogRemoveTableRelatedMeta(pCxt->pParseCxt->pCatalog, &name);
516,523✔
762
#ifdef TD_ENTERPRISE
763
  if (TSDB_CODE_SUCCESS == code) {
516,523✔
764
    char dbFName[TSDB_DB_FNAME_LEN];
507,118✔
765
    (void)tNameGetFullDbName(&name, dbFName);
516,523✔
766
    code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->tableName, 0);
516,523✔
767
  }
768
#endif
769
  if (TSDB_CODE_SUCCESS == code) {
516,523✔
770
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
516,523✔
771
  }
772
  return code;
516,523✔
773
}
774

775
static int32_t collectMetaKeyFromCreateStream(SCollectMetaKeyCxt* pCxt, SCreateStreamStmt* pStmt) {
297,609✔
776
  int32_t code = TSDB_CODE_SUCCESS;
297,609✔
777

778
  if (strcmp(pStmt->targetTabName, "") != 0) {
297,609✔
779
    PAR_ERR_RET(
294,484✔
780
        reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->targetDbName, pStmt->targetTabName, pCxt->pMetaCache));
781
    (void)reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->targetDbName, pStmt->targetTabName,
294,484✔
782
                                    pCxt->pMetaCache);
783
    PAR_ERR_RET(reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->targetDbName, pCxt->pMetaCache));
294,484✔
784
  }
785
  PAR_ERR_RET(reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->streamDbName, pCxt->pMetaCache));
297,609✔
786
  SRealTableNode* pTriggerTable = (SRealTableNode*)((SStreamTriggerNode*)pStmt->pTrigger)->pTrigerTable;
297,609✔
787
  if (pTriggerTable) {
297,609✔
788
    SCollectMetaKeyFromExprCxt cxt = {
293,033✔
789
        .pComCxt = pCxt, .hasLastRowOrLast = false, .tbnameCollect = true, .errCode = TSDB_CODE_SUCCESS};
790
    cxt.pComCxt->collectVStbRefDbs = true;
293,033✔
791
    EDealRes res = collectMetaKeyFromRealTable(&cxt, pTriggerTable);
293,033✔
792
    PAR_ERR_RET(cxt.errCode);
293,033✔
793
    PAR_ERR_RET(reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pTriggerTable->table.dbName, pCxt->pMetaCache));
293,033✔
794
    PAR_ERR_RET(reserveDbCfgInCache(pCxt->pParseCxt->acctId, pTriggerTable->table.dbName, pCxt->pMetaCache));
293,033✔
795
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pTriggerTable->table.dbName,
293,033✔
796
                                       pTriggerTable->table.tableName, PRIV_TBL_SELECT, PRIV_OBJ_TBL,
797
                                       pCxt->pMetaCache));
798
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pTriggerTable->table.dbName,
293,033✔
799
                                       NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache));
800
  }
801
  if (pStmt->pQuery) {
297,609✔
802
    PAR_ERR_RET(collectMetaKeyFromQuery(pCxt, pStmt->pQuery));
294,484✔
803
  }
804
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->streamDbName, NULL,
297,609✔
805
                                     PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache));
806
  PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->streamDbName, NULL,
297,609✔
807
                                     PRIV_STREAM_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache));
808
  if (pStmt->targetDbName[0] != '\0') {
297,609✔
809
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->targetDbName, NULL,
294,484✔
810
                                       PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache));
811
    PAR_ERR_RET(reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->targetDbName, NULL,
294,484✔
812
                                       PRIV_TBL_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache));
813
  }
814

815
  return code;
297,609✔
816
}
817

818
static int32_t collectMetaKeyFromRecalculateStream(SCollectMetaKeyCxt* pCxt, SRecalcStreamStmt* pStmt) {
11,243✔
819
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->streamDbName, pCxt->pMetaCache);
11,243✔
820
}
821

822
static int32_t collectMetaKeyFromShowDnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
21,229✔
823
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES,
21,229✔
824
                                         pCxt->pMetaCache);
825
  if (TSDB_CODE_SUCCESS == code) {
21,229✔
826
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
21,229✔
827
                                  pCxt->pMetaCache);
828
  }
829
  return code;
21,229✔
830
}
831

832
static int32_t collectMetaKeyFromShowMnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
298,700✔
833
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES,
298,700✔
834
                                         pCxt->pMetaCache);
835
  if (TSDB_CODE_SUCCESS == code) {
298,700✔
836
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
298,700✔
837
                                  pCxt->pMetaCache);
838
  }
839
  return code;
298,700✔
840
}
841

842
static int32_t collectMetaKeyFromShowModules(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
843
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES,
×
844
                                         pCxt->pMetaCache);
845
  return code;
×
846
}
847

848
static int32_t collectMetaKeyFromShowQnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,218✔
849
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES,
1,218✔
850
                                         pCxt->pMetaCache);
851
  if (TSDB_CODE_SUCCESS == code) {
1,218✔
852
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
1,218✔
853
                                  pCxt->pMetaCache);
854
  }
855
  return code;
1,218✔
856
}
857

858
static int32_t collectMetaKeyFromShowSnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
59,692✔
859
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SNODES,
59,692✔
860
                                         pCxt->pMetaCache);
861
  if (TSDB_CODE_SUCCESS == code) {
59,692✔
862
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
59,692✔
863
                                  pCxt->pMetaCache);
864
  }
865
  return code;
59,692✔
866
}
867

868
static int32_t collectMetaKeyFromShowAnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
171✔
869
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ANODES,
171✔
870
                                         pCxt->pMetaCache);
871
  if (TSDB_CODE_SUCCESS == code) {
171✔
872
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
171✔
873
                                  pCxt->pMetaCache);
874
  }
875
  return code;
171✔
876
}
877

878
static int32_t collectMetaKeyFromShowAnodesFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
879
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
×
880
                                         TSDB_INS_TABLE_ANODES_FULL, pCxt->pMetaCache);
881
  if (TSDB_CODE_SUCCESS == code) {
×
882
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
×
883
                                  pCxt->pMetaCache);
884
  }
885
  return code;
×
886
}
887

888
static int32_t collectMetaKeyFromShowBnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
55,674✔
889
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_BNODES,
55,674✔
890
                                   pCxt->pMetaCache);
891
  if (TSDB_CODE_SUCCESS == code) {
55,674✔
892
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
55,674✔
893
                                  pCxt->pMetaCache);
894
  }
895
  return code;
55,674✔
896
}
897

898
static int32_t collectMetaKeyFromShowBackupNodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
899
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
×
900
                                         TSDB_INS_TABLE_BACKUP_NODES, pCxt->pMetaCache);
901
  if (TSDB_CODE_SUCCESS == code) {
×
902
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
×
903
                                  pCxt->pMetaCache);
904
  }
905
  return code;
×
906
}
907

908
static int32_t collectMetaKeyFromShowXnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,563✔
909
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_XNODES,
1,563✔
910
                                         pCxt->pMetaCache);
911
  if (TSDB_CODE_SUCCESS == code) {
1,563✔
912
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
1,563✔
913
                                  pCxt->pMetaCache);
914
  }
915
  return code;
1,563✔
916
}
917

918
static int32_t collectMetaKeyFromShowXnodeTasks(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
3,093✔
919
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
3,093✔
920
                                         TSDB_INS_TABLE_XNODE_TASKS, pCxt->pMetaCache);
921
  if (TSDB_CODE_SUCCESS == code) {
3,093✔
922
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
3,093✔
923
                                  pCxt->pMetaCache);
924
  }
925
  return code;
3,093✔
926
}
927
static int32_t collectMetaKeyFromShowXnodeAgents(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
2,310✔
928
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
2,310✔
929
                                         TSDB_INS_TABLE_XNODE_AGENTS, pCxt->pMetaCache);
930
  if (TSDB_CODE_SUCCESS == code) {
2,310✔
931
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
2,310✔
932
                                  pCxt->pMetaCache);
933
  }
934
  return code;
2,310✔
935
}
936
static int32_t collectMetaKeyFromShowXnodeJobs(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
3,267✔
937
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_XNODE_JOBS,
3,267✔
938
                                         pCxt->pMetaCache);
939
  if (TSDB_CODE_SUCCESS == code) {
3,267✔
940
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_NODES_SHOW, 0,
3,267✔
941
                                  pCxt->pMetaCache);
942
  }
943
  return code;
3,267✔
944
}
945
static int32_t collectMetaKeyFromShowArbGroups(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
208✔
946
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ARBGROUPS,
208✔
947
                                         pCxt->pMetaCache);
948
  return code;
208✔
949
}
950

951
static int32_t collectMetaKeyFromShowCluster(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,260✔
952
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CLUSTER,
1,260✔
953
                                   pCxt->pMetaCache);
954
  if (TSDB_CODE_SUCCESS == code) {
1,260✔
955
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_CLUSTER_SHOW, 0,
1,260✔
956
                                  pCxt->pMetaCache);
957
  }
958
  return code;
1,260✔
959
}
960

961
static int32_t collectMetaKeyFromShowDatabases(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
178,942✔
962
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DATABASES,
178,942✔
963
                                 pCxt->pMetaCache);
964
}
965

966
static int32_t collectMetaKeyFromShowFunctions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
25,153✔
967
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_FUNCTIONS,
25,153✔
968
                                         pCxt->pMetaCache);
969
  if (TSDB_CODE_SUCCESS == code) {
25,153✔
970
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_FUNC_SHOW, 0,
25,153✔
971
                                  pCxt->pMetaCache);
972
  }
973
  return code;
25,153✔
974
}
975

976
static int32_t collectMetaKeyFromShowIndexes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
2,646✔
977
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_INDEXES,
2,646✔
978
                                         pCxt->pMetaCache);
979
  if (TSDB_CODE_SUCCESS == code) {
2,646✔
980
    code =
981
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
2,646✔
982
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
983
  }
984
  return code;
2,646✔
985
}
986

987
static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
219,822✔
988
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STABLES,
219,822✔
989
                                         pCxt->pMetaCache);
990
  if (TSDB_CODE_SUCCESS == code) {
219,822✔
991
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
219,822✔
992
  }
993
  if (TSDB_CODE_SUCCESS == code) {
219,822✔
994
    code =
995
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
219,822✔
996
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
997
  }
998
  return code;
219,822✔
999
}
1000

1001
static int32_t collectMetaKeyFromShowStreams(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
104,992✔
1002
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS,
104,992✔
1003
                                         pCxt->pMetaCache);
1004
  if (TSDB_CODE_SUCCESS == code) {
104,992✔
1005
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
104,992✔
1006
  }
1007
  if (TSDB_CODE_SUCCESS == code) {
104,992✔
1008
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
104,992✔
1009
  }
1010
  if (TSDB_CODE_SUCCESS == code) {
104,992✔
1011
    code =
1012
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
104,992✔
1013
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1014
  }
1015
  return code;
104,992✔
1016
}
1017

1018
static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
301,947✔
1019
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES,
301,947✔
1020
                                         pCxt->pMetaCache);
1021
  if (TSDB_CODE_SUCCESS == code) {
301,947✔
1022
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
301,947✔
1023
  }
1024

1025
  if (TSDB_CODE_SUCCESS == code) {
301,947✔
1026
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
301,947✔
1027
  }
1028
  if (TSDB_CODE_SUCCESS == code) {
301,947✔
1029
    code =
1030
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
301,947✔
1031
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1032
  }
1033
  return code;
301,947✔
1034
}
1035

1036
static int32_t collectMetaKeyFromShowFilesets(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1037
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_FILESETS,
×
1038
                                         pCxt->pMetaCache);
1039
  if (TSDB_CODE_SUCCESS == code) {
×
1040
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
×
1041
  }
1042
  if (TSDB_CODE_SUCCESS == code) {
×
1043
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
×
1044
  }
1045
  if (TSDB_CODE_SUCCESS == code) {
×
1046
    code =
1047
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
×
1048
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1049
  }
1050
  return code;
×
1051
}
1052

1053
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
646,605✔
1054
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TAGS,
646,605✔
1055
                                         pCxt->pMetaCache);
1056
  if (TSDB_CODE_SUCCESS == code) {
646,605✔
1057
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal,
1,293,210✔
1058
                                   ((SValueNode*)pStmt->pTbName)->literal, pCxt->pMetaCache);
646,605✔
1059
  }
1060
  if (TSDB_CODE_SUCCESS == code) {
646,605✔
1061
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
646,605✔
1062
  }
1063
  if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pTbName) {
646,605✔
1064
    code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal,
1,293,210✔
1065
                                     ((SValueNode*)pStmt->pTbName)->literal, pCxt->pMetaCache);
646,605✔
1066
  }
1067
  return code;
646,605✔
1068
}
1069

1070
static int32_t collectMetaKeyFromShowStableTags(SCollectMetaKeyCxt* pCxt, SShowTableTagsStmt* pStmt) {
1,091✔
1071
  return collectMetaKeyFromRealTableImpl(pCxt, ((SValueNode*)pStmt->pDbName)->literal,
1,091✔
1072
                                         ((SValueNode*)pStmt->pTbName)->literal, PRIV_TBL_SELECT, PRIV_OBJ_TBL);
1,091✔
1073
}
1074

1075
static int32_t collectMetaKeyFromShowUsers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
119,994✔
1076
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS,
119,994✔
1077
                                         pCxt->pMetaCache);
1078
  if (TSDB_CODE_SUCCESS == code) {
119,994✔
1079
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_USER_SHOW, 0,
119,994✔
1080
                                  pCxt->pMetaCache);
1081
  }
1082
  return code;
119,994✔
1083
}
1084

1085
static int32_t collectMetaKeyFromShowUsersFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
12,870✔
1086
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS_FULL,
12,870✔
1087
                                         pCxt->pMetaCache);
1088
  if (TSDB_CODE_SUCCESS == code) {
12,870✔
1089
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_USER_SHOW, 0,
12,870✔
1090
                                  pCxt->pMetaCache);
1091
  }
1092
  return code;
12,870✔
1093
}
1094

1095
static int32_t collectMetaKeyFromShowRoles(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
165✔
1096
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ROLES,
165✔
1097
                                         pCxt->pMetaCache);
1098
  if (TSDB_CODE_SUCCESS == code) {
165✔
1099
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_ROLE_SHOW, 0,
165✔
1100
                                  pCxt->pMetaCache);
1101
  }
1102
  return code;
165✔
1103
}
1104

1105
static int32_t collectMetaKeyFromShowLicence(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,506✔
1106
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_LICENCES,
1,506✔
1107
                                         pCxt->pMetaCache);
1108
  if (TSDB_CODE_SUCCESS == code) {
1,506✔
1109
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_GRANTS_SHOW, 0,
1,506✔
1110
                                  pCxt->pMetaCache);
1111
  }
1112
  return code;
1,506✔
1113
}
1114

1115
static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
218,969✔
1116
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS,
218,969✔
1117
                                         pCxt->pMetaCache);
1118
  if (TSDB_CODE_SUCCESS == code) {
218,969✔
1119
    // just to verify whether the database exists
1120
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
218,969✔
1121
  }
1122
  return code;
218,969✔
1123
}
1124

1125
static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
17,636✔
1126
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TOPICS,
17,636✔
1127
                                 pCxt->pMetaCache);
1128
}
1129

1130
static int32_t collectMetaKeyFromShowConsumers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
16,345✔
1131
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB,
16,345✔
1132
                                         TSDB_PERFS_TABLE_CONSUMERS, pCxt->pMetaCache);
1133
  if (TSDB_CODE_SUCCESS == code) {
16,345✔
1134
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_CONSUMER_SHOW, 0,
16,345✔
1135
                                  pCxt->pMetaCache);
1136
  }
1137
  return code;
16,345✔
1138
}
1139

1140
static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,914✔
1141
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB,
1,914✔
1142
                                         TSDB_PERFS_TABLE_CONNECTIONS, pCxt->pMetaCache);
1143
  if (TSDB_CODE_SUCCESS == code) {
1,914✔
1144
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_CONN_SHOW, 0,
1,914✔
1145
                                  pCxt->pMetaCache);
1146
  }
1147
  return code;
1,914✔
1148
}
1149

1150
static int32_t collectMetaKeyFromShowQueries(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,218✔
1151
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_QUERIES,
1,218✔
1152
                                         pCxt->pMetaCache);
1153
  if (TSDB_CODE_SUCCESS == code) {
1,218✔
1154
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_QUERY_SHOW, 0,
1,218✔
1155
                                  pCxt->pMetaCache);
1156
  }
1157
  return code;
1,218✔
1158
}
1159

1160
static int32_t collectMetaKeyFromShowVariables(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
7,355✔
1161
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS,
7,355✔
1162
                                 pCxt->pMetaCache);
1163
}
1164

1165
static int32_t collectMetaKeyFromShowDnodeVariables(SCollectMetaKeyCxt* pCxt, SShowDnodeVariablesStmt* pStmt) {
36,041✔
1166
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
36,041✔
1167
                                         TSDB_INS_TABLE_DNODE_VARIABLES, pCxt->pMetaCache);
1168
  if (TSDB_CODE_SUCCESS == code) {
36,041✔
1169
    code = reserveDnodeRequiredInCache(pCxt->pMetaCache);
36,041✔
1170
  }
1171
  return code;
36,041✔
1172
}
1173

1174
static int32_t collectMetaKeyFromShowVnodes(SCollectMetaKeyCxt* pCxt, SShowVnodesStmt* pStmt) {
3,935✔
1175
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VNODES,
3,935✔
1176
                                 pCxt->pMetaCache);
1177
}
1178

1179
static int32_t collectMetaKeyFromShowUserPrivileges(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
3,061✔
1180
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
3,061✔
1181
                                         TSDB_INS_TABLE_USER_PRIVILEGES, pCxt->pMetaCache);
1182
  if (TSDB_CODE_SUCCESS == code) {
3,061✔
1183
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_SHOW_PRIVILEGES, 0,
3,061✔
1184
                                  pCxt->pMetaCache);
1185
  }
1186
  return code;
3,061✔
1187
}
1188

1189
static int32_t collectMetaKeyFromShowRolePrivileges(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
825✔
1190
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
825✔
1191
                                         TSDB_INS_TABLE_ROLE_PRIVILEGES, pCxt->pMetaCache);
1192
  if (TSDB_CODE_SUCCESS == code) {
825✔
1193
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_SHOW_PRIVILEGES, 0,
825✔
1194
                                  pCxt->pMetaCache);
1195
  }
1196
  return code;
825✔
1197
}
1198

1199
static int32_t collectMetaKeyFromShowRoleColPrivileges(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1200
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
×
1201
                                         TSDB_INS_TABLE_ROLE_COL_PRIVILEGES, pCxt->pMetaCache);
1202
  if (TSDB_CODE_SUCCESS == code) {
×
1203
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_SHOW_PRIVILEGES, 0,
×
1204
                                  pCxt->pMetaCache);
1205
  }
1206
  return code;
×
1207
}
1208

1209
static int32_t collectMetaKeyFromShowViews(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
12,864✔
1210
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VIEWS,
12,864✔
1211
                                         pCxt->pMetaCache);
1212
  if (TSDB_CODE_SUCCESS == code) {
12,864✔
1213
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
12,864✔
1214
  }
1215
  if (TSDB_CODE_SUCCESS == code) {
12,864✔
1216
    code =
1217
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
12,864✔
1218
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1219
  }
1220
  return code;
12,864✔
1221
}
1222

1223
static int32_t collectMetaKeyFromShowCompacts(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
965,530✔
1224
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_COMPACTS,
965,530✔
1225
                                         pCxt->pMetaCache);
1226
  return code;
965,530✔
1227
}
1228

1229
static int32_t collectMetaKeyFromShowScans(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
2,684✔
1230
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SCANS,
2,684✔
1231
                                         pCxt->pMetaCache);
1232
  return code;
2,684✔
1233
}
1234

1235
static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
29,941✔
1236
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
29,941✔
1237
                                         TSDB_INS_TABLE_COMPACT_DETAILS, pCxt->pMetaCache);
1238
  return code;
29,941✔
1239
}
1240

1241
static int32_t collectMetaKeyFromShowScanDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
2,318✔
1242
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
2,318✔
1243
                                         TSDB_INS_TABLE_SCAN_DETAILS, pCxt->pMetaCache);
1244
  return code;
2,318✔
1245
}
1246

1247
static int32_t collectMetaKeyFromShowSsMigrates(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1248
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SSMIGRATES,
×
1249
                                         pCxt->pMetaCache);
1250
  return code;
×
1251
}
1252

1253
static int32_t collectMetaKeyFromShowTokens(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,619✔
1254
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TOKENS,
1,619✔
1255
                                         pCxt->pMetaCache);
1256
  return code;
1,619✔
1257
}
1258

1259
static int32_t collectMetaKeyFromShowTransactionDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
288✔
1260
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
288✔
1261
                                         TSDB_INS_TABLE_TRANSACTION_DETAILS, pCxt->pMetaCache);
1262
  if (TSDB_CODE_SUCCESS == code) {
288✔
1263
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_TRANS_SHOW, 0,
288✔
1264
                                  pCxt->pMetaCache);
1265
  }
1266
  return code;
288✔
1267
}
1268

1269
static int32_t collectMetaKeyFromShowGrantsFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,197✔
1270
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
1,197✔
1271
                                         TSDB_INS_TABLE_GRANTS_FULL, pCxt->pMetaCache);
1272
  if (TSDB_CODE_SUCCESS == code) {
1,197✔
1273
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_GRANTS_SHOW, 0,
1,197✔
1274
                                  pCxt->pMetaCache);
1275
  }
1276
  return code;
1,197✔
1277
}
1278

1279
static int32_t collectMetaKeyFromShowGrantsLogs(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,197✔
1280
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
1,197✔
1281
                                         TSDB_INS_TABLE_GRANTS_LOGS, pCxt->pMetaCache);
1282
  if (TSDB_CODE_SUCCESS == code) {
1,197✔
1283
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_GRANTS_SHOW, 0,
1,197✔
1284
                                  pCxt->pMetaCache);
1285
  }
1286
  return code;
1,197✔
1287
}
1288

1289
static int32_t collectMetaKeyFromShowClusterMachines(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,218✔
1290
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MACHINES,
1,218✔
1291
                                         pCxt->pMetaCache);
1292
  if (TSDB_CODE_SUCCESS == code) {
1,218✔
1293
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_GRANTS_SHOW, 0,
1,218✔
1294
                                  pCxt->pMetaCache);
1295
  }
1296
  return code;
1,218✔
1297
}
1298

1299
static int32_t collectMetaKeyFromShowEncryptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
174✔
1300
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ENCRYPTIONS,
174✔
1301
                                 pCxt->pMetaCache);
1302
}
1303

1304
static int32_t collectMetaKeyFromShowEncryptAlgorithms(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,435✔
1305
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
1,435✔
1306
                                         TSDB_INS_TABLE_ENCRYPT_ALGORITHMS, pCxt->pMetaCache);
1307
  return code;
1,435✔
1308
}
1309

1310
static int32_t collectMetaKeyFromShowEncryptStatus(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1311
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ENCRYPT_STATUS,
×
1312
                                         pCxt->pMetaCache);
1313
  return code;
×
1314
}
1315

1316
static int32_t collectMetaKeyFromShowMounts(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
6,432✔
1317
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MOUNTS,
6,432✔
1318
                                         pCxt->pMetaCache);
1319
  if (TSDB_CODE_SUCCESS == code) {
6,432✔
1320
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_MOUNT_SHOW, 0,
6,432✔
1321
                                  pCxt->pMetaCache);
1322
  }
1323
  return code;
6,432✔
1324
}
1325

1326
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
66,523✔
1327
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
66,523✔
1328
}
1329

1330
static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) {
81,813✔
1331
  SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
81,813✔
1332
  tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
81,813✔
1333
  tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
81,813✔
1334
  int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name);
81,813✔
1335
  if (TSDB_CODE_SUCCESS == code) {
81,813✔
1336
    code = reserveTableCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
81,813✔
1337
  }
1338
  if (TSDB_CODE_SUCCESS == code) {
81,813✔
1339
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
81,813✔
1340
  }
1341
  // if (TSDB_CODE_SUCCESS == code) {
1342
  //   code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
1343
  //                                 AUTH_TYPE_READ, pCxt->pMetaCache);
1344
  // }
1345
  if (TSDB_CODE_SUCCESS == code) {
81,813✔
1346
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
81,813✔
1347
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1348
  }
1349
  if (TSDB_CODE_SUCCESS == code) {
81,813✔
1350
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
81,813✔
1351
                                  PRIV_CM_SHOW_CREATE, PRIV_OBJ_TBL, pCxt->pMetaCache);
1352
  }
1353
  return code;
81,813✔
1354
}
1355

1356
static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowCreateViewStmt* pStmt) {
7,436✔
1357
  SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
7,436✔
1358
  tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
7,436✔
1359
  tstrncpy(name.tname, pStmt->viewName, TSDB_TABLE_NAME_LEN);
7,436✔
1360
  char dbFName[TSDB_DB_FNAME_LEN];
7,436✔
1361
  (void)tNameGetFullDbName(&name, dbFName);
7,436✔
1362
  int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0);
7,436✔
1363
  if (TSDB_CODE_SUCCESS == code) {
7,436✔
1364
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
7,436✔
1365
  }
1366
  if (TSDB_CODE_SUCCESS == code) {
7,436✔
1367
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
7,436✔
1368
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1369
  }
1370
  if (TSDB_CODE_SUCCESS == code) {
7,436✔
1371
    code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName,
7,436✔
1372
                                      PRIV_CM_SHOW_CREATE, PRIV_OBJ_VIEW, pCxt->pMetaCache);
1373
  }
1374
  if (TSDB_CODE_SUCCESS == code) {
7,436✔
1375
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
7,436✔
1376
  }
1377
  pCxt->pMetaCache->forceFetchViewMeta = true;
7,436✔
1378
  return code;
7,436✔
1379
}
1380

1381
static int32_t collectMetaKeyFromShowCreateRsma(SCollectMetaKeyCxt* pCxt, SShowCreateRsmaStmt* pStmt) {
2,244✔
1382
  int32_t code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
2,244✔
1383
                                        PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1384
  if (TSDB_CODE_SUCCESS == code) {
2,244✔
1385
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
2,244✔
1386
  }
1387
  if (TSDB_CODE_SUCCESS == code) {
2,244✔
1388
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->rsmaName,
2,244✔
1389
                                  PRIV_CM_SHOW_CREATE, PRIV_OBJ_RSMA, pCxt->pMetaCache);
1390
  }
1391
  return code;
2,244✔
1392
}
1393

1394
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
1,218✔
1395
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS,
1,218✔
1396
                                 pCxt->pMetaCache);
1397
  if (TSDB_CODE_SUCCESS == code) {
1,218✔
1398
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_APPS_SHOW, 0,
1,218✔
1399
                                  pCxt->pMetaCache);
1400
  }
1401
  return code;
1,218✔
1402
}
1403

1404
static int32_t collectMetaKeyFromShowInstances(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1405
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_INSTANCES,
×
1406
                                 pCxt->pMetaCache);
1407
}
1408

1409
static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
417,830✔
1410
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS,
417,830✔
1411
                                         pCxt->pMetaCache);
1412
  if (TSDB_CODE_SUCCESS == code) {
417,830✔
1413
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, PRIV_TRANS_SHOW, 0,
417,830✔
1414
                                  pCxt->pMetaCache);
1415
  }
1416
  return code;
417,830✔
1417
}
1418

1419
static int32_t collectMetaKeyFromDelete(SCollectMetaKeyCxt* pCxt, SDeleteStmt* pStmt) {
1,751,982✔
1420
  STableNode* pTable = (STableNode*)pStmt->pFromTable;
1,751,982✔
1421
  return collectMetaKeyFromRealTableImpl(pCxt, pTable->dbName, pTable->tableName, PRIV_TBL_DELETE, PRIV_OBJ_TBL);
1,751,982✔
1422
}
1423

1424
static int32_t collectMetaKeyFromInsert(SCollectMetaKeyCxt* pCxt, SInsertStmt* pStmt) {
260,244✔
1425
  STableNode* pTable = (STableNode*)pStmt->pTable;
260,244✔
1426
  int32_t     code =
1427
      collectMetaKeyFromRealTableImpl(pCxt, pTable->dbName, pTable->tableName, PRIV_TBL_INSERT, PRIV_OBJ_TBL);
260,244✔
1428
  if (TSDB_CODE_SUCCESS == code) {
260,244✔
1429
    code = collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
260,244✔
1430
  }
1431
  return code;
260,244✔
1432
}
1433

1434
static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTableDistributedStmt* pStmt) {
3,100✔
1435
  SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
3,100✔
1436
  tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
3,100✔
1437
  tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
3,100✔
1438
  int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name);
3,100✔
1439
  if (TSDB_CODE_SUCCESS == code) {
3,100✔
1440
    code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->dbName, pStmt->tableName, PRIV_TBL_SELECT, PRIV_OBJ_TBL);
3,100✔
1441
  }
1442
  return code;
3,100✔
1443
}
1444

1445
static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
23,579✔
1446
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS,
23,579✔
1447
                                 pCxt->pMetaCache);
1448
}
1449

1450
static int32_t collectMetaKeyFromCompactDatabase(SCollectMetaKeyCxt* pCxt, SCompactDatabaseStmt* pStmt) {
27,040✔
1451
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
27,040✔
1452
  if (TSDB_CODE_SUCCESS == code) {
27,040✔
1453
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_COMPACT,
27,040✔
1454
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1455
  }
1456
  return code;
27,040✔
1457
}
1458

1459
static int32_t collectMetaKeyFromRollupDatabase(SCollectMetaKeyCxt* pCxt, SRollupDatabaseStmt* pStmt) {
9,724✔
1460
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
9,724✔
1461
  if (TSDB_CODE_SUCCESS == code) {
9,724✔
1462
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_ROLLUP,
9,724✔
1463
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1464
  }
1465
  return code;
9,724✔
1466
}
1467

1468
static int32_t collectMetaKeyFromScanDatabase(SCollectMetaKeyCxt* pCxt, SScanDatabaseStmt* pStmt) {
122✔
1469
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
122✔
1470
  if (TSDB_CODE_SUCCESS == code) {
122✔
1471
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_SCAN,
122✔
1472
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1473
  }
1474
  return code;
122✔
1475
}
1476

1477
static int32_t collectMetaKeyFromSsmigrateDatabase(SCollectMetaKeyCxt* pCxt, SSsMigrateDatabaseStmt* pStmt) {
×
1478
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
×
1479
  if (TSDB_CODE_SUCCESS == code) {
×
1480
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
×
1481
                                  PRIV_DB_SSMIGRATE, PRIV_OBJ_DB, pCxt->pMetaCache);
1482
  }
1483
  return code;
×
1484
}
1485

1486
static int32_t collectMetaKeyFromTrimDatabase(SCollectMetaKeyCxt* pCxt, STrimDatabaseStmt* pStmt) {
8,262✔
1487
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
8,262✔
1488
  if (TSDB_CODE_SUCCESS == code) {
8,262✔
1489
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_TRIM,
8,262✔
1490
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1491
  }
1492
  return code;
8,262✔
1493
}
1494

1495
static int32_t collectMetaKeyFromCompactVgroups(SCollectMetaKeyCxt* pCxt, SCompactVgroupsStmt* pStmt) {
3,740✔
1496
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
3,740✔
1497
}
1498

1499
static int32_t collectMetaKeyFromRollupVgroups(SCollectMetaKeyCxt* pCxt, SRollupVgroupsStmt* pStmt) {
4,488✔
1500
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
4,488✔
1501
}
1502

1503
static int32_t collectMetaKeyFromScanVgroups(SCollectMetaKeyCxt* pCxt, SScanVgroupsStmt* pStmt) {
305✔
1504
  return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
305✔
1505
}
1506

1507
static int32_t collectMetaKeyFromGrantImpl(SCollectMetaKeyCxt* pCxt, SGrantStmt* pStmt, bool grant) {
1,261,131✔
1508
  int32_t code = TSDB_CODE_SUCCESS;
1,261,131✔
1509

1510
  if (pStmt->optrType == TSDB_ALTER_ROLE_ROLE) {
1,261,131✔
1511
    if (pStmt->roleName[0] == 'S' && pStmt->roleName[1] == 'Y' && pStmt->roleName[2] == 'S') {
3,957✔
1512
      if (strcmp(pStmt->roleName, TSDB_ROLE_SYSDBA) == 0) {
3,792✔
1513
        return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL,
165✔
1514
                                      grant ? PRIV_GRANT_SYSDBA : PRIV_REVOKE_SYSDBA, 0, pCxt->pMetaCache);
1515
      }
1516
      if (strcmp(pStmt->roleName, TSDB_ROLE_SYSSEC) == 0) {
3,627✔
1517
        return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL,
165✔
1518
                                      grant ? PRIV_GRANT_SYSSEC : PRIV_REVOKE_SYSSEC, 0, pCxt->pMetaCache);
1519
      }
1520
      if (strcmp(pStmt->roleName, TSDB_ROLE_SYSAUDIT) == 0) {
3,462✔
1521
        return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL,
165✔
1522
                                      grant ? PRIV_GRANT_SYSAUDIT : PRIV_REVOKE_SYSAUDIT, 0, pCxt->pMetaCache);
1523
      }
1524
    }
1525
  } else if (TSDB_ALTER_ROLE_PRIVILEGES == pStmt->optrType) {
1,257,174✔
1526
    bool isRealObj = ('\0' != pStmt->objName[0] && strncmp(pStmt->objName, "*", TSDB_OBJ_NAME_LEN) != 0);
1,257,174✔
1527
    if (isRealObj) {
1,257,174✔
1528
      code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->objName, pCxt->pMetaCache);
1,249,382✔
1529
    }
1530
    if (TSDB_CODE_SUCCESS == code) {
1,257,174✔
1531
      if (isRealObj && '\0' != pStmt->tabName[0] && strncmp(pStmt->tabName, "*", TSDB_TABLE_NAME_LEN) != 0) {
1,257,174✔
1532
        EPrivObjType objType = PRIV_OBJ_TBL;
603,132✔
1533
        SPrivIter    privIter = {0};
603,132✔
1534
        privIterInit(&privIter, &pStmt->privileges.privSet);
603,132✔
1535
#if 0
1536
        SPrivInfo* pPrivInfo = NULL;
1537
        while (privIterNext(&privIter, &pPrivInfo)) {
1538
          break;
1539
        }
1540
        if (pPrivInfo) objType = pPrivInfo->objType;
1541
#endif
1542
        if (PRIV_OBJ_TBL == pStmt->privileges.objType) {
603,132✔
1543
          code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache);
583,987✔
1544
        } else if (PRIV_OBJ_VIEW == pStmt->privileges.objType) {
19,145✔
1545
          code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache);
14,170✔
1546
          pCxt->pMetaCache->forceFetchViewMeta = true;
14,170✔
1547
        } else {
1548
          // TODO: other object types
1549
        }
1550
      }
1551
    }
1552
  }
1553
  if (TSDB_CODE_SUCCESS == code) {
1,260,636✔
1554
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL,
1,260,636✔
1555
                                  grant ? PRIV_GRANT_PRIVILEGE : PRIV_REVOKE_PRIVILEGE, 0, pCxt->pMetaCache);
1556
  }
1557

1558
  return code;
1,260,636✔
1559
}
1560

1561
static int32_t collectMetaKeyFromGrant(SCollectMetaKeyCxt* pCxt, SGrantStmt* pStmt) {
821,892✔
1562
  return collectMetaKeyFromGrantImpl(pCxt, pStmt, true);
821,892✔
1563
}
1564

1565
static int32_t collectMetaKeyFromRevoke(SCollectMetaKeyCxt* pCxt, SRevokeStmt* pStmt) {
439,239✔
1566
  return collectMetaKeyFromGrantImpl(pCxt, (SGrantStmt*)pStmt, false);
439,239✔
1567
}
1568

1569
static int32_t collectMetaKeyFromCreateViewStmt(SCollectMetaKeyCxt* pCxt, SCreateViewStmt* pStmt) {
205,775✔
1570
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
205,775✔
1571

1572
  if (TSDB_CODE_SUCCESS == code) {
205,775✔
1573
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
205,775✔
1574
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1575
  }
1576
  if (TSDB_CODE_SUCCESS == code) {
205,775✔
1577
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
205,775✔
1578
  }
1579

1580
  if (TSDB_CODE_SUCCESS == code) {
205,775✔
1581
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
205,775✔
1582
                                  PRIV_VIEW_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
1583
  }
1584

1585
  if (TSDB_CODE_SUCCESS == code) {
205,775✔
1586
    if (!pStmt->pQuery ||
205,775✔
1587
        (QUERY_NODE_SELECT_STMT != nodeType(pStmt->pQuery) && QUERY_NODE_SET_OPERATOR != nodeType(pStmt->pQuery))) {
205,775✔
1588
      code = TSDB_CODE_PAR_INVALID_VIEW_QUERY;
×
1589
    } else {
1590
      code = collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
205,775✔
1591
    }
1592
  }
1593

1594
  return code;
205,775✔
1595
}
1596

1597
static int32_t collectMetaKeyFromDropViewStmt(SCollectMetaKeyCxt* pCxt, SDropViewStmt* pStmt) {
157,619✔
1598
  int32_t code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName,
315,238✔
1599
                                            pStmt->viewName, PRIV_CM_DROP, PRIV_OBJ_VIEW, pCxt->pMetaCache);
157,619✔
1600
  pCxt->pMetaCache->forceFetchViewMeta = true;
157,619✔
1601
  if (TSDB_CODE_SUCCESS == code) {
157,619✔
1602
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
157,619✔
1603
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1604
  }
1605
  if (TSDB_CODE_SUCCESS == code) {
157,619✔
1606
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
157,619✔
1607
  }
1608
  if (TSDB_CODE_SUCCESS == code) {
157,619✔
1609
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
157,619✔
1610
  }
1611
  return code;
157,619✔
1612
}
1613

1614
static int32_t collectMetaKeyFromCreateTSMAStmt(SCollectMetaKeyCxt* pCxt, SCreateTSMAStmt* pStmt) {
122✔
1615
  int32_t code;
1616
  if (pStmt->pOptions->recursiveTsma) {
122✔
1617
    // if creating recursive tsma, the tablename is tsmaName
1618
    code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
×
1619
    if (TSDB_CODE_SUCCESS == code) {
×
1620
      char dstTbName[TSDB_TABLE_NAME_LEN] = {0};
×
1621
      snprintf(dstTbName, TSDB_TABLE_NAME_LEN, "%s" TSMA_RES_STB_POSTFIX, pStmt->tableName);
×
1622
      code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
×
1623
      if (TSDB_CODE_SUCCESS == code) {
×
1624
        code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
×
1625
      }
1626
    }
1627
  } else {
1628
    code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
122✔
1629
    if (TSDB_CODE_SUCCESS == code) {
122✔
1630
      code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
122✔
1631
    }
1632
    if (TSDB_CODE_SUCCESS == code) {
122✔
1633
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
122✔
1634
                                    PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache);
1635
    }
1636
    if (TSDB_CODE_SUCCESS == code) {
122✔
1637
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL,
122✔
1638
                                    PRIV_STREAM_CREATE, PRIV_OBJ_DB, pCxt->pMetaCache);
1639
    }
1640
    if (TSDB_CODE_SUCCESS == code) {
122✔
1641
      code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
122✔
1642
                                    PRIV_TSMA_CREATE, PRIV_OBJ_TBL, pCxt->pMetaCache);
1643
    }
1644
  }
1645
  if (TSDB_CODE_SUCCESS == code) {
122✔
1646
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
122✔
1647
  }
1648
  if (TSDB_CODE_SUCCESS == code) {
122✔
1649
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
122✔
1650
  }
1651

1652
  if (TSDB_CODE_SUCCESS == code) {
122✔
1653
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
122✔
1654
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1655
  }
1656
  if (TSDB_CODE_SUCCESS == code) {
122✔
1657
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_TBL_CREATE,
122✔
1658
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1659
  }
1660

1661
  return code;
122✔
1662
}
1663

1664
static int32_t collectMetaKeyFromDropTSMAStmt(SCollectMetaKeyCxt* pCxt, SDropTSMAStmt* pStmt) {
×
1665
  int32_t code;
1666
  code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, pCxt->pMetaCache);
×
1667
  if (TSDB_CODE_SUCCESS == code) {
×
1668
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
×
1669
  }
1670
  if (TSDB_CODE_SUCCESS == code) {
×
1671
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
×
1672
  }
1673

1674
  if (TSDB_CODE_SUCCESS == code) {
×
1675
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
×
1676
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1677
  }
1678
  if (TSDB_CODE_SUCCESS == code) {
×
1679
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tsmaName,
×
1680
                                  PRIV_CM_DROP, PRIV_OBJ_TSMA, pCxt->pMetaCache);
1681
  }
1682
  return code;
×
1683
}
1684

1685
static int32_t collectMetaKeyFromShowUsage(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
328✔
1686
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_DISK_USAGE,
328✔
1687
                                         pCxt->pMetaCache);
1688
  if (TSDB_CODE_SUCCESS == code) {
328✔
1689
    code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
328✔
1690
  }
1691
  if (TSDB_CODE_SUCCESS == code) {
328✔
1692
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
328✔
1693
  }
1694
  if (TSDB_CODE_SUCCESS == code) {
328✔
1695
    code =
1696
        reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
328✔
1697
                               NULL, PRIV_DB_USE, PRIV_OBJ_DB, pCxt->pMetaCache);
1698
  }
1699
  return code;
328✔
1700
}
1701

1702
static int32_t collectMetaKeyFromShowTSMASStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
×
1703
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TSMAS,
×
1704
                                 pCxt->pMetaCache);
1705
}
1706

1707
static int32_t collectMetaKeyFromCreateRsmaStmt(SCollectMetaKeyCxt* pCxt, SCreateRsmaStmt* pStmt) {
111,452✔
1708
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
111,452✔
1709
  if (TSDB_CODE_SUCCESS == code) {
111,452✔
1710
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
111,452✔
1711
  }
1712
  if (TSDB_CODE_SUCCESS == code) {
111,452✔
1713
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
111,452✔
1714
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1715
  }
1716
  if (TSDB_CODE_SUCCESS == code) {
111,452✔
1717
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
111,452✔
1718
                                  PRIV_TBL_SELECT, PRIV_OBJ_TBL, pCxt->pMetaCache);
1719
  }
1720
  if (TSDB_CODE_SUCCESS == code) {
111,452✔
1721
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
111,452✔
1722
                                  PRIV_TBL_INSERT, PRIV_OBJ_TBL, pCxt->pMetaCache);
1723
  }
1724
  if (TSDB_CODE_SUCCESS == code) {
111,452✔
1725
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
111,452✔
1726
                                  PRIV_RSMA_CREATE, PRIV_OBJ_TBL, pCxt->pMetaCache);
1727
  }
1728
  return code;
111,452✔
1729
}
1730

1731
static int32_t collectMetaKeyFromDropRsmaStmt(SCollectMetaKeyCxt* pCxt, SDropRsmaStmt* pStmt) {
2,244✔
1732
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
2,244✔
1733
  if (TSDB_CODE_SUCCESS == code) {
2,244✔
1734
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, PRIV_DB_USE,
2,244✔
1735
                                  PRIV_OBJ_DB, pCxt->pMetaCache);
1736
  }
1737
  if (TSDB_CODE_SUCCESS == code) {
2,244✔
1738
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->rsmaName,
2,244✔
1739
                                  PRIV_CM_DROP, PRIV_OBJ_RSMA, pCxt->pMetaCache);
1740
  }
1741
  return code;
2,244✔
1742
}
1743

1744
static int32_t collectMetaKeyFromAlterRsmaStmt(SCollectMetaKeyCxt* pCxt, SAlterRsmaStmt* pStmt) {
20,196✔
1745
  int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
20,196✔
1746
  if (TSDB_CODE_SUCCESS == code) {
20,196✔
1747
    code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->rsmaName,
20,196✔
1748
                                  PRIV_CM_ALTER, PRIV_OBJ_RSMA, pCxt->pMetaCache);
1749
  }
1750
  return code;
20,196✔
1751
}
1752

1753
static int32_t collectMetaKeyFromShowRsmasStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
13,464✔
1754
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_RSMAS,
13,464✔
1755
                                 pCxt->pMetaCache);
1756
}
1757

1758
static int32_t collectMetaKeyFromShowRetentionsStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
42,636✔
1759
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_RETENTIONS,
42,636✔
1760
                                 pCxt->pMetaCache);
1761
}
1762

1763
static int32_t collectMetaKeyFromShowRetentionDetailsStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
2,244✔
1764
  return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_RETENTION_DETAILS,
2,244✔
1765
                                 pCxt->pMetaCache);
1766
}
1767

1768
static int32_t collectMetaKeyFromShowAlive(SCollectMetaKeyCxt* pCxt, SShowAliveStmt* pStmt) {
4,493✔
1769
  int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS,
4,493✔
1770
                                         pCxt->pMetaCache);
1771
  if (TSDB_CODE_SUCCESS == code && pStmt->dbName[0]) {
4,493✔
1772
    // just to verify whether the database exists
1773
    code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
1,404✔
1774
  }
1775
  return code;
4,493✔
1776
}
1777

1778
static int32_t collectMetaKeyFromAlterLocalStmt(SCollectMetaKeyCxt* pCxt, SAlterLocalStmt* pStmt) {
26,036✔
1779
  if ('\0' == pStmt->value[0]) {
26,036✔
1780
    char* p = strchr(pStmt->config, ' ');
4,980✔
1781
    if (NULL != p) {
4,980✔
1782
      *p = 0;
4,908✔
1783
      tstrncpy(pStmt->value, p + 1, sizeof(pStmt->value));
4,908✔
1784
    }
1785
  }
1786
  int32_t privType = cfgGetPrivType(tsCfg, pStmt->config, 0);
26,036✔
1787
  return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, privType, 0,
26,036✔
1788
                                pCxt->pMetaCache);
1789
  return TSDB_CODE_SUCCESS;
1790
}
1791

1792
static int32_t collectMetaKeyFromSysPrivStmt(SCollectMetaKeyCxt* pCxt, EPrivType privType) {
651,091✔
1793
  return reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, NULL, NULL, privType, 0,
651,091✔
1794
                                pCxt->pMetaCache);
1795
}
1796

1797
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
663,298,252✔
1798
  int32_t code = 0;
663,298,252✔
1799
  SNode* pOrigStmt = pCxt->pStmt;
663,298,252✔
1800
  pCxt->pStmt = pStmt;
663,304,625✔
1801
  
1802
  switch (nodeType(pStmt)) {
663,293,407✔
1803
    case QUERY_NODE_SET_OPERATOR:
12,703,660✔
1804
      code = collectMetaKeyFromSetOperator(pCxt, (SSetOperator*)pStmt);
12,703,660✔
1805
      break;
12,703,660✔
1806
    case QUERY_NODE_SELECT_STMT:
497,249,666✔
1807
      code = collectMetaKeyFromSelect(pCxt, (SSelectStmt*)pStmt);
497,249,666✔
1808
      break;
497,256,421✔
1809
    case QUERY_NODE_ALTER_DATABASE_STMT:
182,528✔
1810
      code = collectMetaKeyFromAlterDatabase(pCxt, (SAlterDatabaseStmt*)pStmt);
182,528✔
1811
      break;
182,528✔
1812
    case QUERY_NODE_FLUSH_DATABASE_STMT:
1,811,455✔
1813
      code = collectMetaKeyFromFlushDatabase(pCxt, (SFlushDatabaseStmt*)pStmt);
1,811,455✔
1814
      break;
1,811,455✔
1815
    case QUERY_NODE_CREATE_TABLE_STMT:
8,309,610✔
1816
      code = collectMetaKeyFromCreateTable(pCxt, (SCreateTableStmt*)pStmt);
8,309,610✔
1817
      break;
8,309,610✔
1818
    case QUERY_NODE_CREATE_VIRTUAL_TABLE_STMT:
160,294✔
1819
      code = collectMetaKeyFromCreateVTable(pCxt, (SCreateVTableStmt*)pStmt);
160,294✔
1820
      break;
160,294✔
1821
    case QUERY_NODE_CREATE_VIRTUAL_SUBTABLE_STMT:
253,748✔
1822
      code = collectMetaKeyFromCreateVSubTable(pCxt, (SCreateVSubTableStmt*)pStmt);
253,748✔
1823
      break;
253,748✔
1824
    case QUERY_NODE_CREATE_MULTI_TABLES_STMT:
31,750,515✔
1825
      code = collectMetaKeyFromCreateMultiTable(pCxt, (SCreateMultiTablesStmt*)pStmt);
31,750,515✔
1826
      break;
31,750,657✔
1827
    case QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE:
1,323✔
1828
      code = collectMetaKeyFromCreateSubTableFromFile(pCxt, (SCreateSubTableFromFileClause*)pStmt);
1,323✔
1829
      break;
1,323✔
1830
    case QUERY_NODE_DROP_TABLE_STMT:
2,103,349✔
1831
      code = collectMetaKeyFromDropTable(pCxt, (SDropTableStmt*)pStmt);
2,103,349✔
1832
      break;
2,103,349✔
1833
    case QUERY_NODE_DROP_SUPER_TABLE_STMT:
87,464✔
1834
      code = collectMetaKeyFromDropStable(pCxt, (SDropSuperTableStmt*)pStmt);
87,464✔
1835
      break;
87,464✔
1836
    case QUERY_NODE_DROP_VIRTUAL_TABLE_STMT:
70,974✔
1837
      code = collectMetaKeyFromDropVtable(pCxt, (SDropVirtualTableStmt*)pStmt);
70,974✔
1838
      break;
70,974✔
1839
    case QUERY_NODE_ALTER_TABLE_STMT:
21,044,742✔
1840
      code = collectMetaKeyFromAlterTable(pCxt, (SAlterTableStmt*)pStmt);
21,044,742✔
1841
      break;
21,044,742✔
1842
    case QUERY_NODE_ALTER_SUPER_TABLE_STMT:
501,248✔
1843
      code = collectMetaKeyFromAlterStable(pCxt, (SAlterTableStmt*)pStmt);
501,248✔
1844
      break;
501,248✔
1845
    case QUERY_NODE_ALTER_VIRTUAL_TABLE_STMT:
373,842✔
1846
      code = collectMetaKeyFromAlterVtable(pCxt, (SAlterTableStmt*)pStmt);
373,842✔
1847
      break;
373,842✔
1848
    case QUERY_NODE_USE_DATABASE_STMT:
2,208,666✔
1849
      code = collectMetaKeyFromUseDatabase(pCxt, (SUseDatabaseStmt*)pStmt);
2,208,666✔
1850
      break;
2,208,673✔
1851
    case QUERY_NODE_CREATE_INDEX_STMT:
11,848✔
1852
      code = collectMetaKeyFromCreateIndex(pCxt, (SCreateIndexStmt*)pStmt);
11,848✔
1853
      break;
11,848✔
1854
    case QUERY_NODE_DROP_INDEX_STMT:
3,399✔
1855
      code = collectMetaKeyFromDropIndex(pCxt, (SDropIndexStmt*)pStmt);
3,399✔
1856
      break;
3,399✔
1857
    case QUERY_NODE_CREATE_TOPIC_STMT:
173,679✔
1858
      code = collectMetaKeyFromCreateTopic(pCxt, (SCreateTopicStmt*)pStmt);
173,679✔
1859
      break;
173,679✔
1860
    case QUERY_NODE_EXPLAIN_STMT:
69,972,579✔
1861
      code = collectMetaKeyFromExplain(pCxt, (SExplainStmt*)pStmt);
69,972,579✔
1862
      break;
69,972,579✔
1863
    case QUERY_NODE_DESCRIBE_STMT:
516,523✔
1864
      code = collectMetaKeyFromDescribe(pCxt, (SDescribeStmt*)pStmt);
516,523✔
1865
      break;
516,523✔
1866
    case QUERY_NODE_COMPACT_DATABASE_STMT:
27,040✔
1867
      code = collectMetaKeyFromCompactDatabase(pCxt, (SCompactDatabaseStmt*)pStmt);
27,040✔
1868
      break;
27,040✔
1869
    case QUERY_NODE_ROLLUP_DATABASE_STMT:
9,724✔
1870
      code = collectMetaKeyFromRollupDatabase(pCxt, (SRollupDatabaseStmt*)pStmt);
9,724✔
1871
      break;
9,724✔
1872
    case QUERY_NODE_SCAN_DATABASE_STMT:
122✔
1873
      code = collectMetaKeyFromScanDatabase(pCxt, (SScanDatabaseStmt*)pStmt);
122✔
1874
      break;
122✔
1875
    case QUERY_NODE_SSMIGRATE_DATABASE_STMT:
×
1876
      code = collectMetaKeyFromSsmigrateDatabase(pCxt, (SSsMigrateDatabaseStmt*)pStmt);
×
1877
      break;
×
1878
    case QUERY_NODE_TRIM_DATABASE_STMT:
8,262✔
1879
      code = collectMetaKeyFromTrimDatabase(pCxt, (STrimDatabaseStmt*)pStmt);
8,262✔
1880
      break;
8,262✔
1881
    case QUERY_NODE_COMPACT_VGROUPS_STMT:
3,740✔
1882
      code = collectMetaKeyFromCompactVgroups(pCxt, (SCompactVgroupsStmt*)pStmt);
3,740✔
1883
      break;
3,740✔
1884
    case QUERY_NODE_ROLLUP_VGROUPS_STMT:
4,488✔
1885
      code = collectMetaKeyFromRollupVgroups(pCxt, (SRollupVgroupsStmt*)pStmt);
4,488✔
1886
      break;
4,488✔
1887
    case QUERY_NODE_SCAN_VGROUPS_STMT:
305✔
1888
      code = collectMetaKeyFromScanVgroups(pCxt, (SScanVgroupsStmt*)pStmt);
305✔
1889
      break;
305✔
1890
    case QUERY_NODE_CREATE_STREAM_STMT:
297,609✔
1891
      code = collectMetaKeyFromCreateStream(pCxt, (SCreateStreamStmt*)pStmt);
297,609✔
1892
      break;
297,609✔
1893
    case QUERY_NODE_RECALCULATE_STREAM_STMT:
11,243✔
1894
      code = collectMetaKeyFromRecalculateStream(pCxt, (SRecalcStreamStmt*)pStmt);
11,243✔
1895
      break;
11,243✔
1896
    case QUERY_NODE_GRANT_STMT:
821,892✔
1897
      code = collectMetaKeyFromGrant(pCxt, (SGrantStmt*)pStmt);
821,892✔
1898
      break;
821,892✔
1899
    case QUERY_NODE_REVOKE_STMT:
439,239✔
1900
      code = collectMetaKeyFromRevoke(pCxt, (SRevokeStmt*)pStmt);
439,239✔
1901
      break;
439,239✔
1902
    case QUERY_NODE_SHOW_DNODES_STMT:
21,229✔
1903
      code = collectMetaKeyFromShowDnodes(pCxt, (SShowStmt*)pStmt);
21,229✔
1904
      break;
21,229✔
1905
    case QUERY_NODE_SHOW_MNODES_STMT:
298,700✔
1906
      code = collectMetaKeyFromShowMnodes(pCxt, (SShowStmt*)pStmt);
298,700✔
1907
      break;
298,700✔
1908
    case QUERY_NODE_SHOW_MODULES_STMT:
×
1909
      code = collectMetaKeyFromShowModules(pCxt, (SShowStmt*)pStmt);
×
1910
      break;
×
1911
    case QUERY_NODE_SHOW_QNODES_STMT:
1,218✔
1912
      code = collectMetaKeyFromShowQnodes(pCxt, (SShowStmt*)pStmt);
1,218✔
1913
      break;
1,218✔
1914
    case QUERY_NODE_SHOW_SNODES_STMT:
59,692✔
1915
      code = collectMetaKeyFromShowSnodes(pCxt, (SShowStmt*)pStmt);
59,692✔
1916
      break;
59,692✔
1917
    case QUERY_NODE_SHOW_ANODES_STMT:
171✔
1918
      code = collectMetaKeyFromShowAnodes(pCxt, (SShowStmt*)pStmt);
171✔
1919
      break;
171✔
1920
    case QUERY_NODE_SHOW_ANODES_FULL_STMT:
×
1921
      code = collectMetaKeyFromShowAnodesFull(pCxt, (SShowStmt*)pStmt);
×
1922
      break;
×
1923
    case QUERY_NODE_SHOW_BNODES_STMT:
55,674✔
1924
      code = collectMetaKeyFromShowBnodes(pCxt, (SShowStmt*)pStmt);
55,674✔
1925
      break;
55,674✔
1926
    case QUERY_NODE_SHOW_BACKUP_NODES_STMT:
×
1927
      code = collectMetaKeyFromShowBackupNodes(pCxt, (SShowStmt*)pStmt);
×
1928
      break;
×
1929
    case QUERY_NODE_SHOW_XNODES_STMT:
1,563✔
1930
      code = collectMetaKeyFromShowXnodes(pCxt, (SShowStmt*)pStmt);
1,563✔
1931
      break;
1,563✔
1932
    case QUERY_NODE_SHOW_XNODE_TASKS_STMT:
3,093✔
1933
      code = collectMetaKeyFromShowXnodeTasks(pCxt, (SShowStmt*)pStmt);
3,093✔
1934
      break;
3,093✔
1935
    case QUERY_NODE_SHOW_XNODE_AGENTS_STMT:
2,310✔
1936
      code = collectMetaKeyFromShowXnodeAgents(pCxt, (SShowStmt*)pStmt);
2,310✔
1937
      break;
2,310✔
1938
    case QUERY_NODE_SHOW_XNODE_JOBS_STMT:
3,267✔
1939
      code = collectMetaKeyFromShowXnodeJobs(pCxt, (SShowStmt*)pStmt);
3,267✔
1940
      break;
3,267✔
1941
    case QUERY_NODE_SHOW_ARBGROUPS_STMT:
208✔
1942
      code = collectMetaKeyFromShowArbGroups(pCxt, (SShowStmt*)pStmt);
208✔
1943
      break;
208✔
1944
    case QUERY_NODE_SHOW_CLUSTER_STMT:
1,260✔
1945
      code = collectMetaKeyFromShowCluster(pCxt, (SShowStmt*)pStmt);
1,260✔
1946
      break;
1,260✔
1947
    case QUERY_NODE_SHOW_DATABASES_STMT:
178,942✔
1948
      code = collectMetaKeyFromShowDatabases(pCxt, (SShowStmt*)pStmt);
178,942✔
1949
      break;
178,942✔
1950
    case QUERY_NODE_SHOW_FUNCTIONS_STMT:
25,153✔
1951
      code = collectMetaKeyFromShowFunctions(pCxt, (SShowStmt*)pStmt);
25,153✔
1952
      break;
25,153✔
1953
    case QUERY_NODE_SHOW_INDEXES_STMT:
2,646✔
1954
      code = collectMetaKeyFromShowIndexes(pCxt, (SShowStmt*)pStmt);
2,646✔
1955
      break;
2,646✔
1956
    case QUERY_NODE_SHOW_STABLES_STMT:
219,822✔
1957
      code = collectMetaKeyFromShowStables(pCxt, (SShowStmt*)pStmt);
219,822✔
1958
      break;
219,822✔
1959
    case QUERY_NODE_SHOW_STREAMS_STMT:
104,992✔
1960
      code = collectMetaKeyFromShowStreams(pCxt, (SShowStmt*)pStmt);
104,992✔
1961
      break;
104,992✔
1962
    case QUERY_NODE_SHOW_TABLES_STMT:
301,947✔
1963
    case QUERY_NODE_SHOW_VTABLES_STMT:
1964
      code = collectMetaKeyFromShowTables(pCxt, (SShowStmt*)pStmt);
301,947✔
1965
      break;
301,947✔
1966
    case QUERY_NODE_SHOW_FILESETS_STMT:
×
1967
      code = collectMetaKeyFromShowFilesets(pCxt, (SShowStmt*)pStmt);
×
1968
      break;
×
1969
    case QUERY_NODE_SHOW_TAGS_STMT:
646,605✔
1970
      code = collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt);
646,605✔
1971
      break;
646,605✔
1972
    case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
1,091✔
1973
      code = collectMetaKeyFromShowStableTags(pCxt, (SShowTableTagsStmt*)pStmt);
1,091✔
1974
      break;
1,091✔
1975
    case QUERY_NODE_SHOW_USERS_STMT:
119,994✔
1976
      code = collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
119,994✔
1977
      break;
119,994✔
1978
    case QUERY_NODE_SHOW_USERS_FULL_STMT:
12,870✔
1979
      code = collectMetaKeyFromShowUsersFull(pCxt, (SShowStmt*)pStmt);
12,870✔
1980
      break;
12,870✔
1981
    case QUERY_NODE_SHOW_ROLES_STMT:
165✔
1982
      code = collectMetaKeyFromShowRoles(pCxt, (SShowStmt*)pStmt);
165✔
1983
      break;
165✔
1984
    case QUERY_NODE_SHOW_LICENCES_STMT:
1,506✔
1985
      code = collectMetaKeyFromShowLicence(pCxt, (SShowStmt*)pStmt);
1,506✔
1986
      break;
1,506✔
1987
    case QUERY_NODE_SHOW_VGROUPS_STMT:
218,969✔
1988
      code = collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
218,969✔
1989
      break;
218,969✔
1990
    case QUERY_NODE_SHOW_TOPICS_STMT:
17,636✔
1991
      code = collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
17,636✔
1992
      break;
17,636✔
1993
    case QUERY_NODE_SHOW_CONSUMERS_STMT:
16,345✔
1994
      code = collectMetaKeyFromShowConsumers(pCxt, (SShowStmt*)pStmt);
16,345✔
1995
      break;
16,345✔
1996
    case QUERY_NODE_SHOW_CONNECTIONS_STMT:
1,914✔
1997
      code = collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt);
1,914✔
1998
      break;
1,914✔
1999
    case QUERY_NODE_SHOW_QUERIES_STMT:
1,218✔
2000
      code = collectMetaKeyFromShowQueries(pCxt, (SShowStmt*)pStmt);
1,218✔
2001
      break;
1,218✔
2002
    case QUERY_NODE_SHOW_VARIABLES_STMT:
7,355✔
2003
      code = collectMetaKeyFromShowVariables(pCxt, (SShowStmt*)pStmt);
7,355✔
2004
      break;
7,355✔
2005
    case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
36,041✔
2006
      code = collectMetaKeyFromShowDnodeVariables(pCxt, (SShowDnodeVariablesStmt*)pStmt);
36,041✔
2007
      break;
36,041✔
2008
    case QUERY_NODE_SHOW_VNODES_STMT:
3,935✔
2009
      code = collectMetaKeyFromShowVnodes(pCxt, (SShowVnodesStmt*)pStmt);
3,935✔
2010
      break;
3,935✔
2011
    case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
3,061✔
2012
      code = collectMetaKeyFromShowUserPrivileges(pCxt, (SShowStmt*)pStmt);
3,061✔
2013
      break;
3,061✔
2014
    case QUERY_NODE_SHOW_ROLE_PRIVILEGES_STMT:
825✔
2015
      code = collectMetaKeyFromShowRolePrivileges(pCxt, (SShowStmt*)pStmt);
825✔
2016
      break;
825✔
2017
    case QUERY_NODE_SHOW_ROLE_COL_PRIVILEGES_STMT:
×
2018
      code = collectMetaKeyFromShowRoleColPrivileges(pCxt, (SShowStmt*)pStmt);
×
2019
      break;
×
2020
    case QUERY_NODE_SHOW_VIEWS_STMT:
12,864✔
2021
      code = collectMetaKeyFromShowViews(pCxt, (SShowStmt*)pStmt);
12,864✔
2022
      break;
12,864✔
2023
    case QUERY_NODE_SHOW_COMPACTS_STMT:
965,530✔
2024
      code = collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
965,530✔
2025
      break;
965,530✔
2026
    case QUERY_NODE_SHOW_SCANS_STMT:
2,684✔
2027
      code = collectMetaKeyFromShowScans(pCxt, (SShowStmt*)pStmt);
2,684✔
2028
      break;
2,684✔
2029
    case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
29,941✔
2030
      code = collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
29,941✔
2031
      break;
29,941✔
2032
    case QUERY_NODE_SHOW_SCAN_DETAILS_STMT:
2,318✔
2033
      code = collectMetaKeyFromShowScanDetails(pCxt, (SShowStmt*)pStmt);
2,318✔
2034
      break;
2,318✔
2035
    case QUERY_NODE_SHOW_SSMIGRATES_STMT:
×
2036
      code = collectMetaKeyFromShowSsMigrates(pCxt, (SShowStmt*)pStmt);
×
2037
      break;
×
2038
    case QUERY_NODE_SHOW_TOKENS_STMT:
1,619✔
2039
      code = collectMetaKeyFromShowTokens(pCxt, (SShowStmt*)pStmt);
1,619✔
2040
      break;
1,619✔
2041
    case QUERY_NODE_SHOW_TRANSACTION_DETAILS_STMT:
288✔
2042
      code = collectMetaKeyFromShowTransactionDetails(pCxt, (SShowStmt*)pStmt);
288✔
2043
      break;
288✔
2044
    case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
1,197✔
2045
      code = collectMetaKeyFromShowGrantsFull(pCxt, (SShowStmt*)pStmt);
1,197✔
2046
      break;
1,197✔
2047
    case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
1,197✔
2048
      code = collectMetaKeyFromShowGrantsLogs(pCxt, (SShowStmt*)pStmt);
1,197✔
2049
      break;
1,197✔
2050
    case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
1,218✔
2051
      code = collectMetaKeyFromShowClusterMachines(pCxt, (SShowStmt*)pStmt);
1,218✔
2052
      break;
1,218✔
2053
    case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
174✔
2054
      code = collectMetaKeyFromShowEncryptions(pCxt, (SShowStmt*)pStmt);
174✔
2055
      break;
174✔
2056
    case QUERY_NODE_SHOW_ENCRYPT_ALGORITHMS_STMT:
1,435✔
2057
      code = collectMetaKeyFromShowEncryptAlgorithms(pCxt, (SShowStmt*)pStmt);
1,435✔
2058
      break;
1,435✔
2059
    case QUERY_NODE_SHOW_ENCRYPT_STATUS_STMT:
×
2060
      code = collectMetaKeyFromShowEncryptStatus(pCxt, (SShowStmt*)pStmt);
×
2061
      break;
×
2062
    case QUERY_NODE_SHOW_MOUNTS_STMT:
6,432✔
2063
      code = collectMetaKeyFromShowMounts(pCxt, (SShowStmt*)pStmt);
6,432✔
2064
      break;
6,432✔
2065
    case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
66,523✔
2066
      code = collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
66,523✔
2067
      break;
66,523✔
2068
    case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
81,813✔
2069
    case QUERY_NODE_SHOW_CREATE_VTABLE_STMT:
2070
    case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
2071
      code = collectMetaKeyFromShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt);
81,813✔
2072
      break;
81,813✔
2073
    case QUERY_NODE_SHOW_CREATE_VIEW_STMT:
7,436✔
2074
      code = collectMetaKeyFromShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt);
7,436✔
2075
      break;
7,436✔
2076
    case QUERY_NODE_SHOW_CREATE_RSMA_STMT:
2,244✔
2077
      code = collectMetaKeyFromShowCreateRsma(pCxt, (SShowCreateRsmaStmt*)pStmt);
2,244✔
2078
      break;
2,244✔
2079
    case QUERY_NODE_SHOW_APPS_STMT:
1,218✔
2080
      code = collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt);
1,218✔
2081
      break;
1,218✔
2082
    case QUERY_NODE_SHOW_INSTANCES_STMT:
×
2083
      code = collectMetaKeyFromShowInstances(pCxt, (SShowStmt*)pStmt);
×
2084
      break;
×
2085
    case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
417,830✔
2086
      code = collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
417,830✔
2087
      break;
417,830✔
2088
    case QUERY_NODE_SHOW_USAGE_STMT:
328✔
2089
      code = collectMetaKeyFromShowUsage(pCxt, (SShowStmt*)pStmt);
328✔
2090
      break;
328✔
2091
    case QUERY_NODE_DELETE_STMT:
1,751,982✔
2092
      code = collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
1,751,982✔
2093
      break;
1,751,982✔
2094
    case QUERY_NODE_INSERT_STMT:
260,244✔
2095
      code = collectMetaKeyFromInsert(pCxt, (SInsertStmt*)pStmt);
260,244✔
2096
      break;
260,244✔
2097
    case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
3,100✔
2098
      code = collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt);
3,100✔
2099
      break;
3,100✔
2100
    case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
23,579✔
2101
      code = collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt);
23,579✔
2102
      break;
23,579✔
2103
    case QUERY_NODE_CREATE_VIEW_STMT:
205,775✔
2104
      code = collectMetaKeyFromCreateViewStmt(pCxt, (SCreateViewStmt*)pStmt);
205,775✔
2105
      break;
205,775✔
2106
    case QUERY_NODE_DROP_VIEW_STMT:
157,619✔
2107
      code = collectMetaKeyFromDropViewStmt(pCxt, (SDropViewStmt*)pStmt);
157,619✔
2108
      break;
157,619✔
2109
    case QUERY_NODE_CREATE_TSMA_STMT:
122✔
2110
      code = collectMetaKeyFromCreateTSMAStmt(pCxt, (SCreateTSMAStmt*)pStmt);
122✔
2111
      break;
122✔
2112
    case QUERY_NODE_DROP_TSMA_STMT:
×
2113
      code = collectMetaKeyFromDropTSMAStmt(pCxt, (SDropTSMAStmt*)pStmt);
×
2114
      break;
×
2115
    case QUERY_NODE_SHOW_TSMAS_STMT:
×
2116
      code = collectMetaKeyFromShowTSMASStmt(pCxt, (SShowStmt*)pStmt);
×
2117
      break;
×
2118
    case QUERY_NODE_CREATE_RSMA_STMT:
111,452✔
2119
      code = collectMetaKeyFromCreateRsmaStmt(pCxt, (SCreateRsmaStmt*)pStmt);
111,452✔
2120
      break;
111,452✔
2121
    case QUERY_NODE_DROP_RSMA_STMT:
2,244✔
2122
      code = collectMetaKeyFromDropRsmaStmt(pCxt, (SDropRsmaStmt*)pStmt);
2,244✔
2123
      break;
2,244✔
2124
    case QUERY_NODE_ALTER_RSMA_STMT:
20,196✔
2125
      code = collectMetaKeyFromAlterRsmaStmt(pCxt, (SAlterRsmaStmt*)pStmt);
20,196✔
2126
      break;
20,196✔
2127
    case QUERY_NODE_SHOW_RSMAS_STMT:
13,464✔
2128
      code = collectMetaKeyFromShowRsmasStmt(pCxt, (SShowStmt*)pStmt);
13,464✔
2129
      break;
13,464✔
2130
    case QUERY_NODE_SHOW_RETENTIONS_STMT:
42,636✔
2131
      code = collectMetaKeyFromShowRetentionsStmt(pCxt, (SShowStmt*)pStmt);
42,636✔
2132
      break;
42,636✔
2133
    case QUERY_NODE_SHOW_RETENTION_DETAILS_STMT:
2,244✔
2134
      code = collectMetaKeyFromShowRetentionDetailsStmt(pCxt, (SShowStmt*)pStmt);
2,244✔
2135
      break;
2,244✔
2136
    case QUERY_NODE_SHOW_DB_ALIVE_STMT:
4,493✔
2137
    case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
2138
      code = collectMetaKeyFromShowAlive(pCxt, (SShowAliveStmt*)pStmt);
4,493✔
2139
      break;
4,493✔
2140
    case QUERY_NODE_CREATE_DATABASE_STMT:
1,384,437✔
2141
      code = collectMetaKeyFromCreateDatabase(pCxt, (SCreateDatabaseStmt*)pStmt);
1,384,437✔
2142
      break;
1,384,437✔
2143
    case QUERY_NODE_DROP_DATABASE_STMT:
1,139,539✔
2144
      code = collectMetaKeyFromDropDatabase(pCxt, (SDropDatabaseStmt*)pStmt);
1,139,539✔
2145
      break;
1,139,539✔
2146
    case QUERY_NODE_BALANCE_VGROUP_STMT:
11,637✔
2147
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_VG_BALANCE);
11,637✔
2148
      break;
11,637✔
2149
    case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
2,254✔
2150
    case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
2151
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_VG_BALANCE_LEADER);
2,254✔
2152
      break;
2,254✔
2153
    case QUERY_NODE_MERGE_VGROUP_STMT:
×
2154
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_VG_MERGE);
×
2155
      break;
×
2156
    case QUERY_NODE_SPLIT_VGROUP_STMT:
17,362✔
2157
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_VG_SPLIT);
17,362✔
2158
      break;
17,362✔
2159
    case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
45,544✔
2160
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_VG_REDISTRIBUTE);
45,544✔
2161
      break;
45,544✔
2162
    case QUERY_NODE_CREATE_FUNCTION_STMT:
32,241✔
2163
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_FUNC_CREATE);
32,241✔
2164
      break;
32,241✔
2165
    case QUERY_NODE_DROP_FUNCTION_STMT:
24,063✔
2166
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_FUNC_DROP);
24,063✔
2167
      break;
24,063✔
2168
    case QUERY_NODE_CREATE_MOUNT_STMT:
1,474✔
2169
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_MOUNT_CREATE);
1,474✔
2170
      break;
1,474✔
2171
    case QUERY_NODE_DROP_MOUNT_STMT:
536✔
2172
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_MOUNT_DROP);
536✔
2173
      break;
536✔
2174
    case QUERY_NODE_CREATE_ROLE_STMT:
165✔
2175
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_ROLE_CREATE);
165✔
2176
      break;
165✔
2177
    case QUERY_NODE_DROP_ROLE_STMT:
×
2178
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_ROLE_DROP);
×
2179
      break;
×
2180
    case QUERY_NODE_CREATE_USER_STMT:
72,192✔
2181
      code =  collectMetaKeyFromSysPrivStmt(pCxt, PRIV_USER_CREATE);
72,192✔
2182
      break;
72,192✔
2183
    case QUERY_NODE_ALTER_USER_STMT:
37,560✔
2184
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_USER_ALTER);
37,560✔
2185
      break;
37,560✔
2186
    case QUERY_NODE_DROP_USER_STMT:
34,186✔
2187
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_USER_DROP);
34,186✔
2188
      break;
34,186✔
2189
    case QUERY_NODE_ALTER_LOCAL_STMT:
26,036✔
2190
      return collectMetaKeyFromAlterLocalStmt(pCxt, (SAlterLocalStmt*)pStmt);
26,036✔
2191
    case QUERY_NODE_CREATE_DNODE_STMT:
282,602✔
2192
    case QUERY_NODE_CREATE_MNODE_STMT:
2193
    case QUERY_NODE_CREATE_QNODE_STMT:
2194
    case QUERY_NODE_CREATE_SNODE_STMT:
2195
    case QUERY_NODE_CREATE_BNODE_STMT:
2196
    case QUERY_NODE_CREATE_ANODE_STMT:
2197
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_NODE_CREATE);
282,602✔
2198
      break;
282,602✔
2199
    case QUERY_NODE_DROP_DNODE_STMT:
88,819✔
2200
    case QUERY_NODE_DROP_MNODE_STMT:
2201
    case QUERY_NODE_DROP_QNODE_STMT:
2202
    case QUERY_NODE_DROP_SNODE_STMT:
2203
    case QUERY_NODE_DROP_BNODE_STMT:
2204
    case QUERY_NODE_DROP_ANODE_STMT:
2205
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_NODE_DROP);
88,819✔
2206
      break;
88,819✔
2207
    case QUERY_NODE_KILL_TRANSACTION_STMT:
285✔
2208
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_TRANS_KILL);
285✔
2209
      break;
285✔
2210
    case QUERY_NODE_KILL_QUERY_STMT:
×
2211
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_QUERY_KILL);
×
2212
      break;
×
2213
    case QUERY_NODE_KILL_CONNECTION_STMT:
171✔
2214
      code = collectMetaKeyFromSysPrivStmt(pCxt, PRIV_CONN_KILL);
171✔
2215
      break;
171✔
2216
    default:
2,405,895✔
2217
      break;
2,405,895✔
2218
  }
2219

2220
  pCxt->pStmt = pOrigStmt;
663,277,498✔
2221

2222
  return code;
663,285,948✔
2223
}
2224

2225
int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
277,057,191✔
2226
  SCollectMetaKeyCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .pStmt = pQuery->pRoot};
277,057,191✔
2227
  return collectMetaKeyFromQuery(&cxt, pQuery->pRoot);
277,048,206✔
2228
}
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