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

taosdata / TDengine / #3558

17 Dec 2024 06:05AM UTC coverage: 59.778% (+1.6%) from 58.204%
#3558

push

travis-ci

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

merge: form main to 3.0 branch

132787 of 287595 branches covered (46.17%)

Branch coverage included in aggregate %.

104 of 191 new or added lines in 5 files covered. (54.45%)

6085 existing lines in 168 files now uncovered.

209348 of 284746 relevant lines covered (73.52%)

8164844.48 hits per line

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

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

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

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
211,350✔
60
    type = TSDB_MGMT_TABLE_DNODE;
7,152✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
204,198✔
62
    type = TSDB_MGMT_TABLE_MNODE;
4,409✔
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) {
199,789✔
68
    type = TSDB_MGMT_TABLE_QNODE;
2,184✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
197,605✔
70
    type = TSDB_MGMT_TABLE_SNODE;
2,171✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
195,434!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
195,434!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
195,434!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
195,434✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
4,303✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
191,131✔
80
    type = TSDB_MGMT_TABLE_DB;
25,336✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
165,795✔
82
    type = TSDB_MGMT_TABLE_FUNC;
7,180✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
158,615✔
84
    type = TSDB_MGMT_TABLE_INDEX;
5,055✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
153,560✔
86
    type = TSDB_MGMT_TABLE_STB;
8,347✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
145,213!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
145,213!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
145,213✔
92
    type = TSDB_MGMT_TABLE_COL;
13,292✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
131,921!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
132,397✔
96
    type = TSDB_MGMT_TABLE_USER;
5,072✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
127,325!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
127,325✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
5,727✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
121,598✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
10,563✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
111,035✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
7,951✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
103,084✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
5,818✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
97,266✔
108
    type = TSDB_MGMT_TABLE_TRANS;
6,742✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
90,524!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
90,524✔
112
    type = TSDB_MGMT_TABLE_CONFIGS;
1,444✔
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
89,080✔
114
    type = TSDB_MGMT_TABLE_CONNS;
6,497✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
82,583✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
11,469✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
71,114✔
118
    type = TSDB_MGMT_TABLE_VNODES;
5,174✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
65,940✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
5,058✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
60,882✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
11,226✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
49,656✔
124
    type = TSDB_MGMT_TABLE_APPS;
10,783✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
38,873✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
19,624✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
19,249✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
4,323✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
14,926✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
6,466✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
8,460✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
2,229✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
6,231✔
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
5,742✔
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
489✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
6✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
483✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
6✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
477✔
140
    type = TSDB_MGMT_TABLE_MACHINES;
6✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
471!
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
×
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
471!
UNCOV
144
    type = TSDB_MGMT_TABLE_TSMAS;
×
145
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
471!
146
    type = TSDB_MGMT_TABLE_USAGE;
×
147
  } else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
471!
148
    type = TSDB_MGMT_TABLE_FILESETS;
×
149
  } else {
150
    mError("invalid show name:%s len:%d", name, len);
471!
151
  }
152

153
  return type;
211,383✔
154
}
155

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

159
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
211,418✔
160
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
212,126!
161

162
  int32_t size = sizeof(SShowObj);
212,126✔
163

164
  SShowObj showObj = {0};
212,126✔
165

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

172
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
211,403✔
173
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
211,403✔
174
  if (pShow == NULL) {
211,989!
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);
211,989✔
181
  return pShow;
211,947✔
182
}
183

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

188
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
212,134✔
189
  if (freeFp != NULL) {
212,134✔
190
    if (pShow->pIter != NULL) {
198,280!
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);
212,134✔
200
}
212,134✔
201

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

205
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
46✔
206
  if (pShow == NULL) {
46!
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);
46!
212
  return pShow;
46✔
213
}
214

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

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

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

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

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

241
  if (retrieveReq.showId == 0) {
211,674✔
242
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
211,628✔
243
    if (pMeta == NULL) {
212,046✔
244
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
43,639✔
245
      if (pMeta == NULL) {
43,645!
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);
212,052✔
253
    if (pShow == NULL) {
211,801✔
254
      code = terrno;
327✔
255
      mError("failed to process show-meta req since %s", tstrerror(code));
×
256
      TAOS_RETURN(code);
×
257
    }
258

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

270
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
211,511✔
271
    rowsToRead = SHOW_COLS_STEP_SIZE;
13,295✔
272
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
198,216✔
273
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
4,334✔
274
  }
275
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
211,511✔
276
  if (retrieveFp == NULL) {
211,511!
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);
211,511✔
284
  if (retrieveReq.user[0] != 0) {
211,521✔
285
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
211,499✔
286
  } else {
287
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
22✔
288
  }
289
  code = -1;
211,521✔
290
  if (retrieveReq.db[0] &&
214,153✔
291
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
2,632✔
292
    TAOS_RETURN(code);
4✔
293
  }
294
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
211,517!
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;
211,517✔
303

304
  SSDataBlock *pBlock = NULL;
211,517✔
305
  code = createDataBlock(&pBlock);
211,517✔
306
  if (code) {
211,988✔
307
    TAOS_RETURN(code);
343✔
308
  }
309

310
  for (int32_t i = 0; i < numOfCols; ++i) {
3,196,893✔
311
    SColumnInfoData idata = {0};
2,985,215✔
312

313
    SSchema *p = &pShow->pMeta->pSchemas[i];
2,985,215✔
314

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

321
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
211,678!
322

323
  if (mndCheckRetrieveFinished(pShow)) {
212,063!
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);
211,934✔
328
    if (rowsRead < 0) {
212,108✔
329
      code = rowsRead;
3✔
330
      mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
3!
331
      mndReleaseShowObj(pShow, true);
3✔
332
      blockDataDestroy(pBlock);
3✔
333
      TAOS_RETURN(code);
3✔
334
    }
335

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

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

344
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
211,982✔
345
  if (pRsp == NULL) {
211,872!
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);
211,872✔
352

353
  if (rowsRead > 0) {
211,788✔
354
    char    *pStart = pRsp->data;
165,902✔
355
    SSchema *ps = pShow->pMeta->pSchemas;
165,902✔
356

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

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

366
      pStart += sizeof(SSysTableSchema);
2,553,226✔
367
    }
368

369
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
165,902✔
370
    if (len < 0) {
166,002!
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);
211,888✔
378
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
211,888✔
379
  pReq->info.rsp = pRsp;
211,888✔
380
  pReq->info.rspLen = size;
211,888✔
381

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

391
  blockDataDestroy(pBlock);
211,797✔
392
  return TSDB_CODE_SUCCESS;
212,148✔
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) {
377,665✔
403
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
377,665!
404
    return true;
165,850✔
405
  }
406
  return false;
211,815✔
407
}
408

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

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