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

taosdata / TDengine / #3796

31 Mar 2025 10:39AM UTC coverage: 30.372% (-7.1%) from 37.443%
#3796

push

travis-ci

happyguoxy
test:add test cases

69287 of 309062 branches covered (22.42%)

Branch coverage included in aggregate %.

118044 of 307720 relevant lines covered (38.36%)

278592.15 hits per line

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

23.69
/source/dnode/mnode/impl/src/mndDef.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
#define _DEFAULT_SOURCE
16
#include "mndConsumer.h"
17
#include "mndDef.h"
18
#include "taoserror.h"
19
#include "tunit.h"
20

21
#ifdef USE_STREAM
22
static void *freeStreamTasks(SArray *pTaskLevel);
23

24
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
2✔
25
  TAOS_CHECK_RETURN(tStartEncode(pEncoder));
2!
26
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->name));
4!
27

28
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->createTime));
4!
29
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->updateTime));
4!
30
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->version));
4!
31
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->totalLevel));
4!
32
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->smaId));
4!
33

34
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->uid));
4!
35
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->status));
4!
36

37
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.igExpired));
4!
38
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.trigger));
4!
39
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.fillHistory));
4!
40
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->conf.triggerParam));
4!
41
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->conf.watermark));
4!
42

43
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->sourceDbUid));
4!
44
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->targetDbUid));
4!
45
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->sourceDb));
4!
46
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->targetDb));
4!
47
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->targetSTbName));
4!
48
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->targetStbUid));
4!
49
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->fixedSinkVgId));
4!
50

51
  if (pObj->sql != NULL) {
2!
52
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->sql));
×
53
  } else {
54
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
2!
55
  }
56

57
  if (pObj->ast != NULL) {
2!
58
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->ast));
×
59
  } else {
60
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
2!
61
  }
62

63
  if (pObj->physicalPlan != NULL) {
2!
64
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->physicalPlan));
×
65
  } else {
66
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
2!
67
  }
68

69
  int32_t sz = taosArrayGetSize(pObj->pTaskList);
2✔
70
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, sz));
2!
71
  for (int32_t i = 0; i < sz; i++) {
4✔
72
    SArray *pArray = taosArrayGetP(pObj->pTaskList, i);
2✔
73
    int32_t innerSz = taosArrayGetSize(pArray);
2✔
74
    TAOS_CHECK_RETURN(tEncodeI32(pEncoder, innerSz));
2!
75
    for (int32_t j = 0; j < innerSz; j++) {
4✔
76
      SStreamTask *pTask = taosArrayGetP(pArray, j);
2✔
77
      if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
2✔
78
        pTask->ver = SSTREAM_TASK_VER;
1✔
79
      }
80
      TAOS_CHECK_RETURN(tEncodeStreamTask(pEncoder, pTask));
2!
81
    }
82
  }
83

84
  TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema));
4!
85

86
  // 3.0.20 ver =2
87
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->checkpointFreq));
4!
88
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->igCheckUpdate));
4!
89

90
  // 3.0.50 ver = 3
91
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->checkpointId));
4!
92
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->subTableWithoutMd5));
4!
93

94
  TAOS_CHECK_RETURN(tEncodeCStrWithLen(pEncoder, pObj->reserve, sizeof(pObj->reserve) - 1));
4!
95

96
  tEndEncode(pEncoder);
2✔
97
  return pEncoder->pos;
2✔
98
}
99

100
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
×
101
  int32_t code = 0;
×
102
  TAOS_CHECK_RETURN(tStartDecode(pDecoder));
×
103
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->name));
×
104

105
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->createTime));
×
106
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->updateTime));
×
107
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->version));
×
108
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->totalLevel));
×
109
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->smaId));
×
110

111
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->uid));
×
112
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->status));
×
113

114
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.igExpired));
×
115
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.trigger));
×
116
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.fillHistory));
×
117
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->conf.triggerParam));
×
118
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->conf.watermark));
×
119

120
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->sourceDbUid));
×
121
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->targetDbUid));
×
122
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->sourceDb));
×
123
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->targetDb));
×
124
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->targetSTbName));
×
125
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->targetStbUid));
×
126
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->fixedSinkVgId));
×
127

128
  TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->sql));
×
129
  TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->ast));
×
130
  TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan));
×
131

132
  if (pObj->pTaskList != NULL) {
×
133
    pObj->pTaskList = freeStreamTasks(pObj->pTaskList);
×
134
  }
135

136
  int32_t sz;
137
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &sz));
×
138

139
  if (sz != 0) {
×
140
    pObj->pTaskList = taosArrayInit(sz, sizeof(void *));
×
141
    if (pObj->pTaskList == NULL) {
×
142
      code = terrno;
×
143
      TAOS_RETURN(code);
×
144
    }
145

146
    for (int32_t i = 0; i < sz; i++) {
×
147
      int32_t innerSz;
148
      TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &innerSz));
×
149
      SArray *pArray = taosArrayInit(innerSz, sizeof(void *));
×
150
      if (pArray != NULL) {
×
151
        for (int32_t j = 0; j < innerSz; j++) {
×
152
          SStreamTask *pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
×
153
          if (pTask == NULL) {
×
154
            taosArrayDestroy(pArray);
×
155
            code = terrno;
×
156
            TAOS_RETURN(code);
×
157
          }
158
          if ((code = tDecodeStreamTask(pDecoder, pTask)) < 0) {
×
159
            taosMemoryFree(pTask);
×
160
            taosArrayDestroy(pArray);
×
161
            TAOS_RETURN(code);
×
162
          }
163
          if (taosArrayPush(pArray, &pTask) == NULL) {
×
164
            taosMemoryFree(pTask);
×
165
            taosArrayDestroy(pArray);
×
166
            code = terrno;
×
167
            TAOS_RETURN(code);
×
168
          }
169
        }
170
      }
171
      if (taosArrayPush(pObj->pTaskList, &pArray) == NULL) {
×
172
        taosArrayDestroy(pArray);
×
173
        code = terrno;
×
174
        TAOS_RETURN(code);
×
175
      }
176
    }
177
  }
178

179
  TAOS_CHECK_RETURN(tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema));
×
180

181
  // 3.0.20
182
  if (sver >= 2) {
×
183
    TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->checkpointFreq));
×
184
    if (!tDecodeIsEnd(pDecoder)) {
×
185
      TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->igCheckUpdate));
×
186
    }
187
  }
188
  if (sver >= 3) {
×
189
    TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->checkpointId));
×
190
  }
191

192
  if (sver >= 5) {
×
193
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->subTableWithoutMd5));
×
194
  }
195
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->reserve));
×
196

197
  tEndDecode(pDecoder);
×
198
  TAOS_RETURN(code);
×
199
}
200

201
void *freeStreamTasks(SArray *pTaskLevel) {
2✔
202
  if (pTaskLevel == NULL) return NULL;
2!
203
  int32_t numOfLevel = taosArrayGetSize(pTaskLevel);
2✔
204

205
  for (int32_t i = 0; i < numOfLevel; i++) {
3✔
206
    SArray *pLevel = taosArrayGetP(pTaskLevel, i);
1✔
207
    int32_t taskSz = taosArrayGetSize(pLevel);
1✔
208
    for (int32_t j = 0; j < taskSz; j++) {
2✔
209
      SStreamTask *pTask = taosArrayGetP(pLevel, j);
1✔
210
      tFreeStreamTask(pTask);
1✔
211
    }
212

213
    taosArrayDestroy(pLevel);
1✔
214
  }
215

216
  taosArrayDestroy(pTaskLevel);
2✔
217

218
  return NULL;
2✔
219
}
220

221
void tFreeStreamObj(SStreamObj *pStream) {
1✔
222
  taosMemoryFree(pStream->sql);
1!
223
  taosMemoryFree(pStream->ast);
1!
224
  taosMemoryFree(pStream->physicalPlan);
1!
225

226
  if (pStream->outputSchema.nCols || pStream->outputSchema.pSchema) {
1!
227
    taosMemoryFree(pStream->outputSchema.pSchema);
×
228
  }
229

230
  pStream->pTaskList = freeStreamTasks(pStream->pTaskList);
1✔
231
  pStream->pHTaskList = freeStreamTasks(pStream->pHTaskList);
1✔
232

233
  // tagSchema.pSchema
234
  if (pStream->tagSchema.nCols > 0) {
1!
235
    taosMemoryFree(pStream->tagSchema.pSchema);
×
236
  }
237

238
  qDestroyQueryPlan(pStream->pPlan);
1✔
239
  pStream->pPlan = NULL;
1✔
240

241
  tSimpleHashCleanup(pStream->pVTableMap);
1✔
242
  pStream->pVTableMap = NULL;
1✔
243
}
1✔
244
#endif
245

246
SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
×
247
  SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));
×
248
  if (pVgEpNew == NULL) {
×
249
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
250
    return NULL;
×
251
  }
252
  pVgEpNew->vgId = pVgEp->vgId;
×
253
  //  pVgEpNew->qmsg = taosStrdup(pVgEp->qmsg);
254
  pVgEpNew->epSet = pVgEp->epSet;
×
255
  return pVgEpNew;
×
256
}
257

258
void tDeleteSMqVgEp(SMqVgEp *pVgEp) {
×
259
  if (pVgEp) {
×
260
    //    taosMemoryFreeClear(pVgEp->qmsg);
261
    taosMemoryFree(pVgEp);
×
262
  }
263
}
×
264

265
int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
×
266
  int32_t tlen = 0;
×
267
  tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
×
268
  //  tlen += taosEncodeString(buf, pVgEp->qmsg);
269
  tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
×
270
  return tlen;
×
271
}
272

273
void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
×
274
  buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
×
275
  if (sver == 1) {
×
276
    uint64_t size = 0;
×
277
    buf = taosDecodeVariantU64(buf, &size);
×
278
    buf = POINTER_SHIFT(buf, size);
×
279
  }
280
  buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
×
281
  return (void *)buf;
×
282
}
283

284
static void *topicNameDup(void *p) { return taosStrdup((char *)p); }
×
285

286
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe,
×
287
                           SMqConsumerObj **ppConsumer) {
288
  int32_t         code = 0;
×
289
  SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
×
290
  if (pConsumer == NULL) {
×
291
    code = terrno;
×
292
    goto END;
×
293
  }
294

295
  pConsumer->consumerId = consumerId;
×
296
  (void)memcpy(pConsumer->cgroup, cgroup, TSDB_CGROUP_LEN);
×
297

298
  pConsumer->epoch = 0;
×
299
  pConsumer->status = MQ_CONSUMER_STATUS_REBALANCE;
×
300
  pConsumer->hbStatus = 0;
×
301
  pConsumer->pollStatus = 0;
×
302

303
  taosInitRWLatch(&pConsumer->lock);
×
304
  pConsumer->createTime = taosGetTimestampMs();
×
305
  pConsumer->updateType = updateType;
×
306

307
  if (updateType == CONSUMER_ADD_REB) {
×
308
    pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *));
×
309
    if (pConsumer->rebNewTopics == NULL) {
×
310
      code = terrno;
×
311
      goto END;
×
312
    }
313

314
    char *topicTmp = taosStrdup(topic);
×
315
    if (taosArrayPush(pConsumer->rebNewTopics, &topicTmp) == NULL) {
×
316
      code = terrno;
×
317
      goto END;
×
318
    }
319
  } else if (updateType == CONSUMER_REMOVE_REB) {
×
320
    pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *));
×
321
    if (pConsumer->rebRemovedTopics == NULL) {
×
322
      code = terrno;
×
323
      goto END;
×
324
    }
325
    char *topicTmp = taosStrdup(topic);
×
326
    if (taosArrayPush(pConsumer->rebRemovedTopics, &topicTmp) == NULL) {
×
327
      code = terrno;
×
328
      goto END;
×
329
    }
330
  } else if (updateType == CONSUMER_INSERT_SUB) {
×
331
    tstrncpy(pConsumer->clientId, subscribe->clientId, tListLen(pConsumer->clientId));
×
332
    pConsumer->withTbName = subscribe->withTbName;
×
333
    pConsumer->autoCommit = subscribe->autoCommit;
×
334
    pConsumer->autoCommitInterval = subscribe->autoCommitInterval;
×
335
    pConsumer->resetOffsetCfg = subscribe->resetOffsetCfg;
×
336
    pConsumer->maxPollIntervalMs = subscribe->maxPollIntervalMs;
×
337
    pConsumer->sessionTimeoutMs = subscribe->sessionTimeoutMs;
×
338
    tstrncpy(pConsumer->user, subscribe->user, TSDB_USER_LEN);
×
339
    tstrncpy(pConsumer->fqdn, subscribe->fqdn, TSDB_FQDN_LEN);
×
340

341
    pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup);
×
342
    if (pConsumer->rebNewTopics == NULL) {
×
343
      code = terrno;
×
344
      goto END;
×
345
    }
346
    pConsumer->assignedTopics = subscribe->topicNames;
×
347
    subscribe->topicNames = NULL;
×
348
  } else if (updateType == CONSUMER_UPDATE_SUB) {
×
349
    pConsumer->assignedTopics = subscribe->topicNames;
×
350
    subscribe->topicNames = NULL;
×
351
  }
352

353
  *ppConsumer = pConsumer;
×
354
  return 0;
×
355

356
END:
×
357
  tDeleteSMqConsumerObj(pConsumer);
×
358
  return code;
×
359
}
360

361
void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) {
×
362
  if (pConsumer == NULL) return;
×
363
  taosArrayDestroyP(pConsumer->currentTopics, NULL);
×
364
  taosArrayDestroyP(pConsumer->rebNewTopics, NULL);
×
365
  taosArrayDestroyP(pConsumer->rebRemovedTopics, NULL);
×
366
  taosArrayDestroyP(pConsumer->assignedTopics, NULL);
×
367
}
368

369
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
×
370
  tClearSMqConsumerObj(pConsumer);
×
371
  taosMemoryFree(pConsumer);
×
372
}
×
373

374
int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
×
375
  int32_t tlen = 0;
×
376
  int32_t sz;
377
  tlen += taosEncodeFixedI64(buf, pConsumer->consumerId);
×
378
  tlen += taosEncodeString(buf, pConsumer->clientId);
×
379
  tlen += taosEncodeString(buf, pConsumer->cgroup);
×
380
  tlen += taosEncodeFixedI8(buf, pConsumer->updateType);
×
381
  tlen += taosEncodeFixedI32(buf, pConsumer->epoch);
×
382
  tlen += taosEncodeFixedI32(buf, pConsumer->status);
×
383

384
  tlen += taosEncodeFixedI32(buf, pConsumer->pid);
×
385
  tlen += taosEncodeSEpSet(buf, &pConsumer->ep);
×
386
  tlen += taosEncodeFixedI64(buf, pConsumer->createTime);
×
387
  tlen += taosEncodeFixedI64(buf, pConsumer->subscribeTime);
×
388
  tlen += taosEncodeFixedI64(buf, pConsumer->rebalanceTime);
×
389

390
  // current topics
391
  if (pConsumer->currentTopics) {
×
392
    sz = taosArrayGetSize(pConsumer->currentTopics);
×
393
    tlen += taosEncodeFixedI32(buf, sz);
×
394
    for (int32_t i = 0; i < sz; i++) {
×
395
      char *topic = taosArrayGetP(pConsumer->currentTopics, i);
×
396
      tlen += taosEncodeString(buf, topic);
×
397
    }
398
  } else {
399
    tlen += taosEncodeFixedI32(buf, 0);
×
400
  }
401

402
  // reb new topics
403
  if (pConsumer->rebNewTopics) {
×
404
    sz = taosArrayGetSize(pConsumer->rebNewTopics);
×
405
    tlen += taosEncodeFixedI32(buf, sz);
×
406
    for (int32_t i = 0; i < sz; i++) {
×
407
      char *topic = taosArrayGetP(pConsumer->rebNewTopics, i);
×
408
      tlen += taosEncodeString(buf, topic);
×
409
    }
410
  } else {
411
    tlen += taosEncodeFixedI32(buf, 0);
×
412
  }
413

414
  // reb removed topics
415
  if (pConsumer->rebRemovedTopics) {
×
416
    sz = taosArrayGetSize(pConsumer->rebRemovedTopics);
×
417
    tlen += taosEncodeFixedI32(buf, sz);
×
418
    for (int32_t i = 0; i < sz; i++) {
×
419
      char *topic = taosArrayGetP(pConsumer->rebRemovedTopics, i);
×
420
      tlen += taosEncodeString(buf, topic);
×
421
    }
422
  } else {
423
    tlen += taosEncodeFixedI32(buf, 0);
×
424
  }
425

426
  // lost topics
427
  if (pConsumer->assignedTopics) {
×
428
    sz = taosArrayGetSize(pConsumer->assignedTopics);
×
429
    tlen += taosEncodeFixedI32(buf, sz);
×
430
    for (int32_t i = 0; i < sz; i++) {
×
431
      char *topic = taosArrayGetP(pConsumer->assignedTopics, i);
×
432
      tlen += taosEncodeString(buf, topic);
×
433
    }
434
  } else {
435
    tlen += taosEncodeFixedI32(buf, 0);
×
436
  }
437

438
  tlen += taosEncodeFixedI8(buf, pConsumer->withTbName);
×
439
  tlen += taosEncodeFixedI8(buf, pConsumer->autoCommit);
×
440
  tlen += taosEncodeFixedI32(buf, pConsumer->autoCommitInterval);
×
441
  tlen += taosEncodeFixedI32(buf, pConsumer->resetOffsetCfg);
×
442
  tlen += taosEncodeFixedI32(buf, pConsumer->maxPollIntervalMs);
×
443
  tlen += taosEncodeFixedI32(buf, pConsumer->sessionTimeoutMs);
×
444
  tlen += taosEncodeString(buf, pConsumer->user);
×
445
  tlen += taosEncodeString(buf, pConsumer->fqdn);
×
446
  return tlen;
×
447
}
448

449
void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t sver) {
×
450
  int32_t sz;
451
  buf = taosDecodeFixedI64(buf, &pConsumer->consumerId);
×
452
  buf = taosDecodeStringTo(buf, pConsumer->clientId);
×
453
  buf = taosDecodeStringTo(buf, pConsumer->cgroup);
×
454
  buf = taosDecodeFixedI8(buf, &pConsumer->updateType);
×
455
  buf = taosDecodeFixedI32(buf, &pConsumer->epoch);
×
456
  buf = taosDecodeFixedI32(buf, &pConsumer->status);
×
457

458
  buf = taosDecodeFixedI32(buf, &pConsumer->pid);
×
459
  buf = taosDecodeSEpSet(buf, &pConsumer->ep);
×
460
  buf = taosDecodeFixedI64(buf, &pConsumer->createTime);
×
461
  buf = taosDecodeFixedI64(buf, &pConsumer->subscribeTime);
×
462
  buf = taosDecodeFixedI64(buf, &pConsumer->rebalanceTime);
×
463

464
  // current topics
465
  buf = taosDecodeFixedI32(buf, &sz);
×
466
  pConsumer->currentTopics = taosArrayInit(sz, sizeof(void *));
×
467
  if (pConsumer->currentTopics == NULL) {
×
468
    return NULL;
×
469
  }
470
  for (int32_t i = 0; i < sz; i++) {
×
471
    char *topic;
472
    buf = taosDecodeString(buf, &topic);
×
473
    if (taosArrayPush(pConsumer->currentTopics, &topic) == NULL) {
×
474
      return NULL;
×
475
    }
476
  }
477

478
  // reb new topics
479
  buf = taosDecodeFixedI32(buf, &sz);
×
480
  pConsumer->rebNewTopics = taosArrayInit(sz, sizeof(void *));
×
481
  for (int32_t i = 0; i < sz; i++) {
×
482
    char *topic;
483
    buf = taosDecodeString(buf, &topic);
×
484
    if (taosArrayPush(pConsumer->rebNewTopics, &topic) == NULL) {
×
485
      return NULL;
×
486
    }
487
  }
488

489
  // reb removed topics
490
  buf = taosDecodeFixedI32(buf, &sz);
×
491
  pConsumer->rebRemovedTopics = taosArrayInit(sz, sizeof(void *));
×
492
  for (int32_t i = 0; i < sz; i++) {
×
493
    char *topic;
494
    buf = taosDecodeString(buf, &topic);
×
495
    if (taosArrayPush(pConsumer->rebRemovedTopics, &topic) == NULL) {
×
496
      return NULL;
×
497
    }
498
  }
499

500
  // reb removed topics
501
  buf = taosDecodeFixedI32(buf, &sz);
×
502
  pConsumer->assignedTopics = taosArrayInit(sz, sizeof(void *));
×
503
  for (int32_t i = 0; i < sz; i++) {
×
504
    char *topic;
505
    buf = taosDecodeString(buf, &topic);
×
506
    if (taosArrayPush(pConsumer->assignedTopics, &topic) == NULL) {
×
507
      return NULL;
×
508
    }
509
  }
510

511
  if (sver > 1) {
×
512
    buf = taosDecodeFixedI8(buf, &pConsumer->withTbName);
×
513
    buf = taosDecodeFixedI8(buf, &pConsumer->autoCommit);
×
514
    buf = taosDecodeFixedI32(buf, &pConsumer->autoCommitInterval);
×
515
    buf = taosDecodeFixedI32(buf, &pConsumer->resetOffsetCfg);
×
516
  }
517
  if (sver > 2) {
×
518
    buf = taosDecodeFixedI32(buf, &pConsumer->maxPollIntervalMs);
×
519
    buf = taosDecodeFixedI32(buf, &pConsumer->sessionTimeoutMs);
×
520
    buf = taosDecodeStringTo(buf, pConsumer->user);
×
521
    buf = taosDecodeStringTo(buf, pConsumer->fqdn);
×
522
  } else {
523
    pConsumer->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
×
524
    pConsumer->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
×
525
  }
526

527
  return (void *)buf;
×
528
}
529

530
int32_t tEncodeOffRows(void **buf, SArray *offsetRows) {
×
531
  int32_t tlen = 0;
×
532
  int32_t szVgs = taosArrayGetSize(offsetRows);
×
533
  tlen += taosEncodeFixedI32(buf, szVgs);
×
534
  for (int32_t j = 0; j < szVgs; ++j) {
×
535
    OffsetRows *offRows = taosArrayGet(offsetRows, j);
×
536
    tlen += taosEncodeFixedI32(buf, offRows->vgId);
×
537
    tlen += taosEncodeFixedI64(buf, offRows->rows);
×
538
    tlen += taosEncodeFixedI8(buf, offRows->offset.type);
×
539
    if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) {
×
540
      tlen += taosEncodeFixedI64(buf, offRows->offset.uid);
×
541
      tlen += taosEncodeFixedI64(buf, offRows->offset.ts);
×
542
    } else if (offRows->offset.type == TMQ_OFFSET__LOG) {
×
543
      tlen += taosEncodeFixedI64(buf, offRows->offset.version);
×
544
    } else {
545
      // do nothing
546
    }
547
    tlen += taosEncodeFixedI64(buf, offRows->ever);
×
548
  }
549

550
  return tlen;
×
551
}
552

553
int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
×
554
  int32_t tlen = 0;
×
555
  tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId);
×
556
  tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp);
×
557

558
  return tlen + tEncodeOffRows(buf, pConsumerEp->offsetRows);
×
559
}
560

561
void *tDecodeOffRows(const void *buf, SArray **offsetRows, int8_t sver) {
×
562
  int32_t szVgs = 0;
×
563
  buf = taosDecodeFixedI32(buf, &szVgs);
×
564
  if (szVgs > 0) {
×
565
    *offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows));
×
566
    if (NULL == *offsetRows) return NULL;
×
567
    for (int32_t j = 0; j < szVgs; ++j) {
×
568
      OffsetRows *offRows = taosArrayReserve(*offsetRows, 1);
×
569
      buf = taosDecodeFixedI32(buf, &offRows->vgId);
×
570
      buf = taosDecodeFixedI64(buf, &offRows->rows);
×
571
      buf = taosDecodeFixedI8(buf, &offRows->offset.type);
×
572
      if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) {
×
573
        buf = taosDecodeFixedI64(buf, &offRows->offset.uid);
×
574
        buf = taosDecodeFixedI64(buf, &offRows->offset.ts);
×
575
      } else if (offRows->offset.type == TMQ_OFFSET__LOG) {
×
576
        buf = taosDecodeFixedI64(buf, &offRows->offset.version);
×
577
      } else {
578
        // do nothing
579
      }
580
      if (sver > 2) {
×
581
        buf = taosDecodeFixedI64(buf, &offRows->ever);
×
582
      }
583
    }
584
  }
585
  return (void *)buf;
×
586
}
587

588
void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t sver) {
×
589
  buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
×
590
  buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver);
×
591
  if (sver > 1) {
×
592
    buf = tDecodeOffRows(buf, &pConsumerEp->offsetRows, sver);
×
593
  }
594

595
  return (void *)buf;
×
596
}
597

598
int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub) {
×
599
  int32_t          code = 0;
×
600
  SMqSubscribeObj *pSubObj = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
×
601
  MND_TMQ_NULL_CHECK(pSubObj);
×
602

603
  (void)memcpy(pSubObj->key, key, TSDB_SUBSCRIBE_KEY_LEN);
×
604
  taosInitRWLatch(&pSubObj->lock);
×
605
  pSubObj->vgNum = 0;
×
606
  pSubObj->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
×
607
  MND_TMQ_NULL_CHECK(pSubObj->consumerHash);
×
608
  pSubObj->unassignedVgs = taosArrayInit(0, POINTER_BYTES);
×
609
  MND_TMQ_NULL_CHECK(pSubObj->unassignedVgs);
×
610
  if (ppSub) {
×
611
    *ppSub = pSubObj;
×
612
  }
613
  return code;
×
614

615
END:
×
616
  taosMemoryFree(pSubObj);
×
617
  return code;
×
618
}
619

620
int32_t tCloneSubscribeObj(const SMqSubscribeObj *pSub, SMqSubscribeObj **ppSub) {
×
621
  int32_t          code = 0;
×
622
  SMqSubscribeObj *pSubNew = taosMemoryMalloc(sizeof(SMqSubscribeObj));
×
623
  if (pSubNew == NULL) {
×
624
    code = terrno;
×
625
    goto END;
×
626
  }
627
  (void)memcpy(pSubNew->key, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
×
628
  taosInitRWLatch(&pSubNew->lock);
×
629

630
  pSubNew->dbUid = pSub->dbUid;
×
631
  pSubNew->stbUid = pSub->stbUid;
×
632
  pSubNew->subType = pSub->subType;
×
633
  pSubNew->withMeta = pSub->withMeta;
×
634

635
  pSubNew->vgNum = pSub->vgNum;
×
636
  pSubNew->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
×
637

638
  void          *pIter = NULL;
×
639
  SMqConsumerEp *pConsumerEp = NULL;
×
640
  while (1) {
×
641
    pIter = taosHashIterate(pSub->consumerHash, pIter);
×
642
    if (pIter == NULL) break;
×
643
    pConsumerEp = (SMqConsumerEp *)pIter;
×
644
    SMqConsumerEp newEp = {
×
645
        .consumerId = pConsumerEp->consumerId,
×
646
        .vgs = taosArrayDup(pConsumerEp->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp),
×
647
    };
648
    if ((code = taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp,
×
649
                            sizeof(SMqConsumerEp))) != 0)
650
      goto END;
×
651
  }
652
  pSubNew->unassignedVgs = taosArrayDup(pSub->unassignedVgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
×
653
  pSubNew->offsetRows = taosArrayDup(pSub->offsetRows, NULL);
×
654
  (void)memcpy(pSubNew->dbName, pSub->dbName, TSDB_DB_FNAME_LEN);
×
655
  pSubNew->qmsg = taosStrdup(pSub->qmsg);
×
656
  if (ppSub) {
×
657
    *ppSub = pSubNew;
×
658
  }
659
END:
×
660
  return code;
×
661
}
662

663
void tDeleteSubscribeObj(SMqSubscribeObj *pSub) {
×
664
  if (pSub == NULL) return;
×
665
  void *pIter = NULL;
×
666
  while (1) {
×
667
    pIter = taosHashIterate(pSub->consumerHash, pIter);
×
668
    if (pIter == NULL) break;
×
669
    SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
×
670
    taosArrayDestroyP(pConsumerEp->vgs, (FDelete)tDeleteSMqVgEp);
×
671
    taosArrayDestroy(pConsumerEp->offsetRows);
×
672
  }
673
  taosHashCleanup(pSub->consumerHash);
×
674
  taosArrayDestroyP(pSub->unassignedVgs, (FDelete)tDeleteSMqVgEp);
×
675
  taosMemoryFreeClear(pSub->qmsg);
×
676
  taosArrayDestroy(pSub->offsetRows);
×
677
}
678

679
int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
×
680
  int32_t tlen = 0;
×
681
  tlen += taosEncodeString(buf, pSub->key);
×
682
  tlen += taosEncodeFixedI64(buf, pSub->dbUid);
×
683
  tlen += taosEncodeFixedI32(buf, pSub->vgNum);
×
684
  tlen += taosEncodeFixedI8(buf, pSub->subType);
×
685
  tlen += taosEncodeFixedI8(buf, pSub->withMeta);
×
686
  tlen += taosEncodeFixedI64(buf, pSub->stbUid);
×
687

688
  void   *pIter = NULL;
×
689
  int32_t sz = taosHashGetSize(pSub->consumerHash);
×
690
  tlen += taosEncodeFixedI32(buf, sz);
×
691

692
  int32_t cnt = 0;
×
693
  while (1) {
×
694
    pIter = taosHashIterate(pSub->consumerHash, pIter);
×
695
    if (pIter == NULL) break;
×
696
    SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
×
697
    tlen += tEncodeSMqConsumerEp(buf, pConsumerEp);
×
698
    cnt++;
×
699
  }
700
  if (cnt != sz) return -1;
×
701
  tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp);
×
702
  tlen += taosEncodeString(buf, pSub->dbName);
×
703

704
  tlen += tEncodeOffRows(buf, pSub->offsetRows);
×
705
  tlen += taosEncodeString(buf, pSub->qmsg);
×
706
  return tlen;
×
707
}
708

709
void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
×
710
  //
711
  buf = taosDecodeStringTo(buf, pSub->key);
×
712
  buf = taosDecodeFixedI64(buf, &pSub->dbUid);
×
713
  buf = taosDecodeFixedI32(buf, &pSub->vgNum);
×
714
  buf = taosDecodeFixedI8(buf, &pSub->subType);
×
715
  buf = taosDecodeFixedI8(buf, &pSub->withMeta);
×
716
  buf = taosDecodeFixedI64(buf, &pSub->stbUid);
×
717

718
  int32_t sz;
719
  buf = taosDecodeFixedI32(buf, &sz);
×
720

721
  pSub->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
×
722
  for (int32_t i = 0; i < sz; i++) {
×
723
    SMqConsumerEp consumerEp = {0};
×
724
    buf = tDecodeSMqConsumerEp(buf, &consumerEp, sver);
×
725
    if (taosHashPut(pSub->consumerHash, &consumerEp.consumerId, sizeof(int64_t), &consumerEp, sizeof(SMqConsumerEp)) !=
×
726
        0)
727
      return NULL;
×
728
  }
729

730
  buf = taosDecodeArray(buf, &pSub->unassignedVgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver);
×
731
  buf = taosDecodeStringTo(buf, pSub->dbName);
×
732

733
  if (sver > 1) {
×
734
    buf = tDecodeOffRows(buf, &pSub->offsetRows, sver);
×
735
    buf = taosDecodeString(buf, &pSub->qmsg);
×
736
  } else {
737
    pSub->qmsg = taosStrdup("");
×
738
  }
739
  return (void *)buf;
×
740
}
741

742
int32_t mndInitConfigObj(SConfigItem *pItem, SConfigObj *pObj) {
89✔
743
  tstrncpy(pObj->name, pItem->name, CFG_NAME_MAX_LEN);
89✔
744
  pObj->dtype = pItem->dtype;
89✔
745
  switch (pItem->dtype) {
89!
746
    case CFG_DTYPE_NONE:
×
747
      break;
×
748
    case CFG_DTYPE_BOOL:
19✔
749
      pObj->bval = pItem->bval;
19✔
750
      break;
19✔
751
    case CFG_DTYPE_INT32:
46✔
752
      pObj->i32 = pItem->i32;
46✔
753
      break;
46✔
754
    case CFG_DTYPE_INT64:
8✔
755
      pObj->i64 = pItem->i64;
8✔
756
      break;
8✔
757
    case CFG_DTYPE_FLOAT:
3✔
758
    case CFG_DTYPE_DOUBLE:
759
      pObj->fval = pItem->fval;
3✔
760
      break;
3✔
761
    case CFG_DTYPE_STRING:
13✔
762
    case CFG_DTYPE_DIR:
763
    case CFG_DTYPE_LOCALE:
764
    case CFG_DTYPE_CHARSET:
765
    case CFG_DTYPE_TIMEZONE:
766
      pObj->str = taosStrdup(pItem->str);
13!
767
      if (pObj->str == NULL) {
13!
768
        taosMemoryFree(pObj);
×
769
        return TSDB_CODE_OUT_OF_MEMORY;
×
770
      }
771
      break;
13✔
772
  }
773
  return TSDB_CODE_SUCCESS;
89✔
774
}
775

776
int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) {
×
777
  int32_t code = 0;
×
778
  switch (pObjNew->dtype) {
×
779
    case CFG_DTYPE_BOOL: {
×
780
      bool tmp = false;
×
781
      if (strcasecmp(value, "true") == 0) {
×
782
        tmp = true;
×
783
      }
784
      if (taosStr2Int32(value, NULL, 10) > 0) {
×
785
        tmp = true;
×
786
      }
787
      pObjNew->bval = tmp;
×
788
      break;
×
789
    }
790
    case CFG_DTYPE_INT32: {
×
791
      int32_t ival;
792
      TAOS_CHECK_RETURN(taosStrHumanToInt32(value, &ival));
×
793
      pObjNew->i32 = ival;
×
794
      break;
×
795
    }
796
    case CFG_DTYPE_INT64: {
×
797
      int64_t ival;
798
      TAOS_CHECK_RETURN(taosStrHumanToInt64(value, &ival));
×
799
      pObjNew->i64 = ival;
×
800
      break;
×
801
    }
802
    case CFG_DTYPE_FLOAT:
×
803
    case CFG_DTYPE_DOUBLE: {
804
      float dval = 0;
×
805
      TAOS_CHECK_RETURN(parseCfgReal(value, &dval));
×
806
      pObjNew->fval = dval;
×
807
      break;
×
808
    }
809
    case CFG_DTYPE_DIR:
×
810
    case CFG_DTYPE_TIMEZONE:
811
    case CFG_DTYPE_CHARSET:
812
    case CFG_DTYPE_LOCALE:
813
    case CFG_DTYPE_STRING: {
814
      pObjNew->str = taosStrdup(value);
×
815
      if (pObjNew->str == NULL) {
×
816
        code = terrno;
×
817
        return code;
×
818
      }
819
      break;
×
820
    }
821
    case CFG_DTYPE_NONE:
×
822
      break;
×
823
    default:
×
824
      code = TSDB_CODE_INVALID_CFG;
×
825
      break;
×
826
  }
827
  return code;
×
828
}
829

830
SConfigObj mndInitConfigVersion() {
9✔
831
  SConfigObj obj;
832
  memset(&obj, 0, sizeof(SConfigObj));
9✔
833

834
  tstrncpy(obj.name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
9✔
835
  obj.dtype = CFG_DTYPE_INT32;
9✔
836
  obj.i32 = 0;
9✔
837
  return obj;
9✔
838
}
839

840
int32_t tEncodeSConfigObj(SEncoder *pEncoder, const SConfigObj *pObj) {
588✔
841
  TAOS_CHECK_RETURN(tStartEncode(pEncoder));
588!
842
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->name));
1,176!
843

844
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->dtype));
1,176!
845
  switch (pObj->dtype) {
588!
846
    case CFG_DTYPE_BOOL:
114✔
847
      TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->bval));
228!
848
      break;
114✔
849
    case CFG_DTYPE_INT32:
330✔
850
      TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->i32));
660!
851
      break;
330✔
852
    case CFG_DTYPE_INT64:
48✔
853
      TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->i64));
96!
854
      break;
48✔
855
    case CFG_DTYPE_FLOAT:
18✔
856
    case CFG_DTYPE_DOUBLE:
857
      TAOS_CHECK_RETURN(tEncodeFloat(pEncoder, pObj->fval));
36!
858
      break;
18✔
859
    case CFG_DTYPE_STRING:
78✔
860
    case CFG_DTYPE_DIR:
861
    case CFG_DTYPE_LOCALE:
862
    case CFG_DTYPE_CHARSET:
863
    case CFG_DTYPE_TIMEZONE:
864
      if (pObj->str != NULL) {
78!
865
        TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->str));
156!
866
      } else {
867
        TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
×
868
      }
869
      break;
78✔
870
    default:
×
871
      break;
×
872
  }
873
  tEndEncode(pEncoder);
588✔
874
  return pEncoder->pos;
588✔
875
}
876

877
int32_t tDecodeSConfigObj(SDecoder *pDecoder, SConfigObj *pObj) {
98✔
878
  TAOS_CHECK_RETURN(tStartDecode(pDecoder));
98!
879
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->name));
98!
880
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, (int32_t *)&pObj->dtype));
196!
881
  switch (pObj->dtype) {
98!
882
    case CFG_DTYPE_NONE:
×
883
      break;
×
884
    case CFG_DTYPE_BOOL:
19✔
885
      TAOS_CHECK_RETURN(tDecodeBool(pDecoder, &pObj->bval));
19!
886
      break;
19✔
887
    case CFG_DTYPE_INT32:
55✔
888
      TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->i32));
110!
889
      break;
55✔
890
    case CFG_DTYPE_INT64:
8✔
891
      TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->i64));
16!
892
      break;
8✔
893
    case CFG_DTYPE_FLOAT:
3✔
894
    case CFG_DTYPE_DOUBLE:
895
      TAOS_CHECK_RETURN(tDecodeFloat(pDecoder, &pObj->fval));
6!
896
      break;
3✔
897
    case CFG_DTYPE_STRING:
13✔
898
    case CFG_DTYPE_DIR:
899
    case CFG_DTYPE_LOCALE:
900
    case CFG_DTYPE_CHARSET:
901
    case CFG_DTYPE_TIMEZONE:
902
      TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->str));
26!
903
      break;
13✔
904
  }
905
  tEndDecode(pDecoder);
98✔
906
  TAOS_RETURN(TSDB_CODE_SUCCESS);
98✔
907
}
908

909
void tFreeSConfigObj(SConfigObj *obj) {
196✔
910
  if (obj == NULL) {
196!
911
    return;
×
912
  }
913
  if (obj->dtype == CFG_DTYPE_STRING || obj->dtype == CFG_DTYPE_DIR || obj->dtype == CFG_DTYPE_LOCALE ||
196!
914
      obj->dtype == CFG_DTYPE_CHARSET || obj->dtype == CFG_DTYPE_TIMEZONE) {
174✔
915
    taosMemoryFree(obj->str);
26!
916
  }
917
}
918

919
// SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
920
//   SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
921
//   if (pEntryNew == NULL) return NULL;
922
//   pEntryNew->epoch = pEntry->epoch;
923
//   pEntryNew->consumers = taosArrayDup(pEntry->consumers, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
924
//   return pEntryNew;
925
// }
926
//
927
// void tDeleteSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
928
//   taosArrayDestroyEx(pEntry->consumers, (FDelete)tDeleteSMqConsumerEp);
929
// }
930

931
// int32_t tEncodeSMqSubActionLogEntry(void **buf, const SMqSubActionLogEntry *pEntry) {
932
//   int32_t tlen = 0;
933
//   tlen += taosEncodeFixedI32(buf, pEntry->epoch);
934
//   tlen += taosEncodeArray(buf, pEntry->consumers, (FEncode)tEncodeSMqSubActionLogEntry);
935
//   return tlen;
936
// }
937
//
938
// void *tDecodeSMqSubActionLogEntry(const void *buf, SMqSubActionLogEntry *pEntry) {
939
//   buf = taosDecodeFixedI32(buf, &pEntry->epoch);
940
//   buf = taosDecodeArray(buf, &pEntry->consumers, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
941
//   return (void *)buf;
942
// }
943

944
// SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
945
//   SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
946
//   if (pLogNew == NULL) return pLogNew;
947
//   memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
948
//   pLogNew->logs = taosArrayDup(pLog->logs, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
949
//   return pLogNew;
950
// }
951
//
952
// void tDeleteSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
953
//   taosArrayDestroyEx(pLog->logs, (FDelete)tDeleteSMqConsumerEp);
954
// }
955

956
// int32_t tEncodeSMqSubActionLogObj(void **buf, const SMqSubActionLogObj *pLog) {
957
//   int32_t tlen = 0;
958
//   tlen += taosEncodeString(buf, pLog->key);
959
//   tlen += taosEncodeArray(buf, pLog->logs, (FEncode)tEncodeSMqSubActionLogEntry);
960
//   return tlen;
961
// }
962
//
963
// void *tDecodeSMqSubActionLogObj(const void *buf, SMqSubActionLogObj *pLog) {
964
//   buf = taosDecodeStringTo(buf, pLog->key);
965
//   buf = taosDecodeArray(buf, &pLog->logs, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
966
//   return (void *)buf;
967
// }
968
//
969
// int32_t tEncodeSMqOffsetObj(void **buf, const SMqOffsetObj *pOffset) {
970
//   int32_t tlen = 0;
971
//   tlen += taosEncodeString(buf, pOffset->key);
972
//   tlen += taosEncodeFixedI64(buf, pOffset->offset);
973
//   return tlen;
974
// }
975
//
976
// void *tDecodeSMqOffsetObj(void *buf, SMqOffsetObj *pOffset) {
977
//   buf = taosDecodeStringTo(buf, pOffset->key);
978
//   buf = taosDecodeFixedI64(buf, &pOffset->offset);
979
//   return buf;
980
// }
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