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

taosdata / TDengine / #3647

13 Mar 2025 05:26AM UTC coverage: 25.9% (-2.5%) from 28.375%
#3647

push

travis-ci

web-flow
Merge pull request #30158 from taosdata/docs/anchor-caps-30

docs: lowercase anchors for 3.0

53974 of 285572 branches covered (18.9%)

Branch coverage included in aggregate %.

92870 of 281392 relevant lines covered (33.0%)

617448.64 hits per line

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

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

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

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

48
  qDebug("db:%s, get %d vgroup, vgVersion:%d, stateTs:%" PRId64, usedbRsp->db, usedbRsp->vgNum, usedbRsp->vgVersion,
2,745✔
49
         usedbRsp->stateTs);
50

51
  if (usedbRsp->vgNum <= 0) {
2,745✔
52
    return TSDB_CODE_SUCCESS;
15✔
53
  }
54

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

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

71
  return TSDB_CODE_SUCCESS;
2,730✔
72
}
73

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

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

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

97
  *msg = pBuf;
77✔
98
  *msgLen = bufLen;
77✔
99

100
  return TSDB_CODE_SUCCESS;
77✔
101
}
102

103
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
2,720✔
104
  QUERY_PARAM_CHECK(input);
2,720!
105
  QUERY_PARAM_CHECK(msg);
2,720!
106
  QUERY_PARAM_CHECK(msgLen);
2,720!
107
  SBuildUseDBInput *pInput = input;
2,720✔
108

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

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

125
  *msg = pBuf;
2,720✔
126
  *msgLen = bufLen;
2,720✔
127

128
  return TSDB_CODE_SUCCESS;
2,720✔
129
}
130

131
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
132
  QUERY_PARAM_CHECK(msg);
1!
133
  QUERY_PARAM_CHECK(msgLen);
1!
134

135
  SQnodeListReq qnodeListReq = {0};
1✔
136
  qnodeListReq.rowNum = -1;
1✔
137

138
  int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
1✔
139
  void   *pBuf = (*mallcFp)(bufLen);
1✔
140
  if (NULL == pBuf) {
1!
141
    return terrno;
×
142
  }
143

144
  int32_t ret = tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq);
1✔
145
  if (ret < 0) return ret;
1!
146

147
  *msg = pBuf;
1✔
148
  *msgLen = bufLen;
1✔
149

150
  return TSDB_CODE_SUCCESS;
1✔
151
}
152

153
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
154
  QUERY_PARAM_CHECK(msg);
1!
155
  QUERY_PARAM_CHECK(msgLen);
1!
156

157
  SDnodeListReq dnodeListReq = {0};
1✔
158
  dnodeListReq.rowNum = -1;
1✔
159

160
  int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
1✔
161
  void   *pBuf = (*mallcFp)(bufLen);
1✔
162
  if (NULL == pBuf) {
1!
163
    return terrno;
×
164
  }
165
  int32_t ret = tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq);
1✔
166
  if (ret < 0) return ret;
1!
167

168
  *msg = pBuf;
1✔
169
  *msgLen = bufLen;
1✔
170

171
  return TSDB_CODE_SUCCESS;
1✔
172
}
173

174
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
175
  QUERY_PARAM_CHECK(msg);
1!
176
  QUERY_PARAM_CHECK(msgLen);
1!
177

178
  SServerVerReq req = {0};
1✔
179

180
  int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
1✔
181
  void   *pBuf = (*mallcFp)(bufLen);
1✔
182
  if (NULL == pBuf) {
1!
183
    return terrno;
×
184
  }
185
  int32_t ret = tSerializeSServerVerReq(pBuf, bufLen, &req);
1✔
186
  if (ret < 0) return ret;
1!
187

188
  *msg = pBuf;
1✔
189
  *msgLen = bufLen;
1✔
190

191
  return TSDB_CODE_SUCCESS;
1✔
192
}
193

194
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
41✔
195
  QUERY_PARAM_CHECK(input);
41!
196
  QUERY_PARAM_CHECK(msg);
41!
197
  QUERY_PARAM_CHECK(msgLen);
41!
198

199
  SDbCfgReq dbCfgReq = {0};
41✔
200
  tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
41✔
201

202
  int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
41✔
203
  void   *pBuf = (*mallcFp)(bufLen);
41✔
204
  if (NULL == pBuf) {
41!
205
    return terrno;
×
206
  }
207
  int32_t ret = tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq);
41✔
208
  if (ret < 0) return ret;
41!
209

210
  *msg = pBuf;
41✔
211
  *msgLen = bufLen;
41✔
212

213
  return TSDB_CODE_SUCCESS;
41✔
214
}
215

216
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
217
  QUERY_PARAM_CHECK(input);
1!
218
  QUERY_PARAM_CHECK(msg);
1!
219
  QUERY_PARAM_CHECK(msgLen);
1!
220

221
  SUserIndexReq indexReq = {0};
1✔
222
  tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
1✔
223

224
  int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
1✔
225
  void   *pBuf = (*mallcFp)(bufLen);
1✔
226
  if (NULL == pBuf) {
1!
227
    return terrno;
×
228
  }
229
  int32_t ret = tSerializeSUserIndexReq(pBuf, bufLen, &indexReq);
1✔
230
  if (ret < 0) return ret;
1!
231

232
  *msg = pBuf;
1✔
233
  *msgLen = bufLen;
1✔
234

235
  return TSDB_CODE_SUCCESS;
1✔
236
}
237

238
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
1✔
239
                                  void *(*mallcFp)(int64_t)) {
240
  QUERY_PARAM_CHECK(input);
1!
241
  QUERY_PARAM_CHECK(msg);
1!
242
  QUERY_PARAM_CHECK(msgLen);
1!
243

244
  SRetrieveFuncReq funcReq = {0};
1✔
245
  funcReq.numOfFuncs = 1;
1✔
246
  funcReq.ignoreCodeComment = true;
1✔
247
  funcReq.pFuncNames = taosArrayInit(1, strlen(input) + 1);
1✔
248
  if (NULL == funcReq.pFuncNames) {
1!
249
    return terrno;
×
250
  }
251
  if (taosArrayPush(funcReq.pFuncNames, input) == NULL) {
2!
252
    taosArrayDestroy(funcReq.pFuncNames);
×
253
    return terrno;
×
254
  }
255

256
  int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
1✔
257
  void   *pBuf = (*mallcFp)(bufLen);
1✔
258
  if (NULL == pBuf) {
1!
259
    taosArrayDestroy(funcReq.pFuncNames);
×
260
    return terrno;
×
261
  }
262
  int32_t ret = tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq);
1✔
263
  if (ret < 0) {
1!
264
    taosArrayDestroy(funcReq.pFuncNames);
×
265
    return ret;
×
266
  }
267

268
  taosArrayDestroy(funcReq.pFuncNames);
1✔
269

270
  *msg = pBuf;
1✔
271
  *msgLen = bufLen;
1✔
272

273
  return TSDB_CODE_SUCCESS;
1✔
274
}
275

276
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
4✔
277
  QUERY_PARAM_CHECK(input);
4!
278
  QUERY_PARAM_CHECK(msg);
4!
279
  QUERY_PARAM_CHECK(msgLen);
4!
280

281
  SGetUserAuthReq req = {0};
4✔
282
  tstrncpy(req.user, input, TSDB_USER_LEN);
4✔
283

284
  int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
4✔
285
  void   *pBuf = (*mallcFp)(bufLen);
4✔
286
  if (NULL == pBuf) {
4!
287
    return terrno;
×
288
  }
289
  int32_t ret = tSerializeSGetUserAuthReq(pBuf, bufLen, &req);
4✔
290
  if (ret < 0) return ret;
4!
291

292
  *msg = pBuf;
4✔
293
  *msgLen = bufLen;
4✔
294

295
  return TSDB_CODE_SUCCESS;
4✔
296
}
297

298
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
299
  QUERY_PARAM_CHECK(input);
1!
300
  QUERY_PARAM_CHECK(msg);
1!
301
  QUERY_PARAM_CHECK(msgLen);
1!
302

303
  STableIndexReq indexReq = {0};
1✔
304
  tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
1✔
305

306
  int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
1✔
307
  void   *pBuf = (*mallcFp)(bufLen);
1✔
308
  if (NULL == pBuf) {
1!
309
    return terrno;
×
310
  }
311
  int32_t ret = tSerializeSTableIndexReq(pBuf, bufLen, &indexReq);
1✔
312
  if (ret < 0) return ret;
1!
313

314
  *msg = pBuf;
1✔
315
  *msgLen = bufLen;
1✔
316

317
  return TSDB_CODE_SUCCESS;
1✔
318
}
319

320
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
1✔
321
  QUERY_PARAM_CHECK(input);
1!
322
  QUERY_PARAM_CHECK(msg);
1!
323
  QUERY_PARAM_CHECK(msgLen);
1!
324

325
  SBuildTableInput *pInput = input;
1✔
326
  STableCfgReq      cfgReq = {0};
1✔
327
  cfgReq.header.vgId = pInput->vgId;
1✔
328
  tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
1✔
329
  tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
1✔
330

331
  int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
1✔
332
  void   *pBuf = (*mallcFp)(bufLen);
1✔
333
  if (NULL == pBuf) {
1!
334
    return terrno;
×
335
  }
336
  int32_t ret = tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq);
1✔
337
  if (ret < 0) return ret;
1!
338

339
  *msg = pBuf;
1✔
340
  *msgLen = bufLen;
1✔
341

342
  return TSDB_CODE_SUCCESS;
1✔
343
}
344

345
int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) {
17✔
346
  QUERY_PARAM_CHECK(input);
17!
347
  QUERY_PARAM_CHECK(msg);
17!
348
  QUERY_PARAM_CHECK(msgLen);
17!
349

350
  SViewMetaReq req = {0};
17✔
351
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
17✔
352

353
  int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
17✔
354
  void   *pBuf = (*mallcFp)(bufLen);
17✔
355
  if (NULL == pBuf) {
17!
356
    return terrno;
×
357
  }
358
  int32_t ret = tSerializeSViewMetaReq(pBuf, bufLen, &req);
17✔
359
  if (ret < 0) return ret;
17!
360

361
  *msg = pBuf;
17✔
362
  *msgLen = bufLen;
17✔
363

364
  return TSDB_CODE_SUCCESS;
17✔
365
}
366

367
int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
×
368
                                  void *(*mallcFp)(int64_t)) {
369
  QUERY_PARAM_CHECK(input);
×
370
  QUERY_PARAM_CHECK(msg);
×
371
  QUERY_PARAM_CHECK(msgLen);
×
372

373
  STableTSMAInfoReq req = {0};
×
374
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
×
375

376
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
×
377
  void *  pBuf = (*mallcFp)(bufLen);
×
378
  if (NULL == pBuf) {
×
379
    return terrno;
×
380
  }
381
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
×
382
  if (ret < 0) return ret;
×
383

384
  *msg = pBuf;
×
385
  *msgLen = bufLen;
×
386
  return TSDB_CODE_SUCCESS;
×
387
}
388

389
int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
×
390
                                  void *(*mallcFp)(int64_t)) {
391
  QUERY_PARAM_CHECK(input);
×
392
  QUERY_PARAM_CHECK(msg);
×
393
  QUERY_PARAM_CHECK(msgLen);
×
394

395
  STableTSMAInfoReq req = {0};
×
396
  req.fetchingWithTsmaName = true;
×
397
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
×
398

399
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
×
400
  void *  pBuf = (*mallcFp)(bufLen);
×
401
  if(pBuf == NULL)
×
402
  {
403
    return terrno;
×
404
  }
405
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
×
406
  if(ret < 0) return ret;
×
407

408
  *msg = pBuf;
×
409
  *msgLen = bufLen;
×
410
  return TSDB_CODE_SUCCESS;
×
411
}
412

413
int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int64_t)) {
×
414
  QUERY_PARAM_CHECK(input);
×
415
  QUERY_PARAM_CHECK(msg);
×
416
  QUERY_PARAM_CHECK(msgLen);
×
417

418
  int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
×
419
  void* pBuf = (*mallcFp)(len);
×
420
  if (NULL == pBuf) {
×
421
    return terrno;
×
422
  }
423

424
  int32_t ret = tSerializeStreamProgressReq(pBuf, len, input);
×
425
  if (ret < 0) return ret;
×
426

427
  *msg = pBuf;
×
428
  *msgLen = len;
×
429
  return TSDB_CODE_SUCCESS;
×
430
}
431

432
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
2,716✔
433
  SUseDbOutput *pOut = output;
2,716✔
434
  SUseDbRsp     usedbRsp = {0};
2,716✔
435
  int32_t       code = -1;
2,716✔
436

437
  if (NULL == output || NULL == msg || msgSize <= 0) {
2,716!
438
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
439
    qError("invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
440
    goto PROCESS_USEDB_OVER;
×
441
  }
442

443
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
2,716!
444
    qError("invalid use db rsp msg, msgSize:%d", msgSize);
×
445
    code = TSDB_CODE_INVALID_MSG;
×
446
    goto PROCESS_USEDB_OVER;
×
447
  }
448

449
  if (usedbRsp.vgNum < 0) {
2,716!
450
    qError("invalid db[%s] vgroup number[%d]", usedbRsp.db, usedbRsp.vgNum);
×
451
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
452
    goto PROCESS_USEDB_OVER;
×
453
  }
454

455
  qTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
2,716✔
456
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
29,176✔
457
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
26,460✔
458
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
26,460✔
459
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
102,240✔
460
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
75,780✔
461
    }
462
  }
463

464
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
2,716✔
465

466
PROCESS_USEDB_OVER:
2,716✔
467

468
  if (code != 0) {
2,716!
469
    if (pOut) {
×
470
      if (pOut->dbVgroup) taosHashCleanup(pOut->dbVgroup->vgHash);
×
471
      taosMemoryFreeClear(pOut->dbVgroup);
×
472
    }
473
    qError("failed to process usedb rsp since %s", terrstr());
×
474
  }
475

476
  tFreeSUsedbRsp(&usedbRsp);
2,716✔
477
  return code;
2,716✔
478
}
479

480
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
56✔
481
  QUERY_PARAM_CHECK(pMetaMsg);
56!
482
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
56!
483
    qError("invalid numOfTags[%d] in table meta rsp msg", pMetaMsg->numOfTags);
×
484
    return TSDB_CODE_TSC_INVALID_VALUE;
×
485
  }
486

487
  if (pMetaMsg->numOfColumns > TSDB_MAX_COLUMNS || pMetaMsg->numOfColumns <= 0) {
56!
488
    qError("invalid numOfColumns[%d] in table meta rsp msg", pMetaMsg->numOfColumns);
×
489
    return TSDB_CODE_TSC_INVALID_VALUE;
×
490
  }
491

492
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
56✔
493
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE) {
14!
494
    qError("invalid tableType[%d] in table meta rsp msg", pMetaMsg->tableType);
×
495
    return TSDB_CODE_TSC_INVALID_VALUE;
×
496
  }
497

498
  if (pMetaMsg->sversion < 0) {
56!
499
    qError("invalid sversion[%d] in table meta rsp msg", pMetaMsg->sversion);
×
500
    return TSDB_CODE_TSC_INVALID_VALUE;
×
501
  }
502

503
  if (pMetaMsg->tversion < 0) {
56!
504
    qError("invalid tversion[%d] in table meta rsp msg", pMetaMsg->tversion);
×
505
    return TSDB_CODE_TSC_INVALID_VALUE;
×
506
  }
507

508
  if (pMetaMsg->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
56!
509
    qError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", pMetaMsg->pSchemas[0].colId);
×
510
    return TSDB_CODE_TSC_INVALID_VALUE;
×
511
  }
512

513
  return TSDB_CODE_SUCCESS;
56✔
514
}
515

516
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
561✔
517
  QUERY_PARAM_CHECK(msg);
561!
518
  QUERY_PARAM_CHECK(pMeta);
561!
519
  pMeta->vgId = msg->vgId;
561✔
520
  pMeta->tableType = msg->tableType;
561✔
521
  pMeta->uid = msg->tuid;
561✔
522
  pMeta->suid = msg->suid;
561✔
523

524
  qDebug("ctb:%s, uid:0x%" PRIx64 " meta returned, type:%d vgId:%d db:%s suid:%" PRIx64, msg->tbName, pMeta->uid,
561!
525
         pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
526

527
  return TSDB_CODE_SUCCESS;
561✔
528
}
529

530
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
107✔
531
  QUERY_PARAM_CHECK(msg);
107!
532
  QUERY_PARAM_CHECK(pMeta);
107!
533
  int32_t total = msg->numOfColumns + msg->numOfTags;
107✔
534
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
107✔
535
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
107✔
536

537
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize);
107!
538
  if (NULL == pTableMeta) {
107!
539
    qError("calloc size[%d] failed", metaSize);
×
540
    return terrno;
×
541
  }
542
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
107✔
543

544
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
107✔
545
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
107✔
546
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
107✔
547
  pTableMeta->suid = msg->suid;
107✔
548
  pTableMeta->sversion = msg->sversion;
107✔
549
  pTableMeta->tversion = msg->tversion;
107✔
550

551
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
107✔
552
  pTableMeta->tableInfo.precision = msg->precision;
107✔
553
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
107✔
554

555
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
107✔
556
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
107✔
557
    pTableMeta->schemaExt = pSchemaExt;
99✔
558
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
99✔
559
  } else {
560
    pTableMeta->schemaExt = NULL;
8✔
561
  }
562

563
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
107!
564
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
515✔
565
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
408✔
566
    if (hasPK && (i > 0)) {
408!
567
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
568
        ++pTableMeta->tableInfo.numOfPKs;
×
569
      } else {
570
        hasPK = false;
×
571
      }
572
    }
573
  }
574

575
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
107✔
576
         " sver:%d tver:%d"
577
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
578
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
579
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
580
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
581

582
  *pMeta = pTableMeta;
107✔
583
  return TSDB_CODE_SUCCESS;
107✔
584
}
585

586
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
×
587
  QUERY_PARAM_CHECK(msg);
×
588
  QUERY_PARAM_CHECK(pMeta);
×
589
  int32_t total = msg->numOfColumns + msg->numOfTags;
×
590
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
×
591
  int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
×
592
  int32_t tbNameSize = strlen(msg->tbName) + 1;
×
593

594
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + tbNameSize);
×
595
  if (NULL == pTableMeta) {
×
596
    qError("calloc size[%d] failed", metaSize);
×
597
    return terrno;
×
598
  }
599
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
×
600

601
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
×
602
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
×
603
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
×
604
  pTableMeta->suid = msg->suid;
×
605
  pTableMeta->sversion = msg->sversion;
×
606
  pTableMeta->tversion = msg->tversion;
×
607

608
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
×
609
  pTableMeta->tableInfo.precision = msg->precision;
×
610
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
×
611

612
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
×
613
  if (useCompress(msg->tableType) && msg->pSchemaExt) {
×
614
    pTableMeta->schemaExt = pSchemaExt;
×
615
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
×
616
  } else {
617
    pTableMeta->schemaExt = NULL;
×
618
  }
619

620
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
×
621
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
×
622
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
×
623
    if (hasPK && (i > 0)) {
×
624
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
625
        ++pTableMeta->tableInfo.numOfPKs;
×
626
      } else {
627
        hasPK = false;
×
628
      }
629
    }
630
  }
631

632
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize;
×
633
  tstrncpy(pTbName, msg->tbName, tbNameSize);
×
634

635
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
×
636
         " sver:%d tver:%d"
637
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
638
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
639
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
640
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
641

642
  *pMeta = pTableMeta;
×
643
  return TSDB_CODE_SUCCESS;
×
644
}
645

646
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
56✔
647
  int32_t       code = 0;
56✔
648
  STableMetaRsp metaRsp = {0};
56✔
649

650
  if (NULL == output || NULL == msg || msgSize <= 0) {
56!
651
    qError("queryProcessTableMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
652
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
653
    goto PROCESS_META_OVER;
×
654
  }
655

656
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
56!
657
    code = TSDB_CODE_INVALID_MSG;
×
658
    goto PROCESS_META_OVER;
×
659
  }
660

661
  code = queryConvertTableMetaMsg(&metaRsp);
56✔
662
  if (code != TSDB_CODE_SUCCESS) {
56!
663
    goto PROCESS_META_OVER;
×
664
  }
665

666
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
56!
667
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
50!
668
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
669
    goto PROCESS_META_OVER;
×
670
  }
671

672
  STableMetaOutput *pOut = output;
56✔
673
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
56✔
674
  pOut->dbId = metaRsp.dbId;
56✔
675

676
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
56✔
677
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
12✔
678

679
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
12✔
680
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
12✔
681

682
    pOut->ctbMeta.vgId = metaRsp.vgId;
12✔
683
    pOut->ctbMeta.tableType = metaRsp.tableType;
12✔
684
    pOut->ctbMeta.uid = metaRsp.tuid;
12✔
685
    pOut->ctbMeta.suid = metaRsp.suid;
12✔
686

687
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
12✔
688
  } else {
689
    SET_META_TYPE_TABLE(pOut->metaType);
44✔
690
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
44✔
691
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
44✔
692
  }
693

694
PROCESS_META_OVER:
56✔
695
  if (code != 0) {
56!
696
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
697
  }
698

699
  tFreeSTableMetaRsp(&metaRsp);
56✔
700
  return code;
56✔
701
}
702

703
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
×
704
  int32_t       code = 0;
×
705
  STableMetaRsp metaRsp = {0};
×
706

707
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
708
    qError("queryProcessTableNameRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
709
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
710
    goto PROCESS_NAME_OVER;
×
711
  }
712

713
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
×
714
    code = TSDB_CODE_INVALID_MSG;
×
715
    goto PROCESS_NAME_OVER;
×
716
  }
717

718
  code = queryConvertTableMetaMsg(&metaRsp);
×
719
  if (code != TSDB_CODE_SUCCESS) {
×
720
    goto PROCESS_NAME_OVER;
×
721
  }
722

723
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
×
724
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
×
725
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
726
    goto PROCESS_NAME_OVER;
×
727
  }
728

729
  STableMetaOutput *pOut = output;
×
730
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
×
731
  pOut->dbId = metaRsp.dbId;
×
732

733
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
×
734
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
×
735

736
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
×
737
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
×
738

739
    pOut->ctbMeta.vgId = metaRsp.vgId;
×
740
    pOut->ctbMeta.tableType = metaRsp.tableType;
×
741
    pOut->ctbMeta.uid = metaRsp.tuid;
×
742
    pOut->ctbMeta.suid = metaRsp.suid;
×
743

744
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
×
745
  } else {
746
    SET_META_TYPE_TABLE(pOut->metaType);
×
747
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
×
748
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
×
749
  }
750

751
PROCESS_NAME_OVER:
×
752
  if (code != 0) {
×
753
    qError("failed to process table name rsp since %s", tstrerror(code));
×
754
  }
755

756
  tFreeSTableMetaRsp(&metaRsp);
×
757
  return code;
×
758
}
759

760
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
1✔
761
  SQnodeListRsp out = {0};
1✔
762
  int32_t       code = 0;
1✔
763

764
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
765
    qError("queryProcessQnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
766
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
767
    return code;
×
768
  }
769

770
  out.qnodeList = (SArray *)output;
1✔
771
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
1!
772
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
773
    code = TSDB_CODE_INVALID_MSG;
×
774
    return code;
×
775
  }
776

777
  return code;
1✔
778
}
779

780
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
1✔
781
  SDnodeListRsp out = {0};
1✔
782
  int32_t       code = 0;
1✔
783

784
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
785
    qError("queryProcessDnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
786
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
787
    return code;
×
788
  }
789

790
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
1!
791
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
792
    code = TSDB_CODE_INVALID_MSG;
×
793
    return code;
×
794
  }
795

796
  *(SArray **)output = out.dnodeList;
1✔
797

798
  return code;
1✔
799
}
800

801
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
1✔
802
  SServerVerRsp out = {0};
1✔
803
  int32_t       code = 0;
1✔
804

805
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
806
    qError("queryProcessGetSerVerRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
807
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
808
    return code;
×
809
  }
810

811
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
1!
812
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
813
    code = TSDB_CODE_INVALID_MSG;
×
814
    return code;
×
815
  }
816

817
  *(char **)output = taosStrdup(out.ver);
1!
818
  if (NULL == *(char **)output) {
1!
819
    return terrno;
×
820
  }
821

822
  return code;
1✔
823
}
824

825
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
41✔
826
  SDbCfgRsp out = {0};
41✔
827

828
  if (NULL == output || NULL == msg || msgSize <= 0) {
41!
829
    qError("queryProcessGetDbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
830
    return TSDB_CODE_TSC_INVALID_INPUT;
×
831
  }
832

833
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
41!
834
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d, dbCfgRsp:%lu", msgSize, sizeof(out));
×
835
    return TSDB_CODE_INVALID_MSG;
×
836
  }
837

838
  memcpy(output, &out, sizeof(out));
41✔
839

840
  return TSDB_CODE_SUCCESS;
41✔
841
}
842

843
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
844
  SUserIndexRsp out = {0};
×
845

846
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
847
    qError("queryProcessGetIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
848
    return TSDB_CODE_TSC_INVALID_INPUT;
×
849
  }
850

851
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
852
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
853
    return TSDB_CODE_INVALID_MSG;
×
854
  }
855

856
  memcpy(output, &out, sizeof(out));
×
857

858
  return TSDB_CODE_SUCCESS;
×
859
}
860

861
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
1✔
862
  SRetrieveFuncRsp out = {0};
1✔
863

864
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
865
    qError("queryProcessRetrieveFuncRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
866
    return TSDB_CODE_TSC_INVALID_INPUT;
×
867
  }
868

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

874
  if (1 != out.numOfFuncs) {
1!
875
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
876
    return TSDB_CODE_INVALID_MSG;
×
877
  }
878

879
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
1✔
880

881
  memcpy(output, funcInfo, sizeof(*funcInfo));
1✔
882
  taosArrayDestroy(out.pFuncInfos);
1✔
883
  taosArrayDestroy(out.pFuncExtraInfos);
1✔
884

885
  return TSDB_CODE_SUCCESS;
1✔
886
}
887

888
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
4✔
889
  if (NULL == output || NULL == msg || msgSize <= 0) {
4!
890
    qError("queryProcessGetUserAuthRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
891
    return TSDB_CODE_TSC_INVALID_INPUT;
×
892
  }
893

894
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
4!
895
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
896
    return TSDB_CODE_INVALID_MSG;
×
897
  }
898

899
  return TSDB_CODE_SUCCESS;
4✔
900
}
901

902
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
1✔
903
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
904
    qError("queryProcessGetTbIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
905
    return TSDB_CODE_TSC_INVALID_INPUT;
×
906
  }
907

908
  STableIndexRsp *out = (STableIndexRsp *)output;
1✔
909
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
1!
910
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
911
    return TSDB_CODE_INVALID_MSG;
×
912
  }
913

914
  return TSDB_CODE_SUCCESS;
1✔
915
}
916

917
int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
1✔
918
  if (NULL == output || NULL == msg || msgSize <= 0) {
1!
919
    qError("queryProcessGetTbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
920
    return TSDB_CODE_TSC_INVALID_INPUT;
×
921
  }
922

923
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
1!
924
  if(out == NULL) {
1!
925
    return terrno;
×
926
  }
927
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
1!
928
    qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize);
×
929
    tFreeSTableCfgRsp(out);
×
930
    taosMemoryFree(out);
×
931
    return TSDB_CODE_INVALID_MSG;
×
932
  }
933

934
  *(STableCfgRsp **)output = out;
1✔
935

936
  return TSDB_CODE_SUCCESS;
1✔
937
}
938

939
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
×
940
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
941
    qError("queryProcessGetViewMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
942
    return TSDB_CODE_TSC_INVALID_INPUT;
×
943
  }
944

945
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
×
946
  if (out == NULL) {
×
947
    return terrno;
×
948
  }
949
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
×
950
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
951
    tFreeSViewMetaRsp(out);
×
952
    taosMemoryFree(out);
×
953
    return TSDB_CODE_INVALID_MSG;
×
954
  }
955

956
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
×
957

958
  *(SViewMetaRsp **)output = out;
×
959

960
  return TSDB_CODE_SUCCESS;
×
961
}
962

963
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
×
964
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
965
    qError("queryProcessGetTbTSMARsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
966
    return TSDB_CODE_TSC_INVALID_INPUT;
×
967
  }
968

969
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
×
970
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
971
    return TSDB_CODE_INVALID_MSG;
×
972
  }
973

974
  return TSDB_CODE_SUCCESS;
×
975
}
976

977
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
×
978
  if (!output || !msg || msgSize <= 0) {
×
979
    qError("queryProcessStreamProgressRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
980
    return TSDB_CODE_TSC_INVALID_INPUT;
×
981
  }
982

983
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
×
984
    qError("tDeserializeStreamProgressRsp failed, msgSize:%d", msgSize);
×
985
    return TSDB_CODE_INVALID_MSG;
×
986
  }
987
  return TSDB_CODE_SUCCESS;
×
988
}
989

990

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

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

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