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

taosdata / TDengine / #5049

11 May 2026 06:30AM UTC coverage: 73.313% (+0.09%) from 73.222%
#5049

push

travis-ci

web-flow
feat: refactor taosdump code to improve backup speed and compression ratio (#35292)

6625 of 8435 new or added lines in 28 files covered. (78.54%)

2491 existing lines in 142 files now uncovered.

281233 of 383605 relevant lines covered (73.31%)

132489999.79 hits per line

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

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

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

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

32
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
124,382,277✔
33
  QUERY_PARAM_CHECK(pOut);
124,382,277✔
34
  QUERY_PARAM_CHECK(usedbRsp);
124,382,277✔
35
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
124,382,277✔
36
  pOut->dbId = usedbRsp->uid;
124,382,277✔
37

38
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
124,382,344✔
39
  if (NULL == pOut->dbVgroup) {
124,433,114✔
40
    return terrno;
×
41
  }
42

43
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
124,433,106✔
44
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
124,432,901✔
45
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
124,433,106✔
46
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
124,433,089✔
47
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
124,432,926✔
48
  pOut->dbVgroup->flags = usedbRsp->flags;
124,432,225✔
49

50
  qDebug("db:%s, get %d vgroup, vgVersion:%d, stateTs:%" PRId64, usedbRsp->db, usedbRsp->vgNum, usedbRsp->vgVersion,
124,432,975✔
51
         usedbRsp->stateTs);
52

53
  if (usedbRsp->vgNum <= 0) {
124,392,398✔
54
    return TSDB_CODE_SUCCESS;
94,913,455✔
55
  }
56

57
  pOut->dbVgroup->vgHash =
58,956,131✔
58
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
58,673,563✔
59
  if (NULL == pOut->dbVgroup->vgHash) {
29,478,030✔
60
    return terrno;
×
61
  }
62

63
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
104,558,479✔
64
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
75,080,594✔
65
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
75,080,725✔
66
    qDebug("db:%s, vgId:%d, epNum:%d, current ep:%s:%u", usedbRsp->db, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
75,079,918✔
67
           pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port);
68
    if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) {
75,080,265✔
69
      return terrno;
×
70
    }
71
  }
72

73
  return TSDB_CODE_SUCCESS;
29,478,161✔
74
}
75

76
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
55,162,748✔
77
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
78
  QUERY_PARAM_CHECK(input);
55,162,748✔
79
  QUERY_PARAM_CHECK(msg);
55,162,748✔
80
  QUERY_PARAM_CHECK(msgLen);
55,162,748✔
81
  SBuildTableInput *pInput = input;
55,162,748✔
82

83
  STableInfoReq infoReq = {0};
55,162,748✔
84
  infoReq.option = pInput->option;
55,162,864✔
85
  infoReq.header.vgId = pInput->vgId;
55,162,919✔
86
  infoReq.autoCreateCtb = pInput->autoCreateCtb;
55,162,808✔
87

88
  if (pInput->dbFName) {
55,163,162✔
89
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
55,162,828✔
90
  }
91
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
55,162,557✔
92

93
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
55,162,973✔
94
  void   *pBuf = (*mallcFp)(bufLen);
55,162,760✔
95
  if (NULL == pBuf) {
55,162,962✔
96
    return terrno;
×
97
  }
98
  int32_t ret = tSerializeSTableInfoReq(pBuf, bufLen, &infoReq);
55,162,962✔
99
  if (ret < 0) {
55,163,205✔
100
    if (freeFp) (*freeFp)(pBuf);
14✔
101
    return ret;
×
102
  }
103

104
  *msg = pBuf;
55,163,191✔
105
  *msgLen = bufLen;
55,163,016✔
106

107
  return TSDB_CODE_SUCCESS;
55,162,623✔
108
}
109

110
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
27,218,542✔
111
                           void (*freeFp)(void *)) {
112
  QUERY_PARAM_CHECK(input);
27,218,542✔
113
  QUERY_PARAM_CHECK(msg);
27,218,542✔
114
  QUERY_PARAM_CHECK(msgLen);
27,218,542✔
115
  SBuildUseDBInput *pInput = input;
27,218,542✔
116

117
  SUseDbReq usedbReq = {0};
27,218,542✔
118
  tstrncpy(usedbReq.db, pInput->db, TSDB_DB_FNAME_LEN);
27,218,542✔
119
  usedbReq.db[sizeof(usedbReq.db) - 1] = 0;
27,218,576✔
120
  usedbReq.vgVersion = pInput->vgVersion;
27,218,576✔
121
  usedbReq.dbId = pInput->dbId;
27,218,453✔
122
  usedbReq.numOfTable = pInput->numOfTable;
27,218,496✔
123
  usedbReq.stateTs = pInput->stateTs;
27,218,453✔
124

125
  int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
27,218,474✔
126
  void   *pBuf = (*mallcFp)(bufLen);
27,218,510✔
127
  if (NULL == pBuf) {
27,218,576✔
128
    return terrno;
×
129
  }
130
  int32_t ret = tSerializeSUseDbReq(pBuf, bufLen, &usedbReq);
27,218,576✔
131
  if (ret < 0) {
27,218,542✔
132
    if (freeFp) (*freeFp)(pBuf);
×
133
    return ret;
×
134
  }
135

136
  *msg = pBuf;
27,218,542✔
137
  *msgLen = bufLen;
27,218,576✔
138

139
  return TSDB_CODE_SUCCESS;
27,218,556✔
140
}
141

142
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
64,270✔
143
                               void (*freeFp)(void *)) {
144
  QUERY_PARAM_CHECK(msg);
64,270✔
145
  QUERY_PARAM_CHECK(msgLen);
64,270✔
146

147
  SQnodeListReq qnodeListReq = {0};
64,270✔
148
  qnodeListReq.rowNum = -1;
64,270✔
149

150
  int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
64,270✔
151
  void   *pBuf = (*mallcFp)(bufLen);
64,270✔
152
  if (NULL == pBuf) {
64,270✔
153
    return terrno;
×
154
  }
155

156
  int32_t ret = tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq);
64,270✔
157
  if (ret < 0) {
64,270✔
158
    if (freeFp) (*freeFp)(pBuf);
×
159
    return ret;
×
160
  }
161

162
  *msg = pBuf;
64,270✔
163
  *msgLen = bufLen;
64,270✔
164

165
  return TSDB_CODE_SUCCESS;
64,270✔
166
}
167

168
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
53,174✔
169
                               void (*freeFp)(void *)) {
170
  QUERY_PARAM_CHECK(msg);
53,174✔
171
  QUERY_PARAM_CHECK(msgLen);
53,174✔
172

173
  SDnodeListReq dnodeListReq = {0};
53,174✔
174
  dnodeListReq.rowNum = -1;
53,174✔
175

176
  int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
53,174✔
177
  void   *pBuf = (*mallcFp)(bufLen);
53,174✔
178
  if (NULL == pBuf) {
53,174✔
179
    return terrno;
×
180
  }
181
  int32_t ret = tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq);
53,174✔
182
  if (ret < 0) {
53,174✔
183
    if (freeFp) (*freeFp)(pBuf);
×
184
    return ret;
×
185
  }
186

187
  *msg = pBuf;
53,174✔
188
  *msgLen = bufLen;
53,174✔
189

190
  return TSDB_CODE_SUCCESS;
53,174✔
191
}
192

193
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
204✔
194
                               void (*freeFp)(void *)) {
195
  QUERY_PARAM_CHECK(msg);
204✔
196
  QUERY_PARAM_CHECK(msgLen);
204✔
197

198
  SServerVerReq req = {0};
204✔
199

200
  int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
204✔
201
  void   *pBuf = (*mallcFp)(bufLen);
204✔
202
  if (NULL == pBuf) {
204✔
203
    return terrno;
×
204
  }
205
  int32_t ret = tSerializeSServerVerReq(pBuf, bufLen, &req);
204✔
206
  if (ret < 0) {
204✔
207
    if (freeFp) (*freeFp)(pBuf);
×
208
    return ret;
×
209
  }
210

211
  *msg = pBuf;
204✔
212
  *msgLen = bufLen;
204✔
213

214
  return TSDB_CODE_SUCCESS;
204✔
215
}
216

217
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
5,920,704✔
218
                              void (*freeFp)(void *)) {
219
  QUERY_PARAM_CHECK(input);
5,920,704✔
220
  QUERY_PARAM_CHECK(msg);
5,920,704✔
221
  QUERY_PARAM_CHECK(msgLen);
5,920,704✔
222

223
  SDbCfgReq dbCfgReq = {0};
5,920,704✔
224
  tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
5,920,704✔
225

226
  int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
5,920,704✔
227
  void   *pBuf = (*mallcFp)(bufLen);
5,920,716✔
228
  if (NULL == pBuf) {
5,920,716✔
229
    return terrno;
×
230
  }
231
  int32_t ret = tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq);
5,920,716✔
232
  if (ret < 0) {
5,920,716✔
233
    if (freeFp) (*freeFp)(pBuf);
×
234
    return ret;
×
235
  }
236

237
  *msg = pBuf;
5,920,716✔
238
  *msgLen = bufLen;
5,920,716✔
239

240
  return TSDB_CODE_SUCCESS;
5,920,716✔
241
}
242

243
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t), 
204✔
244
                              void (*freeFp)(void *)) {
245
  QUERY_PARAM_CHECK(input);
204✔
246
  QUERY_PARAM_CHECK(msg);
204✔
247
  QUERY_PARAM_CHECK(msgLen);
204✔
248

249
  SUserIndexReq indexReq = {0};
204✔
250
  tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
204✔
251

252
  int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
204✔
253
  void   *pBuf = (*mallcFp)(bufLen);
204✔
254
  if (NULL == pBuf) {
204✔
255
    return terrno;
×
256
  }
257
  int32_t ret = tSerializeSUserIndexReq(pBuf, bufLen, &indexReq);
204✔
258
  if (ret < 0) {
204✔
259
    if (freeFp) (*freeFp)(pBuf);
×
260
    return ret;
×
261
  }
262

263
  *msg = pBuf;
204✔
264
  *msgLen = bufLen;
204✔
265

266
  return TSDB_CODE_SUCCESS;
204✔
267
}
268

269
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
169,853✔
270
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
271
  QUERY_PARAM_CHECK(input);
169,853✔
272
  QUERY_PARAM_CHECK(msg);
169,853✔
273
  QUERY_PARAM_CHECK(msgLen);
169,853✔
274

275
  SRetrieveFuncReq funcReq = {0};
169,853✔
276
  funcReq.numOfFuncs = 1;
169,853✔
277
  funcReq.ignoreCodeComment = true;
169,853✔
278
  funcReq.pFuncNames = taosArrayInit(1, strlen(input) + 1);
169,853✔
279
  if (NULL == funcReq.pFuncNames) {
169,853✔
280
    return terrno;
×
281
  }
282
  if (taosArrayPush(funcReq.pFuncNames, input) == NULL) {
339,706✔
283
    taosArrayDestroy(funcReq.pFuncNames);
×
284
    return terrno;
×
285
  }
286

287
  int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
169,853✔
288
  void   *pBuf = (*mallcFp)(bufLen);
169,853✔
289
  if (NULL == pBuf) {
169,853✔
290
    taosArrayDestroy(funcReq.pFuncNames);
×
291
    return terrno;
×
292
  }
293
  int32_t ret = tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq);
169,853✔
294
  if (ret < 0) {
169,853✔
295
    taosArrayDestroy(funcReq.pFuncNames);
×
296
    if (freeFp) (*freeFp)(pBuf);
×
297
    return ret;
×
298
  }
299

300
  taosArrayDestroy(funcReq.pFuncNames);
169,853✔
301

302
  *msg = pBuf;
169,853✔
303
  *msgLen = bufLen;
169,853✔
304

305
  return TSDB_CODE_SUCCESS;
169,853✔
306
}
307

308
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
7,035,407✔
309
                                 void (*freeFp)(void *)) {
310
  QUERY_PARAM_CHECK(input);
7,035,407✔
311
  QUERY_PARAM_CHECK(msg);
7,035,407✔
312
  QUERY_PARAM_CHECK(msgLen);
7,035,407✔
313

314
  SGetUserAuthReq req = {0};
7,035,407✔
315
  tstrncpy(req.user, input, TSDB_USER_LEN);
7,035,407✔
316

317
  int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
7,035,407✔
318
  void   *pBuf = (*mallcFp)(bufLen);
7,035,407✔
319
  if (NULL == pBuf) {
7,035,407✔
320
    return terrno;
×
321
  }
322
  int32_t ret = tSerializeSGetUserAuthReq(pBuf, bufLen, &req);
7,035,407✔
323
  if (ret < 0) {
7,035,407✔
324
    if (freeFp) (*freeFp)(pBuf);
×
325
    return ret;
×
326
  }
327

328
  *msg = pBuf;
7,035,407✔
329
  *msgLen = bufLen;
7,035,407✔
330

331
  return TSDB_CODE_SUCCESS;
7,035,407✔
332
}
333

334
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
204✔
335
                                void (*freeFp)(void *)) {
336
  QUERY_PARAM_CHECK(input);
204✔
337
  QUERY_PARAM_CHECK(msg);
204✔
338
  QUERY_PARAM_CHECK(msgLen);
204✔
339

340
  STableIndexReq indexReq = {0};
204✔
341
  tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
204✔
342

343
  int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
204✔
344
  void   *pBuf = (*mallcFp)(bufLen);
204✔
345
  if (NULL == pBuf) {
204✔
346
    return terrno;
×
347
  }
348
  int32_t ret = tSerializeSTableIndexReq(pBuf, bufLen, &indexReq);
204✔
349
  if (ret < 0) {
204✔
350
    if (freeFp) (*freeFp)(pBuf);
×
351
    return ret;
×
352
  }
353

354
  *msg = pBuf;
204✔
355
  *msgLen = bufLen;
204✔
356

357
  return TSDB_CODE_SUCCESS;
204✔
358
}
359

360
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
122,318✔
361
                              void (*freeFp)(void *)) {
362
  QUERY_PARAM_CHECK(input);
122,318✔
363
  QUERY_PARAM_CHECK(msg);
122,318✔
364
  QUERY_PARAM_CHECK(msgLen);
122,318✔
365

366
  SBuildTableInput *pInput = input;
122,318✔
367
  STableCfgReq      cfgReq = {0};
122,318✔
368
  cfgReq.header.vgId = pInput->vgId;
122,318✔
369
  tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
122,318✔
370
  tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
122,318✔
371

372
  int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
122,318✔
373
  void   *pBuf = (*mallcFp)(bufLen);
122,318✔
374
  if (NULL == pBuf) {
122,318✔
375
    return terrno;
×
376
  }
377
  int32_t ret = tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq);
122,318✔
378
  if (ret < 0) {
122,318✔
379
    if (freeFp) (*freeFp)(pBuf);
×
380
    return ret;
×
381
  }
382

383
  *msg = pBuf;
122,318✔
384
  *msgLen = bufLen;
122,318✔
385

386
  return TSDB_CODE_SUCCESS;
122,318✔
387
}
388

389
int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
21,475,679✔
390
                                 void (*freeFp)(void *)) {
391
  QUERY_PARAM_CHECK(input);
21,475,679✔
392
  QUERY_PARAM_CHECK(msg);
21,475,679✔
393
  QUERY_PARAM_CHECK(msgLen);
21,475,679✔
394

395
  SViewMetaReq req = {0};
21,475,679✔
396
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
21,475,642✔
397

398
  int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
21,475,572✔
399
  void   *pBuf = (*mallcFp)(bufLen);
21,475,535✔
400
  if (NULL == pBuf) {
21,475,523✔
401
    return terrno;
×
402
  }
403
  int32_t ret = tSerializeSViewMetaReq(pBuf, bufLen, &req);
21,475,523✔
404
  if (ret < 0) {
21,475,679✔
405
    if (freeFp) (*freeFp)(pBuf);
×
406
    return ret;
×
407
  }
408

409
  *msg = pBuf;
21,475,679✔
410
  *msgLen = bufLen;
21,475,679✔
411

412
  return TSDB_CODE_SUCCESS;
21,475,641✔
413
}
414

415
int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
12,859✔
416
                                  void (*freeFp)(void *)) {
417
  QUERY_PARAM_CHECK(input);
12,859✔
418
  QUERY_PARAM_CHECK(msg);
12,859✔
419
  QUERY_PARAM_CHECK(msgLen);
12,859✔
420

421
  STableTSMAInfoReq req = {0};
12,859✔
422
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
12,859✔
423

424
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
12,859✔
425
  void *  pBuf = (*mallcFp)(bufLen);
12,859✔
426
  if (NULL == pBuf) {
12,859✔
427
    return terrno;
×
428
  }
429
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
12,859✔
430
  if (ret < 0) {
12,859✔
431
    if (freeFp) (*freeFp)(pBuf);
×
432
    return ret;
×
433
  }
434

435
  *msg = pBuf;
12,859✔
436
  *msgLen = bufLen;
12,859✔
437
  return TSDB_CODE_SUCCESS;
12,859✔
438
}
439

440
int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
2,866✔
441
                             void (*freeFp)(void *)) {
442
  QUERY_PARAM_CHECK(input);
2,866✔
443
  QUERY_PARAM_CHECK(msg);
2,866✔
444
  QUERY_PARAM_CHECK(msgLen);
2,866✔
445

446
  STableTSMAInfoReq req = {0};
2,866✔
447
  req.fetchingWithTsmaName = true;
2,866✔
448
  tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
2,866✔
449

450
  int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
2,866✔
451
  void   *pBuf = (*mallcFp)(bufLen);
2,866✔
452
  if (pBuf == NULL) {
2,866✔
453
    return terrno;
×
454
  }
455
  int32_t ret = tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
2,866✔
456
  if (ret < 0) {
2,866✔
457
    if (freeFp) (*freeFp)(pBuf);
×
458
    return ret;
×
459
  }
460

461
  *msg = pBuf;
2,866✔
462
  *msgLen = bufLen;
2,866✔
463
  return TSDB_CODE_SUCCESS;
2,866✔
464
}
465

466
static int32_t queryBuildGetRsmaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
26,334✔
467
                                    void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
468
  QUERY_PARAM_CHECK(input);
26,334✔
469
  QUERY_PARAM_CHECK(msg);
26,334✔
470
  QUERY_PARAM_CHECK(msgLen);
26,334✔
471

472
  SRsmaInfoReq req = {.withColName = 1};
26,334✔
473
  (void)snprintf(req.name, sizeof(req.name), "%s", (const char *)input);
26,334✔
474

475
  int32_t bufLen = tSerializeRsmaInfoReq(NULL, 0, &req);
26,334✔
476
  void   *pBuf = (*mallcFp)(bufLen);
26,334✔
477
  if (pBuf == NULL) {
26,334✔
478
    return terrno;
×
479
  }
480
  int32_t ret = tSerializeRsmaInfoReq(pBuf, bufLen, &req);
26,334✔
481
  if (ret < 0) {
26,334✔
482
    if (freeFp) (*freeFp)(pBuf);
×
483
    return ret;
×
484
  }
485

486
  *msg = pBuf;
26,334✔
487
  *msgLen = bufLen;
26,334✔
488
  return TSDB_CODE_SUCCESS;
26,334✔
489
}
490

491
int32_t queryBuildGetStreamProgressMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
7,849✔
492
                                       void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
493
  QUERY_PARAM_CHECK(input);
7,849✔
494
  QUERY_PARAM_CHECK(msg);
7,849✔
495
  QUERY_PARAM_CHECK(msgLen);
7,849✔
496

497
  int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
7,849✔
498
  void* pBuf = (*mallcFp)(len);
7,849✔
499
  if (NULL == pBuf) {
7,849✔
500
    return terrno;
×
501
  }
502

503
  int32_t ret = tSerializeStreamProgressReq(pBuf, len, input);
7,849✔
504
  if (ret < 0) {
7,849✔
505
    if (freeFp) (*freeFp)(pBuf);
×
506
    return ret;
×
507
  }
508

509
  *msg = pBuf;
7,849✔
510
  *msgLen = len;
7,849✔
511
  return TSDB_CODE_SUCCESS;
7,849✔
512
}
513

514
int32_t queryBuildVSubTablesMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
×
515
                                void (*freeFp)(void *)) {
516
  QUERY_PARAM_CHECK(input);
×
517
  QUERY_PARAM_CHECK(msg);
×
518
  QUERY_PARAM_CHECK(msgLen);
×
519

520
  SVSubTablesReq req = {0};
×
521
  req.suid = *(int64_t*)input;
×
522

523
  int32_t bufLen = tSerializeSVSubTablesReq(NULL, 0, &req);
×
524
  void   *pBuf = (*mallcFp)(bufLen);
×
525
  if (NULL == pBuf) {
×
526
    return terrno;
×
527
  }
528
  if (tSerializeSVSubTablesReq(pBuf, bufLen, &req) < 0) {
×
529
    if (freeFp) (*freeFp)(pBuf);
×
530
    return TSDB_CODE_TSC_INVALID_INPUT;
×
531
  }
532

533
  *msg = pBuf;
×
534
  *msgLen = bufLen;
×
535

536
  return TSDB_CODE_SUCCESS;
×
537
}
538

539
int32_t queryBuildVStbRefDBsMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t),
8,876,369✔
540
                                void (*freeFp)(void *)) {
541
  QUERY_PARAM_CHECK(input);
8,876,369✔
542
  QUERY_PARAM_CHECK(msg);
8,876,369✔
543
  QUERY_PARAM_CHECK(msgLen);
8,876,369✔
544

545
  SVStbRefDbsReq req = {0};
8,876,369✔
546
  req.suid = *(int64_t*)input;
8,876,369✔
547

548
  int32_t bufLen = tSerializeSVStbRefDbsReq(NULL, 0, &req);
8,876,369✔
549
  void   *pBuf = (*mallcFp)(bufLen);
8,876,369✔
550
  if (NULL == pBuf) {
8,876,369✔
551
    return terrno;
×
552
  }
553
  if (tSerializeSVStbRefDbsReq(pBuf, bufLen, &req) < 0) {
8,876,369✔
554
    if (freeFp) (*freeFp)(pBuf);
×
555
    return TSDB_CODE_TSC_INVALID_INPUT;
×
556
  }
557

558
  *msg = pBuf;
8,876,369✔
559
  *msgLen = bufLen;
8,876,369✔
560

561
  return TSDB_CODE_SUCCESS;
8,876,369✔
562
}
563

564
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
27,082,125✔
565
  SUseDbOutput *pOut = output;
27,082,125✔
566
  SUseDbRsp     usedbRsp = {0};
27,082,125✔
567
  int32_t       code = -1;
27,082,125✔
568

569
  if (NULL == output || NULL == msg || msgSize <= 0) {
27,082,125✔
570
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
571
    qError("invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
572
    goto PROCESS_USEDB_OVER;
×
573
  }
574

575
  if (tDeserializeSUseDbRsp(msg, msgSize, &usedbRsp) != 0) {
27,082,125✔
576
    qError("invalid use db rsp msg, msgSize:%d", msgSize);
×
577
    code = TSDB_CODE_INVALID_MSG;
×
578
    goto PROCESS_USEDB_OVER;
×
579
  }
580

581
  if (usedbRsp.vgNum < 0) {
27,081,994✔
582
    qError("invalid db[%s] vgroup number[%d]", usedbRsp.db, usedbRsp.vgNum);
×
583
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
584
    goto PROCESS_USEDB_OVER;
×
585
  }
586

587
  qTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
27,081,994✔
588
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
91,430,825✔
589
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
64,348,760✔
590
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
64,348,640✔
591
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
131,803,764✔
592
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
67,455,184✔
593
    }
594
  }
595

596
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
27,082,065✔
597

598
PROCESS_USEDB_OVER:
27,082,125✔
599

600
  if (code != 0) {
27,082,125✔
601
    if (pOut) {
×
602
      if (pOut->dbVgroup) taosHashCleanup(pOut->dbVgroup->vgHash);
×
603
      taosMemoryFreeClear(pOut->dbVgroup);
×
604
    }
605
    qError("failed to process usedb rsp since %s", terrstr());
×
606
  }
607

608
  tFreeSUsedbRsp(&usedbRsp);
27,082,125✔
609
  return code;
27,082,125✔
610
}
611

612
static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
42,882,544✔
613
  QUERY_PARAM_CHECK(pMetaMsg);
42,882,544✔
614
  if (pMetaMsg->numOfTags < 0 || pMetaMsg->numOfTags > TSDB_MAX_TAGS) {
42,882,544✔
615
    qError("invalid numOfTags[%d] in table meta rsp msg", pMetaMsg->numOfTags);
83✔
616
    return TSDB_CODE_TSC_INVALID_VALUE;
×
617
  }
618

619
  if (pMetaMsg->numOfColumns > TSDB_MAX_COLUMNS || pMetaMsg->numOfColumns <= 0) {
42,881,559✔
620
    qError("invalid numOfColumns[%d] in table meta rsp msg", pMetaMsg->numOfColumns);
1,380✔
621
    return TSDB_CODE_TSC_INVALID_VALUE;
×
622
  }
623

624
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
42,880,829✔
625
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE &&
6,634,142✔
626
      pMetaMsg->tableType != TSDB_VIRTUAL_NORMAL_TABLE && pMetaMsg->tableType != TSDB_VIRTUAL_CHILD_TABLE) {
407,998✔
627
    qError("invalid tableType[%d] in table meta rsp msg", pMetaMsg->tableType);
×
628
    return TSDB_CODE_TSC_INVALID_VALUE;
×
629
  }
630

631
  if (pMetaMsg->sversion < 0) {
42,881,579✔
632
    qError("invalid sversion[%d] in table meta rsp msg", pMetaMsg->sversion);
×
633
    return TSDB_CODE_TSC_INVALID_VALUE;
×
634
  }
635

636
  if (pMetaMsg->tversion < 0) {
42,881,642✔
637
    qError("invalid tversion[%d] in table meta rsp msg", pMetaMsg->tversion);
×
638
    return TSDB_CODE_TSC_INVALID_VALUE;
×
639
  }
640

641
  if (pMetaMsg->rversion < 0) {
42,881,579✔
642
    qError("invalid rversion[%d] in table meta rsp msg", pMetaMsg->rversion);
×
643
    return TSDB_CODE_TSC_INVALID_VALUE;
×
644
  }
645

646
  if (pMetaMsg->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
42,879,561✔
647
    qError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", pMetaMsg->pSchemas[0].colId);
×
648
    return TSDB_CODE_TSC_INVALID_VALUE;
×
649
  }
650

651
  return TSDB_CODE_SUCCESS;
42,880,374✔
652
}
653

654
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
65,092,841✔
655
  QUERY_PARAM_CHECK(msg);
65,092,841✔
656
  QUERY_PARAM_CHECK(pMeta);
65,092,841✔
657
  pMeta->vgId = msg->vgId;
65,092,841✔
658
  pMeta->tableType = msg->tableType;
65,090,399✔
659
  pMeta->uid = msg->tuid;
65,078,273✔
660
  pMeta->suid = msg->suid;
65,062,399✔
661

662
  qDebug("ctb:%s, uid:0x%" PRIx64 " meta returned, type:%d vgId:%d db:%s suid:%" PRIx64, msg->tbName, pMeta->uid,
65,083,871✔
663
         pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
664

665
  return TSDB_CODE_SUCCESS;
65,089,246✔
666
}
667

668
int32_t queryCreateVCTableMetaFromMsg(STableMetaRsp *msg, SVCTableMeta **pMeta) {
251,538✔
669
  QUERY_PARAM_CHECK(msg);
251,538✔
670
  QUERY_PARAM_CHECK(pMeta);
251,538✔
671
  QUERY_PARAM_CHECK(msg->pColRefs);
251,538✔
672

673
  int32_t pColRefSize = sizeof(SColRef) * msg->numOfColRefs;
251,538✔
674
  int32_t pTagRefSize = (msg->pTagRefs && msg->numOfTagRefs > 0) ? sizeof(SColRef) * msg->numOfTagRefs : 0;
251,538✔
675

676
  SVCTableMeta *pTableMeta = taosMemoryCalloc(1, sizeof(SVCTableMeta) + pColRefSize + pTagRefSize);
251,538✔
677
  if (NULL == pTableMeta) {
251,538✔
678
    qError("calloc size[%d] failed", (int32_t)sizeof(SVCTableMeta) + pColRefSize + pTagRefSize);
×
679
    return terrno;
×
680
  }
681

682
  pTableMeta->vgId = msg->vgId;
251,538✔
683
  pTableMeta->tableType = msg->tableType;
251,538✔
684
  pTableMeta->uid = msg->tuid;
251,538✔
685
  pTableMeta->suid = msg->suid;
251,538✔
686
  pTableMeta->numOfColRefs = msg->numOfColRefs;
251,538✔
687
  pTableMeta->rversion = msg->rversion;
251,538✔
688

689
  pTableMeta->colRef = (SColRef *)((char *)pTableMeta + sizeof(SVCTableMeta));
251,538✔
690
  memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
251,538✔
691

692
  if (pTagRefSize > 0) {
251,538✔
693
    pTableMeta->tagRef = (SColRef *)((char *)pTableMeta + sizeof(SVCTableMeta) + pColRefSize);
×
694
    memcpy(pTableMeta->tagRef, msg->pTagRefs, pTagRefSize);
×
695
    pTableMeta->numOfTagRefs = msg->numOfTagRefs;
×
696
  } else {
697
    pTableMeta->tagRef = NULL;
251,538✔
698
    pTableMeta->numOfTagRefs = 0;
251,538✔
699
  }
700

701
  qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, (pTableMeta)->uid,
251,538✔
702
         (pTableMeta)->tableType, (pTableMeta)->vgId, msg->dbFName, (pTableMeta)->suid);
703

704
  *pMeta = pTableMeta;
251,538✔
705
  return TSDB_CODE_SUCCESS;
251,538✔
706
}
707

708
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
63,303,692✔
709
  QUERY_PARAM_CHECK(msg);
63,303,692✔
710
  QUERY_PARAM_CHECK(pMeta);
63,303,692✔
711
  int32_t total = msg->numOfColumns + msg->numOfTags;
63,303,692✔
712
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
63,303,675✔
713
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
63,303,675✔
714
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) ? sizeof(SColRef) * msg->numOfColRefs : 0;
63,303,417✔
715
  int32_t pTagRefSize = (hasRefCol(msg->tableType) && msg->pTagRefs && !isStb) ? sizeof(SColRef) * msg->numOfTagRefs : 0;
63,303,685✔
716

717
  int32_t sz = metaSize + schemaExtSize + pColRefSize + pTagRefSize;
63,302,442✔
718
  STableMeta *pTableMeta = taosMemoryCalloc(1, sz);
63,302,442✔
719
  if (NULL == pTableMeta) {
63,304,163✔
720
    qError("calloc size[%d] failed since %s", sz, tstrerror(terrno));
×
721
    return terrno;
×
722
  }
723
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
63,304,163✔
724
  // SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
725
  // SColRef    *pTagRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize + pColRefSize);
726

727
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
63,304,163✔
728
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
63,303,725✔
729
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
63,302,999✔
730
  pTableMeta->suid = msg->suid;
63,302,265✔
731
  pTableMeta->sversion = msg->sversion;
63,302,245✔
732
  pTableMeta->tversion = msg->tversion;
63,303,725✔
733
  pTableMeta->rversion = msg->rversion;
63,302,999✔
734
  pTableMeta->ownerId = msg->ownerId;
63,303,417✔
735
  pTableMeta->flag = msg->flag;
63,301,831✔
736
  pTableMeta->secLvl = msg->secLvl;  // explicit copy: bit-field positions differ between STableMetaRsp and STableMeta
63,303,437✔
737
  pTableMeta->secureDelete = msg->secureDelete;
63,301,539✔
738
  if (msg->virtualStb) {
63,301,814✔
739
    pTableMeta->virtualStb = 1;
634,156✔
740
    pTableMeta->numOfColRefs = 0;
634,156✔
741
  } else {
742
    if (msg->tableType == TSDB_VIRTUAL_CHILD_TABLE && isStb) {
62,668,365✔
743
      pTableMeta->virtualStb = 1;
251,538✔
744
      pTableMeta->numOfColRefs = 0;
251,538✔
745
    } else {
746
      pTableMeta->virtualStb = 0;
62,416,555✔
747
      pTableMeta->numOfColRefs = msg->numOfColRefs;
62,416,555✔
748
    }
749
  }
750

751
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
63,302,564✔
752
  pTableMeta->tableInfo.precision = msg->precision;
63,302,999✔
753
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
63,301,499✔
754

755
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
63,301,104✔
756
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
63,302,541✔
757
    pTableMeta->schemaExt = pSchemaExt;
61,021,569✔
758
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
61,021,984✔
759
  } else {
760
    pTableMeta->schemaExt = NULL;
2,282,176✔
761
  }
762

763
  if (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) {
63,301,970✔
764
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
1,107,315✔
765
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
1,107,315✔
766
  } else {
767
    pTableMeta->colRef = NULL;
62,195,385✔
768
  }
769

770
  if (hasRefCol(msg->tableType) && msg->pTagRefs && !isStb) {
63,302,720✔
771
    pTableMeta->tagRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize + pColRefSize);
×
772
    memcpy(pTableMeta->tagRef, msg->pTagRefs, pTagRefSize);
×
773
    pTableMeta->numOfTagRefs = msg->numOfTagRefs;
×
774
  } else {
775
    pTableMeta->tagRef = NULL;
63,301,263✔
776
    pTableMeta->numOfTagRefs = 0;
63,301,097✔
777
  }
778

779
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
63,301,847✔
780
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
2,147,483,647✔
781
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
2,147,483,647✔
782
    if (hasPK && (i > 0)) {
2,147,483,647✔
783
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
602,109✔
784
        ++pTableMeta->tableInfo.numOfPKs;
303,337✔
785
      } else {
786
        hasPK = false;
298,772✔
787
      }
788
    }
789
  }
790

791
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
63,303,138✔
792
         " sver:%d tver:%d"
793
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
794
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
795
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
796
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
797

798
  *pMeta = pTableMeta;
63,304,598✔
799
  return TSDB_CODE_SUCCESS;
63,304,598✔
800
}
801

802
int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
191,794✔
803
  QUERY_PARAM_CHECK(msg);
191,794✔
804
  QUERY_PARAM_CHECK(pMeta);
191,794✔
805
  int32_t total = msg->numOfColumns + msg->numOfTags;
191,794✔
806
  int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
191,794✔
807
  int32_t schemaExtSize = (withExtSchema(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0;
191,794✔
808
  int32_t pColRefSize = (hasRefCol(msg->tableType) && msg->pColRefs) ? sizeof(SColRef) * msg->numOfColRefs : 0;
191,794✔
809
  int32_t tbNameSize = strlen(msg->tbName) + 1;
191,794✔
810

811

812
  STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize + pColRefSize + tbNameSize);
191,794✔
813
  if (NULL == pTableMeta) {
191,794✔
814
    qError("calloc size[%d] failed", metaSize);
×
815
    return terrno;
×
816
  }
817
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
191,794✔
818
  SColRef    *pColRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
191,794✔
819

820
  pTableMeta->vgId = isStb ? 0 : msg->vgId;
191,794✔
821
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
191,794✔
822
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
191,794✔
823
  pTableMeta->suid = msg->suid;
191,794✔
824
  pTableMeta->sversion = msg->sversion;
191,794✔
825
  pTableMeta->tversion = msg->tversion;
191,794✔
826
  pTableMeta->rversion = msg->rversion;
191,794✔
827
  pTableMeta->virtualStb = msg->virtualStb;
191,794✔
828
  pTableMeta->numOfColRefs = msg->numOfColRefs;
191,794✔
829
  pTableMeta->ownerId = msg->ownerId;
191,794✔
830
  pTableMeta->secureDelete = msg->secureDelete;
191,794✔
831

832
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
191,794✔
833
  pTableMeta->tableInfo.precision = msg->precision;
191,794✔
834
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
191,794✔
835

836
  TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
191,794✔
837
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
191,794✔
838
    pTableMeta->schemaExt = pSchemaExt;
191,794✔
839
    TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
191,794✔
840
  } else {
841
    pTableMeta->schemaExt = NULL;
×
842
  }
843

844
  if (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) {
191,794✔
845
    pTableMeta->colRef = pColRef;
×
846
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
×
847
  } else {
848
    pTableMeta->colRef = NULL;
191,794✔
849
  }
850

851
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
191,794✔
852
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
622,019✔
853
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
430,225✔
854
    if (hasPK && (i > 0)) {
430,225✔
855
      if ((pTableMeta->schema[i].flags & COL_IS_KEY)) {
×
856
        ++pTableMeta->tableInfo.numOfPKs;
×
857
      } else {
858
        hasPK = false;
×
859
      }
860
    }
861
  }
862

863
  char *pTbName = (char *)pTableMeta + metaSize + schemaExtSize + pColRefSize;
191,794✔
864
  tstrncpy(pTbName, msg->tbName, tbNameSize);
191,794✔
865

866
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
191,794✔
867
         " sver:%d tver:%d"
868
         " tagNum:%d colNum:%d precision:%d rowSize:%d",
869
         msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
870
         pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
871
         pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize);
872

873
  *pMeta = pTableMeta;
191,794✔
874
  return TSDB_CODE_SUCCESS;
191,794✔
875
}
876

877
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
42,691,291✔
878
  int32_t       code = 0;
42,691,291✔
879
  STableMetaRsp metaRsp = {0};
42,691,291✔
880

881
  if (NULL == output || NULL == msg || msgSize <= 0) {
42,691,291✔
UNCOV
882
    qError("queryProcessTableMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
883
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
884
    goto PROCESS_META_OVER;
×
885
  }
886

887
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
42,691,291✔
888
    code = TSDB_CODE_INVALID_MSG;
×
889
    goto PROCESS_META_OVER;
×
890
  }
891

892
  code = queryConvertTableMetaMsg(&metaRsp);
42,690,770✔
893
  if (code != TSDB_CODE_SUCCESS) {
42,688,477✔
894
    goto PROCESS_META_OVER;
×
895
  }
896

897
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
127,909,429✔
898
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
84,969,414✔
899
                    metaRsp.virtualStb);
42,280,937✔
900
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
42,688,477✔
901
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
40,407,890✔
902
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
903
    goto PROCESS_META_OVER;
×
904
  }
905

906
  STableMetaOutput *pOut = output;
42,690,833✔
907
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
42,690,833✔
908
  pOut->dbId = metaRsp.dbId;
42,690,833✔
909

910
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
42,689,685✔
911
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
14,175,726✔
912

913
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
14,175,726✔
914
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
14,175,706✔
915

916
    pOut->ctbMeta.vgId = metaRsp.vgId;
14,176,144✔
917
    pOut->ctbMeta.tableType = metaRsp.tableType;
14,176,164✔
918
    pOut->ctbMeta.uid = metaRsp.tuid;
14,176,164✔
919
    pOut->ctbMeta.suid = metaRsp.suid;
14,175,726✔
920

921
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
14,175,726✔
922
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
28,513,959✔
923
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
251,538✔
924

925
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
251,538✔
926
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
251,538✔
927

928
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
251,538✔
929
    if (TSDB_CODE_SUCCESS != code) {
251,538✔
930
      goto PROCESS_META_OVER;
×
931
    }
932
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
251,538✔
933
  } else {
934
    SET_META_TYPE_TABLE(pOut->metaType);
28,262,421✔
935
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
28,263,151✔
936
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
28,263,151✔
937
  }
938

939
PROCESS_META_OVER:
42,691,264✔
940
  if (code != 0) {
42,691,264✔
941
    qError("failed to process table meta rsp since %s", tstrerror(code));
×
942
  }
943

944
  tFreeSTableMetaRsp(&metaRsp);
42,691,264✔
945
  return code;
42,691,284✔
946
}
947

948
static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize) {
191,794✔
949
  int32_t       code = 0;
191,794✔
950
  STableMetaRsp metaRsp = {0};
191,794✔
951

952
  if (NULL == output || NULL == msg || msgSize <= 0) {
191,794✔
953
    qError("queryProcessTableNameRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
954
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
955
    goto PROCESS_NAME_OVER;
×
956
  }
957

958
  if (tDeserializeSTableMetaRsp(msg, msgSize, &metaRsp) != 0) {
191,794✔
959
    code = TSDB_CODE_INVALID_MSG;
×
960
    goto PROCESS_NAME_OVER;
×
961
  }
962

963
  code = queryConvertTableMetaMsg(&metaRsp);
191,794✔
964
  if (code != TSDB_CODE_SUCCESS) {
191,794✔
965
    goto PROCESS_NAME_OVER;
×
966
  }
967

968
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
575,382✔
969
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
383,588✔
970
                    metaRsp.virtualStb);
191,794✔
971

972
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
191,794✔
973
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
191,794✔
974
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
975
    goto PROCESS_NAME_OVER;
×
976
  }
977

978
  STableMetaOutput *pOut = output;
191,794✔
979
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
191,794✔
980
  pOut->dbId = metaRsp.dbId;
191,794✔
981

982
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
191,794✔
983
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
47,947✔
984

985
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
47,947✔
986
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
47,947✔
987

988
    pOut->ctbMeta.vgId = metaRsp.vgId;
47,947✔
989
    pOut->ctbMeta.tableType = metaRsp.tableType;
47,947✔
990
    pOut->ctbMeta.uid = metaRsp.tuid;
47,947✔
991
    pOut->ctbMeta.suid = metaRsp.suid;
47,947✔
992

993
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
47,947✔
994
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
143,847✔
995
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
×
996

997
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
×
998
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
×
999

1000
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
×
1001
    if (TSDB_CODE_SUCCESS != code) {
×
1002
      goto PROCESS_NAME_OVER;
×
1003
    }
1004

1005
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
×
1006
  } else {
1007
    SET_META_TYPE_TABLE(pOut->metaType);
143,847✔
1008
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
143,847✔
1009
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
143,847✔
1010
  }
1011

1012
PROCESS_NAME_OVER:
191,794✔
1013
  if (code != 0) {
191,794✔
1014
    qError("failed to process table name rsp since %s", tstrerror(code));
×
1015
  }
1016

1017
  tFreeSTableMetaRsp(&metaRsp);
191,794✔
1018
  return code;
191,794✔
1019
}
1020

1021
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
64,270✔
1022
  SQnodeListRsp out = {0};
64,270✔
1023
  int32_t       code = 0;
64,270✔
1024

1025
  if (NULL == output || NULL == msg || msgSize <= 0) {
64,270✔
1026
    qError("queryProcessQnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1027
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1028
    return code;
×
1029
  }
1030

1031
  out.qnodeList = (SArray *)output;
64,270✔
1032
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
64,270✔
1033
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
1034
    code = TSDB_CODE_INVALID_MSG;
×
1035
    return code;
×
1036
  }
1037

1038
  return code;
64,270✔
1039
}
1040

1041
int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
53,174✔
1042
  SDnodeListRsp out = {0};
53,174✔
1043
  int32_t       code = 0;
53,174✔
1044

1045
  if (NULL == output || NULL == msg || msgSize <= 0) {
53,174✔
1046
    qError("queryProcessDnodeListRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1047
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1048
    return code;
×
1049
  }
1050

1051
  if (tDeserializeSDnodeListRsp(msg, msgSize, &out) != 0) {
53,174✔
1052
    qError("invalid dnode list rsp msg, msgSize:%d", msgSize);
×
1053
    code = TSDB_CODE_INVALID_MSG;
×
1054
    return code;
×
1055
  }
1056

1057
  *(SArray **)output = out.dnodeList;
53,174✔
1058

1059
  return code;
53,174✔
1060
}
1061

1062
int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
204✔
1063
  SServerVerRsp out = {0};
204✔
1064
  int32_t       code = 0;
204✔
1065

1066
  if (NULL == output || NULL == msg || msgSize <= 0) {
204✔
1067
    qError("queryProcessGetSerVerRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1068
    code = TSDB_CODE_TSC_INVALID_INPUT;
×
1069
    return code;
×
1070
  }
1071

1072
  if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) {
204✔
1073
    qError("invalid svr ver rsp msg, msgSize:%d", msgSize);
×
1074
    code = TSDB_CODE_INVALID_MSG;
×
1075
    return code;
×
1076
  }
1077

1078
  *(char **)output = taosStrdup(out.ver);
204✔
1079
  if (NULL == *(char **)output) {
204✔
1080
    return terrno;
×
1081
  }
1082

1083
  return code;
204✔
1084
}
1085

1086
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
5,247,417✔
1087
  SDbCfgRsp out = {0};
5,247,417✔
1088

1089
  if (NULL == output || NULL == msg || msgSize <= 0) {
5,247,417✔
1090
    qError("queryProcessGetDbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1091
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1092
  }
1093

1094
  if (tDeserializeSDbCfgRsp(msg, msgSize, &out) != 0) {
5,247,417✔
1095
    qError("tDeserializeSDbCfgRsp failed, msgSize:%d, dbCfgRsp:%lu", msgSize, sizeof(out));
×
1096
    return TSDB_CODE_INVALID_MSG;
×
1097
  }
1098

1099
  memcpy(output, &out, sizeof(out));
5,247,417✔
1100

1101
  return TSDB_CODE_SUCCESS;
5,247,417✔
1102
}
1103

1104
int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
×
1105
  SUserIndexRsp out = {0};
×
1106

1107
  if (NULL == output || NULL == msg || msgSize <= 0) {
×
1108
    qError("queryProcessGetIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1109
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1110
  }
1111

1112
  if (tDeserializeSUserIndexRsp(msg, msgSize, &out) != 0) {
×
1113
    qError("tDeserializeSUserIndexRsp failed, msgSize:%d", msgSize);
×
1114
    return TSDB_CODE_INVALID_MSG;
×
1115
  }
1116

1117
  memcpy(output, &out, sizeof(out));
×
1118

1119
  return TSDB_CODE_SUCCESS;
×
1120
}
1121

1122
int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
162,551✔
1123
  SRetrieveFuncRsp out = {0};
162,551✔
1124

1125
  if (NULL == output || NULL == msg || msgSize <= 0) {
162,551✔
1126
    qError("queryProcessRetrieveFuncRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1127
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1128
  }
1129

1130
  if (tDeserializeSRetrieveFuncRsp(msg, msgSize, &out) != 0) {
162,551✔
1131
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
1132
    return TSDB_CODE_INVALID_MSG;
×
1133
  }
1134

1135
  if (1 != out.numOfFuncs) {
162,551✔
1136
    qError("invalid func num returned, numOfFuncs:%d", out.numOfFuncs);
×
1137
    return TSDB_CODE_INVALID_MSG;
×
1138
  }
1139

1140
  SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
162,551✔
1141

1142
  memcpy(output, funcInfo, sizeof(*funcInfo));
162,551✔
1143
  taosArrayDestroy(out.pFuncInfos);
162,551✔
1144
  taosArrayDestroy(out.pFuncExtraInfos);
162,551✔
1145

1146
  return TSDB_CODE_SUCCESS;
162,551✔
1147
}
1148

1149
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
7,034,114✔
1150
  if (NULL == output || NULL == msg || msgSize <= 0) {
7,034,114✔
1151
    qError("queryProcessGetUserAuthRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1152
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1153
  }
1154

1155
  if (tDeserializeSGetUserAuthRsp(msg, msgSize, (SGetUserAuthRsp *)output) != 0) {
7,034,114✔
1156
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
1157
    return TSDB_CODE_INVALID_MSG;
×
1158
  }
1159

1160
  return TSDB_CODE_SUCCESS;
7,034,114✔
1161
}
1162

1163
int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
204✔
1164
  if (NULL == output || NULL == msg || msgSize <= 0) {
204✔
1165
    qError("queryProcessGetTbIndexRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1166
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1167
  }
1168

1169
  STableIndexRsp *out = (STableIndexRsp *)output;
204✔
1170
  if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
204✔
1171
    qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
×
1172
    return TSDB_CODE_INVALID_MSG;
×
1173
  }
1174

1175
  return TSDB_CODE_SUCCESS;
204✔
1176
}
1177

1178
int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
122,318✔
1179
  if (NULL == output || NULL == msg || msgSize <= 0) {
122,318✔
1180
    qError("queryProcessGetTbCfgRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1181
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1182
  }
1183

1184
  STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp));
122,318✔
1185
  if(out == NULL) {
122,318✔
1186
    return terrno;
×
1187
  }
1188
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
122,318✔
1189
    qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize);
×
1190
    tFreeSTableCfgRsp(out);
×
1191
    taosMemoryFree(out);
×
1192
    return TSDB_CODE_INVALID_MSG;
×
1193
  }
1194

1195
  *(STableCfgRsp **)output = out;
122,318✔
1196

1197
  return TSDB_CODE_SUCCESS;
122,318✔
1198
}
1199

1200
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
265,432✔
1201
  if (NULL == output || NULL == msg || msgSize <= 0) {
265,432✔
1202
    qError("queryProcessGetViewMetaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1203
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1204
  }
1205

1206
  SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
265,432✔
1207
  if (out == NULL) {
265,432✔
1208
    return terrno;
×
1209
  }
1210
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
265,432✔
1211
    qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize);
×
1212
    tFreeSViewMetaRsp(out);
×
1213
    taosMemoryFree(out);
×
1214
    return TSDB_CODE_INVALID_MSG;
×
1215
  }
1216

1217
  qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql);
265,432✔
1218

1219
  *(SViewMetaRsp **)output = out;
265,432✔
1220

1221
  return TSDB_CODE_SUCCESS;
265,432✔
1222
}
1223

1224
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
7,041✔
1225
  if (NULL == output || NULL == msg || msgSize <= 0) {
7,041✔
1226
    qError("queryProcessGetTbTSMARsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1227
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1228
  }
1229

1230
  if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) {
7,041✔
1231
    qError("tDeserializeTbTSMARsp failed, msgSize:%d", msgSize);
×
1232
    return TSDB_CODE_INVALID_MSG;
×
1233
  }
1234

1235
  return TSDB_CODE_SUCCESS;
7,041✔
1236
}
1237

1238
static int32_t queryProcessGetRsmaRsp(void* output, char* msg, int32_t msgSize) {
20,559✔
1239
  if (NULL == output || NULL == msg || msgSize <= 0) {
20,559✔
1240
    qError("queryProcessGetRsmaRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1241
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1242
  }
1243

1244
  if (tDeserializeRsmaInfoRsp(msg, msgSize, output) != 0) {
20,559✔
1245
    qError("tDeserializeRsmaInfoRsp failed, msgSize:%d", msgSize);
×
1246
    return TSDB_CODE_INVALID_MSG;
×
1247
  }
1248

1249
  return TSDB_CODE_SUCCESS;
20,559✔
1250
}
1251

1252
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
7,849✔
1253
  if (!output || !msg || msgSize <= 0) {
7,849✔
1254
    qError("queryProcessStreamProgressRsp: invalid input param, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1255
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1256
  }
1257

1258
  if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) {
7,849✔
1259
    qError("tDeserializeStreamProgressRsp failed, msgSize:%d", msgSize);
×
1260
    return TSDB_CODE_INVALID_MSG;
×
1261
  }
1262
  return TSDB_CODE_SUCCESS;
7,849✔
1263
}
1264

1265
int32_t queryProcessVSubTablesRsp(void* output, char* msg, int32_t msgSize) {
×
1266
  if (!output || !msg || msgSize <= 0) {
×
1267
    qError("queryProcessVSubTablesRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1268
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1269
  }
1270

1271
  SVSubTablesRsp* pRsp = (SVSubTablesRsp*)output;
×
1272
  int32_t code = tDeserializeSVSubTablesRsp(msg, msgSize, pRsp);
×
1273
  if (code != 0) {
×
1274
    qError("tDeserializeSVSubTablesRsp failed, msgSize: %d, error:%d", msgSize, code);
×
1275
    return code;
×
1276
  }
1277
  
1278
  return TSDB_CODE_SUCCESS;
×
1279
}
1280

1281
int32_t queryProcessVStbRefDbsRsp(void* output, char* msg, int32_t msgSize) {
8,875,736✔
1282
  if (!output || !msg || msgSize <= 0) {
8,875,736✔
1283
    qError("queryProcessVStbRefDbsRsp input error, output:%p, msg:%p, msgSize:%d", output, msg, msgSize);
×
1284
    return TSDB_CODE_TSC_INVALID_INPUT;
×
1285
  }
1286

1287
  SVStbRefDbsRsp * pRsp = (SVStbRefDbsRsp*)output;
8,876,369✔
1288
  int32_t code = tDeserializeSVStbRefDbsRsp(msg, msgSize, pRsp);
8,876,369✔
1289
  if (code != 0) {
8,871,681✔
1290
    qError("tDeserializeSVStbRefDbsRsp failed, msgSize: %d, error:%d", msgSize, code);
4,157✔
1291
    return code;
×
1292
  }
1293

1294
  return TSDB_CODE_SUCCESS;
8,867,524✔
1295
}
1296

1297
void initQueryModuleMsgHandle() {
1,629,833✔
1298
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,629,833✔
1299
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryBuildTableMetaReqMsg;
1,629,833✔
1300
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg;
1,629,833✔
1301
  queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg;
1,629,833✔
1302
  queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg;
1,629,833✔
1303
  queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg;
1,629,833✔
1304
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg;
1,629,833✔
1305
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg;
1,629,833✔
1306
  queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg;
1,629,833✔
1307
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg;
1,629,833✔
1308
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg;
1,629,833✔
1309
  queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,629,833✔
1310
  queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg;
1,629,833✔
1311
  queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg;
1,629,833✔
1312
  queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg;
1,629,833✔
1313
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryBuildGetTableTSMAMsg;
1,629,833✔
1314
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryBuildGetTSMAMsg;
1,629,833✔
1315
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryBuildGetRsmaMsg;
1,629,833✔
1316
  queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryBuildGetStreamProgressMsg;
1,629,833✔
1317
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryBuildVSubTablesMsg;
1,629,833✔
1318
  queryBuildMsg[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryBuildVStbRefDBsMsg;
1,629,833✔
1319

1320
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
1,629,833✔
1321
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_NAME)] = queryProcessTableNameRsp;
1,629,833✔
1322
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp;
1,629,833✔
1323
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
1,629,833✔
1324
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp;
1,629,833✔
1325
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp;
1,629,833✔
1326
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp;
1,629,833✔
1327
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp;
1,629,833✔
1328
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp;
1,629,833✔
1329
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp;
1,629,833✔
1330
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp;
1,629,833✔
1331
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,629,833✔
1332
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp;
1,629,833✔
1333
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp;
1,629,833✔
1334
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp;
1,629,833✔
1335
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp;
1,629,833✔
1336
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp;
1,629,833✔
1337
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_RSMA)] = queryProcessGetRsmaRsp;
1,629,833✔
1338
  queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp;
1,629,833✔
1339
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSUBTABLES_META)] = queryProcessVSubTablesRsp;
1,629,833✔
1340
  queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_VSTB_REF_DBS)] = queryProcessVStbRefDbsRsp;
1,629,833✔
1341
}
1,629,833✔
1342

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