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

taosdata / TDengine / #4997

20 Mar 2026 06:10AM UTC coverage: 71.739% (-0.3%) from 72.069%
#4997

push

travis-ci

web-flow
feat: add query phase tracking for SHOW QUERIES (#34706)

148 of 183 new or added lines in 10 files covered. (80.87%)

9273 existing lines in 172 files now uncovered.

244572 of 340921 relevant lines covered (71.74%)

133392941.95 hits per line

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

67.41
/source/libs/qcom/src/querymsg.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
#include "query.h"
17
#include "queryInt.h"
18
#include "streamMsg.h"
19
#include "systable.h"
20
#include "tmsg.h"
21
#include "trpc.h"
22

23
#pragma GCC diagnostic push
24
#ifdef COMPILER_SUPPORTS_CXX13
25
#pragma GCC diagnostic ignored "-Wformat-truncation"
26
#endif
27

28
int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
29
                                   void *(*mallocFp)(int64_t), void (*freeFp)(void *)) = {0};
30
int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0};
31

32
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
114,197,264✔
33
  QUERY_PARAM_CHECK(pOut);
114,197,264✔
34
  QUERY_PARAM_CHECK(usedbRsp);
114,197,264✔
35
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
114,197,264✔
36
  pOut->dbId = usedbRsp->uid;
114,197,264✔
37

38
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
114,197,264✔
39
  if (NULL == pOut->dbVgroup) {
114,255,261✔
40
    return terrno;
×
41
  }
42

43
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
114,255,261✔
44
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
114,255,222✔
45
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
114,255,220✔
46
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
114,255,261✔
47
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
114,255,220✔
48
  pOut->dbVgroup->flags = usedbRsp->flags;
114,255,220✔
49

50
  qDebug("db:%s, get %d vgroup, vgVersion:%d, stateTs:%" PRId64, usedbRsp->db, usedbRsp->vgNum, usedbRsp->vgVersion,
114,255,220✔
51
         usedbRsp->stateTs);
52

53
  if (usedbRsp->vgNum <= 0) {
114,214,242✔
54
    return TSDB_CODE_SUCCESS;
89,969,450✔
55
  }
56

57
  pOut->dbVgroup->vgHash =
48,489,584✔
58
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
48,261,531✔
59
  if (NULL == pOut->dbVgroup->vgHash) {
24,244,792✔
60
    return terrno;
×
61
  }
62

63
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
85,335,114✔
64
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
61,090,322✔
65
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
61,090,322✔
66
    qDebug("db:%s, vgId:%d, epNum:%d, current ep:%s:%u", usedbRsp->db, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
61,090,322✔
67
           pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port);
68
    if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) {
61,090,322✔
69
      return terrno;
×
70
    }
71
  }
72

73
  return TSDB_CODE_SUCCESS;
24,244,792✔
74
}
75

76
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
48,378,685✔
77
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
78
  QUERY_PARAM_CHECK(input);
48,378,685✔
79
  QUERY_PARAM_CHECK(msg);
48,378,685✔
80
  QUERY_PARAM_CHECK(msgLen);
48,378,685✔
81
  SBuildTableInput *pInput = input;
48,378,685✔
82

83
  STableInfoReq infoReq = {0};
48,378,685✔
84
  infoReq.option = pInput->option;
48,378,687✔
85
  infoReq.header.vgId = pInput->vgId;
48,378,685✔
86
  infoReq.autoCreateCtb = pInput->autoCreateCtb;
48,378,890✔
87

88
  if (pInput->dbFName) {
48,378,725✔
89
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
48,378,657✔
90
  }
91
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
48,378,685✔
92

93
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
48,378,685✔
94
  void   *pBuf = (*mallcFp)(bufLen);
48,378,878✔
95
  if (NULL == pBuf) {
48,378,903✔
96
    return terrno;
×
97
  }
98
  int32_t ret = tSerializeSTableInfoReq(pBuf, bufLen, &infoReq);
48,378,903✔
99
  if (ret < 0) {
48,378,738✔
100
    if (freeFp) (*freeFp)(pBuf);
×
101
    return ret;
×
102
  }
103

104
  *msg = pBuf;
48,378,738✔
105
  *msgLen = bufLen;
48,378,656✔
106

107
  return TSDB_CODE_SUCCESS;
48,378,941✔
108
}
109

110
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
23,600,568✔
111
                           void (*freeFp)(void *)) {
112
  QUERY_PARAM_CHECK(input);
23,600,568✔
113
  QUERY_PARAM_CHECK(msg);
23,600,568✔
114
  QUERY_PARAM_CHECK(msgLen);
23,600,568✔
115
  SBuildUseDBInput *pInput = input;
23,600,568✔
116

117
  SUseDbReq usedbReq = {0};
23,600,568✔
118
  tstrncpy(usedbReq.db, pInput->db, TSDB_DB_FNAME_LEN);
23,600,568✔
119
  usedbReq.db[sizeof(usedbReq.db) - 1] = 0;
23,600,540✔
120
  usedbReq.vgVersion = pInput->vgVersion;
23,600,540✔
121
  usedbReq.dbId = pInput->dbId;
23,600,568✔
122
  usedbReq.numOfTable = pInput->numOfTable;
23,600,568✔
123
  usedbReq.stateTs = pInput->stateTs;
23,600,568✔
124

125
  int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
23,600,568✔
126
  void   *pBuf = (*mallcFp)(bufLen);
23,600,554✔
127
  if (NULL == pBuf) {
23,600,582✔
128
    return terrno;
×
129
  }
130
  int32_t ret = tSerializeSUseDbReq(pBuf, bufLen, &usedbReq);
23,600,582✔
131
  if (ret < 0) {
23,600,554✔
132
    if (freeFp) (*freeFp)(pBuf);
×
133
    return ret;
×
134
  }
135

136
  *msg = pBuf;
23,600,554✔
137
  *msgLen = bufLen;
23,600,554✔
138

139
  return TSDB_CODE_SUCCESS;
23,600,582✔
140
}
141

142
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
53,287✔
143
                               void (*freeFp)(void *)) {
144
  QUERY_PARAM_CHECK(msg);
53,287✔
145
  QUERY_PARAM_CHECK(msgLen);
53,287✔
146

147
  SQnodeListReq qnodeListReq = {0};
53,287✔
148
  qnodeListReq.rowNum = -1;
53,287✔
149

150
  int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
53,287✔
151
  void   *pBuf = (*mallcFp)(bufLen);
53,287✔
152
  if (NULL == pBuf) {
53,287✔
153
    return terrno;
×
154
  }
155

156
  int32_t ret = tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq);
53,287✔
157
  if (ret < 0) {
53,287✔
158
    if (freeFp) (*freeFp)(pBuf);
×
159
    return ret;
×
160
  }
161

162
  *msg = pBuf;
53,287✔
163
  *msgLen = bufLen;
53,287✔
164

165
  return TSDB_CODE_SUCCESS;
53,287✔
166
}
167

168
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
38,877✔
169
                               void (*freeFp)(void *)) {
170
  QUERY_PARAM_CHECK(msg);
38,877✔
171
  QUERY_PARAM_CHECK(msgLen);
38,877✔
172

173
  SDnodeListReq dnodeListReq = {0};
38,877✔
174
  dnodeListReq.rowNum = -1;
38,877✔
175

176
  int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
38,877✔
177
  void   *pBuf = (*mallcFp)(bufLen);
38,877✔
178
  if (NULL == pBuf) {
38,877✔
179
    return terrno;
×
180
  }
181
  int32_t ret = tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq);
38,877✔
182
  if (ret < 0) {
38,877✔
183
    if (freeFp) (*freeFp)(pBuf);
×
184
    return ret;
×
185
  }
186

187
  *msg = pBuf;
38,877✔
188
  *msgLen = bufLen;
38,877✔
189

190
  return TSDB_CODE_SUCCESS;
38,877✔
191
}
192

UNCOV
193
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
×
194
                               void (*freeFp)(void *)) {
UNCOV
195
  QUERY_PARAM_CHECK(msg);
×
UNCOV
196
  QUERY_PARAM_CHECK(msgLen);
×
197

UNCOV
198
  SServerVerReq req = {0};
×
199

UNCOV
200
  int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
×
UNCOV
201
  void   *pBuf = (*mallcFp)(bufLen);
×
UNCOV
202
  if (NULL == pBuf) {
×
203
    return terrno;
×
204
  }
UNCOV
205
  int32_t ret = tSerializeSServerVerReq(pBuf, bufLen, &req);
×
UNCOV
206
  if (ret < 0) {
×
207
    if (freeFp) (*freeFp)(pBuf);
×
208
    return ret;
×
209
  }
210

UNCOV
211
  *msg = pBuf;
×
UNCOV
212
  *msgLen = bufLen;
×
213

UNCOV
214
  return TSDB_CODE_SUCCESS;
×
215
}
216

217
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
5,032,795✔
218
                              void (*freeFp)(void *)) {
219
  QUERY_PARAM_CHECK(input);
5,032,795✔
220
  QUERY_PARAM_CHECK(msg);
5,032,795✔
221
  QUERY_PARAM_CHECK(msgLen);
5,032,795✔
222

223
  SDbCfgReq dbCfgReq = {0};
5,032,795✔
224
  tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
5,032,904✔
225

226
  int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
5,032,904✔
227
  void   *pBuf = (*mallcFp)(bufLen);
5,032,904✔
228
  if (NULL == pBuf) {
5,032,904✔
229
    return terrno;
×
230
  }
231
  int32_t ret = tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq);
5,032,904✔
232
  if (ret < 0) {
5,032,918✔
233
    if (freeFp) (*freeFp)(pBuf);
×
234
    return ret;
×
235
  }
236

237
  *msg = pBuf;
5,032,918✔
238
  *msgLen = bufLen;
5,032,918✔
239

240
  return TSDB_CODE_SUCCESS;
5,032,918✔
241
}
242

UNCOV
243
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
×
244
                              void (*freeFp)(void *)) {
UNCOV
245
  QUERY_PARAM_CHECK(input);
×
UNCOV
246
  QUERY_PARAM_CHECK(msg);
×
UNCOV
247
  QUERY_PARAM_CHECK(msgLen);
×
248

UNCOV
249
  SUserIndexReq indexReq = {0};
×
UNCOV
250
  tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
×
251

UNCOV
252
  int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
×
UNCOV
253
  void   *pBuf = (*mallcFp)(bufLen);
×
UNCOV
254
  if (NULL == pBuf) {
×
255
    return terrno;
×
256
  }
UNCOV
257
  int32_t ret = tSerializeSUserIndexReq(pBuf, bufLen, &indexReq);
×
UNCOV
258
  if (ret < 0) {
×
259
    if (freeFp) (*freeFp)(pBuf);
×
260
    return ret;
×
261
  }
262

UNCOV
263
  *msg = pBuf;
×
UNCOV
264
  *msgLen = bufLen;
×
265

UNCOV
266
  return TSDB_CODE_SUCCESS;
×
267
}
268

269
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
147,171✔
270
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
271
  QUERY_PARAM_CHECK(input);
147,171✔
272
  QUERY_PARAM_CHECK(msg);
147,171✔
273
  QUERY_PARAM_CHECK(msgLen);
147,171✔
274

275
  SRetrieveFuncReq funcReq = {0};
147,171✔
276
  funcReq.numOfFuncs = 1;
147,171✔
277
  funcReq.ignoreCodeComment = true;
147,171✔
278
  funcReq.pFuncNames = taosArrayInit(1, strlen(input) + 1);
147,171✔
279
  if (NULL == funcReq.pFuncNames) {
147,171✔
280
    return terrno;
×
281
  }
282
  if (taosArrayPush(funcReq.pFuncNames, input) == NULL) {
294,342✔
283
    taosArrayDestroy(funcReq.pFuncNames);
×
284
    return terrno;
×
285
  }
286

287
  int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
147,171✔
288
  void   *pBuf = (*mallcFp)(bufLen);
147,171✔
289
  if (NULL == pBuf) {
147,171✔
290
    taosArrayDestroy(funcReq.pFuncNames);
×
291
    return terrno;
×
292
  }
293
  int32_t ret = tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq);
147,171✔
294
  if (ret < 0) {
147,171✔
295
    taosArrayDestroy(funcReq.pFuncNames);
×
296
    if (freeFp) (*freeFp)(pBuf);
×
297
    return ret;
×
298
  }
299

300
  taosArrayDestroy(funcReq.pFuncNames);
147,171✔
301

302
  *msg = pBuf;
147,171✔
303
  *msgLen = bufLen;
147,171✔
304

305
  return TSDB_CODE_SUCCESS;
147,171✔
306
}
307

308
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
6,160,294✔
309
                                 void (*freeFp)(void *)) {
310
  QUERY_PARAM_CHECK(input);
6,160,294✔
311
  QUERY_PARAM_CHECK(msg);
6,160,294✔
312
  QUERY_PARAM_CHECK(msgLen);
6,160,294✔
313

314
  SGetUserAuthReq req = {0};
6,160,294✔
315
  tstrncpy(req.user, input, TSDB_USER_LEN);
6,160,294✔
316

317
  int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
6,160,294✔
318
  void   *pBuf = (*mallcFp)(bufLen);
6,160,294✔
319
  if (NULL == pBuf) {
6,160,294✔
320
    return terrno;
×
321
  }
322
  int32_t ret = tSerializeSGetUserAuthReq(pBuf, bufLen, &req);
6,160,294✔
323
  if (ret < 0) {
6,160,294✔
324
    if (freeFp) (*freeFp)(pBuf);
×
325
    return ret;
×
326
  }
327

328
  *msg = pBuf;
6,160,294✔
329
  *msgLen = bufLen;
6,160,294✔
330

331
  return TSDB_CODE_SUCCESS;
6,160,294✔
332
}
333

UNCOV
334
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
×
335
                                void (*freeFp)(void *)) {
UNCOV
336
  QUERY_PARAM_CHECK(input);
×
UNCOV
337
  QUERY_PARAM_CHECK(msg);
×
UNCOV
338
  QUERY_PARAM_CHECK(msgLen);
×
339

UNCOV
340
  STableIndexReq indexReq = {0};
×
UNCOV
341
  tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
×
342

UNCOV
343
  int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
×
UNCOV
344
  void   *pBuf = (*mallcFp)(bufLen);
×
UNCOV
345
  if (NULL == pBuf) {
×
346
    return terrno;
×
347
  }
UNCOV
348
  int32_t ret = tSerializeSTableIndexReq(pBuf, bufLen, &indexReq);
×
UNCOV
349
  if (ret < 0) {
×
350
    if (freeFp) (*freeFp)(pBuf);
×
351
    return ret;
×
352
  }
353

UNCOV
354
  *msg = pBuf;
×
UNCOV
355
  *msgLen = bufLen;
×
356

UNCOV
357
  return TSDB_CODE_SUCCESS;
×
358
}
359

360
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
95,571✔
361
                              void (*freeFp)(void *)) {
362
  QUERY_PARAM_CHECK(input);
95,571✔
363
  QUERY_PARAM_CHECK(msg);
95,571✔
364
  QUERY_PARAM_CHECK(msgLen);
95,571✔
365

366
  SBuildTableInput *pInput = input;
95,571✔
367
  STableCfgReq      cfgReq = {0};
95,571✔
368
  cfgReq.header.vgId = pInput->vgId;
95,571✔
369
  tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
95,571✔
370
  tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
95,571✔
371

372
  int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
95,571✔
373
  void   *pBuf = (*mallcFp)(bufLen);
95,571✔
374
  if (NULL == pBuf) {
95,571✔
375
    return terrno;
×
376
  }
377
  int32_t ret = tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq);
95,571✔
378
  if (ret < 0) {
95,571✔
379
    if (freeFp) (*freeFp)(pBuf);
×
380
    return ret;
×
381
  }
382

383
  *msg = pBuf;
95,571✔
384
  *msgLen = bufLen;
95,571✔
385

386
  return TSDB_CODE_SUCCESS;
95,571✔
387
}
388

389
int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
19,074,187✔
390
                                 void (*freeFp)(void *)) {
391
  QUERY_PARAM_CHECK(input);
19,074,187✔
392
  QUERY_PARAM_CHECK(msg);
19,074,187✔
393
  QUERY_PARAM_CHECK(msgLen);
19,074,187✔
394

395
  SViewMetaReq req = {0};
19,074,187✔
396
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
19,074,187✔
397

398
  int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
19,074,187✔
399
  void   *pBuf = (*mallcFp)(bufLen);
19,074,187✔
400
  if (NULL == pBuf) {
19,074,151✔
401
    return terrno;
×
402
  }
403
  int32_t ret = tSerializeSViewMetaReq(pBuf, bufLen, &req);
19,074,151✔
404
  if (ret < 0) {
19,074,187✔
405
    if (freeFp) (*freeFp)(pBuf);
×
406
    return ret;
×
407
  }
408

409
  *msg = pBuf;
19,074,187✔
410
  *msgLen = bufLen;
19,074,187✔
411

412
  return TSDB_CODE_SUCCESS;
19,074,154✔
413
}
414

415
int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
9,394✔
416
                                  void (*freeFp)(void *)) {
417
  QUERY_PARAM_CHECK(input);
9,394✔
418
  QUERY_PARAM_CHECK(msg);
9,394✔
419
  QUERY_PARAM_CHECK(msgLen);
9,394✔
420

421
  STableTSMAInfoReq req = {0};
9,394✔
422
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
9,394✔
423

424
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
9,394✔
425
  void *  pBuf = (*mallcFp)(bufLen);
9,394✔
426
  if (NULL == pBuf) {
9,394✔
427
    return terrno;
×
428
  }
429
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
9,394✔
430
  if (ret < 0) {
9,394✔
431
    if (freeFp) (*freeFp)(pBuf);
×
432
    return ret;
×
433
  }
434

435
  *msg = pBuf;
9,394✔
436
  *msgLen = bufLen;
9,394✔
437
  return TSDB_CODE_SUCCESS;
9,394✔
438
}
439

440
int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
1,399✔
441
                             void (*freeFp)(void *)) {
442
  QUERY_PARAM_CHECK(input);
1,399✔
443
  QUERY_PARAM_CHECK(msg);
1,399✔
444
  QUERY_PARAM_CHECK(msgLen);
1,399✔
445

446
  STableTSMAInfoReq req = {0};
1,399✔
447
  req.fetchingWithTsmaName = true;
1,399✔
448
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
1,399✔
449

450
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
1,399✔
451
  void   *pBuf = (*mallcFp)(bufLen);
1,399✔
452
  if (pBuf == NULL) {
1,399✔
453
    return terrno;
×
454
  }
455
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
1,399✔
456
  if (ret < 0) {
1,399✔
457
    if (freeFp) (*freeFp)(pBuf);
×
458
    return ret;
×
459
  }
460

461
  *msg = pBuf;
1,399✔
462
  *msgLen = bufLen;
1,399✔
463
  return TSDB_CODE_SUCCESS;
1,399✔
464
}
465

466
static int32_t queryBuildGetRsmaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
23,829✔
467
                                    void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
468
  QUERY_PARAM_CHECK(input);
23,829✔
469
  QUERY_PARAM_CHECK(msg);
23,829✔
470
  QUERY_PARAM_CHECK(msgLen);
23,829✔
471

472
  SRsmaInfoReq req = {.withColName = 1};
23,829✔
473
  (void)snprintf(req.name, sizeof(req.name), "%s", (const char *)input);
23,829✔
474

475
  int32_t bufLen = tSerializeRsmaInfoReq(NULL, 0, &req);
23,829✔
476
  void   *pBuf = (*mallcFp)(bufLen);
23,829✔
477
  if (pBuf == NULL) {
23,829✔
478
    return terrno;
×
479
  }
480
  int32_t ret = tSerializeRsmaInfoReq(pBuf, bufLen, &req);
23,829✔
481
  if (ret < 0) {
23,829✔
482
    if (freeFp) (*freeFp)(pBuf);
×
483
    return ret;
×
484
  }
485

486
  *msg = pBuf;
23,829✔
487
  *msgLen = bufLen;
23,829✔
488
  return TSDB_CODE_SUCCESS;
23,829✔
489
}
490

491
int32_t queryBuildGetStreamProgressMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
5,734✔
492
                                       void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
493
  QUERY_PARAM_CHECK(input);
5,734✔
494
  QUERY_PARAM_CHECK(msg);
5,734✔
495
  QUERY_PARAM_CHECK(msgLen);
5,734✔
496

497
  int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
5,734✔
498
  void* pBuf = (*mallcFp)(len);
5,734✔
499
  if (NULL == pBuf) {
5,734✔
500
    return terrno;
×
501
  }
502

503
  int32_t ret = tSerializeStreamProgressReq(pBuf, len, input);
5,734✔
504
  if (ret < 0) {
5,734✔
505
    if (freeFp) (*freeFp)(pBuf);
×
506
    return ret;
×
507
  }
508

509
  *msg = pBuf;
5,734✔
510
  *msgLen = len;
5,734✔
511
  return TSDB_CODE_SUCCESS;
5,734✔
512
}
513

514
int32_t queryBuildVSubTablesMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
×
515
                                void (*freeFp)(void *)) {
516
  QUERY_PARAM_CHECK(input);
×
517
  QUERY_PARAM_CHECK(msg);
×
518
  QUERY_PARAM_CHECK(msgLen);
×
519

520
  SVSubTablesReq req = {0};
×
521
  req.suid = *(int64_t*)input;
×
522

523
  int32_t bufLen = tSerializeSVSubTablesReq(NULL, 0, &req);
×
524
  void   *pBuf = (*mallcFp)(bufLen);
×
525
  if (NULL == pBuf) {
×
526
    return terrno;
×
527
  }
528
  if (tSerializeSVSubTablesReq(pBuf, bufLen, &req) < 0) {
×
529
    if (freeFp) (*freeFp)(pBuf);
×
530
    return TSDB_CODE_TSC_INVALID_INPUT;
×
531
  }
532

533
  *msg = pBuf;
×
534
  *msgLen = bufLen;
×
535

536
  return TSDB_CODE_SUCCESS;
×
537
}
538

539
int32_t queryBuildVStbRefDBsMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
8,078,053✔
540
                                void (*freeFp)(void *)) {
541
  QUERY_PARAM_CHECK(input);
8,078,053✔
542
  QUERY_PARAM_CHECK(msg);
8,078,053✔
543
  QUERY_PARAM_CHECK(msgLen);
8,078,053✔
544

545
  SVStbRefDbsReq req = {0};
8,078,053✔
546
  req.suid = *(int64_t*)input;
8,078,053✔
547

548
  int32_t bufLen = tSerializeSVStbRefDbsReq(NULL, 0, &req);
8,078,053✔
549
  void   *pBuf = (*mallcFp)(bufLen);
8,078,053✔
550
  if (NULL == pBuf) {
8,078,053✔
551
    return terrno;
×
552
  }
553
  if (tSerializeSVStbRefDbsReq(pBuf, bufLen, &req) < 0) {
8,078,053✔
554
    if (freeFp) (*freeFp)(pBuf);
×
555
    return TSDB_CODE_TSC_INVALID_INPUT;
×
556
  }
557

558
  *msg = pBuf;
8,078,053✔
559
  *msgLen = bufLen;
8,078,053✔
560

561
  return TSDB_CODE_SUCCESS;
8,078,053✔
562
}
563

564
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
23,480,691✔
565
  SUseDbOutput *pOut = output;
23,480,691✔
566
  SUseDbRsp     usedbRsp = {0};
23,480,691✔
567
  int32_t       code = -1;
23,480,691✔
568

569
  if (NULL == output || NULL == msg || msgSize <= 0) {
23,480,691✔
570
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
571
    qError("invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
572
    goto PROCESS_USEDB_OVER;
×
573
  }
574

575
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
23,480,691✔
576
    qError("invalid use db rsp msg, msgSize:%d", msgSize);
×
577
    code = TSDB_CODE_INVALID_MSG;
×
578
    goto PROCESS_USEDB_OVER;
×
579
  }
580

581
  if (usedbRsp.vgNum < 0) {
23,480,691✔
582
    qError("invalid db[%s] vgroup number[%d]", usedbRsp.db, usedbRsp.vgNum);
×
583
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
584
    goto PROCESS_USEDB_OVER;
×
585
  }
586

587
  qTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
23,480,691✔
588
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
78,118,704✔
589
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
54,638,013✔
590
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
54,638,013✔
591
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
111,277,892✔
592
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
56,639,879✔
593
    }
594
  }
595

596
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
23,480,691✔
597

598
PROCESS_USEDB_OVER:
23,480,691✔
599

600
  if (code != 0) {
23,480,691✔
601
    if (pOut) {
×
602
      if (pOut->dbVgroup) taosHashCleanup(pOut->dbVgroup->vgHash);
×
603
      taosMemoryFreeClear(pOut->dbVgroup);
×
604
    }
605
    qError("failed to process usedb rsp since %s", terrstr());
×
606
  }
607

608
  tFreeSUsedbRsp(&usedbRsp);
23,480,691✔
609
  return code;
23,480,691✔
610
}
611

612
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
37,984,541✔
613
  QUERY_PARAM_CHECK(pMetaMsg);
37,984,541✔
614
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
37,984,541✔
615
    qError("invalid numOfTags[%d] in table meta rsp msg", pMetaMsg->numOfTags);
29✔
616
    return TSDB_CODE_TSC_INVALID_VALUE;
×
617
  }
618

619
  if (pMetaMsg->numOfColumns > TSDB_MAX_COLUMNS || pMetaMsg->numOfColumns <= 0) {
37,984,583✔
620
    qError("invalid numOfColumns[%d] in table meta rsp msg", pMetaMsg->numOfColumns);
40✔
621
    return TSDB_CODE_TSC_INVALID_VALUE;
×
622
  }
623

624
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
37,984,583✔
625
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE &&
5,761,649✔
626
      pMetaMsg->tableType != TSDB_VIRTUAL_NORMAL_TABLE && pMetaMsg->tableType != TSDB_VIRTUAL_CHILD_TABLE) {
354,921✔
627
    qError("invalid tableType[%d] in table meta rsp msg", pMetaMsg->tableType);
×
628
    return TSDB_CODE_TSC_INVALID_VALUE;
×
629
  }
630

631
  if (pMetaMsg->sversion < 0) {
37,985,217✔
632
    qError("invalid sversion[%d] in table meta rsp msg", pMetaMsg->sversion);
×
633
    return TSDB_CODE_TSC_INVALID_VALUE;
×
634
  }
635

636
  if (pMetaMsg->tversion < 0) {
37,985,206✔
637
    qError("invalid tversion[%d] in table meta rsp msg", pMetaMsg->tversion);
×
638
    return TSDB_CODE_TSC_INVALID_VALUE;
×
639
  }
640

641
  if (pMetaMsg->rversion < 0) {
37,984,554✔
642
    qError("invalid rversion[%d] in table meta rsp msg", pMetaMsg->rversion);
×
643
    return TSDB_CODE_TSC_INVALID_VALUE;
×
644
  }
645

646
  if (pMetaMsg->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
37,984,554✔
647
    qError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", pMetaMsg->pSchemas[0].colId);
×
648
    return TSDB_CODE_TSC_INVALID_VALUE;
×
649
  }
650

651
  return TSDB_CODE_SUCCESS;
37,984,583✔
652
}
653

654
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
56,133,748✔
655
  QUERY_PARAM_CHECK(msg);
56,133,748✔
656
  QUERY_PARAM_CHECK(pMeta);
56,133,748✔
657
  pMeta->vgId = msg->vgId;
56,133,748✔
658
  pMeta->tableType = msg->tableType;
56,130,590✔
659
  pMeta->uid = msg->tuid;
56,126,424✔
660
  pMeta->suid = msg->suid;
56,118,520✔
661

662
  qDebug("ctb:%s, uid:0x%" PRIx64 " meta returned, type:%d vgId:%d db:%s suid:%" PRIx64, msg->tbName, pMeta->uid,
56,135,302✔
663
         pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
664

665
  return TSDB_CODE_SUCCESS;
56,135,724✔
666
}
667

668
int32_t queryCreateVCTableMetaFromMsg(STableMetaRsp *msg, SVCTableMeta **pMeta) {
566,597✔
669
  QUERY_PARAM_CHECK(msg);
566,597✔
670
  QUERY_PARAM_CHECK(pMeta);
566,597✔
671
  QUERY_PARAM_CHECK(msg->pColRefs);
566,597✔
672

673
  int32_t pColRefSize = sizeof(SColRef) * msg->numOfColRefs;
566,597✔
674

675
  SVCTableMeta *pTableMeta = taosMemoryCalloc(1, sizeof(SVCTableMeta) + pColRefSize);
566,597✔
676
  if (NULL == pTableMeta) {
566,597✔
677
    qError("calloc size[%d] failed", (int32_t)sizeof(SVCTableMeta) + pColRefSize);
×
678
    return terrno;
×
679
  }
680

681
  pTableMeta->vgId = msg->vgId;
566,597✔
682
  pTableMeta->tableType = msg->tableType;
566,597✔
683
  pTableMeta->uid = msg->tuid;
566,597✔
684
  pTableMeta->suid = msg->suid;
566,597✔
685
  pTableMeta->numOfColRefs = msg->numOfColRefs;
566,597✔
686
  pTableMeta->rversion = msg->rversion;
566,597✔
687

688
  pTableMeta->colRef = (SColRef *)((char *)pTableMeta + sizeof(SVCTableMeta));
566,597✔
689
  memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
566,597✔
690

691
  qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, (pTableMeta)->uid,
566,597✔
692
         (pTableMeta)->tableType, (pTableMeta)->vgId, msg->dbFName, (pTableMeta)->suid);
693

694
  *pMeta = pTableMeta;
566,597✔
695
  return TSDB_CODE_SUCCESS;
566,597✔
696
}
697

698
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
55,311,245✔
699
  QUERY_PARAM_CHECK(msg);
55,311,245✔
700
  QUERY_PARAM_CHECK(pMeta);
55,311,245✔
701
  int32_t total = msg->numOfColumns + msg->numOfTags;
55,311,245✔
702
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
55,311,325✔
703
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
55,311,325✔
704
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) ? sizeof(SColRef) * msg->numOfColRefs : 0;
55,311,285✔
705

706
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + pColRefSize);
55,311,245✔
707
  if (NULL == pTableMeta) {
55,311,442✔
708
    qError("calloc size[%d] failed", metaSize);
×
709
    return terrno;
×
710
  }
711
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
55,311,442✔
712
  SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
55,311,442✔
713

714
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
55,311,442✔
715
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
55,311,442✔
716
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
55,311,402✔
717
  pTableMeta->suid = msg->suid;
55,311,402✔
718
  pTableMeta->sversion = msg->sversion;
55,311,402✔
719
  pTableMeta->tversion = msg->tversion;
55,311,402✔
720
  pTableMeta->rversion = msg->rversion;
55,311,442✔
721
  pTableMeta->ownerId = msg->ownerId;
55,311,977✔
722
  pTableMeta->flag = msg->flag;
55,311,442✔
723
  pTableMeta->secureDelete = msg->secureDelete;
55,311,977✔
724
  if (msg->virtualStb) {
55,311,977✔
725
    pTableMeta->virtualStb = 1;
539,472✔
726
    pTableMeta->numOfColRefs = 0;
539,472✔
727
  } else {
728
    if (msg->tableType == TSDB_VIRTUAL_CHILD_TABLE && isStb) {
54,772,465✔
729
      pTableMeta->virtualStb = 1;
220,089✔
730
      pTableMeta->numOfColRefs = 0;
220,089✔
731
    } else {
732
      pTableMeta->virtualStb = 0;
54,551,841✔
733
      pTableMeta->numOfColRefs = msg->numOfColRefs;
54,551,841✔
734
    }
735
  }
736

737
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
55,311,402✔
738
  pTableMeta->tableInfo.precision = msg->precision;
55,311,402✔
739
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
55,311,402✔
740

741
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
55,311,413✔
742
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
55,311,977✔
743
    pTableMeta->schemaExt = pSchemaExt;
52,601,700✔
744
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
52,601,700✔
745
  } else {
746
    pTableMeta->schemaExt = NULL;
2,710,277✔
747
  }
748

749
  if (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) {
55,311,908✔
750
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
571,171✔
751
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
571,171✔
752
  } else {
753
    pTableMeta->colRef = NULL;
54,740,766✔
754
  }
755

756
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
55,311,908✔
757
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,147,483,647✔
758
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,147,483,647✔
759
    if (hasPK && (i > 0)) {
2,147,483,647✔
760
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
548,164✔
761
        ++pTableMeta->tableInfo.numOfPKs;
276,140✔
762
      } else {
763
        hasPK = false;
272,024✔
764
      }
765
    }
766
  }
767

768
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
55,311,908✔
769
         " sver:%d tver:%d"
770
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
771
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
772
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
773
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
774

775
  *pMeta = pTableMeta;
55,312,560✔
776
  return TSDB_CODE_SUCCESS;
55,311,909✔
777
}
778

779
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
159,154✔
780
  QUERY_PARAM_CHECK(msg);
159,154✔
781
  QUERY_PARAM_CHECK(pMeta);
159,154✔
782
  int32_t total = msg->numOfColumns + msg->numOfTags;
159,154✔
783
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
159,154✔
784
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
159,154✔
785
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs) ? sizeof(SColRef) * msg->numOfColRefs : 0;
159,154✔
786
  int32_t tbNameSize = strlen(msg->tbName) + 1;
159,154✔
787

788
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + pColRefSize + tbNameSize);
159,154✔
789
  if (NULL == pTableMeta) {
159,154✔
790
    qError("calloc size[%d] failed", metaSize);
×
791
    return terrno;
×
792
  }
793
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
159,154✔
794
  SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
159,154✔
795

796
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
159,154✔
797
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
159,154✔
798
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
159,154✔
799
  pTableMeta->suid = msg->suid;
159,154✔
800
  pTableMeta->sversion = msg->sversion;
159,154✔
801
  pTableMeta->tversion = msg->tversion;
159,154✔
802
  pTableMeta->rversion = msg->rversion;
159,154✔
803
  pTableMeta->virtualStb = msg->virtualStb;
159,154✔
804
  pTableMeta->numOfColRefs = msg->numOfColRefs;
159,154✔
805
  pTableMeta->ownerId = msg->ownerId;
159,154✔
806
  pTableMeta->secureDelete = msg->secureDelete;
159,154✔
807

808
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
159,154✔
809
  pTableMeta->tableInfo.precision = msg->precision;
159,154✔
810
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
159,154✔
811

812
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
159,154✔
813
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
159,154✔
814
    pTableMeta->schemaExt = pSchemaExt;
159,154✔
815
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
159,154✔
816
  } else {
817
    pTableMeta->schemaExt = NULL;
×
818
  }
819

820
  if (hasRefCol(msg->tableType) && msg->pColRefs) {
159,154✔
821
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
×
822
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
×
823
  } else {
824
    pTableMeta->colRef = NULL;
159,154✔
825
  }
826

827
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
159,154✔
828
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
515,282✔
829
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
356,128✔
830
    if (hasPK && (i > 0)) {
356,128✔
831
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
832
        ++pTableMeta->tableInfo.numOfPKs;
×
833
      } else {
834
        hasPK = false;
×
835
      }
836
    }
837
  }
838

839
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize + pColRefSize;
159,154✔
840
  tstrncpy(pTbName, msg->tbName, tbNameSize);
159,154✔
841

842
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
159,154✔
843
         " sver:%d tver:%d"
844
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
845
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
846
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
847
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
848

849
  *pMeta = pTableMeta;
159,154✔
850
  return TSDB_CODE_SUCCESS;
159,154✔
851
}
852

853
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
37,825,878✔
854
  int32_t       code = 0;
37,825,878✔
855
  STableMetaRsp metaRsp = {0};
37,825,878✔
856

857
  if (NULL == output || NULL == msg || msgSize <= 0) {
37,825,918✔
858
    qError("queryProcessTableMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
78✔
859
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
860
    goto PROCESS_META_OVER;
×
861
  }
862

863
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
37,825,840✔
864
    code = TSDB_CODE_INVALID_MSG;
×
865
    goto PROCESS_META_OVER;
×
866
  }
867

868
  code = queryConvertTableMetaMsg(&metaRsp);
37,825,429✔
869
  if (code != TSDB_CODE_SUCCESS) {
37,825,387✔
870
    goto PROCESS_META_OVER;
×
871
  }
872

873
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
113,341,329✔
874
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
75,295,935✔
875
                    metaRsp.virtualStb);
37,470,548✔
876
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
37,825,387✔
877
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
35,906,370✔
878
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
879
    goto PROCESS_META_OVER;
×
880
  }
881

882
  STableMetaOutput *pOut = output;
37,826,041✔
883
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
37,826,041✔
884
  pOut->dbId = metaRsp.dbId;
37,826,081✔
885

886
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
37,826,081✔
887
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
12,724,338✔
888

889
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
12,724,338✔
890
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
12,724,298✔
891

892
    pOut->ctbMeta.vgId = metaRsp.vgId;
12,724,298✔
893
    pOut->ctbMeta.tableType = metaRsp.tableType;
12,724,378✔
894
    pOut->ctbMeta.uid = metaRsp.tuid;
12,724,338✔
895
    pOut->ctbMeta.suid = metaRsp.suid;
12,724,338✔
896

897
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
12,724,338✔
898
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
25,101,743✔
899
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
220,089✔
900

901
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
220,089✔
902
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
220,089✔
903

904
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
220,089✔
905
    if (TSDB_CODE_SUCCESS != code) {
220,089✔
906
      goto PROCESS_META_OVER;
×
907
    }
908
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
220,089✔
909
  } else {
910
    SET_META_TYPE_TABLE(pOut->metaType);
24,881,654✔
911
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
24,881,654✔
912
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
24,881,645✔
913
  }
914

915
PROCESS_META_OVER:
37,826,053✔
916
  if (code != 0) {
37,826,013✔
917
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
918
  }
919

920
  tFreeSTableMetaRsp(&metaRsp);
37,826,013✔
921
  return code;
37,826,013✔
922
}
923

924
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
159,154✔
925
  int32_t       code = 0;
159,154✔
926
  STableMetaRsp metaRsp = {0};
159,154✔
927

928
  if (NULL == output || NULL == msg || msgSize <= 0) {
159,154✔
929
    qError("queryProcessTableNameRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
930
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
931
    goto PROCESS_NAME_OVER;
×
932
  }
933

934
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
159,154✔
935
    code = TSDB_CODE_INVALID_MSG;
×
936
    goto PROCESS_NAME_OVER;
×
937
  }
938

939
  code = queryConvertTableMetaMsg(&metaRsp);
159,154✔
940
  if (code != TSDB_CODE_SUCCESS) {
159,154✔
941
    goto PROCESS_NAME_OVER;
×
942
  }
943

944
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
477,462✔
945
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
318,308✔
946
                    metaRsp.virtualStb);
159,154✔
947

948
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
159,154✔
949
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
159,154✔
950
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
951
    goto PROCESS_NAME_OVER;
×
952
  }
953

954
  STableMetaOutput *pOut = output;
159,154✔
955
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
159,154✔
956
  pOut->dbId = metaRsp.dbId;
159,154✔
957

958
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
159,154✔
959
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
39,321✔
960

961
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
39,321✔
962
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
39,321✔
963

964
    pOut->ctbMeta.vgId = metaRsp.vgId;
39,321✔
965
    pOut->ctbMeta.tableType = metaRsp.tableType;
39,321✔
966
    pOut->ctbMeta.uid = metaRsp.tuid;
39,321✔
967
    pOut->ctbMeta.suid = metaRsp.suid;
39,321✔
968

969
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
39,321✔
970
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
119,833✔
971
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
×
972

973
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
×
974
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
×
975

976
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
×
977
    if (TSDB_CODE_SUCCESS != code) {
×
978
      goto PROCESS_NAME_OVER;
×
979
    }
980

981
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
×
982
  } else {
983
    SET_META_TYPE_TABLE(pOut->metaType);
119,833✔
984
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
119,833✔
985
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
119,833✔
986
  }
987

988
PROCESS_NAME_OVER:
159,154✔
989
  if (code != 0) {
159,154✔
990
    qError("failed to process table name rsp since %s", tstrerror(code));
×
991
  }
992

993
  tFreeSTableMetaRsp(&metaRsp);
159,154✔
994
  return code;
159,154✔
995
}
996

997
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
53,287✔
998
  SQnodeListRsp out = {0};
53,287✔
999
  int32_t       code = 0;
53,287✔
1000

1001
  if (NULL == output || NULL == msg || msgSize <= 0) {
53,287✔
1002
    qError("queryProcessQnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1003
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1004
    return code;
×
1005
  }
1006

1007
  out.qnodeList = (SArray *)output;
53,287✔
1008
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
53,287✔
1009
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
1010
    code = TSDB_CODE_INVALID_MSG;
×
1011
    return code;
×
1012
  }
1013

1014
  return code;
53,287✔
1015
}
1016

1017
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
38,877✔
1018
  SDnodeListRsp out = {0};
38,877✔
1019
  int32_t       code = 0;
38,877✔
1020

1021
  if (NULL == output || NULL == msg || msgSize <= 0) {
38,877✔
1022
    qError("queryProcessDnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1023
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1024
    return code;
×
1025
  }
1026

1027
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
38,877✔
1028
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
1029
    code = TSDB_CODE_INVALID_MSG;
×
1030
    return code;
×
1031
  }
1032

1033
  *(SArray **)output = out.dnodeList;
38,877✔
1034

1035
  return code;
38,877✔
1036
}
1037

UNCOV
1038
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
×
UNCOV
1039
  SServerVerRsp out = {0};
×
UNCOV
1040
  int32_t       code = 0;
×
1041

UNCOV
1042
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1043
    qError("queryProcessGetSerVerRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1044
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1045
    return code;
×
1046
  }
1047

UNCOV
1048
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
×
1049
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
1050
    code = TSDB_CODE_INVALID_MSG;
×
1051
    return code;
×
1052
  }
1053

UNCOV
1054
  *(char **)output = taosStrdup(out.ver);
×
UNCOV
1055
  if (NULL == *(char **)output) {
×
1056
    return terrno;
×
1057
  }
1058

UNCOV
1059
  return code;
×
1060
}
1061

1062
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
4,500,071✔
1063
  SDbCfgRsp out = {0};
4,500,071✔
1064

1065
  if (NULL == output || NULL == msg || msgSize <= 0) {
4,500,071✔
UNCOV
1066
    qError("queryProcessGetDbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1067
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1068
  }
1069

1070
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
4,500,071✔
1071
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d, dbCfgRsp:%lu", msgSize, sizeof(out));
×
1072
    return TSDB_CODE_INVALID_MSG;
×
1073
  }
1074

1075
  memcpy(output, &out, sizeof(out));
4,500,071✔
1076

1077
  return TSDB_CODE_SUCCESS;
4,500,071✔
1078
}
1079

1080
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
1081
  SUserIndexRsp out = {0};
×
1082

1083
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1084
    qError("queryProcessGetIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1085
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1086
  }
1087

1088
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
1089
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
1090
    return TSDB_CODE_INVALID_MSG;
×
1091
  }
1092

1093
  memcpy(output, &out, sizeof(out));
×
1094

1095
  return TSDB_CODE_SUCCESS;
×
1096
}
1097

1098
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
140,612✔
1099
  SRetrieveFuncRsp out = {0};
140,612✔
1100

1101
  if (NULL == output || NULL == msg || msgSize <= 0) {
140,612✔
1102
    qError("queryProcessRetrieveFuncRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1103
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1104
  }
1105

1106
  if (tDeserializeSRetrieveFuncRsp(msg, msgSize, &out) != 0) {
140,612✔
1107
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
1108
    return TSDB_CODE_INVALID_MSG;
×
1109
  }
1110

1111
  if (1 != out.numOfFuncs) {
140,612✔
1112
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
1113
    return TSDB_CODE_INVALID_MSG;
×
1114
  }
1115

1116
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
140,612✔
1117

1118
  memcpy(output, funcInfo, sizeof(*funcInfo));
140,612✔
1119
  taosArrayDestroy(out.pFuncInfos);
140,612✔
1120
  taosArrayDestroy(out.pFuncExtraInfos);
140,612✔
1121

1122
  return TSDB_CODE_SUCCESS;
140,612✔
1123
}
1124

1125
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
6,159,139✔
1126
  if (NULL == output || NULL == msg || msgSize <= 0) {
6,159,139✔
1127
    qError("queryProcessGetUserAuthRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1128
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1129
  }
1130

1131
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
6,159,139✔
1132
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
1133
    return TSDB_CODE_INVALID_MSG;
×
1134
  }
1135

1136
  return TSDB_CODE_SUCCESS;
6,159,139✔
1137
}
1138

UNCOV
1139
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
×
UNCOV
1140
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1141
    qError("queryProcessGetTbIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1142
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1143
  }
1144

UNCOV
1145
  STableIndexRsp *out = (STableIndexRsp *)output;
×
UNCOV
1146
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
×
1147
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
1148
    return TSDB_CODE_INVALID_MSG;
×
1149
  }
1150

UNCOV
1151
  return TSDB_CODE_SUCCESS;
×
1152
}
1153

1154
int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
95,571✔
1155
  if (NULL == output || NULL == msg || msgSize <= 0) {
95,571✔
1156
    qError("queryProcessGetTbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1157
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1158
  }
1159

1160
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
95,571✔
1161
  if(out == NULL) {
95,571✔
1162
    return terrno;
×
1163
  }
1164
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
95,571✔
1165
    qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize);
×
1166
    tFreeSTableCfgRsp(out);
×
1167
    taosMemoryFree(out);
×
1168
    return TSDB_CODE_INVALID_MSG;
×
1169
  }
1170

1171
  *(STableCfgRsp **)output = out;
95,571✔
1172

1173
  return TSDB_CODE_SUCCESS;
95,571✔
1174
}
1175

1176
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
238,069✔
1177
  if (NULL == output || NULL == msg || msgSize <= 0) {
238,069✔
1178
    qError("queryProcessGetViewMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1179
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1180
  }
1181

1182
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
238,069✔
1183
  if (out == NULL) {
238,069✔
1184
    return terrno;
×
1185
  }
1186
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
238,069✔
1187
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
1188
    tFreeSViewMetaRsp(out);
×
1189
    taosMemoryFree(out);
×
1190
    return TSDB_CODE_INVALID_MSG;
×
1191
  }
1192

1193
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
238,069✔
1194

1195
  *(SViewMetaRsp **)output = out;
238,069✔
1196

1197
  return TSDB_CODE_SUCCESS;
238,069✔
1198
}
1199

1200
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
5,181✔
1201
  if (NULL == output || NULL == msg || msgSize <= 0) {
5,181✔
1202
    qError("queryProcessGetTbTSMARsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1203
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1204
  }
1205

1206
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
5,181✔
1207
    qError("tDeserializeTbTSMARsp failed, msgSize:%d", msgSize);
×
1208
    return TSDB_CODE_INVALID_MSG;
×
1209
  }
1210

1211
  return TSDB_CODE_SUCCESS;
5,181✔
1212
}
1213

1214
static int32_t queryProcessGetRsmaRsp(void* output, char* msg, int32_t msgSize) {
18,565✔
1215
  if (NULL == output || NULL == msg || msgSize <= 0) {
18,565✔
1216
    qError("queryProcessGetRsmaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1217
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1218
  }
1219

1220
  if (tDeserializeRsmaInfoRsp(msg, msgSize, output) != 0) {
18,565✔
1221
    qError("tDeserializeRsmaInfoRsp failed, msgSize:%d", msgSize);
×
1222
    return TSDB_CODE_INVALID_MSG;
×
1223
  }
1224

1225
  return TSDB_CODE_SUCCESS;
18,565✔
1226
}
1227

1228
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
5,734✔
1229
  if (!output || !msg || msgSize <= 0) {
5,734✔
1230
    qError("queryProcessStreamProgressRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1231
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1232
  }
1233

1234
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
5,734✔
1235
    qError("tDeserializeStreamProgressRsp failed, msgSize:%d", msgSize);
×
1236
    return TSDB_CODE_INVALID_MSG;
×
1237
  }
1238
  return TSDB_CODE_SUCCESS;
5,734✔
1239
}
1240

1241
int32_t queryProcessVSubTablesRsp(void* output, char* msg, int32_t msgSize) {
×
1242
  if (!output || !msg || msgSize <= 0) {
×
1243
    qError("queryProcessVSubTablesRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1244
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1245
  }
1246

1247
  SVSubTablesRsp* pRsp = (SVSubTablesRsp*)output;
×
1248
  int32_t code = tDeserializeSVSubTablesRsp(msg, msgSize, pRsp);
×
1249
  if (code != 0) {
×
1250
    qError("tDeserializeSVSubTablesRsp failed, msgSize: %d, error:%d", msgSize, code);
×
1251
    return code;
×
1252
  }
1253
  
1254
  return TSDB_CODE_SUCCESS;
×
1255
}
1256

1257
int32_t queryProcessVStbRefDbsRsp(void* output, char* msg, int32_t msgSize) {
8,078,053✔
1258
  if (!output || !msg || msgSize <= 0) {
8,078,053✔
1259
    qError("queryProcessVStbRefDbsRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
96✔
1260
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1261
  }
1262

1263
  SVStbRefDbsRsp * pRsp = (SVStbRefDbsRsp*)output;
8,077,957✔
1264
  int32_t code = tDeserializeSVStbRefDbsRsp(msg, msgSize, pRsp);
8,077,957✔
1265
  if (code != 0) {
8,071,940✔
1266
    qError("tDeserializeSVStbRefDbsRsp failed, msgSize: %d, error:%d", msgSize, code);
×
1267
    return code;
×
1268
  }
1269

1270
  return TSDB_CODE_SUCCESS;
8,073,101✔
1271
}
1272

1273
void initQueryModuleMsgHandle() {
1,352,877✔
1274
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,352,877✔
1275
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryBuildTableMetaReqMsg;
1,352,877✔
1276
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,352,877✔
1277
  queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg;
1,352,877✔
1278
  queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg;
1,352,877✔
1279
  queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg;
1,352,877✔
1280
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg;
1,352,877✔
1281
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg;
1,352,877✔
1282
  queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg;
1,352,877✔
1283
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg;
1,352,877✔
1284
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg;
1,352,877✔
1285
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,352,877✔
1286
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,352,877✔
1287
  queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg;
1,352,877✔
1288
  queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg;
1,352,877✔
1289
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryBuildGetTableTSMAMsg;
1,352,877✔
1290
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryBuildGetTSMAMsg;
1,352,877✔
1291
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryBuildGetRsmaMsg;
1,352,877✔
1292
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryBuildGetStreamProgressMsg;
1,352,877✔
1293
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryBuildVSubTablesMsg;
1,352,877✔
1294
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryBuildVStbRefDBsMsg;
1,352,877✔
1295

1296
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
1,352,877✔
1297
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryProcessTableNameRsp;
1,352,877✔
1298
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp;
1,352,877✔
1299
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
1,352,877✔
1300
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp;
1,352,877✔
1301
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp;
1,352,877✔
1302
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp;
1,352,877✔
1303
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp;
1,352,877✔
1304
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp;
1,352,877✔
1305
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp;
1,352,877✔
1306
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp;
1,352,877✔
1307
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,352,877✔
1308
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,352,877✔
1309
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp;
1,352,877✔
1310
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp;
1,352,877✔
1311
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp;
1,352,877✔
1312
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp;
1,352,877✔
1313
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryProcessGetRsmaRsp;
1,352,877✔
1314
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp;
1,352,877✔
1315
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryProcessVSubTablesRsp;
1,352,877✔
1316
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryProcessVStbRefDbsRsp;
1,352,877✔
1317
}
1,352,877✔
1318

1319
#pragma GCC diagnostic pop
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