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

taosdata / TDengine / #4513

17 Jul 2025 02:02AM UTC coverage: 31.359% (-31.1%) from 62.446%
#4513

push

travis-ci

web-flow
Merge pull request #31914 from taosdata/fix/3.0/compare-ans-failed

fix:Convert line endings from LF to CRLF for ans file

68541 of 301034 branches covered (22.77%)

Branch coverage included in aggregate %.

117356 of 291771 relevant lines covered (40.22%)

602262.98 hits per line

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

50.59
/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) {
15✔
34
  int32_t    code = 0;
15✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
15✔
36

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

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

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

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

163
  return type;
25✔
164
}
165

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

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

172
  int32_t size = sizeof(SShowObj);
25✔
173

174
  SShowObj showObj = {0};
25✔
175

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

182
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
25✔
183
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
25✔
184
  if (pShow == NULL) {
25!
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);
25✔
191
  return pShow;
25✔
192
}
193

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

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

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

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

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

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

215
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
×
216
  if (pShow == NULL) {
×
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);
×
222
  return pShow;
×
223
}
224

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

229
  // A bug in tcache.c
230
  forceRemove = 0;
25✔
231

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

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

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

252
  if (retrieveReq.showId == 0) {
25!
253
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
25✔
254
    if (pMeta == NULL) {
25✔
255
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
4✔
256
      if (pMeta == NULL) {
4!
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);
25✔
264
    if (pShow == NULL) {
25!
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;
25✔
271
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
25✔
272
  } else {
273
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
×
274
    if (pShow == NULL) {
×
275
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
×
276
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
277
      TAOS_RETURN(code);
×
278
    }
279
  }
280

281
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
25!
282
    rowsToRead = SHOW_COLS_STEP_SIZE;
×
283
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
25!
284
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
×
285
  }
286
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
25✔
287
  if (retrieveFp == NULL) {
25!
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);
25!
295
  if (retrieveReq.user[0] != 0) {
25✔
296
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
3✔
297
  } else {
298
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
22✔
299
  }
300
  code = -1;
25✔
301
  if (retrieveReq.db[0] &&
39!
302
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
14✔
303
    TAOS_RETURN(code);
×
304
  }
305
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
25!
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;
25✔
314

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

321
  for (int32_t i = 0; i < numOfCols; ++i) {
346✔
322
    SColumnInfoData idata = {0};
321✔
323

324
    SSchema *p = &pShow->pMeta->pSchemas[i];
321✔
325

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

332
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
25!
333

334
  if (mndCheckRetrieveFinished(pShow)) {
25!
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);
25✔
339
    if (rowsRead < 0) {
25!
340
      code = rowsRead;
×
341
      mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
×
342
      mndReleaseShowObj(pShow, true);
×
343
      blockDataDestroy(pBlock);
×
344
      TAOS_RETURN(code);
×
345
    }
346

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

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

355
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
25✔
356
  if (pRsp == NULL) {
25!
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);
25✔
363

364
  if (rowsRead > 0) {
25✔
365
    char    *pStart = pRsp->data;
20✔
366
    SSchema *ps = pShow->pMeta->pSchemas;
20✔
367

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

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

377
      pStart += sizeof(SSysTableSchema);
257✔
378
    }
379

380
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
20✔
381
    if (len < 0) {
20!
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);
25✔
389
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
25✔
390
  pReq->info.rsp = pRsp;
25✔
391
  pReq->info.rspLen = size;
25✔
392

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

402
  blockDataDestroy(pBlock);
25✔
403
  return TSDB_CODE_SUCCESS;
25✔
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) {
45✔
414
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
45!
415
    return true;
20✔
416
  }
417
  return false;
25✔
418
}
419

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

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