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

taosdata / TDengine / #3638

11 Mar 2025 12:59PM UTC coverage: 3.066% (-18.3%) from 21.409%
#3638

push

travis-ci

web-flow
Merge pull request #30118 from taosdata/wl30

udpate ci workflow

5914 of 287117 branches covered (2.06%)

Branch coverage included in aggregate %.

11588 of 283747 relevant lines covered (4.08%)

142.17 hits per line

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

8.68
/source/libs/qcom/src/querymsg.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "query.h"
17
#include "queryInt.h"
18
#include "systable.h"
19
#include "tmsg.h"
20
#include "trpc.h"
21

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

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

31
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
5✔
32
  QUERY_PARAM_CHECK(pOut);
5!
33
  QUERY_PARAM_CHECK(usedbRsp);
5!
34
  memcpy(pOut->db, usedbRsp->db, TSDB_DB_FNAME_LEN);
5✔
35
  pOut->dbId = usedbRsp->uid;
5✔
36

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

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

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

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

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

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

71
  return TSDB_CODE_SUCCESS;
3✔
72
}
73

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

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

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

97
  *msg = pBuf;
×
98
  *msgLen = bufLen;
×
99

100
  return TSDB_CODE_SUCCESS;
×
101
}
102

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

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

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

125
  *msg = pBuf;
4✔
126
  *msgLen = bufLen;
4✔
127

128
  return TSDB_CODE_SUCCESS;
4✔
129
}
130

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

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

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

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

147
  *msg = pBuf;
×
148
  *msgLen = bufLen;
×
149

150
  return TSDB_CODE_SUCCESS;
×
151
}
152

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

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

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

168
  *msg = pBuf;
×
169
  *msgLen = bufLen;
×
170

171
  return TSDB_CODE_SUCCESS;
×
172
}
173

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

178
  SServerVerReq req = {0};
×
179

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

188
  *msg = pBuf;
×
189
  *msgLen = bufLen;
×
190

191
  return TSDB_CODE_SUCCESS;
×
192
}
193

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

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

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

210
  *msg = pBuf;
×
211
  *msgLen = bufLen;
×
212

213
  return TSDB_CODE_SUCCESS;
×
214
}
215

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

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

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

232
  *msg = pBuf;
×
233
  *msgLen = bufLen;
×
234

235
  return TSDB_CODE_SUCCESS;
×
236
}
237

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

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

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

268
  taosArrayDestroy(funcReq.pFuncNames);
×
269

270
  *msg = pBuf;
×
271
  *msgLen = bufLen;
×
272

273
  return TSDB_CODE_SUCCESS;
×
274
}
275

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

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

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

292
  *msg = pBuf;
×
293
  *msgLen = bufLen;
×
294

295
  return TSDB_CODE_SUCCESS;
×
296
}
297

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

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

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

314
  *msg = pBuf;
×
315
  *msgLen = bufLen;
×
316

317
  return TSDB_CODE_SUCCESS;
×
318
}
319

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

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

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

339
  *msg = pBuf;
×
340
  *msgLen = bufLen;
×
341

342
  return TSDB_CODE_SUCCESS;
×
343
}
344

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

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

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

361
  *msg = pBuf;
×
362
  *msgLen = bufLen;
×
363

364
  return TSDB_CODE_SUCCESS;
×
365
}
366

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

466
PROCESS_USEDB_OVER:
4✔
467

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

476
  tFreeSUsedbRsp(&usedbRsp);
4✔
477
  return code;
4✔
478
}
479

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

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

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

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

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

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

513
  return TSDB_CODE_SUCCESS;
×
514
}
515

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

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

527
  return TSDB_CODE_SUCCESS;
×
528
}
529

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

777
  return code;
×
778
}
779

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

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

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

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

798
  return code;
×
799
}
800

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

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

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

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

822
  return code;
×
823
}
824

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

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

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

838
  memcpy(output, &out, sizeof(out));
×
839

840
  return TSDB_CODE_SUCCESS;
×
841
}
842

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

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

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

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

858
  return TSDB_CODE_SUCCESS;
×
859
}
860

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

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

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

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

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

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

885
  return TSDB_CODE_SUCCESS;
×
886
}
887

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

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

899
  return TSDB_CODE_SUCCESS;
×
900
}
901

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

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

914
  return TSDB_CODE_SUCCESS;
×
915
}
916

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

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

934
  *(STableCfgRsp **)output = out;
×
935

936
  return TSDB_CODE_SUCCESS;
×
937
}
938

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

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

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

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

960
  return TSDB_CODE_SUCCESS;
×
961
}
962

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

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

974
  return TSDB_CODE_SUCCESS;
×
975
}
976

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

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

990

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

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

1031
#pragma GCC diagnostic pop
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc