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

taosdata / TDengine / #3561

19 Dec 2024 03:15AM UTC coverage: 58.812% (-1.3%) from 60.124%
#3561

push

travis-ci

web-flow
Merge pull request #29213 from taosdata/merge/mainto3.0

merge: from main to 3.0 branch

130770 of 287658 branches covered (45.46%)

Branch coverage included in aggregate %.

32 of 78 new or added lines in 4 files covered. (41.03%)

7347 existing lines in 166 files now uncovered.

205356 of 283866 relevant lines covered (72.34%)

7187865.64 hits per line

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

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

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

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
12,983✔
60
    type = TSDB_MGMT_TABLE_DNODE;
533✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
12,450✔
62
    type = TSDB_MGMT_TABLE_MNODE;
68✔
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) {
12,382✔
68
    type = TSDB_MGMT_TABLE_QNODE;
25✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
12,357✔
70
    type = TSDB_MGMT_TABLE_SNODE;
21✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
12,336!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
12,336!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
12,336!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
12,336✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
7✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
12,329✔
80
    type = TSDB_MGMT_TABLE_DB;
868✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
11,461✔
82
    type = TSDB_MGMT_TABLE_FUNC;
30✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
11,431✔
84
    type = TSDB_MGMT_TABLE_INDEX;
34✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
11,397✔
86
    type = TSDB_MGMT_TABLE_STB;
381✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
11,016!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
11,016!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
11,016✔
92
    type = TSDB_MGMT_TABLE_COL;
6,824✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
4,192!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
4,192✔
96
    type = TSDB_MGMT_TABLE_USER;
32✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
4,160!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
4,160✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
11✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
4,149✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
390✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
3,759✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
75✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
3,684✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
79✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
3,605✔
108
    type = TSDB_MGMT_TABLE_TRANS;
146✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
3,459!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
3,459✔
112
    type = TSDB_MGMT_TABLE_CONFIGS;
7✔
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
3,452✔
114
    type = TSDB_MGMT_TABLE_CONNS;
32✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
3,420✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
15✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
3,405✔
118
    type = TSDB_MGMT_TABLE_VNODES;
133✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
3,272✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
36✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
3,236✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
463✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
2,773✔
124
    type = TSDB_MGMT_TABLE_APPS;
14✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
2,759✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
2,686✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
73✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
19✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
54✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
36✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
18!
UNCOV
132
    type = TSDB_MGMT_TABLE_COMPACT;
×
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
18!
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
×
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
18✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
6✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
12✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
6✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
6!
140
    type = TSDB_MGMT_TABLE_MACHINES;
6✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
×
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
×
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
×
144
    type = TSDB_MGMT_TABLE_TSMAS;
×
145
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
×
146
    type = TSDB_MGMT_TABLE_USAGE;
×
147
  } else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
×
148
    type = TSDB_MGMT_TABLE_FILESETS;
×
149
  } else {
150
    mError("invalid show name:%s len:%d", name, len);
×
151
  }
152

153
  return type;
12,983✔
154
}
155

156
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
12,983✔
157
  SShowMgmt *pMgmt = &pMnode->showMgmt;
12,983✔
158

159
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
12,983✔
160
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
12,983!
161

162
  int32_t size = sizeof(SShowObj);
12,983✔
163

164
  SShowObj showObj = {0};
12,983✔
165

166
  showObj.id = showId;
12,983✔
167
  showObj.pMnode = pMnode;
12,983✔
168
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
12,983✔
169
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
12,983✔
170
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
12,983✔
171

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

180
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
12,983✔
181
  return pShow;
12,983✔
182
}
183

184
static void mndFreeShowObj(SShowObj *pShow) {
12,983✔
185
  SMnode    *pMnode = pShow->pMnode;
12,983✔
186
  SShowMgmt *pMgmt = &pMnode->showMgmt;
12,983✔
187

188
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
12,983✔
189
  if (freeFp != NULL) {
12,983✔
190
    if (pShow->pIter != NULL) {
12,904!
191
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
×
192

193
      (*freeFp)(pMnode, pShow->pIter);
×
194

195
      pShow->pIter = NULL;
×
196
    }
197
  }
198

199
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
12,983✔
200
}
12,983✔
201

202
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
42✔
203
  SShowMgmt *pMgmt = &pMnode->showMgmt;
42✔
204

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

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

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

219
  // A bug in tcache.c
220
  forceRemove = 0;
13,021✔
221

222
  SMnode    *pMnode = pShow->pMnode;
13,021✔
223
  SShowMgmt *pMgmt = &pMnode->showMgmt;
13,021✔
224
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
13,021✔
225
}
226

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

239
  mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb);
13,025✔
240

241
  if (retrieveReq.showId == 0) {
13,025✔
242
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
12,983✔
243
    if (pMeta == NULL) {
12,983✔
244
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
282✔
245
      if (pMeta == NULL) {
282!
246
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
247
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
248
        TAOS_RETURN(code);
×
249
      }
250
    }
251

252
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
12,983✔
253
    if (pShow == NULL) {
12,983!
254
      code = terrno;
×
255
      mError("failed to process show-meta req since %s", tstrerror(code));
×
256
      TAOS_RETURN(code);
×
257
    }
258

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

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

283
  mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
13,025✔
284
  if (retrieveReq.user[0] != 0) {
13,025✔
285
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
13,003✔
286
  } else {
287
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
22✔
288
  }
289
  code = -1;
13,025✔
290
  if (retrieveReq.db[0] &&
15,233✔
291
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
2,208✔
292
    TAOS_RETURN(code);
4✔
293
  }
294
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
13,021!
295
    if (strcmp(pReq->info.conn.user, "root") != 0) {
×
296
      mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
×
297
      code = TSDB_CODE_MND_NO_RIGHTS;
×
298
      TAOS_RETURN(code);
×
299
    }
300
  }
301

302
  int32_t numOfCols = pShow->pMeta->numOfColumns;
13,021✔
303

304
  SSDataBlock *pBlock = NULL;
13,021✔
305
  code = createDataBlock(&pBlock);
13,021✔
306
  if (code) {
13,021!
307
    TAOS_RETURN(code);
×
308
  }
309

310
  for (int32_t i = 0; i < numOfCols; ++i) {
197,414✔
311
    SColumnInfoData idata = {0};
184,393✔
312

313
    SSchema *p = &pShow->pMeta->pSchemas[i];
184,393✔
314

315
    idata.info.bytes = p->bytes;
184,393✔
316
    idata.info.type = p->type;
184,393✔
317
    idata.info.colId = p->colId;
184,393✔
318
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
184,393!
319
  }
320

321
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
13,021!
322

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

336
    pBlock->info.rows = rowsRead;
13,020✔
337
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
13,020✔
338
  }
339

340
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
13,020✔
341
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
13,020✔
342
         dataEncodeBufSize;
343

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

351
  pRsp->handle = htobe64(pShow->id);
13,020✔
352

353
  if (rowsRead > 0) {
13,020✔
354
    char    *pStart = pRsp->data;
12,609✔
355
    SSchema *ps = pShow->pMeta->pSchemas;
12,609✔
356

357
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
12,609✔
358
    pStart += sizeof(int32_t);  // number of columns
12,609✔
359

360
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
192,447✔
361
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
179,838✔
362
      pSchema->bytes = htonl(ps[i].bytes);
179,838✔
363
      pSchema->colId = htons(ps[i].colId);
179,838✔
364
      pSchema->type = ps[i].type;
179,838✔
365

366
      pStart += sizeof(SSysTableSchema);
179,838✔
367
    }
368

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

377
  pRsp->numOfRows = htonl(rowsRead);
13,020✔
378
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
13,020✔
379
  pReq->info.rsp = pRsp;
13,020✔
380
  pReq->info.rspLen = size;
13,020✔
381

382
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
13,020✔
383
    pRsp->completed = 1;
12,978✔
384
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
12,978✔
385
    mndReleaseShowObj(pShow, true);
12,978✔
386
  } else {
387
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
42!
388
    mndReleaseShowObj(pShow, false);
42✔
389
  }
390

391
  blockDataDestroy(pBlock);
13,020✔
392
  return TSDB_CODE_SUCCESS;
13,020✔
393
_exit:
×
394
  mndReleaseShowObj(pShow, false);
×
395
  blockDataDestroy(pBlock);
×
396
  if (pRsp) {
×
397
    rpcFreeCont(pRsp);
×
398
  }
399
  return code;
×
400
}
401

402
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
25,630✔
403
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
25,630✔
404
    return true;
12,567✔
405
  }
406
  return false;
13,063✔
407
}
408

409
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
50,542✔
410
  SShowMgmt *pMgmt = &pMnode->showMgmt;
50,542✔
411
  pMgmt->retrieveFps[showType] = fp;
50,542✔
412
}
50,542✔
413

414
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType showType, ShowFreeIterFp fp) {
47,810✔
415
  SShowMgmt *pMgmt = &pMnode->showMgmt;
47,810✔
416
  pMgmt->freeIterFps[showType] = fp;
47,810✔
417
}
47,810✔
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