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

taosdata / TDengine / #3523

06 Nov 2024 02:29AM UTC coverage: 55.861% (-2.4%) from 58.216%
#3523

push

travis-ci

web-flow
Merge pull request #28551 from taosdata/feat/TS-5215-2

test(blob): testing & fixes for blob

106075 of 245834 branches covered (43.15%)

Branch coverage included in aggregate %.

0 of 15 new or added lines in 2 files covered. (0.0%)

17003 existing lines in 254 files now uncovered.

181910 of 269703 relevant lines covered (67.45%)

1527639.59 hits per line

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

56.3
/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) {
59,057✔
32
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
59,057✔
33
  pOut->dbId = usedbRsp->uid;
59,057✔
34

35
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
59,057✔
36
  if (NULL == pOut->dbVgroup) {
59,058!
37
    return terrno;
×
38
  }
39

40
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
59,058✔
41
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
59,058✔
42
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
59,058✔
43
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
59,058✔
44
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
59,058✔
45

46
  qDebug("Got %d vgroup for db %s, vgVersion:%d, stateTs:%" PRId64, usedbRsp->vgNum, usedbRsp->db, usedbRsp->vgVersion,
59,058✔
47
         usedbRsp->stateTs);
48

49
  if (usedbRsp->vgNum <= 0) {
59,058✔
50
    return TSDB_CODE_SUCCESS;
7,438✔
51
  }
52

53
  pOut->dbVgroup->vgHash =
103,240✔
54
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
51,620✔
55
  if (NULL == pOut->dbVgroup->vgHash) {
51,620!
56
    return terrno;
×
57
  }
58

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

69
  return TSDB_CODE_SUCCESS;
51,620✔
70
}
71

72
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
40,007✔
73
                                  void *(*mallcFp)(int64_t)) {
74
  SBuildTableInput *pInput = input;
40,007✔
75
  if (NULL == input || NULL == msg || NULL == msgLen) {
40,007!
76
    return TSDB_CODE_TSC_INVALID_INPUT;
×
77
  }
78

79
  STableInfoReq infoReq = {0};
40,012✔
80
  infoReq.option = pInput->option;
40,012✔
81
  infoReq.header.vgId = pInput->vgId;
40,012✔
82
  if (pInput->dbFName) {
40,012✔
83
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
40,010✔
84
  }
85
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
40,012✔
86

87
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
40,012✔
88
  void   *pBuf = (*mallcFp)(bufLen);
40,013✔
89
  if (NULL == pBuf) {
40,012!
90
    return terrno;
×
91
  }
92
  if(tSerializeSTableInfoReq(pBuf, bufLen, &infoReq) < 0)
40,012!
93
  {
94
    return TSDB_CODE_TSC_INVALID_INPUT;
×
95
  }
96

97
  *msg = pBuf;
40,014✔
98
  *msgLen = bufLen;
40,014✔
99

100
  return TSDB_CODE_SUCCESS;
40,014✔
101
}
102

103
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
55,351✔
104
  SBuildUseDBInput *pInput = input;
55,351✔
105
  if (NULL == pInput || NULL == msg || NULL == msgLen) {
55,351!
106
    return TSDB_CODE_TSC_INVALID_INPUT;
×
107
  }
108

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

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

127
  *msg = pBuf;
55,350✔
128
  *msgLen = bufLen;
55,350✔
129

130
  return TSDB_CODE_SUCCESS;
55,350✔
131
}
132

133
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
5,894✔
134
  if (NULL == msg || NULL == msgLen) {
5,894!
135
    return TSDB_CODE_TSC_INVALID_INPUT;
×
136
  }
137

138
  SQnodeListReq qnodeListReq = {0};
5,894✔
139
  qnodeListReq.rowNum = -1;
5,894✔
140

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

151
  *msg = pBuf;
5,894✔
152
  *msgLen = bufLen;
5,894✔
153

154
  return TSDB_CODE_SUCCESS;
5,894✔
155
}
156

157
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
87✔
158
  if (NULL == msg || NULL == msgLen) {
87!
159
    return TSDB_CODE_TSC_INVALID_INPUT;
×
160
  }
161

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

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

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

178
  return TSDB_CODE_SUCCESS;
87✔
179
}
180

181
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
×
182
  if (NULL == msg || NULL == msgLen) {
×
183
    return TSDB_CODE_TSC_INVALID_INPUT;
×
184
  }
185

186
  SServerVerReq req = {0};
×
187

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

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

201
  return TSDB_CODE_SUCCESS;
×
202
}
203

204
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
2,905✔
205
  if (NULL == msg || NULL == msgLen) {
2,905!
206
    return TSDB_CODE_TSC_INVALID_INPUT;
×
207
  }
208

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

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

222
  *msg = pBuf;
2,905✔
223
  *msgLen = bufLen;
2,905✔
224

225
  return TSDB_CODE_SUCCESS;
2,905✔
226
}
227

228
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
×
229
  if (NULL == msg || NULL == msgLen) {
×
230
    return TSDB_CODE_TSC_INVALID_INPUT;
×
231
  }
232

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

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

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

249
  return TSDB_CODE_SUCCESS;
×
250
}
251

252
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
1,276✔
253
                                  void *(*mallcFp)(int64_t)) {
254
  if (NULL == msg || NULL == msgLen) {
1,276!
255
    return TSDB_CODE_TSC_INVALID_INPUT;
×
256
  }
257

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

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

282
  taosArrayDestroy(funcReq.pFuncNames);
1,276✔
283

284
  *msg = pBuf;
1,276✔
285
  *msgLen = bufLen;
1,276✔
286

287
  return TSDB_CODE_SUCCESS;
1,276✔
288
}
289

290
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
3,198✔
291
  if (NULL == msg || NULL == msgLen) {
3,198!
292
    return TSDB_CODE_TSC_INVALID_INPUT;
×
293
  }
294

295
  SGetUserAuthReq req = {0};
3,198✔
296
  tstrncpy(req.user, input, TSDB_USER_LEN);
3,198✔
297

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

307
  *msg = pBuf;
3,198✔
308
  *msgLen = bufLen;
3,198✔
309

310
  return TSDB_CODE_SUCCESS;
3,198✔
311
}
312

313
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
196✔
314
  if (NULL == msg || NULL == msgLen) {
196!
315
    return TSDB_CODE_TSC_INVALID_INPUT;
×
316
  }
317

318
  STableIndexReq indexReq = {0};
196✔
319
  tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
196✔
320

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

331
  *msg = pBuf;
196✔
332
  *msgLen = bufLen;
196✔
333

334
  return TSDB_CODE_SUCCESS;
196✔
335
}
336

337
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
128✔
338
  if (NULL == msg || NULL == msgLen) {
128!
339
    return TSDB_CODE_TSC_INVALID_INPUT;
×
340
  }
341

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

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

358
  *msg = pBuf;
128✔
359
  *msgLen = bufLen;
128✔
360

361
  return TSDB_CODE_SUCCESS;
128✔
362
}
363

364
int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
399,472✔
365
  if (NULL == msg || NULL == msgLen) {
399,472!
366
    return TSDB_CODE_TSC_INVALID_INPUT;
×
367
  }
368

369
  SViewMetaReq req = {0};
399,478✔
370
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
399,478✔
371

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

382
  *msg = pBuf;
399,480✔
383
  *msgLen = bufLen;
399,480✔
384

385
  return TSDB_CODE_SUCCESS;
399,480✔
386
}
387

388
int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
9,506✔
389
                                  void *(*mallcFp)(int64_t)) {
390
  if (NULL == msg || NULL == msgLen) {
9,506!
391
    return TSDB_CODE_TSC_INVALID_INPUT;
×
392
  }
393

394
  STableTSMAInfoReq req = {0};
9,506✔
395
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
9,506✔
396

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

407
  *msg = pBuf;
9,506✔
408
  *msgLen = bufLen;
9,506✔
409
  return TSDB_CODE_SUCCESS;
9,506✔
410
}
411

412
int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
13✔
413
                                  void *(*mallcFp)(int64_t)) {
414
  if (NULL == msg || NULL == msgLen) {
13!
415
    return TSDB_CODE_TSC_INVALID_INPUT;
×
416
  }
417

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

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

433
  *msg = pBuf;
13✔
434
  *msgLen = bufLen;
13✔
435
  return TSDB_CODE_SUCCESS;
13✔
436
}
437

438
int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int64_t)) {
1,028✔
439
  if (!msg || !msgLen) {
1,028!
440
    return TSDB_CODE_TSC_INVALID_INPUT;
×
441
  }
442

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

449
  if(tSerializeStreamProgressReq(pBuf, len, input) < 0)
1,028!
450
  {
451
    return TSDB_CODE_TSC_INVALID_INPUT;
×
452
  }
453

454
  *msg = pBuf;
1,028✔
455
  *msgLen = len;
1,028✔
456
  return TSDB_CODE_SUCCESS;
1,028✔
457
}
458

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

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

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

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

481
  qTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
54,905✔
482
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
168,188✔
483
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
113,284✔
484
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
113,283✔
485
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
232,299✔
486
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
119,016✔
487
    }
488
  }
489

490
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
54,904✔
491

492
PROCESS_USEDB_OVER:
54,905✔
493

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

502
  tFreeSUsedbRsp(&usedbRsp);
54,905✔
503
  return code;
54,905✔
504
}
505

506
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
25,531✔
507
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
25,531!
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) {
25,531!
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 &&
25,531✔
518
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE) {
5,912!
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) {
25,531!
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) {
25,531!
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) {
25,531!
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;
25,531✔
539
}
540

541
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
48,538✔
542
  pMeta->vgId = msg->vgId;
48,538✔
543
  pMeta->tableType = msg->tableType;
48,538✔
544
  pMeta->uid = msg->tuid;
48,538✔
545
  pMeta->suid = msg->suid;
48,538✔
546

547
  qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, pMeta->uid,
48,538✔
548
         pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
549

550
  return TSDB_CODE_SUCCESS;
48,541✔
551
}
552

553
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
37,209✔
554
  int32_t total = msg->numOfColumns + msg->numOfTags;
37,209✔
555
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
37,209✔
556
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
37,209!
557

558
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize);
37,209✔
559
  if (NULL == pTableMeta) {
37,209!
560
    qError("calloc size[%d] failed", metaSize);
×
561
    return terrno;
×
562
  }
563
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
37,209✔
564

565
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
37,209✔
566
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
37,209✔
567
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
37,209✔
568
  pTableMeta->suid = msg->suid;
37,209✔
569
  pTableMeta->sversion = msg->sversion;
37,209✔
570
  pTableMeta->tversion = msg->tversion;
37,209✔
571

572
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
37,209✔
573
  pTableMeta->tableInfo.precision = msg->precision;
37,209✔
574
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
37,209✔
575

576
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
37,209✔
577
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
37,209!
578
    pTableMeta->schemaExt = pSchemaExt;
35,863✔
579
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
35,863✔
580
  } else {
581
    pTableMeta->schemaExt = NULL;
1,345✔
582
  }
583

584
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
37,208!
585
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
645,753✔
586
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
608,545✔
587
    if (hasPK && (i > 0)) {
608,545✔
588
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
1,105✔
589
        ++pTableMeta->tableInfo.numOfPKs;
554✔
590
      } else {
591
        hasPK = false;
551✔
592
      }
593
    }
594
  }
595

596
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
37,208✔
597
         " sver %d tver %d"
598
         " tagNum %d colNum %d precision %d rowSize %d",
599
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
600
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
601
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
602

603
  *pMeta = pTableMeta;
37,210✔
604
  return TSDB_CODE_SUCCESS;
37,210✔
605
}
606

607
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
402✔
608
  int32_t total = msg->numOfColumns + msg->numOfTags;
402✔
609
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
402✔
610
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
402!
611
  int32_t tbNameSize = strlen(msg->tbName) + 1;
402✔
612

613
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + tbNameSize);
402✔
614
  if (NULL == pTableMeta) {
402!
615
    qError("calloc size[%d] failed", metaSize);
×
616
    return terrno;
×
617
  }
618
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
402✔
619

620
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
402✔
621
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
402✔
622
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
402✔
623
  pTableMeta->suid = msg->suid;
402✔
624
  pTableMeta->sversion = msg->sversion;
402✔
625
  pTableMeta->tversion = msg->tversion;
402✔
626

627
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
402✔
628
  pTableMeta->tableInfo.precision = msg->precision;
402✔
629
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
402✔
630

631
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
402✔
632
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
402!
633
    pTableMeta->schemaExt = pSchemaExt;
402✔
634
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
402✔
635
  } else {
636
    pTableMeta->schemaExt = NULL;
×
637
  }
638

639
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
402!
640
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
1,206✔
641
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
804✔
642
    if (hasPK && (i > 0)) {
804!
643
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
644
        ++pTableMeta->tableInfo.numOfPKs;
×
645
      } else {
646
        hasPK = false;
×
647
      }
648
    }
649
  }
650

651
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize;
402✔
652
  tstrncpy(pTbName, msg->tbName, tbNameSize);
402✔
653

654
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
402!
655
         " sver %d tver %d"
656
         " tagNum %d colNum %d precision %d rowSize %d",
657
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
658
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
659
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
660

661
  *pMeta = pTableMeta;
402✔
662
  return TSDB_CODE_SUCCESS;
402✔
663
}
664

665
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
25,129✔
666
  int32_t       code = 0;
25,129✔
667
  STableMetaRsp metaRsp = {0};
25,129✔
668

669
  if (NULL == output || NULL == msg || msgSize <= 0) {
25,129!
670
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
671
    goto PROCESS_META_OVER;
×
672
  }
673

674
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
25,129!
675
    code = TSDB_CODE_INVALID_MSG;
×
676
    goto PROCESS_META_OVER;
×
677
  }
678

679
  code = queryConvertTableMetaMsg(&metaRsp);
25,128✔
680
  if (code != TSDB_CODE_SUCCESS) {
25,129!
681
    goto PROCESS_META_OVER;
×
682
  }
683

684
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
25,129!
685
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
23,784!
686
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
687
    goto PROCESS_META_OVER;
×
688
  }
689

690
  STableMetaOutput *pOut = output;
25,128✔
691
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
25,128✔
692
  pOut->dbId = metaRsp.dbId;
25,128✔
693

694
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
25,128✔
695
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
8,939✔
696

697
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
8,939✔
698
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
8,939✔
699

700
    pOut->ctbMeta.vgId = metaRsp.vgId;
8,939✔
701
    pOut->ctbMeta.tableType = metaRsp.tableType;
8,939✔
702
    pOut->ctbMeta.uid = metaRsp.tuid;
8,939✔
703
    pOut->ctbMeta.suid = metaRsp.suid;
8,939✔
704

705
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
8,939✔
706
  } else {
707
    SET_META_TYPE_TABLE(pOut->metaType);
16,189✔
708
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
16,189✔
709
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
16,189✔
710
  }
711

712
PROCESS_META_OVER:
25,129✔
713
  if (code != 0) {
25,129!
714
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
715
  }
716

717
  tFreeSTableMetaRsp(&metaRsp);
25,129✔
718
  return code;
25,127✔
719
}
720

721
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
402✔
722
  int32_t       code = 0;
402✔
723
  STableMetaRsp metaRsp = {0};
402✔
724

725
  if (NULL == output || NULL == msg || msgSize <= 0) {
402!
726
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
727
    goto PROCESS_NAME_OVER;
×
728
  }
729

730
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
402!
731
    code = TSDB_CODE_INVALID_MSG;
×
732
    goto PROCESS_NAME_OVER;
×
733
  }
734

735
  code = queryConvertTableMetaMsg(&metaRsp);
402✔
736
  if (code != TSDB_CODE_SUCCESS) {
402!
737
    goto PROCESS_NAME_OVER;
×
738
  }
739

740
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
402!
741
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
402!
742
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
743
    goto PROCESS_NAME_OVER;
×
744
  }
745

746
  STableMetaOutput *pOut = output;
402✔
747
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
402✔
748
  pOut->dbId = metaRsp.dbId;
402✔
749

750
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
402✔
751
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
22✔
752

753
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
22✔
754
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
22✔
755

756
    pOut->ctbMeta.vgId = metaRsp.vgId;
22✔
757
    pOut->ctbMeta.tableType = metaRsp.tableType;
22✔
758
    pOut->ctbMeta.uid = metaRsp.tuid;
22✔
759
    pOut->ctbMeta.suid = metaRsp.suid;
22✔
760

761
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
22✔
762
  } else {
763
    SET_META_TYPE_TABLE(pOut->metaType);
380✔
764
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
380✔
765
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
380✔
766
  }
767

768
PROCESS_NAME_OVER:
402✔
769
  if (code != 0) {
402!
770
    qError("failed to process table name rsp since %s", tstrerror(code));
×
771
  }
772

773
  tFreeSTableMetaRsp(&metaRsp);
402✔
774
  return code;
402✔
775
}
776

777
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
5,892✔
778
  SQnodeListRsp out = {0};
5,892✔
779
  int32_t       code = 0;
5,892✔
780

781
  if (NULL == output || NULL == msg || msgSize <= 0) {
5,892!
782
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
783
    return code;
×
784
  }
785

786
  out.qnodeList = (SArray *)output;
5,892✔
787
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
5,892!
788
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
789
    code = TSDB_CODE_INVALID_MSG;
×
790
    return code;
×
791
  }
792

793
  return code;
5,892✔
794
}
795

796
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
87✔
797
  SDnodeListRsp out = {0};
87✔
798
  int32_t       code = 0;
87✔
799

800
  if (NULL == output || NULL == msg || msgSize <= 0) {
87!
801
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
802
    return code;
×
803
  }
804

805
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
87!
806
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
807
    code = TSDB_CODE_INVALID_MSG;
×
808
    return code;
×
809
  }
810

811
  *(SArray **)output = out.dnodeList;
87✔
812

813
  return code;
87✔
814
}
815

816
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
×
817
  SServerVerRsp out = {0};
×
818
  int32_t       code = 0;
×
819

820
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
821
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
822
    return code;
×
823
  }
824

825
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
×
826
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
827
    code = TSDB_CODE_INVALID_MSG;
×
828
    return code;
×
829
  }
830

831
  *(char **)output = taosStrdup(out.ver);
×
832
  if (NULL == *(char **)output) {
×
833
    return terrno;
×
834
  }
835

836
  return code;
×
837
}
838

839
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
2,821✔
840
  SDbCfgRsp out = {0};
2,821✔
841

842
  if (NULL == output || NULL == msg || msgSize <= 0) {
2,821!
843
    return TSDB_CODE_TSC_INVALID_INPUT;
×
844
  }
845

846
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
2,821!
847
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d,dbCfgRsp:%lu", msgSize, sizeof(out));
×
848
    return TSDB_CODE_INVALID_MSG;
×
849
  }
850

851
  memcpy(output, &out, sizeof(out));
2,821✔
852

853
  return TSDB_CODE_SUCCESS;
2,821✔
854
}
855

856
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
857
  SUserIndexRsp out = {0};
×
858

859
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
860
    return TSDB_CODE_TSC_INVALID_INPUT;
×
861
  }
862

863
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
864
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
865
    return TSDB_CODE_INVALID_MSG;
×
866
  }
867

868
  memcpy(output, &out, sizeof(out));
×
869

870
  return TSDB_CODE_SUCCESS;
×
871
}
872

873
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
1,266✔
874
  SRetrieveFuncRsp out = {0};
1,266✔
875

876
  if (NULL == output || NULL == msg || msgSize <= 0) {
1,266!
877
    return TSDB_CODE_TSC_INVALID_INPUT;
×
878
  }
879

880
  if (tDeserializeSRetrieveFuncRsp(msg, msgSize, &out) != 0) {
1,266!
881
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
882
    return TSDB_CODE_INVALID_MSG;
×
883
  }
884

885
  if (1 != out.numOfFuncs) {
1,266!
886
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
887
    return TSDB_CODE_INVALID_MSG;
×
888
  }
889

890
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
1,266✔
891

892
  memcpy(output, funcInfo, sizeof(*funcInfo));
1,266✔
893
  taosArrayDestroy(out.pFuncInfos);
1,266✔
894
  taosArrayDestroy(out.pFuncExtraInfos);
1,266✔
895

896
  return TSDB_CODE_SUCCESS;
1,266✔
897
}
898

899
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
3,193✔
900
  if (NULL == output || NULL == msg || msgSize <= 0) {
3,193!
901
    return TSDB_CODE_TSC_INVALID_INPUT;
×
902
  }
903

904
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
3,193!
905
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
906
    return TSDB_CODE_INVALID_MSG;
×
907
  }
908

909
  return TSDB_CODE_SUCCESS;
3,193✔
910
}
911

UNCOV
912
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
×
UNCOV
913
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
914
    return TSDB_CODE_TSC_INVALID_INPUT;
×
915
  }
916

UNCOV
917
  STableIndexRsp *out = (STableIndexRsp *)output;
×
UNCOV
918
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
×
919
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
920
    return TSDB_CODE_INVALID_MSG;
×
921
  }
922

UNCOV
923
  return TSDB_CODE_SUCCESS;
×
924
}
925

926
int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
128✔
927
  if (NULL == output || NULL == msg || msgSize <= 0) {
128!
928
    return TSDB_CODE_TSC_INVALID_INPUT;
×
929
  }
930

931
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
128✔
932
  if(out == NULL) {
128!
933
    return terrno;
×
934
  }
935
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
128!
936
    qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize);
×
937
    tFreeSTableCfgRsp(out);
×
938
    taosMemoryFree(out);
×
939
    return TSDB_CODE_INVALID_MSG;
×
940
  }
941

942
  *(STableCfgRsp **)output = out;
128✔
943

944
  return TSDB_CODE_SUCCESS;
128✔
945
}
946

947
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
223✔
948
  if (NULL == output || NULL == msg || msgSize <= 0) {
223!
949
    return TSDB_CODE_TSC_INVALID_INPUT;
×
950
  }
951

952
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
223✔
953
  if (out == NULL) {
223!
954
    return terrno;
×
955
  }
956
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
223!
957
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
958
    tFreeSViewMetaRsp(out);
×
959
    taosMemoryFree(out);
×
960
    return TSDB_CODE_INVALID_MSG;
×
961
  }
962

963
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
223!
964

965
  *(SViewMetaRsp **)output = out;
223✔
966

967
  return TSDB_CODE_SUCCESS;
223✔
968
}
969

970
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
209✔
971
  if (NULL == output || NULL == msg || msgSize <= 0) {
209!
972
    return TSDB_CODE_TSC_INVALID_INPUT;
×
973
  }
974

975
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
209!
976
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
977
    return TSDB_CODE_INVALID_MSG;
×
978
  }
979

980
  return TSDB_CODE_SUCCESS;
209✔
981
}
982

983
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
1,028✔
984
  if (!output || !msg || msgSize <= 0) {
1,028!
985
    return TSDB_CODE_TSC_INVALID_INPUT;
×
986
  }
987

988
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
1,028!
989
    qError("tDeserializeStreamProgressRsp failed, msgSize: %d", msgSize);
×
990
    return TSDB_CODE_INVALID_MSG;
×
991
  }
992
  return TSDB_CODE_SUCCESS;
1,028✔
993
}
994

995

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

1016
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
2,161✔
1017
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryProcessTableNameRsp;
2,161✔
1018
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp;
2,161✔
1019
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
2,161✔
1020
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp;
2,161✔
1021
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp;
2,161✔
1022
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp;
2,161✔
1023
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp;
2,161✔
1024
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp;
2,161✔
1025
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp;
2,161✔
1026
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp;
2,161✔
1027
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
2,161✔
1028
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
2,161✔
1029
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp;
2,161✔
1030
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp;
2,161✔
1031
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp;
2,161✔
1032
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp;
2,161✔
1033
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp;
2,161✔
1034
}
2,161✔
1035

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