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

taosdata / TDengine / #3546

03 Dec 2024 10:02AM UTC coverage: 60.691% (-0.1%) from 60.839%
#3546

push

travis-ci

web-flow
Merge pull request #29015 from taosdata/fix/TS-5668

[TS-5668] fix(keeper): fix endpoint value too long for column/tag and eliminate warnings

120577 of 253823 branches covered (47.5%)

Branch coverage included in aggregate %.

201666 of 277134 relevant lines covered (72.77%)

18719900.08 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,014✔
34
  int32_t    code = 0;
2,014✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
2,014✔
36

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

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

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

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
211,944✔
60
    type = TSDB_MGMT_TABLE_DNODE;
7,300✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
204,644✔
62
    type = TSDB_MGMT_TABLE_MNODE;
4,482✔
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) {
200,162✔
68
    type = TSDB_MGMT_TABLE_QNODE;
2,190✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
197,972✔
70
    type = TSDB_MGMT_TABLE_SNODE;
2,188✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
195,784!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
195,784!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
195,784!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
195,784✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
4,323✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
191,461✔
80
    type = TSDB_MGMT_TABLE_DB;
25,754✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
165,707✔
82
    type = TSDB_MGMT_TABLE_FUNC;
7,284✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
158,423✔
84
    type = TSDB_MGMT_TABLE_INDEX;
6,735✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
151,688✔
86
    type = TSDB_MGMT_TABLE_STB;
8,963✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
142,725!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
142,725!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
142,725✔
92
    type = TSDB_MGMT_TABLE_COL;
13,331✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
129,394✔
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
129,353✔
96
    type = TSDB_MGMT_TABLE_USER;
5,073✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
124,280!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
124,280✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
5,762✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
118,518✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
10,979✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
107,539✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
7,994✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
99,545✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
5,850✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
93,695✔
108
    type = TSDB_MGMT_TABLE_TRANS;
7,605✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
86,090!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
86,090✔
112
    type = TSDB_MGMT_TABLE_CONFIGS;
1,445✔
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
84,645✔
114
    type = TSDB_MGMT_TABLE_CONNS;
5,052✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
79,593✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
10,076✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
69,517✔
118
    type = TSDB_MGMT_TABLE_VNODES;
5,185✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
64,332✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
5,072✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
59,260✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
11,244✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
48,016✔
124
    type = TSDB_MGMT_TABLE_APPS;
10,792✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
37,224✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
19,680✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
17,544✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
4,357✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
13,187✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
6,524✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
6,663✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
2,296✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
4,367✔
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
4,311✔
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
56✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
7✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
49✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
7✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
42✔
140
    type = TSDB_MGMT_TABLE_MACHINES;
7✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
35✔
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
4✔
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
31✔
144
    type = TSDB_MGMT_TABLE_TSMAS;
6✔
145
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
25!
146
    type = TSDB_MGMT_TABLE_USAGE;
×
147
  } else {
148
    mError("invalid show name:%s len:%d", name, len);
25!
149
  }
150

151
  return type;
211,904✔
152
}
153

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

157
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
211,872✔
158
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
212,179!
159

160
  int32_t size = sizeof(SShowObj);
212,179✔
161

162
  SShowObj showObj = {0};
212,179✔
163

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

170
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
211,927✔
171
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
211,927✔
172
  if (pShow == NULL) {
212,121!
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);
212,121✔
179
  return pShow;
212,096✔
180
}
181

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

186
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
212,234✔
187
  if (freeFp != NULL) {
212,234✔
188
    if (pShow->pIter != NULL) {
199,761✔
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);
212,234✔
198
}
212,234✔
199

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

203
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
7,315✔
204
  if (pShow == NULL) {
7,320!
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);
7,320!
210
  return pShow;
7,320✔
211
}
212

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

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

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

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

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

239
  if (retrieveReq.showId == 0) {
219,405✔
240
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
212,091✔
241
    if (pMeta == NULL) {
212,008✔
242
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
41,561✔
243
      if (pMeta == NULL) {
41,578!
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);
212,025✔
251
    if (pShow == NULL) {
212,053✔
252
      code = terrno;
11✔
253
      mError("failed to process show-meta req since %s", tstrerror(code));
×
254
      TAOS_RETURN(code);
×
255
    }
256

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

268
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
219,290✔
269
    rowsToRead = SHOW_COLS_STEP_SIZE;
13,356✔
270
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
205,934✔
271
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
4,363✔
272
  }
273
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
219,290✔
274
  if (retrieveFp == NULL) {
219,290!
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);
219,290✔
282
  if (retrieveReq.user[0] != 0) {
219,219!
283
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
219,219✔
284
  } else {
285
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
×
286
  }
287
  code = -1;
219,219✔
288
  if (retrieveReq.db[0] &&
223,796✔
289
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
4,577✔
290
    TAOS_RETURN(code);
6✔
291
  }
292
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
219,213!
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;
219,213✔
301

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

308
  for (int32_t i = 0; i < numOfCols; ++i) {
3,239,003✔
309
    SColumnInfoData idata = {0};
3,019,254✔
310

311
    SSchema *p = &pShow->pMeta->pSchemas[i];
3,019,254✔
312

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

319
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
219,749!
320

321
  if (mndCheckRetrieveFinished(pShow)) {
219,364!
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);
219,357✔
326
    if (rowsRead < 0) {
219,440✔
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;
219,435✔
335
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
219,435✔
336
  }
337

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

342
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
219,350✔
343
  if (pRsp == NULL) {
219,367!
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);
219,367✔
350

351
  if (rowsRead > 0) {
219,381✔
352
    char    *pStart = pRsp->data;
173,439✔
353
    SSchema *ps = pShow->pMeta->pSchemas;
173,439✔
354

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

358
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
2,816,457✔
359
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
2,643,018✔
360
      pSchema->bytes = htonl(ps[i].bytes);
2,643,018✔
361
      pSchema->colId = htons(ps[i].colId);
2,643,018✔
362
      pSchema->type = ps[i].type;
2,643,018✔
363

364
      pStart += sizeof(SSysTableSchema);
2,643,018✔
365
    }
366

367
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
173,439✔
368
    if (len < 0) {
173,564!
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);
219,506✔
376
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
219,506✔
377
  pReq->info.rsp = pRsp;
219,506✔
378
  pReq->info.rspLen = size;
219,506✔
379

380
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
219,506✔
381
    pRsp->completed = 1;
212,211✔
382
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
212,211✔
383
    mndReleaseShowObj(pShow, true);
212,211✔
384
  } else {
385
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
7,323✔
386
    mndReleaseShowObj(pShow, false);
7,323✔
387
  }
388

389
  blockDataDestroy(pBlock);
219,354✔
390
  return TSDB_CODE_SUCCESS;
219,469✔
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) {
392,771✔
401
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
392,771✔
402
    return true;
166,165✔
403
  }
404
  return false;
226,606✔
405
}
406

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

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

© 2025 Coveralls, Inc