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

taosdata / TDengine / #4725

08 Sep 2025 08:43AM UTC coverage: 59.112% (+0.003%) from 59.109%
#4725

push

travis-ci

web-flow
Merge pull request #32881 from taosdata/enh/add-new-windows-ci

fix(ci): update workflow reference to use new Windows CI YAML

135818 of 292179 branches covered (46.48%)

Branch coverage included in aggregate %.

204660 of 283811 relevant lines covered (72.11%)

23953203.49 hits per line

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

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

16
#define _DEFAULT_SOURCE
17
#include "mndShow.h"
18
#include "mndPrivilege.h"
19
#include "mndUser.h"
20
#include "systable.h"
21

22
#define SHOW_STEP_SIZE            100
23
#define SHOW_COLS_STEP_SIZE       4096
24
#define SHOW_PRIVILEGES_STEP_SIZE 2048
25

26
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq);
27
static void      mndFreeShowObj(SShowObj *pShow);
28
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId);
29
static void      mndReleaseShowObj(SShowObj *pShow, bool forceRemove);
30
static bool      mndCheckRetrieveFinished(SShowObj *pShow);
31
static int32_t   mndProcessRetrieveSysTableReq(SRpcMsg *pReq);
32

33
int32_t mndInitShow(SMnode *pMnode) {
1,962✔
34
  int32_t    code = 0;
1,962✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,962✔
36

37
  pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, 5000, true, (__cache_free_fn_t)mndFreeShowObj, "show");
1,962✔
38
  if (pMgmt->cache == NULL) {
1,962!
39
    code = TSDB_CODE_OUT_OF_MEMORY;
×
40
    mError("failed to alloc show cache since %s", tstrerror(code));
×
41
    TAOS_RETURN(code);
×
42
  }
43

44
  mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveSysTableReq);
1,962✔
45
  TAOS_RETURN(code);
1,962✔
46
}
47

48
void mndCleanupShow(SMnode *pMnode) {
1,959✔
49
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,959✔
50
  if (pMgmt->cache != NULL) {
1,959!
51
    taosCacheCleanup(pMgmt->cache);
1,959✔
52
    pMgmt->cache = NULL;
1,959✔
53
  }
54
}
1,959✔
55

56
static int32_t convertToRetrieveType(char *name, int32_t len) {
427,723✔
57
  int32_t type = -1;
427,723✔
58

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
427,723✔
60
    type = TSDB_MGMT_TABLE_DNODE;
15,486✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
412,237✔
62
    type = TSDB_MGMT_TABLE_MNODE;
10,200✔
63
    /*
64
      } else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, len) == 0) {
65
        type = TSDB_MGMT_TABLE_MODULE;
66
    */
67
  } else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, len) == 0) {
402,037✔
68
    type = TSDB_MGMT_TABLE_QNODE;
4,354✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
397,683✔
70
    type = TSDB_MGMT_TABLE_SNODE;
7,608✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
390,075✔
72
    type = TSDB_MGMT_TABLE_ANODE;
1✔
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
390,074!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_BNODES, len) == 0) {
390,074✔
76
    type = TSDB_MGMT_TABLE_BNODE;
283✔
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
389,791✔
78
    type = TSDB_MGMT_TABLE_ARBGROUP;
13✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
389,778✔
80
    type = TSDB_MGMT_TABLE_CLUSTER;
8,636✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
381,142✔
82
    type = TSDB_MGMT_TABLE_DB;
54,553✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
326,589✔
84
    type = TSDB_MGMT_TABLE_FUNC;
14,421✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
312,168✔
86
    type = TSDB_MGMT_TABLE_INDEX;
13,520✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
298,648✔
88
    type = TSDB_MGMT_TABLE_STB;
20,155✔
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
278,493!
90
    type = TSDB_MGMT_TABLE_TABLE;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
278,493!
92
    type = TSDB_MGMT_TABLE_TAG;
×
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
278,493✔
94
    type = TSDB_MGMT_TABLE_COL;
22,762✔
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
255,731!
96
    //    type = TSDB_MGMT_TABLE_DIST;
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
255,842✔
98
    type = TSDB_MGMT_TABLE_USER;
10,135✔
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
245,707!
100
    type = TSDB_MGMT_TABLE_USER_FULL;
×
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
245,707✔
102
    type = TSDB_MGMT_TABLE_GRANTS;
14,391✔
103
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
231,316✔
104
    type = TSDB_MGMT_TABLE_VGROUP;
27,968✔
105
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
203,348✔
106
    type = TSDB_MGMT_TABLE_CONSUMERS;
17,327✔
107
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
186,021✔
108
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
11,579✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
174,442✔
110
    type = TSDB_MGMT_TABLE_TRANS;
15,231✔
111
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
159,211!
112
    type = TSDB_MGMT_TABLE_SMAS;
×
113
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
159,211✔
114
    type = TSDB_MGMT_TABLE_CONFIGS;
2,884✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
156,327✔
116
    type = TSDB_MGMT_TABLE_CONNS;
12,992✔
117
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
143,335✔
118
    type = TSDB_MGMT_TABLE_QUERIES;
23,026✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
120,309✔
120
    type = TSDB_MGMT_TABLE_VNODES;
15,932✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
104,377✔
122
    type = TSDB_MGMT_TABLE_TOPICS;
10,128✔
123
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
94,249✔
124
    type = TSDB_MGMT_TABLE_STREAMS;
13,589✔
125
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
80,660✔
126
    type = TSDB_MGMT_TABLE_APPS;
21,571✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
59,089✔
128
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
20,609✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_RECALCULATES, len) == 0) {
38,480✔
130
    type = TSDB_MGMT_TABLE_STREAM_RECALCULATES;
1✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
38,479✔
132
    type = TSDB_MGMT_TABLE_PRIVILEGES;
8,693✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
29,786✔
134
    type = TSDB_MGMT_TABLE_VIEWS;
13,011✔
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
16,775✔
136
    type = TSDB_MGMT_TABLE_COMPACT;
4,917✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
11,858✔
138
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
11,544✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_TRANSACTION_DETAILS, len) == 0) {
314✔
140
    type = TSDB_MGMT_TABLE_TRANSACTION_DETAIL;
2✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
312✔
142
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
7✔
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
305✔
144
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
7✔
145
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
298✔
146
    type = TSDB_MGMT_TABLE_MACHINES;
8✔
147
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
290✔
148
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
5✔
149
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
285!
150
    type = TSDB_MGMT_TABLE_TSMAS;
×
151
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
285!
152
    type = TSDB_MGMT_TABLE_USAGE;
×
153
  } else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
285!
154
    type = TSDB_MGMT_TABLE_FILESETS;
×
155
  } else if (strncasecmp(name, TSDB_INS_TABLE_VC_COLS, len) == 0) {
285!
156
    type = TSDB_MGMT_TABLE_VC_COL;
×
157
  } else if (strncasecmp(name, TSDB_INS_TABLE_MOUNTS, len) == 0) {
285✔
158
    type = TSDB_MGMT_TABLE_MOUNT;
48✔
159
  } else {
160
    mError("invalid show name:%s len:%d", name, len);
237!
161
  }
162

163
  return type;
427,630✔
164
}
165

166
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
427,578✔
167
  SShowMgmt *pMgmt = &pMnode->showMgmt;
427,578✔
168

169
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
427,578✔
170
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
428,150!
171

172
  int32_t size = sizeof(SShowObj);
428,150✔
173

174
  SShowObj showObj = {0};
428,150✔
175

176
  showObj.id = showId;
428,150✔
177
  showObj.pMnode = pMnode;
428,150✔
178
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
428,150✔
179
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
427,690✔
180
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
427,690✔
181

182
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
427,690✔
183
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
427,690✔
184
  if (pShow == NULL) {
427,861!
185
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
186
    mError("show:0x%" PRIx64 ", failed to put into cache since %s", showId, terrstr());
×
187
    return NULL;
×
188
  }
189

190
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
427,861✔
191
  return pShow;
427,833✔
192
}
193

194
static void mndFreeShowObj(SShowObj *pShow) {
428,262✔
195
  SMnode    *pMnode = pShow->pMnode;
428,262✔
196
  SShowMgmt *pMgmt = &pMnode->showMgmt;
428,262✔
197

198
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
428,262✔
199
  if (freeFp != NULL) {
428,262✔
200
    if (pShow->pIter != NULL) {
400,176✔
201
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
1!
202

203
      (*freeFp)(pMnode, pShow->pIter);
1✔
204

205
      pShow->pIter = NULL;
1✔
206
    }
207
  }
208

209
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
428,262✔
210
}
428,262✔
211

212
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
16,445✔
213
  SShowMgmt *pMgmt = &pMnode->showMgmt;
16,445✔
214

215
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
16,445✔
216
  if (pShow == NULL) {
16,448!
217
    mError("show:0x%" PRIx64 ", already destroyed", showId);
×
218
    return NULL;
×
219
  }
220

221
  mTrace("show:0x%" PRIx64 ", acquired from cache, data:%p", pShow->id, pShow);
16,448!
222
  return pShow;
16,446✔
223
}
224

225
static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
444,195✔
226
  if (pShow == NULL) return;
444,195!
227
  mTrace("show:0x%" PRIx64 ", released from cache, data:%p force:%d", pShow->id, pShow, forceRemove);
444,195✔
228

229
  // A bug in tcache.c
230
  forceRemove = 0;
444,195✔
231

232
  SMnode    *pMnode = pShow->pMnode;
444,195✔
233
  SShowMgmt *pMgmt = &pMnode->showMgmt;
444,195✔
234
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
444,195✔
235
}
236

237
static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
444,452✔
238
  int32_t    code = 0;
444,452✔
239
  SMnode    *pMnode = pReq->info.node;
444,452✔
240
  SShowMgmt *pMgmt = &pMnode->showMgmt;
444,452✔
241
  SShowObj  *pShow = NULL;
444,452✔
242
  int32_t    rowsToRead = SHOW_STEP_SIZE;
444,452✔
243
  int32_t    size = 0;
444,452✔
244
  int32_t    rowsRead = 0;
444,452✔
245
  mDebug("mndProcessRetrieveSysTableReq start");
444,452✔
246
  SRetrieveTableReq retrieveReq = {0};
444,452✔
247
  TAOS_CHECK_RETURN(tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq));
444,452✔
248

249
  mDebug("process to retrieve systable req db:%s, tb:%s, compactId:%" PRId64, retrieveReq.db, retrieveReq.tb,
444,499✔
250
         retrieveReq.compactId);
251

252
  if (retrieveReq.showId == 0) {
444,493✔
253
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
428,048✔
254
    if (pMeta == NULL) {
427,698✔
255
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
90,180✔
256
      if (pMeta == NULL) {
90,218!
257
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
258
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
259
        TAOS_RETURN(code);
×
260
      }
261
    }
262

263
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
427,736✔
264
    if (pShow == NULL) {
427,704!
265
      code = terrno;
×
266
      mError("failed to process show-meta req since %s", tstrerror(code));
×
267
      TAOS_RETURN(code);
×
268
    }
269

270
    pShow->pMeta = pMeta;
427,708✔
271
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
427,708✔
272
  } else {
273
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
16,445✔
274
    if (pShow == NULL) {
16,445✔
275
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
153✔
276
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
153!
277
      TAOS_RETURN(code);
153✔
278
    }
279
  }
280

281
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
444,000✔
282
    rowsToRead = SHOW_COLS_STEP_SIZE;
22,786✔
283
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
421,214✔
284
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
8,689✔
285
  }
286
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
444,000✔
287
  if (retrieveFp == NULL) {
444,000!
288
    mndReleaseShowObj(pShow, false);
×
289
    code = TSDB_CODE_MSG_NOT_PROCESSED;
×
290
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
291
    TAOS_RETURN(code);
×
292
  }
293

294
  mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
444,000✔
295
  if (retrieveReq.user[0] != 0) {
443,782✔
296
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
443,716✔
297
  } else {
298
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
66✔
299
  }
300
  code = -1;
443,782✔
301
  if (retrieveReq.db[0] &&
451,237✔
302
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
7,455✔
303
    TAOS_RETURN(code);
6✔
304
  }
305
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
443,776!
306
    if (strcmp(pReq->info.conn.user, "root") != 0) {
×
307
      mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
×
308
      code = TSDB_CODE_MND_NO_RIGHTS;
×
309
      TAOS_RETURN(code);
×
310
    }
311
  }
312

313
  int32_t numOfCols = pShow->pMeta->numOfColumns;
443,776✔
314

315
  SSDataBlock *pBlock = NULL;
443,776✔
316
  code = createDataBlock(&pBlock);
443,776✔
317
  if (code) {
444,168!
318
    TAOS_RETURN(code);
×
319
  }
320

321
  for (int32_t i = 0; i < numOfCols; ++i) {
6,643,335✔
322
    SColumnInfoData idata = {0};
6,198,386✔
323

324
    SSchema *p = &pShow->pMeta->pSchemas[i];
6,198,386✔
325

326
    idata.info.bytes = p->bytes;
6,198,386✔
327
    idata.info.type = p->type;
6,198,386✔
328
    idata.info.colId = p->colId;
6,198,386✔
329
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
6,198,386!
330
  }
331

332
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
444,949!
333

334
  if (mndCheckRetrieveFinished(pShow)) {
444,376!
335
    mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows);
×
336
    rowsRead = 0;
×
337
  } else {
338
    rowsRead = (*retrieveFp)(pReq, pShow, pBlock, rowsToRead);
444,322✔
339
    if (rowsRead < 0) {
444,425✔
340
      code = rowsRead;
5✔
341
      mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
5!
342
      mndReleaseShowObj(pShow, true);
5✔
343
      blockDataDestroy(pBlock);
5✔
344
      TAOS_RETURN(code);
5✔
345
    }
346

347
    pBlock->info.rows = rowsRead;
444,420✔
348
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
444,420✔
349
  }
350

351
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
444,420✔
352
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
443,888✔
353
         dataEncodeBufSize;
354

355
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
443,888✔
356
  if (pRsp == NULL) {
444,410!
357
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(terrno));
×
358
    code = terrno;
×
359
    goto _exit;
×
360
  }
361

362
  pRsp->handle = htobe64(pShow->id);
444,410✔
363

364
  if (rowsRead > 0) {
444,337✔
365
    char    *pStart = pRsp->data;
298,408✔
366
    SSchema *ps = pShow->pMeta->pSchemas;
298,408✔
367

368
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
298,408✔
369
    pStart += sizeof(int32_t);  // number of columns
298,408✔
370

371
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
5,045,673✔
372
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
4,747,265✔
373
      pSchema->bytes = htonl(ps[i].bytes);
4,747,265✔
374
      pSchema->colId = htons(ps[i].colId);
4,747,265✔
375
      pSchema->type = ps[i].type;
4,747,265✔
376

377
      pStart += sizeof(SSysTableSchema);
4,747,265✔
378
    }
379

380
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
298,408✔
381
    if (len < 0) {
298,377!
382
      mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(terrno));
×
383
      code = terrno;
×
384
      return code;
×
385
    }
386
  }
387

388
  pRsp->numOfRows = htonl(rowsRead);
444,306✔
389
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
444,306✔
390
  pReq->info.rsp = pRsp;
444,306✔
391
  pReq->info.rspLen = size;
444,306✔
392

393
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
444,306✔
394
    pRsp->completed = 1;
427,973✔
395
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
427,973✔
396
    mndReleaseShowObj(pShow, true);
427,973✔
397
  } else {
398
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
16,438✔
399
    mndReleaseShowObj(pShow, false);
16,438✔
400
  }
401

402
  blockDataDestroy(pBlock);
444,411✔
403
  return TSDB_CODE_SUCCESS;
444,569✔
404
_exit:
×
405
  mndReleaseShowObj(pShow, false);
×
406
  blockDataDestroy(pBlock);
×
407
  if (pRsp) {
×
408
    rpcFreeCont(pRsp);
×
409
  }
410
  return code;
×
411
}
412

413
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
742,560✔
414
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
742,560✔
415
    return true;
281,930✔
416
  }
417
  return false;
460,630✔
418
}
419

420
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
82,404✔
421
  SShowMgmt *pMgmt = &pMnode->showMgmt;
82,404✔
422
  pMgmt->retrieveFps[showType] = fp;
82,404✔
423
}
82,404✔
424

425
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType showType, ShowFreeIterFp fp) {
74,556✔
426
  SShowMgmt *pMgmt = &pMnode->showMgmt;
74,556✔
427
  pMgmt->freeIterFps[showType] = fp;
74,556✔
428
}
74,556✔
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