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

taosdata / TDengine / #5048

10 May 2026 03:11AM UTC coverage: 73.222% (+0.07%) from 73.152%
#5048

push

travis-ci

web-flow
merge: from main to 3.0 branch #35290

353 of 452 new or added lines in 9 files covered. (78.1%)

587 existing lines in 140 files now uncovered.

278189 of 379928 relevant lines covered (73.22%)

135206397.85 hits per line

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

73.2
/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) {
123,848,570✔
33
  QUERY_PARAM_CHECK(pOut);
123,848,570✔
34
  QUERY_PARAM_CHECK(usedbRsp);
123,848,570✔
35
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
123,848,570✔
36
  pOut->dbId = usedbRsp->uid;
123,848,570✔
37

38
  pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo));
123,848,321✔
39
  if (NULL == pOut->dbVgroup) {
123,902,478✔
40
    return terrno;
×
41
  }
42

43
  pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
123,902,478✔
44
  pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
123,902,435✔
45
  pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
123,902,435✔
46
  pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
123,902,478✔
47
  pOut->dbVgroup->stateTs = usedbRsp->stateTs;
123,902,435✔
48
  pOut->dbVgroup->flags = usedbRsp->flags;
123,902,478✔
49

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

53
  if (usedbRsp->vgNum <= 0) {
123,857,007✔
54
    return TSDB_CODE_SUCCESS;
95,525,857✔
55
  }
56

57
  pOut->dbVgroup->vgHash =
56,661,856✔
58
      taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
56,391,670✔
59
  if (NULL == pOut->dbVgroup->vgHash) {
28,330,934✔
60
    return terrno;
×
61
  }
62

63
  for (int32_t i = 0; i < usedbRsp->vgNum; ++i) {
100,292,383✔
64
    SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i);
71,961,449✔
65
    pOut->dbVgroup->numOfTable += pVgInfo->numOfTable;
71,961,449✔
66
    qDebug("db:%s, vgId:%d, epNum:%d, current ep:%s:%u", usedbRsp->db, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
71,961,449✔
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))) {
71,961,449✔
69
      return terrno;
×
70
    }
71
  }
72

73
  return TSDB_CODE_SUCCESS;
28,330,934✔
74
}
75

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

83
  STableInfoReq infoReq = {0};
53,028,688✔
84
  infoReq.option = pInput->option;
53,028,706✔
85
  infoReq.header.vgId = pInput->vgId;
53,028,681✔
86
  infoReq.autoCreateCtb = pInput->autoCreateCtb;
53,028,764✔
87

88
  if (pInput->dbFName) {
53,028,404✔
89
    tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
53,028,388✔
90
  }
91
  tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
53,028,818✔
92

93
  int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
53,028,548✔
94
  void   *pBuf = (*mallcFp)(bufLen);
53,028,070✔
95
  if (NULL == pBuf) {
53,028,545✔
96
    return terrno;
×
97
  }
98
  int32_t ret = tSerializeSTableInfoReq(pBuf, bufLen, &infoReq);
53,028,545✔
99
  if (ret < 0) {
53,028,860✔
UNCOV
100
    if (freeFp) (*freeFp)(pBuf);
×
101
    return ret;
×
102
  }
103

104
  *msg = pBuf;
53,028,873✔
105
  *msgLen = bufLen;
53,028,682✔
106

107
  return TSDB_CODE_SUCCESS;
53,028,842✔
108
}
109

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

117
  SUseDbReq usedbReq = {0};
26,130,489✔
118
  tstrncpy(usedbReq.db, pInput->db, TSDB_DB_FNAME_LEN);
26,130,526✔
119
  usedbReq.db[sizeof(usedbReq.db) - 1] = 0;
26,130,489✔
120
  usedbReq.vgVersion = pInput->vgVersion;
26,130,489✔
121
  usedbReq.dbId = pInput->dbId;
26,130,526✔
122
  usedbReq.numOfTable = pInput->numOfTable;
26,130,489✔
123
  usedbReq.stateTs = pInput->stateTs;
26,130,526✔
124

125
  int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
26,130,489✔
126
  void   *pBuf = (*mallcFp)(bufLen);
26,130,452✔
127
  if (NULL == pBuf) {
26,130,526✔
128
    return terrno;
×
129
  }
130
  int32_t ret = tSerializeSUseDbReq(pBuf, bufLen, &usedbReq);
26,130,526✔
131
  if (ret < 0) {
26,130,526✔
132
    if (freeFp) (*freeFp)(pBuf);
×
133
    return ret;
×
134
  }
135

136
  *msg = pBuf;
26,130,526✔
137
  *msgLen = bufLen;
26,130,526✔
138

139
  return TSDB_CODE_SUCCESS;
26,130,526✔
140
}
141

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

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

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

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

162
  *msg = pBuf;
42,942✔
163
  *msgLen = bufLen;
42,942✔
164

165
  return TSDB_CODE_SUCCESS;
42,942✔
166
}
167

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

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

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

187
  *msg = pBuf;
43,819✔
188
  *msgLen = bufLen;
43,819✔
189

190
  return TSDB_CODE_SUCCESS;
43,819✔
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,677,289✔
218
                              void (*freeFp)(void *)) {
219
  QUERY_PARAM_CHECK(input);
5,677,289✔
220
  QUERY_PARAM_CHECK(msg);
5,677,289✔
221
  QUERY_PARAM_CHECK(msgLen);
5,677,289✔
222

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

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

237
  *msg = pBuf;
5,677,404✔
238
  *msgLen = bufLen;
5,677,404✔
239

240
  return TSDB_CODE_SUCCESS;
5,677,404✔
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,
157,469✔
270
                                  void *(*mallcFp)(int64_t), void (*freeFp)(void *)) {
271
  QUERY_PARAM_CHECK(input);
157,469✔
272
  QUERY_PARAM_CHECK(msg);
157,469✔
273
  QUERY_PARAM_CHECK(msgLen);
157,469✔
274

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

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

300
  taosArrayDestroy(funcReq.pFuncNames);
157,469✔
301

302
  *msg = pBuf;
157,469✔
303
  *msgLen = bufLen;
157,469✔
304

305
  return TSDB_CODE_SUCCESS;
157,469✔
306
}
307

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

314
  SGetUserAuthReq req = {0};
6,763,935✔
315
  tstrncpy(req.user, input, TSDB_USER_LEN);
6,763,935✔
316

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

328
  *msg = pBuf;
6,763,935✔
329
  *msgLen = bufLen;
6,763,935✔
330

331
  return TSDB_CODE_SUCCESS;
6,763,935✔
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),
107,670✔
361
                              void (*freeFp)(void *)) {
362
  QUERY_PARAM_CHECK(input);
107,670✔
363
  QUERY_PARAM_CHECK(msg);
107,670✔
364
  QUERY_PARAM_CHECK(msgLen);
107,670✔
365

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

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

383
  *msg = pBuf;
107,670✔
384
  *msgLen = bufLen;
107,670✔
385

386
  return TSDB_CODE_SUCCESS;
107,670✔
387
}
388

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

395
  SViewMetaReq req = {0};
20,961,247✔
396
  tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
20,961,208✔
397

398
  int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
20,961,294✔
399
  void   *pBuf = (*mallcFp)(bufLen);
20,961,325✔
400
  if (NULL == pBuf) {
20,961,315✔
401
    return terrno;
×
402
  }
403
  int32_t ret = tSerializeSViewMetaReq(pBuf, bufLen, &req);
20,961,315✔
404
  if (ret < 0) {
20,961,325✔
405
    if (freeFp) (*freeFp)(pBuf);
×
406
    return ret;
×
407
  }
408

409
  *msg = pBuf;
20,961,325✔
410
  *msgLen = bufLen;
20,961,294✔
411

412
  return TSDB_CODE_SUCCESS;
20,961,257✔
413
}
414

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

509
  *msg = pBuf;
6,815✔
510
  *msgLen = len;
6,815✔
511
  return TSDB_CODE_SUCCESS;
6,815✔
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,454,633✔
540
                                void (*freeFp)(void *)) {
541
  QUERY_PARAM_CHECK(input);
8,454,633✔
542
  QUERY_PARAM_CHECK(msg);
8,454,633✔
543
  QUERY_PARAM_CHECK(msgLen);
8,454,633✔
544

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

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

558
  *msg = pBuf;
8,454,633✔
559
  *msgLen = bufLen;
8,454,633✔
560

561
  return TSDB_CODE_SUCCESS;
8,454,633✔
562
}
563

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

569
  if (NULL == output || NULL == msg || msgSize <= 0) {
26,000,209✔
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) {
26,000,209✔
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) {
26,000,209✔
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);
26,000,209✔
588
  for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
87,636,884✔
589
    SVgroupInfo *pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
61,636,824✔
590
    qTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
61,636,824✔
591
    for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
125,849,550✔
592
      qTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
64,212,767✔
593
    }
594
  }
595

596
  code = queryBuildUseDbOutput(pOut, &usedbRsp);
26,000,060✔
597

598
PROCESS_USEDB_OVER:
26,000,209✔
599

600
  if (code != 0) {
26,000,209✔
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);
26,000,209✔
609
  return code;
26,000,209✔
610
}
611

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

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

624
  if (pMetaMsg->tableType != TSDB_SUPER_TABLE && pMetaMsg->tableType != TSDB_CHILD_TABLE &&
41,556,573✔
625
      pMetaMsg->tableType != TSDB_NORMAL_TABLE && pMetaMsg->tableType != TSDB_SYSTEM_TABLE &&
6,431,742✔
626
      pMetaMsg->tableType != TSDB_VIRTUAL_NORMAL_TABLE && pMetaMsg->tableType != TSDB_VIRTUAL_CHILD_TABLE) {
394,365✔
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) {
41,556,573✔
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) {
41,556,573✔
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) {
41,556,573✔
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) {
41,556,514✔
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;
41,556,573✔
652
}
653

654
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
60,639,593✔
655
  QUERY_PARAM_CHECK(msg);
60,639,593✔
656
  QUERY_PARAM_CHECK(pMeta);
60,639,593✔
657
  pMeta->vgId = msg->vgId;
60,639,593✔
658
  pMeta->tableType = msg->tableType;
60,633,945✔
659
  pMeta->uid = msg->tuid;
60,634,532✔
660
  pMeta->suid = msg->suid;
60,628,218✔
661

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

665
  return TSDB_CODE_SUCCESS;
60,626,020✔
666
}
667

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

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

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

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

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

692
  if (pTagRefSize > 0) {
243,554✔
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;
243,554✔
698
    pTableMeta->numOfTagRefs = 0;
243,554✔
699
  }
700

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

704
  *pMeta = pTableMeta;
243,554✔
705
  return TSDB_CODE_SUCCESS;
243,554✔
706
}
707

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

717
  int32_t sz = metaSize + schemaExtSize + pColRefSize + pTagRefSize;
61,326,678✔
718
  STableMeta *pTableMeta = taosMemoryCalloc(1, sz);
61,326,678✔
719
  if (NULL == pTableMeta) {
61,326,307✔
720
    qError("calloc size[%d] failed since %s", sz, tstrerror(terrno));
×
721
    return terrno;
×
722
  }
723
  SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
61,326,307✔
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;
61,326,307✔
728
  pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
61,326,307✔
729
  pTableMeta->uid = isStb ? msg->suid : msg->tuid;
61,326,719✔
730
  pTableMeta->suid = msg->suid;
61,326,719✔
731
  pTableMeta->sversion = msg->sversion;
61,325,895✔
732
  pTableMeta->tversion = msg->tversion;
61,326,307✔
733
  pTableMeta->rversion = msg->rversion;
61,326,307✔
734
  pTableMeta->ownerId = msg->ownerId;
61,325,895✔
735
  pTableMeta->flag = msg->flag;
61,326,307✔
736
  pTableMeta->secLvl = msg->secLvl;  // explicit copy: bit-field positions differ between STableMetaRsp and STableMeta
61,325,895✔
737
  pTableMeta->secureDelete = msg->secureDelete;
61,326,719✔
738
  if (msg->virtualStb) {
61,326,307✔
739
    pTableMeta->virtualStb = 1;
605,673✔
740
    pTableMeta->numOfColRefs = 0;
605,673✔
741
  } else {
742
    if (msg->tableType == TSDB_VIRTUAL_CHILD_TABLE && isStb) {
60,719,806✔
743
      pTableMeta->virtualStb = 1;
243,554✔
744
      pTableMeta->numOfColRefs = 0;
243,554✔
745
    } else {
746
      pTableMeta->virtualStb = 0;
60,477,076✔
747
      pTableMeta->numOfColRefs = msg->numOfColRefs;
60,476,664✔
748
    }
749
  }
750

751
  pTableMeta->tableInfo.numOfTags = msg->numOfTags;
61,325,891✔
752
  pTableMeta->tableInfo.precision = msg->precision;
61,326,307✔
753
  pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
61,325,187✔
754

755
  memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
61,325,067✔
756
  if (withExtSchema(msg->tableType) && msg->pSchemaExt) {
61,324,359✔
757
    pTableMeta->schemaExt = pSchemaExt;
59,142,843✔
758
    memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
59,143,251✔
759
  } else {
760
    pTableMeta->schemaExt = NULL;
2,182,636✔
761
  }
762

763
  if (hasRefCol(msg->tableType) && msg->pColRefs && !isStb) {
61,325,595✔
764
    pTableMeta->colRef = (SColRef *)((char *)pTableMeta + metaSize + schemaExtSize);
1,078,536✔
765
    memcpy(pTableMeta->colRef, msg->pColRefs, pColRefSize);
1,078,536✔
766
  } else {
767
    pTableMeta->colRef = NULL;
60,247,475✔
768
  }
769

770
  if (hasRefCol(msg->tableType) && msg->pTagRefs && !isStb) {
61,324,359✔
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;
61,324,771✔
776
    pTableMeta->numOfTagRefs = 0;
61,325,895✔
777
  }
778

779
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
61,325,479✔
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)) {
579,147✔
784
        ++pTableMeta->tableInfo.numOfPKs;
292,259✔
785
      } else {
786
        hasPK = false;
286,888✔
787
      }
788
    }
789
  }
790

791
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
61,326,719✔
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;
61,326,719✔
799
  return TSDB_CODE_SUCCESS;
61,326,719✔
800
}
801

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

811

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

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

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

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

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

851
  bool hasPK = (msg->numOfColumns > 1) && (pTableMeta->schema[1].flags & COL_IS_KEY);
167,026✔
852
  for (int32_t i = 0; i < msg->numOfColumns; ++i) {
538,797✔
853
    pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
371,771✔
854
    if (hasPK && (i > 0)) {
371,771✔
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;
167,026✔
864
  tstrncpy(pTbName, msg->tbName, tbNameSize);
167,026✔
865

866
  qDebug("tb:%s, uid:%" PRIx64 " meta returned, type:%d vgId:%d db:%s stb:%s suid:%" PRIx64
167,026✔
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;
167,026✔
874
  return TSDB_CODE_SUCCESS;
167,026✔
875
}
876

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

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

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

892
  code = queryConvertTableMetaMsg(&metaRsp);
41,389,547✔
893
  if (code != TSDB_CODE_SUCCESS) {
41,389,547✔
894
    goto PROCESS_META_OVER;
×
895
  }
896

897
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
124,017,830✔
898
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
82,384,729✔
899
                    metaRsp.virtualStb);
40,995,182✔
900
  if (!IS_SYS_DBNAME(metaRsp.dbFName) &&
41,389,547✔
901
      !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags, isVirtual)) {
39,206,916✔
902
    code = TSDB_CODE_TSC_INVALID_VALUE;
×
903
    goto PROCESS_META_OVER;
×
904
  }
905

906
  STableMetaOutput *pOut = output;
41,389,493✔
907
  tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
41,389,493✔
908
  pOut->dbId = metaRsp.dbId;
41,389,122✔
909

910
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
41,389,118✔
911
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
13,779,029✔
912

913
    tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
13,779,445✔
914
    tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
13,779,029✔
915

916
    pOut->ctbMeta.vgId = metaRsp.vgId;
13,779,033✔
917
    pOut->ctbMeta.tableType = metaRsp.tableType;
13,779,029✔
918
    pOut->ctbMeta.uid = metaRsp.tuid;
13,778,617✔
919
    pOut->ctbMeta.suid = metaRsp.suid;
13,779,029✔
920

921
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
13,778,617✔
922
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
27,610,089✔
923
    SET_META_TYPE_BOTH_VTABLE(pOut->metaType);
243,554✔
924

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

928
    code = queryCreateVCTableMetaFromMsg(&metaRsp, &pOut->vctbMeta);
243,554✔
929
    if (TSDB_CODE_SUCCESS != code) {
243,554✔
930
      goto PROCESS_META_OVER;
×
931
    }
932
    code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
243,554✔
933
  } else {
934
    SET_META_TYPE_TABLE(pOut->metaType);
27,366,535✔
935
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
27,366,535✔
936
    code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
27,366,476✔
937
  }
938

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

944
  tFreeSTableMetaRsp(&metaRsp);
41,389,547✔
945
  return code;
41,389,547✔
946
}
947

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

952
  if (NULL == output || NULL == msg || msgSize <= 0) {
167,026✔
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) {
167,026✔
959
    code = TSDB_CODE_INVALID_MSG;
×
960
    goto PROCESS_NAME_OVER;
×
961
  }
962

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

968
  bool isVirtual = (metaRsp.tableType == TSDB_VIRTUAL_NORMAL_TABLE ||
501,078✔
969
                    metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE ||
334,052✔
970
                    metaRsp.virtualStb);
167,026✔
971

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

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

982
  if (metaRsp.tableType == TSDB_CHILD_TABLE) {
167,026✔
983
    SET_META_TYPE_BOTH_TABLE(pOut->metaType);
41,895✔
984

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

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

993
    code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
41,895✔
994
  } else if (metaRsp.tableType == TSDB_VIRTUAL_CHILD_TABLE) {
125,131✔
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);
125,131✔
1008
    tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
125,131✔
1009
    code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
125,131✔
1010
  }
1011

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

1017
  tFreeSTableMetaRsp(&metaRsp);
167,026✔
1018
  return code;
167,026✔
1019
}
1020

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

1025
  if (NULL == output || NULL == msg || msgSize <= 0) {
42,942✔
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;
42,942✔
1032
  if (tDeserializeSQnodeListRsp(msg, msgSize, &out) != 0) {
42,942✔
1033
    qError("invalid qnode list rsp msg, msgSize:%d", msgSize);
×
1034
    code = TSDB_CODE_INVALID_MSG;
×
1035
    return code;
×
1036
  }
1037

1038
  return code;
42,942✔
1039
}
1040

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

1045
  if (NULL == output || NULL == msg || msgSize <= 0) {
43,819✔
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) {
43,819✔
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;
43,819✔
1058

1059
  return code;
43,819✔
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,038,615✔
1087
  SDbCfgRsp out = {0};
5,038,615✔
1088

1089
  if (NULL == output || NULL == msg || msgSize <= 0) {
5,038,615✔
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,038,615✔
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,038,615✔
1100

1101
  return TSDB_CODE_SUCCESS;
5,038,615✔
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) {
150,494✔
1123
  SRetrieveFuncRsp out = {0};
150,494✔
1124

1125
  if (NULL == output || NULL == msg || msgSize <= 0) {
150,494✔
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) {
150,494✔
1131
    qError("tDeserializeSRetrieveFuncRsp failed, msgSize:%d", msgSize);
×
1132
    return TSDB_CODE_INVALID_MSG;
×
1133
  }
1134

1135
  if (1 != out.numOfFuncs) {
150,494✔
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);
150,494✔
1141

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

1146
  return TSDB_CODE_SUCCESS;
150,494✔
1147
}
1148

1149
int32_t queryProcessGetUserAuthRsp(void *output, char *msg, int32_t msgSize) {
6,762,705✔
1150
  if (NULL == output || NULL == msg || msgSize <= 0) {
6,762,705✔
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) {
6,762,705✔
1156
    qError("tDeserializeSGetUserAuthRsp failed, msgSize:%d", msgSize);
×
1157
    return TSDB_CODE_INVALID_MSG;
×
1158
  }
1159

1160
  return TSDB_CODE_SUCCESS;
6,762,705✔
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) {
107,670✔
1179
  if (NULL == output || NULL == msg || msgSize <= 0) {
107,670✔
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));
107,670✔
1185
  if(out == NULL) {
107,670✔
1186
    return terrno;
×
1187
  }
1188
  if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) {
107,670✔
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;
107,670✔
1196

1197
  return TSDB_CODE_SUCCESS;
107,670✔
1198
}
1199

1200
int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
252,490✔
1201
  if (NULL == output || NULL == msg || msgSize <= 0) {
252,490✔
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));
252,490✔
1207
  if (out == NULL) {
252,490✔
1208
    return terrno;
×
1209
  }
1210
  if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) {
252,490✔
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);
252,490✔
1218

1219
  *(SViewMetaRsp **)output = out;
252,490✔
1220

1221
  return TSDB_CODE_SUCCESS;
252,490✔
1222
}
1223

1224
int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) {
6,099✔
1225
  if (NULL == output || NULL == msg || msgSize <= 0) {
6,099✔
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) {
6,099✔
1231
    qError("tDeserializeTbTSMARsp failed, msgSize:%d", msgSize);
×
1232
    return TSDB_CODE_INVALID_MSG;
×
1233
  }
1234

1235
  return TSDB_CODE_SUCCESS;
6,099✔
1236
}
1237

1238
static int32_t queryProcessGetRsmaRsp(void* output, char* msg, int32_t msgSize) {
19,995✔
1239
  if (NULL == output || NULL == msg || msgSize <= 0) {
19,995✔
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) {
19,995✔
1245
    qError("tDeserializeRsmaInfoRsp failed, msgSize:%d", msgSize);
×
1246
    return TSDB_CODE_INVALID_MSG;
×
1247
  }
1248

1249
  return TSDB_CODE_SUCCESS;
19,995✔
1250
}
1251

1252
int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) {
6,815✔
1253
  if (!output || !msg || msgSize <= 0) {
6,815✔
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) {
6,815✔
1259
    qError("tDeserializeStreamProgressRsp failed, msgSize:%d", msgSize);
×
1260
    return TSDB_CODE_INVALID_MSG;
×
1261
  }
1262
  return TSDB_CODE_SUCCESS;
6,815✔
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,454,633✔
1282
  if (!output || !msg || msgSize <= 0) {
8,454,633✔
UNCOV
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,454,633✔
1288
  int32_t code = tDeserializeSVStbRefDbsRsp(msg, msgSize, pRsp);
8,454,633✔
1289
  if (code != 0) {
8,452,920✔
1290
    qError("tDeserializeSVStbRefDbsRsp failed, msgSize: %d, error:%d", msgSize, code);
4,228✔
1291
    return code;
×
1292
  }
1293

1294
  return TSDB_CODE_SUCCESS;
8,448,692✔
1295
}
1296

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

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