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

taosdata / TDengine / #5005

26 Mar 2026 12:51PM UTC coverage: 72.152% (-0.2%) from 72.338%
#5005

push

travis-ci

web-flow
merge: from main to 3.0 branch #34951

512 of 851 new or added lines in 47 files covered. (60.16%)

6189 existing lines in 147 files now uncovered.

253282 of 351039 relevant lines covered (72.15%)

132156710.33 hits per line

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

66.9
/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) {
117,324,047✔
33
  QUERY_PARAM_CHECK(pOut);
117,324,047✔
34
  QUERY_PARAM_CHECK(usedbRsp);
117,324,047✔
35
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
117,324,047✔
36
  pOut->dbId = usedbRsp->uid;
117,325,055✔
37

38
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
117,324,264✔
39
  if (NULL == pOut->dbVgroup) {
117,378,620✔
40
    return terrno;
×
41
  }
42

43
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
117,376,946✔
44
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
117,378,664✔
45
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
117,378,620✔
46
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
117,377,113✔
47
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
117,377,874✔
48
  pOut->dbVgroup->flags = usedbRsp->flags;
117,377,707✔
49

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

53
  if (usedbRsp->vgNum <= 0) {
117,333,718✔
54
    return TSDB_CODE_SUCCESS;
91,590,430✔
55
  }
56

57
  pOut->dbVgroup->vgHash =
51,486,763✔
58
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
51,261,580✔
59
  if (NULL == pOut->dbVgroup->vgHash) {
25,743,424✔
60
    return terrno;
×
61
  }
62

63
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
90,339,122✔
64
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
64,595,698✔
65
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
64,595,698✔
66
    qDebug("db:%s, vgId:%d, epNum:%d, current ep:%s:%u", usedbRsp->db, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
64,595,698✔
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))) {
64,595,698✔
69
      return terrno;
×
70
    }
71
  }
72

73
  return TSDB_CODE_SUCCESS;
25,743,424✔
74
}
75

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

83
  STableInfoReq infoReq = {0};
49,021,832✔
84
  infoReq.option = pInput->option;
49,021,935✔
85
  infoReq.header.vgId = pInput->vgId;
49,021,980✔
86
  infoReq.autoCreateCtb = pInput->autoCreateCtb;
49,021,890✔
87

88
  if (pInput->dbFName) {
49,021,922✔
89
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
49,021,907✔
90
  }
91
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
49,020,641✔
92

93
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
49,021,838✔
94
  void   *pBuf = (*mallcFp)(bufLen);
49,021,845✔
95
  if (NULL == pBuf) {
49,022,063✔
96
    return terrno;
×
97
  }
98
  int32_t ret = tSerializeSTableInfoReq(pBuf, bufLen, &infoReq);
49,022,063✔
99
  if (ret < 0) {
49,021,924✔
100
    if (freeFp) (*freeFp)(pBuf);
×
101
    return ret;
×
102
  }
103

104
  *msg = pBuf;
49,021,924✔
105
  *msgLen = bufLen;
49,021,270✔
106

107
  return TSDB_CODE_SUCCESS;
49,021,367✔
108
}
109

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

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

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

136
  *msg = pBuf;
23,945,895✔
137
  *msgLen = bufLen;
23,945,895✔
138

139
  return TSDB_CODE_SUCCESS;
23,945,869✔
140
}
141

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

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

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

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

162
  *msg = pBuf;
52,749✔
163
  *msgLen = bufLen;
52,749✔
164

165
  return TSDB_CODE_SUCCESS;
52,749✔
166
}
167

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

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

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

187
  *msg = pBuf;
40,641✔
188
  *msgLen = bufLen;
40,641✔
189

190
  return TSDB_CODE_SUCCESS;
40,641✔
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,157,463✔
218
                              void (*freeFp)(void *)) {
219
  QUERY_PARAM_CHECK(input);
5,157,463✔
220
  QUERY_PARAM_CHECK(msg);
5,157,463✔
221
  QUERY_PARAM_CHECK(msgLen);
5,157,463✔
222

223
  SDbCfgReq dbCfgReq = {0};
5,157,463✔
224
  tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
5,157,507✔
225

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

237
  *msg = pBuf;
5,157,520✔
238
  *msgLen = bufLen;
5,157,520✔
239

240
  return TSDB_CODE_SUCCESS;
5,157,520✔
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,
148,663✔
270
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
271
  QUERY_PARAM_CHECK(input);
148,663✔
272
  QUERY_PARAM_CHECK(msg);
148,663✔
273
  QUERY_PARAM_CHECK(msgLen);
148,663✔
274

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

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

300
  taosArrayDestroy(funcReq.pFuncNames);
148,663✔
301

302
  *msg = pBuf;
148,663✔
303
  *msgLen = bufLen;
148,663✔
304

305
  return TSDB_CODE_SUCCESS;
148,663✔
306
}
307

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

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

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

328
  *msg = pBuf;
6,265,556✔
329
  *msgLen = bufLen;
6,265,512✔
330

331
  return TSDB_CODE_SUCCESS;
6,265,556✔
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,929✔
361
                              void (*freeFp)(void *)) {
362
  QUERY_PARAM_CHECK(input);
95,929✔
363
  QUERY_PARAM_CHECK(msg);
95,929✔
364
  QUERY_PARAM_CHECK(msgLen);
95,929✔
365

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

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

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

386
  return TSDB_CODE_SUCCESS;
95,929✔
387
}
388

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

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

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

409
  *msg = pBuf;
19,338,230✔
410
  *msgLen = bufLen;
19,338,230✔
411

412
  return TSDB_CODE_SUCCESS;
19,338,230✔
413
}
414

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

509
  *msg = pBuf;
5,640✔
510
  *msgLen = len;
5,640✔
511
  return TSDB_CODE_SUCCESS;
5,640✔
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),
6,980,933✔
540
                                void (*freeFp)(void *)) {
541
  QUERY_PARAM_CHECK(input);
6,980,933✔
542
  QUERY_PARAM_CHECK(msg);
6,980,933✔
543
  QUERY_PARAM_CHECK(msgLen);
6,980,933✔
544

545
  SVStbRefDbsReq req = {0};
6,980,933✔
546
  req.suid = *(int64_t*)input;
6,980,933✔
547

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

558
  *msg = pBuf;
6,980,933✔
559
  *msgLen = bufLen;
6,980,933✔
560

561
  return TSDB_CODE_SUCCESS;
6,980,933✔
562
}
563

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

569
  if (NULL == output || NULL == msg || msgSize <= 0) {
23,824,884✔
UNCOV
570
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
UNCOV
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,824,884✔
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,824,884✔
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,824,884✔
588
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
79,556,555✔
589
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
55,731,671✔
590
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
55,731,671✔
591
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
113,468,995✔
592
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
57,737,324✔
593
    }
594
  }
595

596
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
23,824,884✔
597

598
PROCESS_USEDB_OVER:
23,824,884✔
599

600
  if (code != 0) {
23,824,884✔
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,824,884✔
609
  return code;
23,824,884✔
610
}
611

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

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

624
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
38,574,096✔
625
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE &&
5,818,473✔
626
      pMetaMsg->tableType != TSDB_VIRTUAL_NORMAL_TABLE && pMetaMsg->tableType != TSDB_VIRTUAL_CHILD_TABLE) {
361,696✔
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) {
38,574,517✔
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) {
38,573,985✔
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) {
38,574,014✔
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) {
38,574,014✔
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;
38,574,517✔
652
}
653

654
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
57,176,758✔
655
  QUERY_PARAM_CHECK(msg);
57,176,758✔
656
  QUERY_PARAM_CHECK(pMeta);
57,176,758✔
657
  pMeta->vgId = msg->vgId;
57,176,758✔
658
  pMeta->tableType = msg->tableType;
57,175,929✔
659
  pMeta->uid = msg->tuid;
57,181,443✔
660
  pMeta->suid = msg->suid;
57,164,697✔
661

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

665
  return TSDB_CODE_SUCCESS;
57,175,782✔
666
}
667

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

673
  int32_t pColRefSize = sizeof(SColRef) * msg->numOfColRefs;
570,710✔
674
  int32_t pTagRefSize = (msg->pTagRefs && msg->numOfTagRefs > 0) ? sizeof(SColRef) * msg->numOfTagRefs : 0;
570,710✔
675

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

682
  pTableMeta->vgId = msg->vgId;
570,710✔
683
  pTableMeta->tableType = msg->tableType;
570,710✔
684
  pTableMeta->uid = msg->tuid;
570,710✔
685
  pTableMeta->suid = msg->suid;
570,710✔
686
  pTableMeta->numOfColRefs = msg->numOfColRefs;
570,710✔
687
  pTableMeta->rversion = msg->rversion;
570,710✔
688

689
  pTableMeta->colRef = (SColRef *)((char *)pTableMeta + sizeof(SVCTableMeta));
570,710✔
690
  memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
570,710✔
691

692
  if (pTagRefSize > 0) {
570,710✔
693
    pTableMeta->tagRef = (SColRef *)((char *)pTableMeta + sizeof(SVCTableMeta) + pColRefSize);
×
694
    memcpy(pTableMeta->tagRef, msg->pTagRefs, pTagRefSize);
×
695
    pTableMeta->numOfTagRefs = msg->numOfTagRefs;
×
696
  } else {
697
    pTableMeta->tagRef = NULL;
570,710✔
698
    pTableMeta->numOfTagRefs = 0;
570,710✔
699
  }
700

701
  qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, (pTableMeta)->uid,
570,710✔
702
         (pTableMeta)->tableType, (pTableMeta)->vgId, msg->dbFName, (pTableMeta)->suid);
703

704
  *pMeta = pTableMeta;
570,710✔
705
  return TSDB_CODE_SUCCESS;
570,710✔
706
}
707

708
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
56,101,913✔
709
  QUERY_PARAM_CHECK(msg);
56,101,913✔
710
  QUERY_PARAM_CHECK(pMeta);
56,101,913✔
711
  int32_t total = msg->numOfColumns + msg->numOfTags;
56,101,913✔
712
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
56,101,521✔
713
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
56,101,521✔
714
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) ? sizeof(SColRef) * msg->numOfColRefs : 0;
56,101,492✔
715
  int32_t pTagRefSize = (hasRefCol(msg->tableType) && msg->pTagRefs && !isStb) ? sizeof(SColRef) * msg->numOfTagRefs : 0;
56,101,913✔
716

717
  int32_t sz = metaSize + schemaExtSize + pColRefSize + pTagRefSize;
56,101,864✔
718
  STableMeta *pTableMeta = taosMemoryCalloc(1, sz);
56,101,864✔
719
  if (NULL == pTableMeta) {
56,099,145✔
720
    qError("calloc size[%d] failed since %s", sz, tstrerror(terrno));
×
721
    return terrno;
×
722
  }
723
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
56,099,145✔
724
  // SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
725
  // SColRef    *pTagRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize + pColRefSize);
726

727
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
56,099,816✔
728
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
56,101,939✔
729
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
56,101,942✔
730
  pTableMeta->suid = msg->suid;
56,100,876✔
731
  pTableMeta->sversion = msg->sversion;
56,100,879✔
732
  pTableMeta->tversion = msg->tversion;
56,100,487✔
733
  pTableMeta->rversion = msg->rversion;
56,100,879✔
734
  pTableMeta->ownerId = msg->ownerId;
56,100,879✔
735
  pTableMeta->flag = msg->flag;
56,098,753✔
736
  pTableMeta->secureDelete = msg->secureDelete;
56,100,487✔
737
  if (msg->virtualStb) {
56,100,597✔
738
    pTableMeta->virtualStb = 1;
540,087✔
739
    pTableMeta->numOfColRefs = 0;
540,087✔
740
  } else {
741
    if (msg->tableType == TSDB_VIRTUAL_CHILD_TABLE && isStb) {
55,560,005✔
742
      pTableMeta->virtualStb = 1;
224,443✔
743
      pTableMeta->numOfColRefs = 0;
224,443✔
744
    } else {
745
      pTableMeta->virtualStb = 0;
55,337,409✔
746
      pTableMeta->numOfColRefs = msg->numOfColRefs;
55,337,409✔
747
    }
748
  }
749

750
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
56,101,942✔
751
  pTableMeta->tableInfo.precision = msg->precision;
56,101,158✔
752
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
56,101,550✔
753

754
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
56,101,942✔
755
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
56,101,158✔
756
    pTableMeta->schemaExt = pSchemaExt;
53,304,246✔
757
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
53,304,638✔
758
  } else {
759
    pTableMeta->schemaExt = NULL;
2,797,696✔
760
  }
761

762
  if (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) {
56,100,879✔
763
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
608,743✔
764
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
608,743✔
765
  } else {
766
    pTableMeta->colRef = NULL;
55,493,185✔
767
  }
768

769
  if (hasRefCol(msg->tableType) && msg->pTagRefs && !isStb) {
56,101,928✔
770
    pTableMeta->tagRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize + pColRefSize);
×
771
    memcpy(pTableMeta->tagRef, msg->pTagRefs, pTagRefSize);
×
772
    pTableMeta->numOfTagRefs = msg->numOfTagRefs;
×
773
  } else {
774
    pTableMeta->tagRef = NULL;
56,101,158✔
775
    pTableMeta->numOfTagRefs = 0;
56,101,942✔
776
  }
777

778
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
56,101,942✔
779
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,147,483,647✔
780
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,147,483,647✔
781
    if (hasPK && (i > 0)) {
2,147,483,647✔
782
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
530,676✔
783
        ++pTableMeta->tableInfo.numOfPKs;
267,861✔
784
      } else {
785
        hasPK = false;
262,815✔
786
      }
787
    }
788
  }
789

790
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
56,100,600✔
791
         " sver:%d tver:%d"
792
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
793
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
794
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
795
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
796

797
  *pMeta = pTableMeta;
56,101,271✔
798
  return TSDB_CODE_SUCCESS;
56,101,942✔
799
}
800

801
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
161,577✔
802
  QUERY_PARAM_CHECK(msg);
161,577✔
803
  QUERY_PARAM_CHECK(pMeta);
161,577✔
804
  int32_t total = msg->numOfColumns + msg->numOfTags;
161,577✔
805
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
161,577✔
806
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
161,577✔
807
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs) ? sizeof(SColRef) * msg->numOfColRefs : 0;
161,577✔
808
  int32_t tbNameSize = strlen(msg->tbName) + 1;
161,577✔
809

810
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + pColRefSize + tbNameSize);
161,577✔
811
  if (NULL == pTableMeta) {
161,577✔
812
    qError("calloc size[%d] failed", metaSize);
×
813
    return terrno;
×
814
  }
815
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
161,577✔
816
  SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
161,577✔
817

818
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
161,577✔
819
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
161,577✔
820
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
161,577✔
821
  pTableMeta->suid = msg->suid;
161,577✔
822
  pTableMeta->sversion = msg->sversion;
161,577✔
823
  pTableMeta->tversion = msg->tversion;
161,577✔
824
  pTableMeta->rversion = msg->rversion;
161,577✔
825
  pTableMeta->virtualStb = msg->virtualStb;
161,577✔
826
  pTableMeta->numOfColRefs = msg->numOfColRefs;
161,577✔
827
  pTableMeta->ownerId = msg->ownerId;
161,577✔
828
  pTableMeta->secureDelete = msg->secureDelete;
161,577✔
829

830
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
161,577✔
831
  pTableMeta->tableInfo.precision = msg->precision;
161,577✔
832
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
161,577✔
833

834
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
161,577✔
835
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
161,577✔
836
    pTableMeta->schemaExt = pSchemaExt;
161,577✔
837
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
161,577✔
838
  } else {
839
    pTableMeta->schemaExt = NULL;
×
840
  }
841

842
  if (hasRefCol(msg->tableType) && msg->pColRefs) {
161,577✔
843
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
×
844
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
×
845
  } else {
846
    pTableMeta->colRef = NULL;
161,577✔
847
  }
848

849
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
161,577✔
850
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
523,107✔
851
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
361,530✔
852
    if (hasPK && (i > 0)) {
361,530✔
853
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
854
        ++pTableMeta->tableInfo.numOfPKs;
×
855
      } else {
856
        hasPK = false;
×
857
      }
858
    }
859
  }
860

861
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize + pColRefSize;
161,577✔
862
  tstrncpy(pTbName, msg->tbName, tbNameSize);
161,577✔
863

864
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
161,577✔
865
         " sver:%d tver:%d"
866
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
867
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
868
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
869
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
870

871
  *pMeta = pTableMeta;
161,577✔
872
  return TSDB_CODE_SUCCESS;
161,577✔
873
}
874

875
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
38,412,887✔
876
  int32_t       code = 0;
38,412,887✔
877
  STableMetaRsp metaRsp = {0};
38,412,887✔
878

879
  if (NULL == output || NULL == msg || msgSize <= 0) {
38,412,940✔
880
    qError("queryProcessTableMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
881
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
882
    goto PROCESS_META_OVER;
×
883
  }
884

885
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
38,412,940✔
886
    code = TSDB_CODE_INVALID_MSG;
×
887
    goto PROCESS_META_OVER;
×
888
  }
889

890
  code = queryConvertTableMetaMsg(&metaRsp);
38,412,940✔
891
  if (code != TSDB_CODE_SUCCESS) {
38,412,940✔
892
    goto PROCESS_META_OVER;
×
893
  }
894

895
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
115,101,567✔
896
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
76,464,184✔
897
                    metaRsp.virtualStb);
38,051,244✔
898
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
38,412,940✔
899
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
36,449,507✔
900
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
901
    goto PROCESS_META_OVER;
×
902
  }
903

904
  STableMetaOutput *pOut = output;
38,412,878✔
905
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
38,412,878✔
906
  pOut->dbId = metaRsp.dbId;
38,412,907✔
907

908
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
38,412,882✔
909
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
12,934,913✔
910

911
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
12,934,913✔
912
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
12,934,909✔
913

914
    pOut->ctbMeta.vgId = metaRsp.vgId;
12,934,880✔
915
    pOut->ctbMeta.tableType = metaRsp.tableType;
12,934,913✔
916
    pOut->ctbMeta.uid = metaRsp.tuid;
12,934,517✔
917
    pOut->ctbMeta.suid = metaRsp.suid;
12,934,942✔
918

919
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
12,934,488✔
920
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
25,477,969✔
921
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
224,443✔
922

923
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
224,443✔
924
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
224,443✔
925

926
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
224,443✔
927
    if (TSDB_CODE_SUCCESS != code) {
224,443✔
928
      goto PROCESS_META_OVER;
×
929
    }
930
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
224,443✔
931
  } else {
932
    SET_META_TYPE_TABLE(pOut->metaType);
25,253,526✔
933
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
25,253,526✔
934
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
25,253,526✔
935
  }
936

937
PROCESS_META_OVER:
38,412,940✔
938
  if (code != 0) {
38,412,940✔
939
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
940
  }
941

942
  tFreeSTableMetaRsp(&metaRsp);
38,412,940✔
943
  return code;
38,412,940✔
944
}
945

946
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
161,577✔
947
  int32_t       code = 0;
161,577✔
948
  STableMetaRsp metaRsp = {0};
161,577✔
949

950
  if (NULL == output || NULL == msg || msgSize <= 0) {
161,577✔
951
    qError("queryProcessTableNameRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
952
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
953
    goto PROCESS_NAME_OVER;
×
954
  }
955

956
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
161,577✔
957
    code = TSDB_CODE_INVALID_MSG;
×
958
    goto PROCESS_NAME_OVER;
×
959
  }
960

961
  code = queryConvertTableMetaMsg(&metaRsp);
161,577✔
962
  if (code != TSDB_CODE_SUCCESS) {
161,577✔
963
    goto PROCESS_NAME_OVER;
×
964
  }
965

966
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
484,731✔
967
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
323,154✔
968
                    metaRsp.virtualStb);
161,577✔
969

970
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
161,577✔
971
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
161,577✔
972
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
973
    goto PROCESS_NAME_OVER;
×
974
  }
975

976
  STableMetaOutput *pOut = output;
161,577✔
977
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
161,577✔
978
  pOut->dbId = metaRsp.dbId;
161,577✔
979

980
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
161,577✔
981
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
40,539✔
982

983
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
40,539✔
984
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
40,539✔
985

986
    pOut->ctbMeta.vgId = metaRsp.vgId;
40,539✔
987
    pOut->ctbMeta.tableType = metaRsp.tableType;
40,539✔
988
    pOut->ctbMeta.uid = metaRsp.tuid;
40,539✔
989
    pOut->ctbMeta.suid = metaRsp.suid;
40,539✔
990

991
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
40,539✔
992
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
121,038✔
993
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
×
994

995
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
×
996
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
×
997

998
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
×
999
    if (TSDB_CODE_SUCCESS != code) {
×
1000
      goto PROCESS_NAME_OVER;
×
1001
    }
1002

1003
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
×
1004
  } else {
1005
    SET_META_TYPE_TABLE(pOut->metaType);
121,038✔
1006
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
121,038✔
1007
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
121,038✔
1008
  }
1009

1010
PROCESS_NAME_OVER:
161,577✔
1011
  if (code != 0) {
161,577✔
1012
    qError("failed to process table name rsp since %s", tstrerror(code));
×
1013
  }
1014

1015
  tFreeSTableMetaRsp(&metaRsp);
161,577✔
1016
  return code;
161,577✔
1017
}
1018

1019
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
52,749✔
1020
  SQnodeListRsp out = {0};
52,749✔
1021
  int32_t       code = 0;
52,749✔
1022

1023
  if (NULL == output || NULL == msg || msgSize <= 0) {
52,749✔
1024
    qError("queryProcessQnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1025
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1026
    return code;
×
1027
  }
1028

1029
  out.qnodeList = (SArray *)output;
52,749✔
1030
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
52,749✔
1031
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
1032
    code = TSDB_CODE_INVALID_MSG;
×
1033
    return code;
×
1034
  }
1035

1036
  return code;
52,749✔
1037
}
1038

1039
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
40,641✔
1040
  SDnodeListRsp out = {0};
40,641✔
1041
  int32_t       code = 0;
40,641✔
1042

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

1049
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
40,641✔
1050
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
1051
    code = TSDB_CODE_INVALID_MSG;
×
1052
    return code;
×
1053
  }
1054

1055
  *(SArray **)output = out.dnodeList;
40,641✔
1056

1057
  return code;
40,641✔
1058
}
1059

UNCOV
1060
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
×
UNCOV
1061
  SServerVerRsp out = {0};
×
UNCOV
1062
  int32_t       code = 0;
×
1063

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

UNCOV
1070
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
×
1071
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
1072
    code = TSDB_CODE_INVALID_MSG;
×
1073
    return code;
×
1074
  }
1075

UNCOV
1076
  *(char **)output = taosStrdup(out.ver);
×
UNCOV
1077
  if (NULL == *(char **)output) {
×
1078
    return terrno;
×
1079
  }
1080

UNCOV
1081
  return code;
×
1082
}
1083

1084
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
4,604,092✔
1085
  SDbCfgRsp out = {0};
4,604,092✔
1086

1087
  if (NULL == output || NULL == msg || msgSize <= 0) {
4,604,092✔
1088
    qError("queryProcessGetDbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1089
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1090
  }
1091

1092
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
4,604,092✔
1093
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d, dbCfgRsp:%lu", msgSize, sizeof(out));
×
1094
    return TSDB_CODE_INVALID_MSG;
×
1095
  }
1096

1097
  memcpy(output, &out, sizeof(out));
4,604,092✔
1098

1099
  return TSDB_CODE_SUCCESS;
4,604,092✔
1100
}
1101

1102
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
1103
  SUserIndexRsp out = {0};
×
1104

1105
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1106
    qError("queryProcessGetIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1107
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1108
  }
1109

1110
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
1111
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
1112
    return TSDB_CODE_INVALID_MSG;
×
1113
  }
1114

1115
  memcpy(output, &out, sizeof(out));
×
1116

1117
  return TSDB_CODE_SUCCESS;
×
1118
}
1119

1120
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
142,020✔
1121
  SRetrieveFuncRsp out = {0};
142,020✔
1122

1123
  if (NULL == output || NULL == msg || msgSize <= 0) {
142,020✔
1124
    qError("queryProcessRetrieveFuncRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1125
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1126
  }
1127

1128
  if (tDeserializeSRetrieveFuncRsp(msg, msgSize, &out) != 0) {
142,020✔
1129
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
1130
    return TSDB_CODE_INVALID_MSG;
×
1131
  }
1132

1133
  if (1 != out.numOfFuncs) {
142,020✔
1134
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
1135
    return TSDB_CODE_INVALID_MSG;
×
1136
  }
1137

1138
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
142,020✔
1139

1140
  memcpy(output, funcInfo, sizeof(*funcInfo));
142,020✔
1141
  taosArrayDestroy(out.pFuncInfos);
142,020✔
1142
  taosArrayDestroy(out.pFuncExtraInfos);
142,020✔
1143

1144
  return TSDB_CODE_SUCCESS;
142,020✔
1145
}
1146

1147
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
6,264,383✔
1148
  if (NULL == output || NULL == msg || msgSize <= 0) {
6,264,383✔
1149
    qError("queryProcessGetUserAuthRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1150
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1151
  }
1152

1153
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
6,264,383✔
1154
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
1155
    return TSDB_CODE_INVALID_MSG;
×
1156
  }
1157

1158
  return TSDB_CODE_SUCCESS;
6,264,383✔
1159
}
1160

UNCOV
1161
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
×
UNCOV
1162
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1163
    qError("queryProcessGetTbIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1164
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1165
  }
1166

UNCOV
1167
  STableIndexRsp *out = (STableIndexRsp *)output;
×
UNCOV
1168
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
×
1169
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
1170
    return TSDB_CODE_INVALID_MSG;
×
1171
  }
1172

UNCOV
1173
  return TSDB_CODE_SUCCESS;
×
1174
}
1175

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

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

1193
  *(STableCfgRsp **)output = out;
95,929✔
1194

1195
  return TSDB_CODE_SUCCESS;
95,929✔
1196
}
1197

1198
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
239,584✔
1199
  if (NULL == output || NULL == msg || msgSize <= 0) {
239,584✔
1200
    qError("queryProcessGetViewMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1201
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1202
  }
1203

1204
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
239,584✔
1205
  if (out == NULL) {
239,584✔
1206
    return terrno;
×
1207
  }
1208
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
239,584✔
1209
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
1210
    tFreeSViewMetaRsp(out);
×
1211
    taosMemoryFree(out);
×
1212
    return TSDB_CODE_INVALID_MSG;
×
1213
  }
1214

1215
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
239,584✔
1216

1217
  *(SViewMetaRsp **)output = out;
239,584✔
1218

1219
  return TSDB_CODE_SUCCESS;
239,584✔
1220
}
1221

1222
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
5,108✔
1223
  if (NULL == output || NULL == msg || msgSize <= 0) {
5,108✔
1224
    qError("queryProcessGetTbTSMARsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1225
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1226
  }
1227

1228
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
5,108✔
1229
    qError("tDeserializeTbTSMARsp failed, msgSize:%d", msgSize);
×
1230
    return TSDB_CODE_INVALID_MSG;
×
1231
  }
1232

1233
  return TSDB_CODE_SUCCESS;
5,108✔
1234
}
1235

1236
static int32_t queryProcessGetRsmaRsp(void* output, char* msg, int32_t msgSize) {
18,466✔
1237
  if (NULL == output || NULL == msg || msgSize <= 0) {
18,466✔
1238
    qError("queryProcessGetRsmaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1239
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1240
  }
1241

1242
  if (tDeserializeRsmaInfoRsp(msg, msgSize, output) != 0) {
18,466✔
1243
    qError("tDeserializeRsmaInfoRsp failed, msgSize:%d", msgSize);
×
1244
    return TSDB_CODE_INVALID_MSG;
×
1245
  }
1246

1247
  return TSDB_CODE_SUCCESS;
18,466✔
1248
}
1249

1250
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
5,640✔
1251
  if (!output || !msg || msgSize <= 0) {
5,640✔
1252
    qError("queryProcessStreamProgressRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1253
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1254
  }
1255

1256
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
5,640✔
1257
    qError("tDeserializeStreamProgressRsp failed, msgSize:%d", msgSize);
×
1258
    return TSDB_CODE_INVALID_MSG;
×
1259
  }
1260
  return TSDB_CODE_SUCCESS;
5,640✔
1261
}
1262

1263
int32_t queryProcessVSubTablesRsp(void* output, char* msg, int32_t msgSize) {
×
1264
  if (!output || !msg || msgSize <= 0) {
×
1265
    qError("queryProcessVSubTablesRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1266
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1267
  }
1268

1269
  SVSubTablesRsp* pRsp = (SVSubTablesRsp*)output;
×
1270
  int32_t code = tDeserializeSVSubTablesRsp(msg, msgSize, pRsp);
×
1271
  if (code != 0) {
×
1272
    qError("tDeserializeSVSubTablesRsp failed, msgSize: %d, error:%d", msgSize, code);
×
1273
    return code;
×
1274
  }
1275
  
1276
  return TSDB_CODE_SUCCESS;
×
1277
}
1278

1279
int32_t queryProcessVStbRefDbsRsp(void* output, char* msg, int32_t msgSize) {
6,980,933✔
1280
  if (!output || !msg || msgSize <= 0) {
6,980,933✔
1281
    qError("queryProcessVStbRefDbsRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1282
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1283
  }
1284

1285
  SVStbRefDbsRsp * pRsp = (SVStbRefDbsRsp*)output;
6,980,933✔
1286
  int32_t code = tDeserializeSVStbRefDbsRsp(msg, msgSize, pRsp);
6,980,933✔
1287
  if (code != 0) {
6,976,993✔
1288
    qError("tDeserializeSVStbRefDbsRsp failed, msgSize: %d, error:%d", msgSize, code);
×
1289
    return code;
×
1290
  }
1291

1292
  return TSDB_CODE_SUCCESS;
6,977,631✔
1293
}
1294

1295
void initQueryModuleMsgHandle() {
1,381,911✔
1296
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,381,911✔
1297
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryBuildTableMetaReqMsg;
1,381,911✔
1298
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,381,911✔
1299
  queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg;
1,381,911✔
1300
  queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg;
1,381,911✔
1301
  queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg;
1,381,911✔
1302
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg;
1,381,911✔
1303
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg;
1,381,911✔
1304
  queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg;
1,381,911✔
1305
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg;
1,381,911✔
1306
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg;
1,381,911✔
1307
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,381,911✔
1308
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,381,911✔
1309
  queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg;
1,381,911✔
1310
  queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg;
1,381,911✔
1311
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryBuildGetTableTSMAMsg;
1,381,911✔
1312
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryBuildGetTSMAMsg;
1,381,911✔
1313
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryBuildGetRsmaMsg;
1,381,911✔
1314
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryBuildGetStreamProgressMsg;
1,381,911✔
1315
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryBuildVSubTablesMsg;
1,381,911✔
1316
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryBuildVStbRefDBsMsg;
1,381,911✔
1317

1318
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
1,381,911✔
1319
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryProcessTableNameRsp;
1,381,911✔
1320
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp;
1,381,911✔
1321
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
1,381,911✔
1322
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp;
1,381,911✔
1323
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp;
1,381,911✔
1324
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp;
1,381,911✔
1325
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp;
1,381,911✔
1326
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp;
1,381,911✔
1327
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp;
1,381,911✔
1328
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp;
1,381,911✔
1329
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,381,911✔
1330
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,381,911✔
1331
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp;
1,381,911✔
1332
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp;
1,381,911✔
1333
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp;
1,381,911✔
1334
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp;
1,381,911✔
1335
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryProcessGetRsmaRsp;
1,381,911✔
1336
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp;
1,381,911✔
1337
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryProcessVSubTablesRsp;
1,381,911✔
1338
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryProcessVStbRefDbsRsp;
1,381,911✔
1339
}
1,381,911✔
1340

1341
#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