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

taosdata / TDengine / #3552

11 Dec 2024 06:08AM UTC coverage: 62.526% (+0.7%) from 61.798%
#3552

push

travis-ci

web-flow
Merge pull request #29092 from taosdata/fix/3.0/TD-33146

fix:[TD-33146] stmt_get_tag_fields return error code

124833 of 255773 branches covered (48.81%)

Branch coverage included in aggregate %.

209830 of 279467 relevant lines covered (75.08%)

19111707.6 hits per line

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

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

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

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
278,797✔
60
    type = TSDB_MGMT_TABLE_DNODE;
13,787✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
265,010✔
62
    type = TSDB_MGMT_TABLE_MNODE;
8,787✔
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) {
256,223✔
68
    type = TSDB_MGMT_TABLE_QNODE;
4,348✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
251,875✔
70
    type = TSDB_MGMT_TABLE_SNODE;
4,337✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
247,538!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
247,538!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
247,538!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
247,538✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
8,639✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
238,899✔
80
    type = TSDB_MGMT_TABLE_DB;
50,190✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
188,709✔
82
    type = TSDB_MGMT_TABLE_FUNC;
14,470✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
174,239✔
84
    type = TSDB_MGMT_TABLE_INDEX;
11,811✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
162,428✔
86
    type = TSDB_MGMT_TABLE_STB;
16,922✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
145,506!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
145,506!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
145,506✔
92
    type = TSDB_MGMT_TABLE_COL;
13,311✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
132,195!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
132,242✔
96
    type = TSDB_MGMT_TABLE_USER;
5,076✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
127,166!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
127,166✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
5,765✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
121,401✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
10,963✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
110,438✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
7,993✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
102,445✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
5,829✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
96,616✔
108
    type = TSDB_MGMT_TABLE_TRANS;
7,649✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
88,967!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
88,967✔
112
    type = TSDB_MGMT_TABLE_CONFIGS;
1,445✔
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
87,522✔
114
    type = TSDB_MGMT_TABLE_CONNS;
6,493✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
81,029✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
11,507✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
69,522✔
118
    type = TSDB_MGMT_TABLE_VNODES;
5,161✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
64,361✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
5,071✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
59,290✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
11,234✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
48,056✔
124
    type = TSDB_MGMT_TABLE_APPS;
10,792✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
37,264✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
19,629✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
17,635✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
4,346✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
13,289✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
6,523✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
6,766✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
2,296✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
4,470✔
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
4,309✔
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
161✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
7✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
154✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
7✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
147✔
140
    type = TSDB_MGMT_TABLE_MACHINES;
7✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
140✔
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
4✔
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
136✔
144
    type = TSDB_MGMT_TABLE_TSMAS;
6✔
145
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
130!
146
    type = TSDB_MGMT_TABLE_USAGE;
×
147
  } else {
148
    mError("invalid show name:%s len:%d", name, len);
130!
149
  }
150

151
  return type;
278,748✔
152
}
153

154
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
278,770✔
155
  SShowMgmt *pMgmt = &pMnode->showMgmt;
278,770✔
156

157
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
278,770✔
158
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
278,970!
159

160
  int32_t size = sizeof(SShowObj);
278,970✔
161

162
  SShowObj showObj = {0};
278,970✔
163

164
  showObj.id = showId;
278,970✔
165
  showObj.pMnode = pMnode;
278,970✔
166
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
278,970✔
167
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
278,799✔
168
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
278,799✔
169

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

178
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
279,145✔
179
  return pShow;
279,131✔
180
}
181

182
static void mndFreeShowObj(SShowObj *pShow) {
279,282✔
183
  SMnode    *pMnode = pShow->pMnode;
279,282✔
184
  SShowMgmt *pMgmt = &pMnode->showMgmt;
279,282✔
185

186
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
279,282✔
187
  if (freeFp != NULL) {
279,282✔
188
    if (pShow->pIter != NULL) {
266,818✔
189
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
1!
190

191
      (*freeFp)(pMnode, pShow->pIter);
1✔
192

193
      pShow->pIter = NULL;
1✔
194
    }
195
  }
196

197
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
279,282✔
198
}
279,282✔
199

200
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
4,819✔
201
  SShowMgmt *pMgmt = &pMnode->showMgmt;
4,819✔
202

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

209
  mTrace("show:0x%" PRIx64 ", acquired from cache, data:%p", pShow->id, pShow);
4,822!
210
  return pShow;
4,822✔
211
}
212

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

217
  // A bug in tcache.c
218
  forceRemove = 0;
283,592✔
219

220
  SMnode    *pMnode = pShow->pMnode;
283,592✔
221
  SShowMgmt *pMgmt = &pMnode->showMgmt;
283,592✔
222
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
283,592✔
223
}
224

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

237
  mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb);
283,790✔
238

239
  if (retrieveReq.showId == 0) {
283,766✔
240
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
278,947✔
241
    if (pMeta == NULL) {
279,039✔
242
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
44,515✔
243
      if (pMeta == NULL) {
44,516!
244
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
245
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
246
        TAOS_RETURN(code);
×
247
      }
248
    }
249

250
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
279,040✔
251
    if (pShow == NULL) {
278,952!
252
      code = terrno;
×
253
      mError("failed to process show-meta req since %s", tstrerror(code));
×
254
      TAOS_RETURN(code);
×
255
    }
256

257
    pShow->pMeta = pMeta;
278,984✔
258
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
278,984✔
259
  } else {
260
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
4,819✔
261
    if (pShow == NULL) {
4,821✔
262
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
120✔
263
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
120!
264
      TAOS_RETURN(code);
120✔
265
    }
266
  }
267

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

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

300
  int32_t numOfCols = pShow->pMeta->numOfColumns;
283,594✔
301

302
  SSDataBlock *pBlock = NULL;
283,594✔
303
  code = createDataBlock(&pBlock);
283,594✔
304
  if (code) {
283,759!
305
    TAOS_RETURN(code);
×
306
  }
307

308
  for (int32_t i = 0; i < numOfCols; ++i) {
4,488,520✔
309
    SColumnInfoData idata = {0};
4,203,923✔
310

311
    SSchema *p = &pShow->pMeta->pSchemas[i];
4,203,923✔
312

313
    idata.info.bytes = p->bytes;
4,203,923✔
314
    idata.info.type = p->type;
4,203,923✔
315
    idata.info.colId = p->colId;
4,203,923✔
316
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
4,203,923!
317
  }
318

319
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
284,597!
320

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

334
    pBlock->info.rows = rowsRead;
283,999✔
335
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
283,999✔
336
  }
337

338
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
283,999✔
339
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
283,903✔
340
         dataEncodeBufSize;
341

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

349
  pRsp->handle = htobe64(pShow->id);
283,844✔
350

351
  if (rowsRead > 0) {
283,806✔
352
    char    *pStart = pRsp->data;
230,581✔
353
    SSchema *ps = pShow->pMeta->pSchemas;
230,581✔
354

355
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
230,581✔
356
    pStart += sizeof(int32_t);  // number of columns
230,581✔
357

358
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
3,987,274✔
359
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
3,756,693✔
360
      pSchema->bytes = htonl(ps[i].bytes);
3,756,693✔
361
      pSchema->colId = htons(ps[i].colId);
3,756,693✔
362
      pSchema->type = ps[i].type;
3,756,693✔
363

364
      pStart += sizeof(SSysTableSchema);
3,756,693✔
365
    }
366

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

375
  pRsp->numOfRows = htonl(rowsRead);
284,009✔
376
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
284,009✔
377
  pReq->info.rsp = pRsp;
284,009✔
378
  pReq->info.rspLen = size;
284,009✔
379

380
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
284,009✔
381
    pRsp->completed = 1;
279,273✔
382
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
279,273✔
383
    mndReleaseShowObj(pShow, true);
279,273✔
384
  } else {
385
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
4,818✔
386
    mndReleaseShowObj(pShow, false);
4,818✔
387
  }
388

389
  blockDataDestroy(pBlock);
283,815✔
390
  return TSDB_CODE_SUCCESS;
283,989✔
391
_exit:
×
392
  mndReleaseShowObj(pShow, false);
×
393
  blockDataDestroy(pBlock);
×
394
  if (pRsp) {
×
395
    rpcFreeCont(pRsp);
×
396
  }
397
  return code;
×
398
}
399

400
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
514,280✔
401
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
514,280✔
402
    return true;
225,762✔
403
  }
404
  return false;
288,518✔
405
}
406

407
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
75,147✔
408
  SShowMgmt *pMgmt = &pMnode->showMgmt;
75,147✔
409
  pMgmt->retrieveFps[showType] = fp;
75,147✔
410
}
75,147✔
411

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