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

taosdata / TDengine / #3592

24 Jan 2025 08:57AM UTC coverage: 63.546% (-0.1%) from 63.688%
#3592

push

travis-ci

web-flow
Merge pull request #29638 from taosdata/docs/TS-5846-3.0

enh: TDengine modify taosBenchmark new query rule cases and add doc

141205 of 285630 branches covered (49.44%)

Branch coverage included in aggregate %.

220039 of 282844 relevant lines covered (77.8%)

18746126.97 hits per line

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

52.93
/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) {
71,365✔
32
  QUERY_PARAM_CHECK(pOut);
71,365!
33
  QUERY_PARAM_CHECK(usedbRsp);
71,365!
34
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
71,365✔
35
  pOut->dbId = usedbRsp->uid;
71,365✔
36

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

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

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

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

55
  pOut->dbVgroup->vgHash =
126,814✔
56
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
63,407✔
57
  if (NULL == pOut->dbVgroup->vgHash) {
63,407!
58
    return terrno;
×
59
  }
60

61
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
256,847✔
62
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
193,441✔
63
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
193,440✔
64
    qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
193,440✔
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))) {
193,440!
67
      return terrno;
×
68
    }
69
  }
70

71
  return TSDB_CODE_SUCCESS;
63,406✔
72
}
73

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

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

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

99
  *msg = pBuf;
66,335✔
100
  *msgLen = bufLen;
66,335✔
101

102
  return TSDB_CODE_SUCCESS;
66,335✔
103
}
104

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

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

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

129
  *msg = pBuf;
65,284✔
130
  *msgLen = bufLen;
65,284✔
131

132
  return TSDB_CODE_SUCCESS;
65,284✔
133
}
134

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

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

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

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

155
  return TSDB_CODE_SUCCESS;
9,599✔
156
}
157

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

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

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

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

178
  return TSDB_CODE_SUCCESS;
345✔
179
}
180

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

185
  SServerVerReq req = {0};
1✔
186

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

197
  *msg = pBuf;
1✔
198
  *msgLen = bufLen;
1✔
199

200
  return TSDB_CODE_SUCCESS;
1✔
201
}
202

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

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

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

221
  *msg = pBuf;
3,653✔
222
  *msgLen = bufLen;
3,653✔
223

224
  return TSDB_CODE_SUCCESS;
3,653✔
225
}
226

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

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

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

245
  *msg = pBuf;
1✔
246
  *msgLen = bufLen;
1✔
247

248
  return TSDB_CODE_SUCCESS;
1✔
249
}
250

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

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

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

281
  taosArrayDestroy(funcReq.pFuncNames);
97✔
282

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

286
  return TSDB_CODE_SUCCESS;
97✔
287
}
288

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

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

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

306
  *msg = pBuf;
7,342✔
307
  *msgLen = bufLen;
7,342✔
308

309
  return TSDB_CODE_SUCCESS;
7,342✔
310
}
311

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

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

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

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

333
  return TSDB_CODE_SUCCESS;
7,332✔
334
}
335

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

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

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

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

360
  return TSDB_CODE_SUCCESS;
99✔
361
}
362

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

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

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

381
  *msg = pBuf;
23,006✔
382
  *msgLen = bufLen;
23,006✔
383

384
  return TSDB_CODE_SUCCESS;
23,006✔
385
}
386

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

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

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

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

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

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

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

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

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

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

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

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

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

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

468
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
64,834!
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) {
64,835!
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);
64,835✔
481
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
251,254✔
482
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
186,419✔
483
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
186,419✔
484
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
436,075✔
485
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
249,656✔
486
    }
487
  }
488

489
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
64,835✔
490

491
PROCESS_USEDB_OVER:
64,835✔
492

493
  if (code != 0) {
64,835!
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);
64,835✔
502
  return code;
64,833✔
503
}
504

505
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
56,489✔
506
  QUERY_PARAM_CHECK(pMetaMsg);
56,489!
507
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
56,489!
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) {
56,489!
513
    qError("invalid numOfColumns[%d] in table meta rsp msg", pMetaMsg->numOfColumns);
×
514
    return TSDB_CODE_TSC_INVALID_VALUE;
×
515
  }
516

517
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
56,490✔
518
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE) {
6,230!
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) {
56,490!
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) {
56,490!
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) {
56,490!
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;
56,490✔
539
}
540

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

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

552
  return TSDB_CODE_SUCCESS;
109,711✔
553
}
554

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

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

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

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

580
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
79,938✔
581
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
79,938✔
582
    pTableMeta->schemaExt = pSchemaExt;
78,538✔
583
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
78,538✔
584
  } else {
585
    pTableMeta->schemaExt = NULL;
1,400✔
586
  }
587

588
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
79,938!
589
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,105,043✔
590
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,025,105✔
591
    if (hasPK && (i > 0)) {
2,025,105✔
592
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
58,491✔
593
        ++pTableMeta->tableInfo.numOfPKs;
29,255✔
594
      } else {
595
        hasPK = false;
29,236✔
596
      }
597
    }
598
  }
599

600
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
79,938✔
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;
79,939✔
608
  return TSDB_CODE_SUCCESS;
79,939✔
609
}
610

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

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

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

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

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

645
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
1,222!
646
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
3,968✔
647
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,746✔
648
    if (hasPK && (i > 0)) {
2,746!
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;
1,222✔
658
  tstrncpy(pTbName, msg->tbName, tbNameSize);
1,222✔
659

660
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
1,222!
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;
1,222✔
668
  return TSDB_CODE_SUCCESS;
1,222✔
669
}
670

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

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

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

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

690
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
55,267!
691
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
53,869!
692
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
693
    goto PROCESS_META_OVER;
×
694
  }
695

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

700
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
55,268✔
701
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
36,653✔
702

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

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

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

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

723
  tFreeSTableMetaRsp(&metaRsp);
55,266✔
724
  return code;
55,268✔
725
}
726

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

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

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

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

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

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

756
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
1,222✔
757
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
331✔
758

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

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

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

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

779
  tFreeSTableMetaRsp(&metaRsp);
1,222✔
780
  return code;
1,222✔
781
}
782

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

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

792
  out.qnodeList = (SArray *)output;
9,599✔
793
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
9,599!
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,599✔
800
}
801

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

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

811
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
345!
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;
345✔
818

819
  return code;
345✔
820
}
821

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

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

831
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
1!
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);
1!
838
  if (NULL == *(char **)output) {
1!
839
    return terrno;
×
840
  }
841

842
  return code;
1✔
843
}
844

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

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

852
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
3,602!
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));
3,602✔
858

859
  return TSDB_CODE_SUCCESS;
3,602✔
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) {
87✔
880
  SRetrieveFuncRsp out = {0};
87✔
881

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

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

891
  if (1 != out.numOfFuncs) {
87!
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);
87✔
897

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

902
  return TSDB_CODE_SUCCESS;
87✔
903
}
904

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

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

915
  return TSDB_CODE_SUCCESS;
7,338✔
916
}
917

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

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

929
  return TSDB_CODE_SUCCESS;
2✔
930
}
931

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

937
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
99!
938
  if(out == NULL) {
99!
939
    return terrno;
×
940
  }
941
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
99!
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;
99✔
949

950
  return TSDB_CODE_SUCCESS;
99✔
951
}
952

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

958
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
306!
959
  if (out == NULL) {
306!
960
    return terrno;
×
961
  }
962
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
306!
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);
306✔
970

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

973
  return TSDB_CODE_SUCCESS;
306✔
974
}
975

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

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

986
  return TSDB_CODE_SUCCESS;
906✔
987
}
988

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

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

1001

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

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