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

taosdata / TDengine / #3610

12 Feb 2025 09:54AM UTC coverage: 54.713% (-8.4%) from 63.066%
#3610

push

travis-ci

web-flow
Merge pull request #29745 from taosdata/fix/TD33664-3.0

fix: --version show information check for 3.0

120957 of 286549 branches covered (42.21%)

Branch coverage included in aggregate %.

190849 of 283342 relevant lines covered (67.36%)

4969786.97 hits per line

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

67.94
/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,081✔
34
  int32_t    code = 0;
1,081✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,081✔
36

37
  pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, 5000, true, (__cache_free_fn_t)mndFreeShowObj, "show");
1,081✔
38
  if (pMgmt->cache == NULL) {
1,081!
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,081✔
45
  TAOS_RETURN(code);
1,081✔
46
}
47

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
9,326✔
60
    type = TSDB_MGMT_TABLE_DNODE;
419✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
8,907✔
62
    type = TSDB_MGMT_TABLE_MNODE;
93✔
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) {
8,814✔
68
    type = TSDB_MGMT_TABLE_QNODE;
1✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
8,813!
70
    type = TSDB_MGMT_TABLE_SNODE;
×
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
8,813!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
8,813!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
8,813!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
8,813!
78
    type = TSDB_MGMT_TABLE_CLUSTER;
×
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
8,813✔
80
    type = TSDB_MGMT_TABLE_DB;
276✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
8,537✔
82
    type = TSDB_MGMT_TABLE_FUNC;
3✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
8,534✔
84
    type = TSDB_MGMT_TABLE_INDEX;
3✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
8,531✔
86
    type = TSDB_MGMT_TABLE_STB;
175✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
8,356!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
8,356!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
8,356✔
92
    type = TSDB_MGMT_TABLE_COL;
6,824✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
1,532!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
1,532✔
96
    type = TSDB_MGMT_TABLE_USER;
1✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
1,531!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
1,531!
100
    type = TSDB_MGMT_TABLE_GRANTS;
×
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
1,531✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
330✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
1,201✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
80✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
1,121✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
103✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
1,018✔
108
    type = TSDB_MGMT_TABLE_TRANS;
198✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
820!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
820!
112
    type = TSDB_MGMT_TABLE_CONFIGS;
×
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
820!
114
    type = TSDB_MGMT_TABLE_CONNS;
×
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
820!
116
    type = TSDB_MGMT_TABLE_QUERIES;
×
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
820✔
118
    type = TSDB_MGMT_TABLE_VNODES;
92✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
728✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
24✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
704✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
120✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
584!
124
    type = TSDB_MGMT_TABLE_APPS;
×
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
584✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
498✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
86!
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
×
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
86✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
5✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
81✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
75✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
6!
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
×
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_TRANSACTION_DETAILS, len) == 0) {
6!
136
    type = TSDB_MGMT_TABLE_TRANSACTION_DETAIL;
×
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
6!
138
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
×
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
6!
140
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
×
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
6!
142
    type = TSDB_MGMT_TABLE_MACHINES;
×
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
6!
144
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
×
145
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
6!
146
    type = TSDB_MGMT_TABLE_TSMAS;
6✔
147
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
×
148
    type = TSDB_MGMT_TABLE_USAGE;
×
149
  } else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
×
150
    type = TSDB_MGMT_TABLE_FILESETS;
×
151
  } else {
152
    mError("invalid show name:%s len:%d", name, len);
×
153
  }
154

155
  return type;
9,326✔
156
}
157

158
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
9,326✔
159
  SShowMgmt *pMgmt = &pMnode->showMgmt;
9,326✔
160

161
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
9,326✔
162
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
9,326!
163

164
  int32_t size = sizeof(SShowObj);
9,326✔
165

166
  SShowObj showObj = {0};
9,326✔
167

168
  showObj.id = showId;
9,326✔
169
  showObj.pMnode = pMnode;
9,326✔
170
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
9,326✔
171
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
9,326✔
172
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
9,326✔
173

174
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
9,326✔
175
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
9,326✔
176
  if (pShow == NULL) {
9,326!
177
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
178
    mError("show:0x%" PRIx64 ", failed to put into cache since %s", showId, terrstr());
×
179
    return NULL;
×
180
  }
181

182
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
9,326✔
183
  return pShow;
9,326✔
184
}
185

186
static void mndFreeShowObj(SShowObj *pShow) {
9,326✔
187
  SMnode    *pMnode = pShow->pMnode;
9,326✔
188
  SShowMgmt *pMgmt = &pMnode->showMgmt;
9,326✔
189

190
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
9,326✔
191
  if (freeFp != NULL) {
9,326✔
192
    if (pShow->pIter != NULL) {
9,148!
193
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
×
194

195
      (*freeFp)(pMnode, pShow->pIter);
×
196

197
      pShow->pIter = NULL;
×
198
    }
199
  }
200

201
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
9,326✔
202
}
9,326✔
203

204
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
3✔
205
  SShowMgmt *pMgmt = &pMnode->showMgmt;
3✔
206

207
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
3✔
208
  if (pShow == NULL) {
3!
209
    mError("show:0x%" PRIx64 ", already destroyed", showId);
×
210
    return NULL;
×
211
  }
212

213
  mTrace("show:0x%" PRIx64 ", acquired from cache, data:%p", pShow->id, pShow);
3!
214
  return pShow;
3✔
215
}
216

217
static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
9,329✔
218
  if (pShow == NULL) return;
9,329!
219
  mTrace("show:0x%" PRIx64 ", released from cache, data:%p force:%d", pShow->id, pShow, forceRemove);
9,329✔
220

221
  // A bug in tcache.c
222
  forceRemove = 0;
9,329✔
223

224
  SMnode    *pMnode = pShow->pMnode;
9,329✔
225
  SShowMgmt *pMgmt = &pMnode->showMgmt;
9,329✔
226
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
9,329✔
227
}
228

229
static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
9,328✔
230
  int32_t    code = 0;
9,328✔
231
  SMnode    *pMnode = pReq->info.node;
9,328✔
232
  SShowMgmt *pMgmt = &pMnode->showMgmt;
9,328✔
233
  SShowObj  *pShow = NULL;
9,328✔
234
  int32_t    rowsToRead = SHOW_STEP_SIZE;
9,328✔
235
  int32_t    size = 0;
9,328✔
236
  int32_t    rowsRead = 0;
9,328✔
237
  mDebug("mndProcessRetrieveSysTableReq start");
9,328!
238
  SRetrieveTableReq retrieveReq = {0};
9,329✔
239
  TAOS_CHECK_RETURN(tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq));
9,329!
240

241
  mDebug("process to retrieve systable req db:%s, tb:%s, compactId:%" PRId64, retrieveReq.db, retrieveReq.tb,
9,329!
242
         retrieveReq.compactId);
243

244
  if (retrieveReq.showId == 0) {
9,329✔
245
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
9,326✔
246
    if (pMeta == NULL) {
9,326✔
247
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
278✔
248
      if (pMeta == NULL) {
278!
249
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
250
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
251
        TAOS_RETURN(code);
×
252
      }
253
    }
254

255
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
9,326✔
256
    if (pShow == NULL) {
9,326!
257
      code = terrno;
×
258
      mError("failed to process show-meta req since %s", tstrerror(code));
×
259
      TAOS_RETURN(code);
×
260
    }
261

262
    pShow->pMeta = pMeta;
9,326✔
263
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
9,326✔
264
  } else {
265
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
3✔
266
    if (pShow == NULL) {
3!
267
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
×
268
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
269
      TAOS_RETURN(code);
×
270
    }
271
  }
272

273
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
9,329✔
274
    rowsToRead = SHOW_COLS_STEP_SIZE;
6,824✔
275
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
2,505!
276
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
×
277
  }
278
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
9,329✔
279
  if (retrieveFp == NULL) {
9,329!
280
    mndReleaseShowObj(pShow, false);
×
281
    code = TSDB_CODE_MSG_NOT_PROCESSED;
×
282
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
283
    TAOS_RETURN(code);
×
284
  }
285

286
  mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
9,329!
287
  if (retrieveReq.user[0] != 0) {
9,329!
288
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
9,329✔
289
  } else {
290
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
×
291
  }
292
  code = -1;
9,329✔
293
  if (retrieveReq.db[0] &&
10,440!
294
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
1,111✔
295
    TAOS_RETURN(code);
×
296
  }
297
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
9,329!
298
    if (strcmp(pReq->info.conn.user, "root") != 0) {
×
299
      mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
×
300
      code = TSDB_CODE_MND_NO_RIGHTS;
×
301
      TAOS_RETURN(code);
×
302
    }
303
  }
304

305
  int32_t numOfCols = pShow->pMeta->numOfColumns;
9,329✔
306

307
  SSDataBlock *pBlock = NULL;
9,329✔
308
  code = createDataBlock(&pBlock);
9,329✔
309
  if (code) {
9,329!
310
    TAOS_RETURN(code);
×
311
  }
312

313
  for (int32_t i = 0; i < numOfCols; ++i) {
110,500✔
314
    SColumnInfoData idata = {0};
101,170✔
315

316
    SSchema *p = &pShow->pMeta->pSchemas[i];
101,170✔
317

318
    idata.info.bytes = p->bytes;
101,170✔
319
    idata.info.type = p->type;
101,170✔
320
    idata.info.colId = p->colId;
101,170✔
321
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
101,170!
322
  }
323

324
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
9,330!
325

326
  if (mndCheckRetrieveFinished(pShow)) {
9,329!
327
    mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows);
×
328
    rowsRead = 0;
×
329
  } else {
330
    rowsRead = (*retrieveFp)(pReq, pShow, pBlock, rowsToRead);
9,329✔
331
    if (rowsRead < 0) {
9,329✔
332
      code = rowsRead;
10✔
333
      mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
10!
334
      mndReleaseShowObj(pShow, true);
10✔
335
      blockDataDestroy(pBlock);
10✔
336
      TAOS_RETURN(code);
10✔
337
    }
338

339
    pBlock->info.rows = rowsRead;
9,319✔
340
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
9,319!
341
  }
342

343
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
9,319✔
344
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
9,319✔
345
         dataEncodeBufSize;
346

347
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
9,319✔
348
  if (pRsp == NULL) {
9,319!
349
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
350
    code = terrno;
×
351
    goto _exit;
×
352
  }
353

354
  pRsp->handle = htobe64(pShow->id);
9,319✔
355

356
  if (rowsRead > 0) {
9,319✔
357
    char    *pStart = pRsp->data;
9,172✔
358
    SSchema *ps = pShow->pMeta->pSchemas;
9,172✔
359

360
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
9,172✔
361
    pStart += sizeof(int32_t);  // number of columns
9,172✔
362

363
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
108,587✔
364
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
99,415✔
365
      pSchema->bytes = htonl(ps[i].bytes);
99,415✔
366
      pSchema->colId = htons(ps[i].colId);
99,415✔
367
      pSchema->type = ps[i].type;
99,415✔
368

369
      pStart += sizeof(SSysTableSchema);
99,415✔
370
    }
371

372
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
9,172✔
373
    if (len < 0) {
9,172!
374
      mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
375
      code = terrno;
×
376
      return code;
×
377
    }
378
  }
379

380
  pRsp->numOfRows = htonl(rowsRead);
9,319✔
381
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
9,319✔
382
  pReq->info.rsp = pRsp;
9,319✔
383
  pReq->info.rspLen = size;
9,319✔
384

385
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
9,319✔
386
    pRsp->completed = 1;
9,316✔
387
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
9,316!
388
    mndReleaseShowObj(pShow, true);
9,316✔
389
  } else {
390
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
3!
391
    mndReleaseShowObj(pShow, false);
3✔
392
  }
393

394
  blockDataDestroy(pBlock);
9,319✔
395
  return TSDB_CODE_SUCCESS;
9,319✔
396
_exit:
×
397
  mndReleaseShowObj(pShow, false);
×
398
  blockDataDestroy(pBlock);
×
399
  if (pRsp) {
×
400
    rpcFreeCont(pRsp);
×
401
  }
402
  return code;
×
403
}
404

405
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
18,501✔
406
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
18,501✔
407
    return true;
9,169✔
408
  }
409
  return false;
9,332✔
410
}
411

412
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
41,078✔
413
  SShowMgmt *pMgmt = &pMnode->showMgmt;
41,078✔
414
  pMgmt->retrieveFps[showType] = fp;
41,078✔
415
}
41,078✔
416

417
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType showType, ShowFreeIterFp fp) {
37,835✔
418
  SShowMgmt *pMgmt = &pMnode->showMgmt;
37,835✔
419
  pMgmt->freeIterFps[showType] = fp;
37,835✔
420
}
37,835✔
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