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

taosdata / TDengine / #3533

20 Nov 2024 07:11AM UTC coverage: 58.848% (-1.9%) from 60.78%
#3533

push

travis-ci

web-flow
Merge pull request #28823 from taosdata/fix/3.0/TD-32587

fix:[TD-32587]fix stmt segmentation fault

115578 of 252434 branches covered (45.79%)

Branch coverage included in aggregate %.

1 of 4 new or added lines in 1 file covered. (25.0%)

8038 existing lines in 233 files now uncovered.

194926 of 275199 relevant lines covered (70.83%)

1494459.59 hits per line

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

76.24
/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 "systable.h"
20
#include "mndUser.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,309✔
34
  int32_t    code = 0;
1,309✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,309✔
36

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

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
11,062✔
60
    type = TSDB_MGMT_TABLE_DNODE;
505✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
10,557✔
62
    type = TSDB_MGMT_TABLE_MNODE;
86✔
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) {
10,471✔
68
    type = TSDB_MGMT_TABLE_QNODE;
14✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
10,457✔
70
    type = TSDB_MGMT_TABLE_SNODE;
10✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
10,447!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
10,447!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
10,447!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
10,447✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
3✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
10,444✔
80
    type = TSDB_MGMT_TABLE_DB;
556✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
9,888✔
82
    type = TSDB_MGMT_TABLE_FUNC;
78✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
9,810✔
84
    type = TSDB_MGMT_TABLE_INDEX;
26✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
9,784✔
86
    type = TSDB_MGMT_TABLE_STB;
410✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
9,374!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
9,374!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
9,374✔
92
    type = TSDB_MGMT_TABLE_COL;
6,461✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
2,913!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
2,913✔
96
    type = TSDB_MGMT_TABLE_USER;
30✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
2,883!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
2,883✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
10✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
2,873✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
643✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
2,230✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
49✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
2,181✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
34✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
2,147✔
108
    type = TSDB_MGMT_TABLE_TRANS;
22✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
2,125!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
2,125!
UNCOV
112
    type = TSDB_MGMT_TABLE_CONFIGS;
×
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
2,125✔
114
    type = TSDB_MGMT_TABLE_CONNS;
22✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
2,103✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
1✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
2,102✔
118
    type = TSDB_MGMT_TABLE_VNODES;
18✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
2,084✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
28✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
2,056✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
134✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
1,922✔
124
    type = TSDB_MGMT_TABLE_APPS;
2✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
1,920✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
1,768✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
152✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
39✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
113✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
49✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
64✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
54✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
10!
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
×
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
10✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
1✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
9✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
1✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
8✔
140
    type = TSDB_MGMT_TABLE_MACHINES;
1✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
7✔
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
4✔
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
3!
144
    type = TSDB_MGMT_TABLE_TSMAS;
3✔
145
  } else {
146
    mError("invalid show name:%s len:%d", name, len);
×
147
  }
148

149
  return type;
11,062✔
150
}
151

152
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
11,062✔
153
  SShowMgmt *pMgmt = &pMnode->showMgmt;
11,062✔
154

155
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
11,062✔
156
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
11,062!
157

158
  int32_t size = sizeof(SShowObj);
11,062✔
159

160
  SShowObj showObj = {0};
11,062✔
161

162
  showObj.id = showId;
11,062✔
163
  showObj.pMnode = pMnode;
11,062✔
164
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
11,062✔
165
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
11,062✔
166
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
11,062✔
167

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

176
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
11,062✔
177
  return pShow;
11,062✔
178
}
179

180
static void mndFreeShowObj(SShowObj *pShow) {
11,062✔
181
  SMnode    *pMnode = pShow->pMnode;
11,062✔
182
  SShowMgmt *pMgmt = &pMnode->showMgmt;
11,062✔
183

184
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
11,062✔
185
  if (freeFp != NULL) {
11,062✔
186
    if (pShow->pIter != NULL) {
10,974✔
187
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
1!
188

189
      (*freeFp)(pMnode, pShow->pIter);
1✔
190

191
      pShow->pIter = NULL;
1✔
192
    }
193
  }
194

195
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
11,062✔
196
}
11,062✔
197

198
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
72✔
199
  SShowMgmt *pMgmt = &pMnode->showMgmt;
72✔
200

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

207
  mTrace("show:0x%" PRIx64 ", acquired from cache, data:%p", pShow->id, pShow);
72!
208
  return pShow;
72✔
209
}
210

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

215
  // A bug in tcache.c
216
  forceRemove = 0;
11,134✔
217

218
  SMnode    *pMnode = pShow->pMnode;
11,134✔
219
  SShowMgmt *pMgmt = &pMnode->showMgmt;
11,134✔
220
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
11,134✔
221
}
222

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

235
  mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb);
11,134✔
236

237
  if (retrieveReq.showId == 0) {
11,134✔
238
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
11,062✔
239
    if (pMeta == NULL) {
11,062✔
240
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
96✔
241
      if (pMeta == NULL) {
96!
242
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
243
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
244
        TAOS_RETURN(code);
×
245
      }
246
    }
247

248
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
11,062✔
249
    if (pShow == NULL) {
11,062!
250
      code = terrno;
×
251
      mError("failed to process show-meta req since %s", tstrerror(code));
×
252
      TAOS_RETURN(code);
×
253
    }
254

255
    pShow->pMeta = pMeta;
11,062✔
256
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
11,062✔
257
  } else {
258
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
72✔
259
    if (pShow == NULL) {
72!
260
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
×
261
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
262
      TAOS_RETURN(code);
×
263
    }
264
  }
265

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

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

298
  int32_t numOfCols = pShow->pMeta->numOfColumns;
11,134✔
299

300
  SSDataBlock *pBlock = NULL;
11,134✔
301
  code = createDataBlock(&pBlock);
11,134✔
302
  if (code) {
11,134!
303
    TAOS_RETURN(code);
×
304
  }
305

306
  for (int32_t i = 0; i < numOfCols; ++i) {
156,216✔
307
    SColumnInfoData idata = {0};
145,082✔
308

309
    SSchema *p = &pShow->pMeta->pSchemas[i];
145,082✔
310

311
    idata.info.bytes = p->bytes;
145,082✔
312
    idata.info.type = p->type;
145,082✔
313
    idata.info.colId = p->colId;
145,082✔
314
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
145,082!
315
  }
316

317
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
11,134!
318

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

332
    pBlock->info.rows = rowsRead;
11,130✔
333
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
11,130✔
334
  }
335

336
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
11,130✔
337
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns + dataEncodeBufSize;
11,130✔
338

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

346
  pRsp->handle = htobe64(pShow->id);
11,130✔
347

348
  if (rowsRead > 0) {
11,130✔
349
    char    *pStart = pRsp->data;
10,932✔
350
    SSchema *ps = pShow->pMeta->pSchemas;
10,932✔
351

352
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
10,932✔
353
    pStart += sizeof(int32_t);  // number of columns
10,932✔
354

355
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
153,668✔
356
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
142,736✔
357
      pSchema->bytes = htonl(ps[i].bytes);
142,736✔
358
      pSchema->colId = htons(ps[i].colId);
142,736✔
359
      pSchema->type = ps[i].type;
142,736✔
360

361
      pStart += sizeof(SSysTableSchema);
142,736✔
362
    }
363

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

372
  pRsp->numOfRows = htonl(rowsRead);
11,130✔
373
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
11,130✔
374
  pReq->info.rsp = pRsp;
11,130✔
375
  pReq->info.rspLen = size;
11,130✔
376

377
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
11,130✔
378
    pRsp->completed = 1;
11,057✔
379
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
11,057✔
380
    mndReleaseShowObj(pShow, true);
11,057✔
381
  } else {
382
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
73!
383
    mndReleaseShowObj(pShow, false);
73✔
384
  }
385

386
  blockDataDestroy(pBlock);
11,130✔
387
  return TSDB_CODE_SUCCESS;
11,130✔
388
_exit:
×
389
  mndReleaseShowObj(pShow, false);
×
390
  blockDataDestroy(pBlock);
×
391
  if(pRsp) {
×
392
    rpcFreeCont(pRsp);
×
393
  }
394
  return code;
×
395
}
396

397
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
22,066✔
398
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
22,066✔
399
    return true;
10,859✔
400
  }
401
  return false;
11,207✔
402
}
403

404
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
48,433✔
405
  SShowMgmt *pMgmt = &pMnode->showMgmt;
48,433✔
406
  pMgmt->retrieveFps[showType] = fp;
48,433✔
407
}
48,433✔
408

409
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType showType, ShowFreeIterFp fp) {
45,815✔
410
  SShowMgmt *pMgmt = &pMnode->showMgmt;
45,815✔
411
  pMgmt->freeIterFps[showType] = fp;
45,815✔
412
}
45,815✔
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