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

taosdata / TDengine / #3522

07 Nov 2024 05:59AM UTC coverage: 58.216% (+1.3%) from 56.943%
#3522

push

travis-ci

web-flow
Merge pull request #28663 from taosdata/fix/3_liaohj

fix(stream): stop the underlying scan operations for stream

111884 of 248391 branches covered (45.04%)

Branch coverage included in aggregate %.

3 of 4 new or added lines in 1 file covered. (75.0%)

1164 existing lines in 134 files now uncovered.

191720 of 273118 relevant lines covered (70.2%)

13088725.13 hits per line

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

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

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

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

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

49
  if (usedbRsp->vgNum <= 0) {
102,916✔
50
    return TSDB_CODE_SUCCESS;
12,518✔
51
  }
52

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

59
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
296,788✔
60
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
206,388✔
61
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
206,388✔
62
    qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
206,388✔
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))) {
206,388!
65
      return TSDB_CODE_OUT_OF_MEMORY;
×
66
    }
67
  }
68

69
  return TSDB_CODE_SUCCESS;
90,400✔
70
}
71

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

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

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

97
  *msg = pBuf;
101,648✔
98
  *msgLen = bufLen;
101,648✔
99

100
  return TSDB_CODE_SUCCESS;
101,648✔
101
}
102

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

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

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

127
  *msg = pBuf;
94,033✔
128
  *msgLen = bufLen;
94,033✔
129

130
  return TSDB_CODE_SUCCESS;
94,033✔
131
}
132

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

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

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

151
  *msg = pBuf;
10,670✔
152
  *msgLen = bufLen;
10,670✔
153

154
  return TSDB_CODE_SUCCESS;
10,670✔
155
}
156

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

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

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

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

178
  return TSDB_CODE_SUCCESS;
86✔
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)) {
4,878✔
205
  if (NULL == msg || NULL == msgLen) {
4,878!
206
    return TSDB_CODE_TSC_INVALID_INPUT;
×
207
  }
208

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

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

222
  *msg = pBuf;
4,878✔
223
  *msgLen = bufLen;
4,878✔
224

225
  return TSDB_CODE_SUCCESS;
4,878✔
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,244✔
253
                                  void *(*mallcFp)(int64_t)) {
254
  if (NULL == msg || NULL == msgLen) {
1,244!
255
    return TSDB_CODE_TSC_INVALID_INPUT;
×
256
  }
257

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

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

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

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

287
  return TSDB_CODE_SUCCESS;
1,244✔
288
}
289

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

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

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

307
  *msg = pBuf;
8,914✔
308
  *msgLen = bufLen;
8,914✔
309

310
  return TSDB_CODE_SUCCESS;
8,914✔
311
}
312

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

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

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

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

334
  return TSDB_CODE_SUCCESS;
7,428✔
335
}
336

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

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

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

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

361
  return TSDB_CODE_SUCCESS;
141✔
362
}
363

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

369
  SViewMetaReq req = {0};
1,263,698✔
370
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
1,263,698✔
371

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

382
  *msg = pBuf;
1,263,714✔
383
  *msgLen = bufLen;
1,263,714✔
384

385
  return TSDB_CODE_SUCCESS;
1,263,714✔
386
}
387

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

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

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

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

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

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

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

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

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

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

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

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

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

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

469
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
93,549!
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) {
93,548!
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);
93,548✔
482
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
292,824✔
483
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
199,276✔
484
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
199,276✔
485
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
406,385✔
486
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
207,108✔
487
    }
488
  }
489

490
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
93,548✔
491

492
PROCESS_USEDB_OVER:
93,549✔
493

494
  if (code != 0) {
93,549!
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);
93,549✔
503
  return code;
93,549✔
504
}
505

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

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

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

550
  return TSDB_CODE_SUCCESS;
116,298✔
551
}
552

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

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

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

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

576
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
103,979✔
577
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
103,979!
578
    pTableMeta->schemaExt = pSchemaExt;
102,241✔
579
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
102,241✔
580
  } else {
581
    pTableMeta->schemaExt = NULL;
1,738✔
582
  }
583

584
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
103,979!
585
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,013,847✔
586
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
1,909,868✔
587
    if (hasPK && (i > 0)) {
1,909,868✔
588
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
59,533✔
589
        ++pTableMeta->tableInfo.numOfPKs;
29,769✔
590
      } else {
591
        hasPK = false;
29,764✔
592
      }
593
    }
594
  }
595

596
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
103,979✔
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;
103,979✔
604
  return TSDB_CODE_SUCCESS;
103,979✔
605
}
606

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

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

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

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

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

639
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
1,217!
640
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
3,955✔
641
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,738✔
642
    if (hasPK && (i > 0)) {
2,738!
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;
1,217✔
652
  tstrncpy(pTbName, msg->tbName, tbNameSize);
1,217✔
653

654
  qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
1,217!
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;
1,217✔
662
  return TSDB_CODE_SUCCESS;
1,217✔
663
}
664

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

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

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

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

684
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
79,944!
685
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
78,207!
686
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
687
    goto PROCESS_META_OVER;
×
688
  }
689

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

694
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
79,942✔
695
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
45,297✔
696

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

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

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

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

717
  tFreeSTableMetaRsp(&metaRsp);
79,944✔
718
  return code;
79,944✔
719
}
720

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

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

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

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

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

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

750
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
1,217✔
751
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
324✔
752

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

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

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

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

773
  tFreeSTableMetaRsp(&metaRsp);
1,217✔
774
  return code;
1,217✔
775
}
776

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

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

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

793
  return code;
10,670✔
794
}
795

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

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

805
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
86!
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;
86✔
812

813
  return code;
86✔
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) {
4,796✔
840
  SDbCfgRsp out = {0};
4,796✔
841

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

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

853
  return TSDB_CODE_SUCCESS;
4,796✔
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,234✔
874
  SRetrieveFuncRsp out = {0};
1,234✔
875

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

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

885
  if (1 != out.numOfFuncs) {
1,234!
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,234✔
891

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

896
  return TSDB_CODE_SUCCESS;
1,234✔
897
}
898

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

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

909
  return TSDB_CODE_SUCCESS;
8,901✔
910
}
911

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

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

923
  return TSDB_CODE_SUCCESS;
2✔
924
}
925

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

931
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
141✔
932
  if(out == NULL) {
141!
933
    return terrno;
×
934
  }
935
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
141!
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;
141✔
943

944
  return TSDB_CODE_SUCCESS;
141✔
945
}
946

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

952
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
222✔
953
  if (out == NULL) {
222!
954
    return terrno;
×
955
  }
956
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
222!
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);
222!
964

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

967
  return TSDB_CODE_SUCCESS;
222✔
968
}
969

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

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

980
  return TSDB_CODE_SUCCESS;
845✔
981
}
982

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

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

995

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

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