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

taosdata / TDengine / #3558

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

push

travis-ci

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

merge: form main to 3.0 branch

132787 of 287595 branches covered (46.17%)

Branch coverage included in aggregate %.

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

6085 existing lines in 168 files now uncovered.

209348 of 284746 relevant lines covered (73.52%)

8164844.48 hits per line

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

49.79
/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 "systable.h"
19
#include "tmsg.h"
20
#include "trpc.h"
21

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

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

31
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
53,052✔
32
  QUERY_PARAM_CHECK(pOut);
53,052!
33
  QUERY_PARAM_CHECK(usedbRsp);
53,052!
34
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
53,052✔
35
  pOut->dbId = usedbRsp->uid;
53,052✔
36

37
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
53,052!
38
  if (NULL == pOut->dbVgroup) {
53,052!
39
    return terrno;
×
40
  }
41

42
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
53,052✔
43
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
53,052✔
44
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
53,052✔
45
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
53,052✔
46
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
53,052✔
47

48
  qDebug("Got %d vgroup for db %s, vgVersion:%d, stateTs:%" PRId64, usedbRsp->vgNum, usedbRsp->db, usedbRsp->vgVersion,
53,052✔
49
         usedbRsp->stateTs);
50

51
  if (usedbRsp->vgNum <= 0) {
53,051✔
52
    return TSDB_CODE_SUCCESS;
7,183✔
53
  }
54

55
  pOut->dbVgroup->vgHash =
91,739✔
56
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
45,868✔
57
  if (NULL == pOut->dbVgroup->vgHash) {
45,870!
58
    return terrno;
×
59
  }
60

61
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
158,556✔
62
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
112,684✔
63
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
112,685✔
64
    qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
112,685✔
65
           pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port);
66
    if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) {
112,685!
67
      return terrno;
×
68
    }
69
  }
70

71
  return TSDB_CODE_SUCCESS;
45,872✔
72
}
73

74
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
57,030✔
75
                                  void *(*mallcFp)(int64_t)) {
76
  QUERY_PARAM_CHECK(input);
57,030!
77
  QUERY_PARAM_CHECK(msg);
57,030!
78
  QUERY_PARAM_CHECK(msgLen);
57,030!
79
  SBuildTableInput *pInput = input;
57,030✔
80

81
  STableInfoReq infoReq = {0};
57,030✔
82
  infoReq.option = pInput->option;
57,030✔
83
  infoReq.header.vgId = pInput->vgId;
57,030✔
84
  if (pInput->dbFName) {
57,030!
85
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
57,033✔
86
  }
87
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
57,030✔
88

89
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
57,030✔
90
  void   *pBuf = (*mallcFp)(bufLen);
57,039✔
91
  if (NULL == pBuf) {
57,041!
92
    return terrno;
×
93
  }
94
  if(tSerializeSTableInfoReq(pBuf, bufLen, &infoReq) < 0)
57,041!
95
  {
96
    return TSDB_CODE_TSC_INVALID_INPUT;
×
97
  }
98

99
  *msg = pBuf;
57,040✔
100
  *msgLen = bufLen;
57,040✔
101

102
  return TSDB_CODE_SUCCESS;
57,040✔
103
}
104

105
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
47,795✔
106
  QUERY_PARAM_CHECK(input);
47,795!
107
  QUERY_PARAM_CHECK(msg);
47,795!
108
  QUERY_PARAM_CHECK(msgLen);
47,795!
109
  SBuildUseDBInput *pInput = input;
47,795✔
110

111
  SUseDbReq usedbReq = {0};
47,795✔
112
  tstrncpy(usedbReq.db, pInput->db, TSDB_DB_FNAME_LEN);
47,795✔
113
  usedbReq.db[sizeof(usedbReq.db) - 1] = 0;
47,795✔
114
  usedbReq.vgVersion = pInput->vgVersion;
47,795✔
115
  usedbReq.dbId = pInput->dbId;
47,795✔
116
  usedbReq.numOfTable = pInput->numOfTable;
47,795✔
117
  usedbReq.stateTs = pInput->stateTs;
47,795✔
118

119
  int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
47,795✔
120
  void   *pBuf = (*mallcFp)(bufLen);
47,795✔
121
  if (NULL == pBuf) {
47,795!
122
    return terrno;
×
123
  }
124
  if(tSerializeSUseDbReq(pBuf, bufLen, &usedbReq) < 0)
47,795!
125
  {
126
    return TSDB_CODE_TSC_INVALID_INPUT;
×
127
  }
128

129
  *msg = pBuf;
47,796✔
130
  *msgLen = bufLen;
47,796✔
131

132
  return TSDB_CODE_SUCCESS;
47,796✔
133
}
134

135
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
9,910✔
136
  QUERY_PARAM_CHECK(msg);
9,910!
137
  QUERY_PARAM_CHECK(msgLen);
9,910!
138

139
  SQnodeListReq qnodeListReq = {0};
9,910✔
140
  qnodeListReq.rowNum = -1;
9,910✔
141

142
  int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
9,910✔
143
  void   *pBuf = (*mallcFp)(bufLen);
9,910✔
144
  if (NULL == pBuf) {
9,910!
145
    return terrno;
×
146
  }
147
  if(tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq) < 0)
9,910!
148
  {
149
    return TSDB_CODE_TSC_INVALID_INPUT;
×
150
  }
151

152
  *msg = pBuf;
9,910✔
153
  *msgLen = bufLen;
9,910✔
154

155
  return TSDB_CODE_SUCCESS;
9,910✔
156
}
157

158
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
347✔
159
  QUERY_PARAM_CHECK(msg);
347!
160
  QUERY_PARAM_CHECK(msgLen);
347!
161

162
  SDnodeListReq dnodeListReq = {0};
347✔
163
  dnodeListReq.rowNum = -1;
347✔
164

165
  int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
347✔
166
  void   *pBuf = (*mallcFp)(bufLen);
347✔
167
  if (NULL == pBuf) {
347!
168
    return terrno;
×
169
  }
170
  if(tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq) < 0)
347!
171
  {
172
    return TSDB_CODE_TSC_INVALID_INPUT;
×
173
  }
174

175
  *msg = pBuf;
347✔
176
  *msgLen = bufLen;
347✔
177

178
  return TSDB_CODE_SUCCESS;
347✔
179
}
180

181
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
×
182
  QUERY_PARAM_CHECK(msg);
×
183
  QUERY_PARAM_CHECK(msgLen);
×
184

185
  SServerVerReq req = {0};
×
186

187
  int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
×
188
  void   *pBuf = (*mallcFp)(bufLen);
×
189
  if (NULL == pBuf) {
×
190
    return terrno;
×
191
  }
192
  if(tSerializeSServerVerReq(pBuf, bufLen, &req) < 0)
×
193
  {
194
    return TSDB_CODE_TSC_INVALID_INPUT;
×
195
  }
196

197
  *msg = pBuf;
×
198
  *msgLen = bufLen;
×
199

200
  return TSDB_CODE_SUCCESS;
×
201
}
202

203
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
2,806✔
204
  QUERY_PARAM_CHECK(input);
2,806!
205
  QUERY_PARAM_CHECK(msg);
2,806!
206
  QUERY_PARAM_CHECK(msgLen);
2,806!
207

208
  SDbCfgReq dbCfgReq = {0};
2,806✔
209
  tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
2,806✔
210

211
  int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
2,806✔
212
  void   *pBuf = (*mallcFp)(bufLen);
2,806✔
213
  if (NULL == pBuf) {
2,806!
214
    return terrno;
×
215
  }
216
  if(tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq) < 0)
2,806!
217
  {
218
    return TSDB_CODE_TSC_INVALID_INPUT;
×
219
  }
220

221
  *msg = pBuf;
2,806✔
222
  *msgLen = bufLen;
2,806✔
223

224
  return TSDB_CODE_SUCCESS;
2,806✔
225
}
226

227
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
×
228
  QUERY_PARAM_CHECK(input);
×
229
  QUERY_PARAM_CHECK(msg);
×
230
  QUERY_PARAM_CHECK(msgLen);
×
231

232
  SUserIndexReq indexReq = {0};
×
233
  tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
×
234

235
  int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
×
236
  void   *pBuf = (*mallcFp)(bufLen);
×
237
  if (NULL == pBuf) {
×
238
    return terrno;
×
239
  }
240
  if(tSerializeSUserIndexReq(pBuf, bufLen, &indexReq) < 0)
×
241
  {
242
    return TSDB_CODE_TSC_INVALID_INPUT;
×
243
  }
244

245
  *msg = pBuf;
×
246
  *msgLen = bufLen;
×
247

248
  return TSDB_CODE_SUCCESS;
×
249
}
250

251
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
96✔
252
                                  void *(*mallcFp)(int64_t)) {
253
  QUERY_PARAM_CHECK(input);
96!
254
  QUERY_PARAM_CHECK(msg);
96!
255
  QUERY_PARAM_CHECK(msgLen);
96!
256

257
  SRetrieveFuncReq funcReq = {0};
96✔
258
  funcReq.numOfFuncs = 1;
96✔
259
  funcReq.ignoreCodeComment = true;
96✔
260
  funcReq.pFuncNames = taosArrayInit(1, strlen(input) + 1);
96✔
261
  if (NULL == funcReq.pFuncNames) {
96!
262
    return terrno;
×
263
  }
264
  if (taosArrayPush(funcReq.pFuncNames, input) == NULL) {
192!
265
    taosArrayDestroy(funcReq.pFuncNames);
×
266
    return terrno;
×
267
  }
268

269
  int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
96✔
270
  void   *pBuf = (*mallcFp)(bufLen);
96✔
271
  if (NULL == pBuf) {
96!
272
    taosArrayDestroy(funcReq.pFuncNames);
×
273
    return terrno;
×
274
  }
275
  if(tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq) < 0)
96!
276
  {
277
    taosArrayDestroy(funcReq.pFuncNames);
×
278
    return TSDB_CODE_TSC_INVALID_INPUT;
×
279
  }
280

281
  taosArrayDestroy(funcReq.pFuncNames);
96✔
282

283
  *msg = pBuf;
96✔
284
  *msgLen = bufLen;
96✔
285

286
  return TSDB_CODE_SUCCESS;
96✔
287
}
288

289
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
4,218✔
290
  QUERY_PARAM_CHECK(input);
4,218!
291
  QUERY_PARAM_CHECK(msg);
4,218!
292
  QUERY_PARAM_CHECK(msgLen);
4,218!
293

294
  SGetUserAuthReq req = {0};
4,218✔
295
  tstrncpy(req.user, input, TSDB_USER_LEN);
4,218✔
296

297
  int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
4,218✔
298
  void   *pBuf = (*mallcFp)(bufLen);
4,218✔
299
  if (NULL == pBuf) {
4,218!
300
    return terrno;
×
301
  }
302
  if (tSerializeSGetUserAuthReq(pBuf, bufLen, &req) < 0) {
4,218!
303
    return TSDB_CODE_TSC_INVALID_INPUT;
×
304
  }
305

306
  *msg = pBuf;
4,219✔
307
  *msgLen = bufLen;
4,219✔
308

309
  return TSDB_CODE_SUCCESS;
4,219✔
310
}
311

312
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
7,260✔
313
  QUERY_PARAM_CHECK(input);
7,260!
314
  QUERY_PARAM_CHECK(msg);
7,260!
315
  QUERY_PARAM_CHECK(msgLen);
7,260!
316

317
  STableIndexReq indexReq = {0};
7,260✔
318
  tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
7,260✔
319

320
  int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
7,260✔
321
  void   *pBuf = (*mallcFp)(bufLen);
7,260✔
322
  if (NULL == pBuf) {
7,260!
323
    return terrno;
×
324
  }
325
  if(tSerializeSTableIndexReq(pBuf, bufLen, &indexReq) < 0)
7,260!
326
  {
327
    return TSDB_CODE_TSC_INVALID_INPUT;
×
328
  }
329

330
  *msg = pBuf;
7,260✔
331
  *msgLen = bufLen;
7,260✔
332

333
  return TSDB_CODE_SUCCESS;
7,260✔
334
}
335

336
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
93✔
337
  QUERY_PARAM_CHECK(input);
93!
338
  QUERY_PARAM_CHECK(msg);
93!
339
  QUERY_PARAM_CHECK(msgLen);
93!
340

341
  SBuildTableInput *pInput = input;
93✔
342
  STableCfgReq      cfgReq = {0};
93✔
343
  cfgReq.header.vgId = pInput->vgId;
93✔
344
  tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
93✔
345
  tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
93✔
346

347
  int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
93✔
348
  void   *pBuf = (*mallcFp)(bufLen);
93✔
349
  if (NULL == pBuf) {
93!
350
    return terrno;
×
351
  }
352
  if(tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq) < 0)
93!
353
  {
354
    return TSDB_CODE_TSC_INVALID_INPUT;
×
355
  }
356

357
  *msg = pBuf;
93✔
358
  *msgLen = bufLen;
93✔
359

360
  return TSDB_CODE_SUCCESS;
93✔
361
}
362

363
int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
18,241✔
364
  QUERY_PARAM_CHECK(input);
18,241!
365
  QUERY_PARAM_CHECK(msg);
18,241!
366
  QUERY_PARAM_CHECK(msgLen);
18,241!
367

368
  SViewMetaReq req = {0};
18,241✔
369
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
18,241✔
370

371
  int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
18,241✔
372
  void   *pBuf = (*mallcFp)(bufLen);
18,241✔
373
  if (NULL == pBuf) {
18,241!
374
    return terrno;
×
375
  }
376
  if(tSerializeSViewMetaReq(pBuf, bufLen, &req) < 0)
18,241!
377
  {
378
    return TSDB_CODE_TSC_INVALID_INPUT;
×
379
  }
380

381
  *msg = pBuf;
18,241✔
382
  *msgLen = bufLen;
18,241✔
383

384
  return TSDB_CODE_SUCCESS;
18,241✔
385
}
386

387
int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
1,026✔
388
                                  void *(*mallcFp)(int64_t)) {
389
  QUERY_PARAM_CHECK(input);
1,026!
390
  QUERY_PARAM_CHECK(msg);
1,026!
391
  QUERY_PARAM_CHECK(msgLen);
1,026!
392

393
  STableTSMAInfoReq req = {0};
1,026✔
394
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
1,026✔
395

396
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
1,026✔
397
  void *  pBuf = (*mallcFp)(bufLen);
1,026✔
398
  if (NULL == pBuf) {
1,026!
399
    return terrno;
×
400
  }
401
  if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
1,026!
402
  {
403
    return TSDB_CODE_TSC_INVALID_INPUT;
×
404
  }
405

406
  *msg = pBuf;
1,026✔
407
  *msgLen = bufLen;
1,026✔
408
  return TSDB_CODE_SUCCESS;
1,026✔
409
}
410

411
int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
72✔
412
                                  void *(*mallcFp)(int64_t)) {
413
  QUERY_PARAM_CHECK(input);
72!
414
  QUERY_PARAM_CHECK(msg);
72!
415
  QUERY_PARAM_CHECK(msgLen);
72!
416

417
  STableTSMAInfoReq req = {0};
72✔
418
  req.fetchingWithTsmaName = true;
72✔
419
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
72✔
420

421
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
72✔
422
  void *  pBuf = (*mallcFp)(bufLen);
72✔
423
  if(pBuf == NULL)
72!
424
  {
425
    return terrno;
×
426
  }
427
  if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
72!
428
  {
429
    return TSDB_CODE_TSC_INVALID_INPUT;
×
430
  }
431

432
  *msg = pBuf;
72✔
433
  *msgLen = bufLen;
72✔
434
  return TSDB_CODE_SUCCESS;
72✔
435
}
436

437
int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int64_t)) {
4,694✔
438
  QUERY_PARAM_CHECK(input);
4,694!
439
  QUERY_PARAM_CHECK(msg);
4,694!
440
  QUERY_PARAM_CHECK(msgLen);
4,694!
441

442
  int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
4,694✔
443
  void* pBuf = (*mallcFp)(len);
4,694✔
444
  if (NULL == pBuf) {
4,694!
445
    return terrno;
×
446
  }
447

448
  if(tSerializeStreamProgressReq(pBuf, len, input) < 0)
4,694!
449
  {
450
    return TSDB_CODE_TSC_INVALID_INPUT;
×
451
  }
452

453
  *msg = pBuf;
4,694✔
454
  *msgLen = len;
4,694✔
455
  return TSDB_CODE_SUCCESS;
4,694✔
456
}
457

458
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
47,350✔
459
  SUseDbOutput *pOut = output;
47,350✔
460
  SUseDbRsp     usedbRsp = {0};
47,350✔
461
  int32_t       code = -1;
47,350✔
462

463
  if (NULL == output || NULL == msg || msgSize <= 0) {
47,350!
UNCOV
464
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
UNCOV
465
    goto PROCESS_USEDB_OVER;
×
466
  }
467

468
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
47,351!
469
    qError("invalid use db rsp msg, msgSize:%d", msgSize);
×
470
    code = TSDB_CODE_INVALID_MSG;
×
471
    goto PROCESS_USEDB_OVER;
×
472
  }
473

474
  if (usedbRsp.vgNum < 0) {
47,350!
475
    qError("invalid db[%s] vgroup number[%d]", usedbRsp.db, usedbRsp.vgNum);
×
476
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
477
    goto PROCESS_USEDB_OVER;
×
478
  }
479

480
  qTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
47,350✔
481
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
154,179✔
482
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
106,830✔
483
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
106,831✔
484
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
216,580✔
485
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
109,750✔
486
    }
487
  }
488

489
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
47,349✔
490

491
PROCESS_USEDB_OVER:
47,349✔
492

493
  if (code != 0) {
47,349!
494
    if (pOut) {
×
495
      if (pOut->dbVgroup) taosHashCleanup(pOut->dbVgroup->vgHash);
×
496
      taosMemoryFreeClear(pOut->dbVgroup);
×
497
    }
498
    qError("failed to process usedb rsp since %s", terrstr());
×
499
  }
500

501
  tFreeSUsedbRsp(&usedbRsp);
47,349✔
502
  return code;
47,348✔
503
}
504

505
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
48,010✔
506
  QUERY_PARAM_CHECK(pMetaMsg);
48,010!
507
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
48,010!
508
    qError("invalid numOfTags[%d] in table meta rsp msg", pMetaMsg->numOfTags);
×
509
    return TSDB_CODE_TSC_INVALID_VALUE;
×
510
  }
511

512
  if (pMetaMsg->numOfColumns > TSDB_MAX_COLUMNS || pMetaMsg->numOfColumns <= 0) {
48,010!
513
    qError("invalid numOfColumns[%d] in table meta rsp msg", pMetaMsg->numOfColumns);
1!
514
    return TSDB_CODE_TSC_INVALID_VALUE;
×
515
  }
516

517
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
48,009✔
518
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE) {
4,494!
519
    qError("invalid tableType[%d] in table meta rsp msg", pMetaMsg->tableType);
×
520
    return TSDB_CODE_TSC_INVALID_VALUE;
×
521
  }
522

523
  if (pMetaMsg->sversion < 0) {
48,009!
524
    qError("invalid sversion[%d] in table meta rsp msg", pMetaMsg->sversion);
×
525
    return TSDB_CODE_TSC_INVALID_VALUE;
×
526
  }
527

528
  if (pMetaMsg->tversion < 0) {
48,009!
529
    qError("invalid tversion[%d] in table meta rsp msg", pMetaMsg->tversion);
×
530
    return TSDB_CODE_TSC_INVALID_VALUE;
×
531
  }
532

533
  if (pMetaMsg->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
48,009!
534
    qError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", pMetaMsg->pSchemas[0].colId);
×
535
    return TSDB_CODE_TSC_INVALID_VALUE;
×
536
  }
537

538
  return TSDB_CODE_SUCCESS;
48,009✔
539
}
540

541
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
88,696✔
542
  QUERY_PARAM_CHECK(msg);
88,696!
543
  QUERY_PARAM_CHECK(pMeta);
88,696!
544
  pMeta->vgId = msg->vgId;
88,696✔
545
  pMeta->tableType = msg->tableType;
88,696✔
546
  pMeta->uid = msg->tuid;
88,696✔
547
  pMeta->suid = msg->suid;
88,696✔
548

549
  qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, pMeta->uid,
88,696✔
550
         pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
551

552
  return TSDB_CODE_SUCCESS;
88,696✔
553
}
554

555
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
67,729✔
556
  QUERY_PARAM_CHECK(msg);
67,729!
557
  QUERY_PARAM_CHECK(pMeta);
67,729!
558
  int32_t total = msg->numOfColumns + msg->numOfTags;
67,729✔
559
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
67,729✔
560
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
67,729!
561

562
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize);
67,728!
563
  if (NULL == pTableMeta) {
67,729!
564
    qError("calloc size[%d] failed", metaSize);
×
565
    return terrno;
×
566
  }
567
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
67,729✔
568

569
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
67,729✔
570
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
67,729✔
571
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
67,729✔
572
  pTableMeta->suid = msg->suid;
67,729✔
573
  pTableMeta->sversion = msg->sversion;
67,729✔
574
  pTableMeta->tversion = msg->tversion;
67,729✔
575

576
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
67,729✔
577
  pTableMeta->tableInfo.precision = msg->precision;
67,729✔
578
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
67,729✔
579

580
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
67,729✔
581
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
67,729!
582
    pTableMeta->schemaExt = pSchemaExt;
66,529✔
583
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
66,529✔
584
  } else {
585
    pTableMeta->schemaExt = NULL;
1,201✔
586
  }
587

588
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
67,730!
589
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
1,990,387✔
590
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
1,922,657✔
591
    if (hasPK && (i > 0)) {
1,922,657✔
592
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
55,401✔
593
        ++pTableMeta->tableInfo.numOfPKs;
27,701✔
594
      } else {
595
        hasPK = false;
27,700✔
596
      }
597
    }
598
  }
599

600
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
67,730✔
601
         " sver %d tver %d"
602
         " tagNum %d colNum %d precision %d rowSize %d",
603
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
604
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
605
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
606

607
  *pMeta = pTableMeta;
67,732✔
608
  return TSDB_CODE_SUCCESS;
67,732✔
609
}
610

611
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
800✔
612
  QUERY_PARAM_CHECK(msg);
800!
613
  QUERY_PARAM_CHECK(pMeta);
800!
614
  int32_t total = msg->numOfColumns + msg->numOfTags;
800✔
615
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
800✔
616
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
800!
617
  int32_t tbNameSize = strlen(msg->tbName) + 1;
800✔
618

619
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + tbNameSize);
800!
620
  if (NULL == pTableMeta) {
800!
621
    qError("calloc size[%d] failed", metaSize);
×
622
    return terrno;
×
623
  }
624
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
800✔
625

626
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
800✔
627
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
800✔
628
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
800✔
629
  pTableMeta->suid = msg->suid;
800✔
630
  pTableMeta->sversion = msg->sversion;
800✔
631
  pTableMeta->tversion = msg->tversion;
800✔
632

633
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
800✔
634
  pTableMeta->tableInfo.precision = msg->precision;
800✔
635
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
800✔
636

637
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
800✔
638
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
800!
639
    pTableMeta->schemaExt = pSchemaExt;
800✔
640
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
800✔
641
  } else {
642
    pTableMeta->schemaExt = NULL;
×
643
  }
644

645
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
800!
646
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,705✔
647
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
1,905✔
648
    if (hasPK && (i > 0)) {
1,905!
649
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
650
        ++pTableMeta->tableInfo.numOfPKs;
×
651
      } else {
652
        hasPK = false;
×
653
      }
654
    }
655
  }
656

657
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize;
800✔
658
  tstrncpy(pTbName, msg->tbName, tbNameSize);
800✔
659

660
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
800!
661
         " sver %d tver %d"
662
         " tagNum %d colNum %d precision %d rowSize %d",
663
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
664
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
665
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
666

667
  *pMeta = pTableMeta;
800✔
668
  return TSDB_CODE_SUCCESS;
800✔
669
}
670

671
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
47,206✔
672
  int32_t       code = 0;
47,206✔
673
  STableMetaRsp metaRsp = {0};
47,206✔
674

675
  if (NULL == output || NULL == msg || msgSize <= 0) {
47,206!
676
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
677
    goto PROCESS_META_OVER;
×
678
  }
679

680
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
47,206!
681
    code = TSDB_CODE_INVALID_MSG;
×
682
    goto PROCESS_META_OVER;
×
683
  }
684

685
  code = queryConvertTableMetaMsg(&metaRsp);
47,211✔
686
  if (code != TSDB_CODE_SUCCESS) {
47,207!
687
    goto PROCESS_META_OVER;
×
688
  }
689

690
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
47,207!
691
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
46,008!
692
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
693
    goto PROCESS_META_OVER;
×
694
  }
695

696
  STableMetaOutput *pOut = output;
47,208✔
697
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
47,208✔
698
  pOut->dbId = metaRsp.dbId;
47,208✔
699

700
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
47,208✔
701
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
33,135✔
702

703
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
33,135✔
704
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
33,135✔
705

706
    pOut->ctbMeta.vgId = metaRsp.vgId;
33,135✔
707
    pOut->ctbMeta.tableType = metaRsp.tableType;
33,135✔
708
    pOut->ctbMeta.uid = metaRsp.tuid;
33,135✔
709
    pOut->ctbMeta.suid = metaRsp.suid;
33,135✔
710

711
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
33,135✔
712
  } else {
713
    SET_META_TYPE_TABLE(pOut->metaType);
14,073✔
714
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
14,073✔
715
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
14,073✔
716
  }
717

718
PROCESS_META_OVER:
47,211✔
719
  if (code != 0) {
47,211!
720
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
721
  }
722

723
  tFreeSTableMetaRsp(&metaRsp);
47,211✔
724
  return code;
47,209✔
725
}
726

727
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
800✔
728
  int32_t       code = 0;
800✔
729
  STableMetaRsp metaRsp = {0};
800✔
730

731
  if (NULL == output || NULL == msg || msgSize <= 0) {
800!
732
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
733
    goto PROCESS_NAME_OVER;
×
734
  }
735

736
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
800!
737
    code = TSDB_CODE_INVALID_MSG;
×
738
    goto PROCESS_NAME_OVER;
×
739
  }
740

741
  code = queryConvertTableMetaMsg(&metaRsp);
800✔
742
  if (code != TSDB_CODE_SUCCESS) {
800!
743
    goto PROCESS_NAME_OVER;
×
744
  }
745

746
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
800!
747
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
800!
748
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
749
    goto PROCESS_NAME_OVER;
×
750
  }
751

752
  STableMetaOutput *pOut = output;
800✔
753
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
800✔
754
  pOut->dbId = metaRsp.dbId;
800✔
755

756
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
800✔
757
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
287✔
758

759
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
287✔
760
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
287✔
761

762
    pOut->ctbMeta.vgId = metaRsp.vgId;
287✔
763
    pOut->ctbMeta.tableType = metaRsp.tableType;
287✔
764
    pOut->ctbMeta.uid = metaRsp.tuid;
287✔
765
    pOut->ctbMeta.suid = metaRsp.suid;
287✔
766

767
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
287✔
768
  } else {
769
    SET_META_TYPE_TABLE(pOut->metaType);
513✔
770
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
513✔
771
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
513✔
772
  }
773

774
PROCESS_NAME_OVER:
800✔
775
  if (code != 0) {
800!
776
    qError("failed to process table name rsp since %s", tstrerror(code));
×
777
  }
778

779
  tFreeSTableMetaRsp(&metaRsp);
800✔
780
  return code;
800✔
781
}
782

783
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
9,910✔
784
  SQnodeListRsp out = {0};
9,910✔
785
  int32_t       code = 0;
9,910✔
786

787
  if (NULL == output || NULL == msg || msgSize <= 0) {
9,910!
788
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
789
    return code;
×
790
  }
791

792
  out.qnodeList = (SArray *)output;
9,910✔
793
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
9,910!
794
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
795
    code = TSDB_CODE_INVALID_MSG;
×
796
    return code;
×
797
  }
798

799
  return code;
9,910✔
800
}
801

802
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
347✔
803
  SDnodeListRsp out = {0};
347✔
804
  int32_t       code = 0;
347✔
805

806
  if (NULL == output || NULL == msg || msgSize <= 0) {
347!
807
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
808
    return code;
×
809
  }
810

811
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
347!
812
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
813
    code = TSDB_CODE_INVALID_MSG;
×
814
    return code;
×
815
  }
816

817
  *(SArray **)output = out.dnodeList;
347✔
818

819
  return code;
347✔
820
}
821

822
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
×
823
  SServerVerRsp out = {0};
×
824
  int32_t       code = 0;
×
825

826
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
827
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
828
    return code;
×
829
  }
830

831
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
×
832
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
833
    code = TSDB_CODE_INVALID_MSG;
×
834
    return code;
×
835
  }
836

837
  *(char **)output = taosStrdup(out.ver);
×
838
  if (NULL == *(char **)output) {
×
839
    return terrno;
×
840
  }
841

842
  return code;
×
843
}
844

845
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
2,795✔
846
  SDbCfgRsp out = {0};
2,795✔
847

848
  if (NULL == output || NULL == msg || msgSize <= 0) {
2,795!
849
    return TSDB_CODE_TSC_INVALID_INPUT;
×
850
  }
851

852
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
2,795!
853
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d,dbCfgRsp:%lu", msgSize, sizeof(out));
×
854
    return TSDB_CODE_INVALID_MSG;
×
855
  }
856

857
  memcpy(output, &out, sizeof(out));
2,795✔
858

859
  return TSDB_CODE_SUCCESS;
2,795✔
860
}
861

862
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
863
  SUserIndexRsp out = {0};
×
864

865
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
866
    return TSDB_CODE_TSC_INVALID_INPUT;
×
867
  }
868

869
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
870
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
871
    return TSDB_CODE_INVALID_MSG;
×
872
  }
873

874
  memcpy(output, &out, sizeof(out));
×
875

876
  return TSDB_CODE_SUCCESS;
×
877
}
878

879
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
86✔
880
  SRetrieveFuncRsp out = {0};
86✔
881

882
  if (NULL == output || NULL == msg || msgSize <= 0) {
86!
883
    return TSDB_CODE_TSC_INVALID_INPUT;
×
884
  }
885

886
  if (tDeserializeSRetrieveFuncRsp(msg, msgSize, &out) != 0) {
86!
887
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
888
    return TSDB_CODE_INVALID_MSG;
×
889
  }
890

891
  if (1 != out.numOfFuncs) {
86!
892
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
893
    return TSDB_CODE_INVALID_MSG;
×
894
  }
895

896
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
86✔
897

898
  memcpy(output, funcInfo, sizeof(*funcInfo));
86✔
899
  taosArrayDestroy(out.pFuncInfos);
86✔
900
  taosArrayDestroy(out.pFuncExtraInfos);
86✔
901

902
  return TSDB_CODE_SUCCESS;
86✔
903
}
904

905
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
4,215✔
906
  if (NULL == output || NULL == msg || msgSize <= 0) {
4,215!
907
    return TSDB_CODE_TSC_INVALID_INPUT;
×
908
  }
909

910
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
4,215!
911
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
912
    return TSDB_CODE_INVALID_MSG;
×
913
  }
914

915
  return TSDB_CODE_SUCCESS;
4,215✔
916
}
917

918
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
1✔
919
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
920
    return TSDB_CODE_TSC_INVALID_INPUT;
×
921
  }
922

923
  STableIndexRsp *out = (STableIndexRsp *)output;
1✔
924
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
1!
925
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
926
    return TSDB_CODE_INVALID_MSG;
×
927
  }
928

929
  return TSDB_CODE_SUCCESS;
1✔
930
}
931

932
int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
93✔
933
  if (NULL == output || NULL == msg || msgSize <= 0) {
93!
934
    return TSDB_CODE_TSC_INVALID_INPUT;
×
935
  }
936

937
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
93!
938
  if(out == NULL) {
93!
939
    return terrno;
×
940
  }
941
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
93!
942
    qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize);
×
943
    tFreeSTableCfgRsp(out);
×
944
    taosMemoryFree(out);
×
945
    return TSDB_CODE_INVALID_MSG;
×
946
  }
947

948
  *(STableCfgRsp **)output = out;
93✔
949

950
  return TSDB_CODE_SUCCESS;
93✔
951
}
952

953
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
197✔
954
  if (NULL == output || NULL == msg || msgSize <= 0) {
197!
955
    return TSDB_CODE_TSC_INVALID_INPUT;
×
956
  }
957

958
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
197!
959
  if (out == NULL) {
197!
960
    return terrno;
×
961
  }
962
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
197!
963
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
964
    tFreeSViewMetaRsp(out);
×
965
    taosMemoryFree(out);
×
966
    return TSDB_CODE_INVALID_MSG;
×
967
  }
968

969
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
197!
970

971
  *(SViewMetaRsp **)output = out;
197✔
972

973
  return TSDB_CODE_SUCCESS;
197✔
974
}
975

976
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
907✔
977
  if (NULL == output || NULL == msg || msgSize <= 0) {
907!
978
    return TSDB_CODE_TSC_INVALID_INPUT;
×
979
  }
980

981
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
907!
982
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
983
    return TSDB_CODE_INVALID_MSG;
×
984
  }
985

986
  return TSDB_CODE_SUCCESS;
907✔
987
}
988

989
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
4,694✔
990
  if (!output || !msg || msgSize <= 0) {
4,694!
991
    return TSDB_CODE_TSC_INVALID_INPUT;
×
992
  }
993

994
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
4,694!
995
    qError("tDeserializeStreamProgressRsp failed, msgSize: %d", msgSize);
×
996
    return TSDB_CODE_INVALID_MSG;
×
997
  }
998
  return TSDB_CODE_SUCCESS;
4,694✔
999
}
1000

1001

1002
void initQueryModuleMsgHandle() {
1,975✔
1003
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,975✔
1004
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryBuildTableMetaReqMsg;
1,975✔
1005
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,975✔
1006
  queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg;
1,975✔
1007
  queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg;
1,975✔
1008
  queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg;
1,975✔
1009
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg;
1,975✔
1010
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg;
1,975✔
1011
  queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg;
1,975✔
1012
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg;
1,975✔
1013
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg;
1,975✔
1014
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,975✔
1015
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,975✔
1016
  queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg;
1,975✔
1017
  queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg;
1,975✔
1018
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryBuildGetTableTSMAMsg;
1,975✔
1019
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryBuildGetTSMAMsg;
1,975✔
1020
  queryBuildMsg[TMSG_INDEX(TDMT_VND_GET_STREAM_PROGRESS)] = queryBuildGetStreamProgressMsg;
1,975✔
1021

1022
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
1,975✔
1023
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryProcessTableNameRsp;
1,975✔
1024
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp;
1,975✔
1025
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
1,975✔
1026
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp;
1,975✔
1027
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp;
1,975✔
1028
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp;
1,975✔
1029
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp;
1,975✔
1030
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp;
1,975✔
1031
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp;
1,975✔
1032
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp;
1,975✔
1033
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,975✔
1034
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,975✔
1035
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp;
1,975✔
1036
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp;
1,975✔
1037
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp;
1,975✔
1038
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp;
1,975✔
1039
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp;
1,975✔
1040
}
1,975✔
1041

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