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

taosdata / TDengine / #5052

13 May 2026 12:00PM UTC coverage: 73.338% (-0.02%) from 73.358%
#5052

push

travis-ci

web-flow
feat: taosdump support stream backup/restore (#35326)

139 of 170 new or added lines in 3 files covered. (81.76%)

761 existing lines in 163 files now uncovered.

281469 of 383795 relevant lines covered (73.34%)

134502812.98 hits per line

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

78.92
/source/dnode/vnode/src/meta/metaEntry.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 "meta.h"
17
#include "osMemPool.h"
18
#include "osMemory.h"
19
#include "tencode.h"
20
#include "tmsg.h"
21

22
bool schemasHasTypeMod(const SSchema *pSchema, int32_t nCols) {
1,466,066,638✔
23
  for (int32_t i = 0; i < nCols; i++) {
2,147,483,647✔
24
    if (HAS_TYPE_MOD(pSchema + i)) {
2,147,483,647✔
25
      return true;
180,842,563✔
26
    }
27
  }
28
  return false;
1,281,302,153✔
29
}
30

31
static const SSchemaWrapper *metaGetEntryRowSchema(const SMetaEntry *pME) {
1,898,244,906✔
32
  if (pME == NULL) {
1,898,244,906✔
33
    return NULL;
×
34
  }
35

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,898,244,906✔
37
    return &pME->stbEntry.schemaRow;
1,313,291,791✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
585,147,459✔
41
    return &pME->ntbEntry.schemaRow;
372,550,460✔
42
  }
43

44
  return NULL;
212,539,241✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
234,417,640✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
234,417,640✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
234,434,490✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
238,562,611✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
238,562,611✔
54
  bool                  hasTypeMods = false;
238,589,090✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
238,589,090✔
57
    return 0;
224,455,098✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
14,134,037✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,619,913,797✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
14,131,282✔
65
}
66

67
int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
2,229,802✔
68
  const SColRefWrapper *pw = &pME->colRef;
2,229,802✔
69
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
4,459,604✔
70
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
4,459,604✔
71
  uTrace("encode cols:%d", pw->nCols);
2,229,802✔
72

73
  for (int32_t i = 0; i < pw->nCols; i++) {
501,808,328✔
74
    SColRef *p = &pw->pColRef[i];
499,579,204✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
999,158,408✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
999,157,730✔
77
    if (p->hasRef) {
499,578,526✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
662,036,224✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
662,036,224✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
662,036,224✔
81
    }
82
  }
83

84
  // Encode tag references
85
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nTagRefs));
4,458,926✔
86
  for (int32_t i = 0; i < pw->nTagRefs; i++) {
2,229,802✔
87
    SColRef *p = &pw->pTagRef[i];
×
88
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
×
89
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
×
90
    if (p->hasRef) {
×
91
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
×
92
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
×
93
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
×
94
    }
95
  }
96

97
  return 0;
2,229,802✔
98
}
99

100
static int32_t metaDecodeExtSchemas(SDecoder* pDecoder, SMetaEntry* pME) {
1,372,857,980✔
101
  bool                  hasExtSchema = false;
1,372,857,980✔
102
  const SSchemaWrapper* pSchWrapper = metaGetEntryRowSchema((const SMetaEntry*)pME);
1,372,857,980✔
103

104
  if (pSchWrapper == NULL) {
1,372,669,515✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,372,669,515✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,372,922,077✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
330,721,090✔
111
    if (pME->pExtSchemas == NULL) {
165,364,918✔
112
      return terrno;
×
113
    }
114

115
    for (int32_t i = 0; i < pSchWrapper->nCols && hasExtSchema; i++) {
2,147,483,647✔
116
      TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pME->pExtSchemas[i].typeMod));
2,147,483,647✔
117
    }
118
  } else {
119
    pME->pExtSchemas = NULL;
1,207,553,304✔
120
  }
121

122
  return 0;
1,372,958,191✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
52,514,490✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
52,514,490✔
127
  bool                  hasTypeMods = false;
52,553,935✔
128

129
  if (pSchWrapper == NULL) {
52,553,935✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
52,553,935✔
134

135
  if (hasTypeMods) {
52,503,096✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
40,239✔
137
    if (ret != NULL) {
40,239✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
40,239✔
139
    }
140
    return ret;
40,239✔
141
  }
142
  return NULL;
52,462,857✔
143
}
144

145
int32_t metaGetRsmaSchema(const SMetaEntry *pME, SSchemaRsma **rsmaSchema) {
30,488✔
146
  if (!rsmaSchema) return 0;
30,488✔
147
  if ((pME->type != TSDB_SUPER_TABLE) || !TABLE_IS_ROLLUP(pME->flags)) {  // only support super table
30,488✔
148
    *rsmaSchema = NULL;
×
149
    return 0;
×
150
  }
151

152
  const SRSmaParam *pParam = &pME->stbEntry.rsmaParam;
30,488✔
153
  const SSchema    *pSchema = pME->stbEntry.schemaRow.pSchema;
30,488✔
154
  int32_t           nCols = pME->stbEntry.schemaRow.nCols;
30,488✔
155

156
  *rsmaSchema = (SSchemaRsma *)taosMemoryMalloc(sizeof(SSchemaRsma));
30,488✔
157
  if (*rsmaSchema == NULL) {
30,488✔
158
    return terrno;
×
159
  }
160

161
  (*rsmaSchema)->funcIds = taosMemoryMalloc(sizeof(func_id_t) * nCols);
30,488✔
162
  if ((*rsmaSchema)->funcIds == NULL) {
30,488✔
163
    taosMemoryFree(*rsmaSchema);
×
164
    *rsmaSchema = NULL;
×
165
    return terrno;
×
166
  }
167

168
  (void)snprintf((*rsmaSchema)->tbName, TSDB_TABLE_NAME_LEN, "%s", pME->name);
30,488✔
169
  (*rsmaSchema)->tbUid = pME->uid;
30,488✔
170
  (*rsmaSchema)->tbType = pME->type;
30,488✔
171
  (*rsmaSchema)->interval[0] = pParam->interval[0];
30,488✔
172
  (*rsmaSchema)->interval[1] = pParam->interval[1];
30,488✔
173
  (*rsmaSchema)->nFuncs = nCols;
30,488✔
174

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
30,488✔
176
  int32_t    i = 0, j = 0;
30,488✔
177
  for (i = 0; i < nCols; ++i) {
230,720✔
178
    while (j < pParam->nFuncs) {
364,208✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
349,376✔
180
        pFuncIds[i] = pParam->funcIds[j];
163,152✔
181
        break;
163,152✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
186,224✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
37,080✔
185
        break;
37,080✔
186
      }
187
      ++j;
149,144✔
188
    }
189
    if (j >= pParam->nFuncs) {
215,064✔
190
      for (; i < nCols; ++i) {
29,664✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,832✔
192
      }
193
      break;
14,832✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
30,488✔
197

198
  return 0;
30,488✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
45,723,220✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
45,723,220✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
91,459,312✔
204
  if (pWrapper->nCols == 0) {
45,728,006✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
91,453,232✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
45,729,334✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
91,449,346✔
211
  if (pWrapper->pColRef == NULL) {
45,712,314✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
761,370,889✔
216
    SColRef *p = &pWrapper->pColRef[i];
715,656,747✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,431,323,273✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,431,344,998✔
219
    if (p->hasRef) {
715,681,802✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
407,657,143✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
407,644,143✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
407,659,704✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
45,701,178✔
228
  pWrapper->pTagRef = NULL;
45,738,764✔
229
  if (!tDecodeIsEnd(pDecoder)) {
45,733,066✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
91,466,777✔
231
    if (pWrapper->nTagRefs > 0) {
45,731,677✔
232
      pWrapper->pTagRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nTagRefs * sizeof(SColRef));
×
233
      if (pWrapper->pTagRef == NULL) {
×
234
        return terrno;
×
235
      }
236

237
      for (int i = 0; i < pWrapper->nTagRefs; i++) {
×
238
        SColRef *p = &pWrapper->pTagRef[i];
×
239
        TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
×
240
        TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
×
241
        if (p->hasRef) {
×
242
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
×
243
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
×
244
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
×
245
        }
246
      }
247
    }
248
  }
249

250
  return 0;
45,723,194✔
251
}
252

253
static FORCE_INLINE int32_t metatInitDefaultSColRefWrapper(SDecoder *pDecoder, SColRefWrapper *pRef,
254
                                                            SSchemaWrapper *pSchema) {
255
  pRef->nCols = pSchema->nCols;
×
256
  if ((pRef->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pRef->nCols * sizeof(SColRef))) == NULL) {
×
257
    return terrno;
×
258
  }
259

260
  for (int32_t i = 0; i < pRef->nCols; i++) {
×
261
    SColRef  *pColRef = &pRef->pColRef[i];
×
262
    SSchema  *pColSchema = &pSchema->pSchema[i];
×
263
    pColRef->id = pColSchema->colId;
×
264
    pColRef->hasRef = false;
×
265
  }
266
  return 0;
×
267
}
268

269
static int32_t metaCloneColRef(const SColRefWrapper*pSrc, SColRefWrapper *pDst) {
1,410,937✔
270
  if (pSrc->nCols > 0) {
1,410,937✔
271
    pDst->nCols = pSrc->nCols;
1,410,937✔
272
    pDst->version = pSrc->version;
1,410,937✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,410,937✔
274
    if (NULL == pDst->pColRef) {
1,410,259✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,410,259✔
278
  }
279
  return 0;
1,410,937✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
55,132,432✔
283
  int32_t code = 0;
55,132,432✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
110,219,342✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
110,212,895✔
286
  uTrace("encode cols:%d", pw->nCols);
55,125,985✔
287

288
  for (int32_t i = 0; i < pw->nCols; i++) {
2,147,483,647✔
289
    SColCmpr *p = &pw->pColCmpr[i];
2,147,483,647✔
290
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
2,147,483,647✔
291
    TAOS_CHECK_RETURN(tEncodeU32(pCoder, p->alg));
2,147,483,647✔
292
  }
293
  return code;
55,192,483✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
54,882,560✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
54,882,560✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
54,897,131✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,372,820,100✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,372,820,100✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,372,913,141✔
303
    return 0;
×
304
  }
305

306
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
2,147,483,647✔
307
  uDebug("dencode cols:%d", pWrapper->nCols);
1,373,021,928✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,372,817,575✔
310
    return terrno;
×
311
  }
312

313
  for (int i = 0; i < pWrapper->nCols; i++) {
2,147,483,647✔
314
    SColCmpr *p = &pWrapper->pColCmpr[i];
2,147,483,647✔
315
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
2,147,483,647✔
316
    TAOS_CHECK_RETURN(tDecodeU32(pDecoder, &p->alg));
2,147,483,647✔
317
  }
318
  return 0;
1,373,448,360✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
325,918✔
323

324
  if (pDecoder == NULL) {
325,918✔
325
    pCmpr->pColCmpr = taosMemoryCalloc(1, pCmpr->nCols * sizeof(SColCmpr));
325,918✔
326
  } else {
327
    pCmpr->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pCmpr->nCols * sizeof(SColCmpr));
×
328
  }
329

330
  if (pCmpr->pColCmpr == NULL) {
325,467✔
331
    return terrno;
×
332
  }
333

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,618,935✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,293,017✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,293,468✔
337
    pColCmpr->id = pColSchema->colId;
1,293,017✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,293,017✔
339
  }
340
  return 0;
325,918✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
233,017,544✔
344
  if (pSrc->nCols > 0) {
233,017,544✔
345
    pDst->nCols = pSrc->nCols;
203,837,699✔
346
    pDst->version = pSrc->version;
203,830,325✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
203,817,864✔
348
    if (NULL == pDst->pColCmpr) {
203,797,534✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
203,805,671✔
352
  }
353
  return 0;
233,005,463✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
234,422,404✔
357
  if (pColRef) {
234,422,404✔
358
    taosMemoryFreeClear(pColRef->pColRef);
234,438,791✔
359
  }
360
}
234,428,090✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
234,422,985✔
363
  if (pCmpr) {
234,422,985✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
234,428,367✔
365
  }
366
}
234,472,985✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
244,400,068✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
244,400,068✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
488,821,364✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
488,800,188✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
488,836,724✔
373

374
  if (pME->type > 0) {
244,415,292✔
375
    if (pME->name == NULL) {
238,581,317✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
477,128,166✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
238,585,076✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
60,432,272✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
60,467,879✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
60,526,340✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
30,249,827✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
125,340✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
208,310,589✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
364,931,666✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
364,945,146✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
364,960,720✔
392
      if (pME->ctbEntry.commentLen > 0) {
182,481,491✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
32,676✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
364,957,802✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
182,481,428✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
25,865,106✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
51,729,761✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
51,729,761✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
51,729,761✔
401
      if (pME->ntbEntry.commentLen > 0) {
25,864,655✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
46,884✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
51,729,310✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
51,729,761✔
406
    } else if (pME->type == TSDB_TSMA_TABLE) {
×
407
      TAOS_CHECK_RETURN(tEncodeTSma(pCoder, pME->smaEntry.tsma));
×
408
    } else {
409
      metaError("meta/entry: invalide table type: %" PRId8 " encode failed.", pME->type);
×
410
      return TSDB_CODE_INVALID_PARA;
×
411
    }
412
    if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
238,590,320✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,373,362✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
236,265,274✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
30,279,401✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
206,115,789✔
418
        if (pME->colCmpr.nCols != 0) {
24,934,916✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
24,608,998✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
325,918✔
422
          SColCmprWrapper colCmprs = {0};
325,918✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
325,918✔
424
          if (code != 0) {
325,918✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
325,918✔
429
          taosMemoryFree(colCmprs.pColCmpr);
325,918✔
430
          TAOS_CHECK_RETURN(code);
325,918✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
238,600,415✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
244,425,753✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
60,372,088✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
60,353,444✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
60,384,023✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
214,119,980✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
49,869,381✔
442
  }
443

444
  tEndEncode(pCoder);
244,331,923✔
445
  return 0;
244,391,562✔
446
}
447

448
int metaDecodeEntryImpl(SDecoder *pCoder, SMetaEntry *pME, bool headerOnly) {
2,147,483,647✔
449
  TAOS_CHECK_RETURN(tStartDecode(pCoder));
2,147,483,647✔
450
  TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->version));
2,147,483,647✔
451
  TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->type));
2,147,483,647✔
452
  TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->uid));
2,147,483,647✔
453

454
  if (headerOnly) {
2,147,483,647✔
455
    tEndDecode(pCoder);
377,300✔
456
    return 0;
377,300✔
457
  }
458

459
  if (pME->type > 0) {
2,147,483,647✔
460
    TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->name));
2,147,483,647✔
461

462
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
463
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
2,101,382,985✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
2,101,449,345✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
2,101,408,393✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
1,050,665,613✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
379,284✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,310,401,514✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,960,795,873✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,961,011,915✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,960,706,635✔
473
      if (pME->ctbEntry.commentLen > 0) {
980,198,643✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
56,556✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,960,734,987✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
980,509,215✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
330,385,930✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
660,970,778✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
661,092,929✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
660,990,682✔
482
      if (pME->ntbEntry.commentLen > 0) {
330,447,853✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
86,274✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
660,828,006✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
660,894,335✔
487
    } else if (pME->type == TSDB_TSMA_TABLE) {
×
488
      pME->smaEntry.tsma = tDecoderMalloc(pCoder, sizeof(STSma));
×
489
      if (!pME->smaEntry.tsma) {
×
490
        return terrno;
×
491
      }
492
      TAOS_CHECK_RETURN(tDecodeTSma(pCoder, pME->smaEntry.tsma, true));
×
493
    } else {
494
      metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
×
495
      return TSDB_CODE_INVALID_PARA;
×
496
    }
497
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
498
      if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
1,050,702,984✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
1,050,691,098✔
500

501
        if (pME->colCmpr.nCols == 0) {
1,050,787,618✔
502
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
×
503
        }
504
      } else {
505
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
×
506
        TABLE_SET_COL_COMPRESSED(pME->flags);
×
507
      }
508
    } else if (pME->type == TSDB_NORMAL_TABLE) {
1,310,314,579✔
509
      if (!tDecodeIsEnd(pCoder)) {
322,590,662✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
322,587,328✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
322,587,602✔
512
        if (pME->colCmpr.nCols == 0) {
322,402,106✔
513
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
514
        }
515
      } else {
516
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
3,359✔
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
3,359✔
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
322,524,585✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
987,880,742✔
521
      if (!tDecodeIsEnd(pCoder)) {
45,733,106✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
45,733,784✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
45,733,784✔
524
      } else {
UNCOV
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
526
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
×
527
           TAOS_CHECK_RETURN(metatInitDefaultSColRefWrapper(pCoder, &pME->colRef, &pME->ntbEntry.schemaRow));
×
528
        }
529
      }
530
    }
531
    if (!tDecodeIsEnd(pCoder)) {
2,147,483,647✔
532
      TAOS_CHECK_RETURN(metaDecodeExtSchemas(pCoder, pME));
1,373,343,640✔
533
    } else {
534
      pME->pExtSchemas = NULL;
988,141,321✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
1,050,291,308✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
2,101,061,703✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
1,050,474,678✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
2,101,083,781✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
1,050,469,592✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
2,101,032,841✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,310,277,154✔
548
    if (!tDecodeIsEnd(pCoder)) {
322,516,604✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
645,114,522✔
550
    }
551
  }
552

553

554
  tEndDecode(pCoder);
2,147,483,647✔
555
  return 0;
2,147,483,647✔
556
}
557

558
int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { return metaDecodeEntryImpl(pCoder, pME, false); }
2,147,483,647✔
559

560
static int32_t metaCloneSchema(const SSchemaWrapper *pSrc, SSchemaWrapper *pDst) {
398,638,054✔
561
  if (pSrc == NULL || pDst == NULL) {
398,638,054✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
398,662,323✔
566
  pDst->version = pSrc->version;
398,653,062✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
398,659,935✔
568
  if (pDst->pSchema == NULL) {
398,516,624✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
398,562,853✔
572
  return TSDB_CODE_SUCCESS;
398,676,769✔
573
}
574

575
static int32_t metaCloneRsmaParam(const SRSmaParam *pSrc, SRSmaParam *pDst) {
83,592✔
576
  if (pSrc == NULL || pDst == NULL) {
83,592✔
577
    return TSDB_CODE_INVALID_PARA;
×
578
  }
579
  memcpy(pDst, pSrc, sizeof(SRSmaParam));
83,592✔
580
  pDst->name = tstrdup(pSrc->name);
83,592✔
581
  if (pDst->name == NULL) {
83,592✔
582
    return terrno;
×
583
  }
584
  if (pSrc->nFuncs > 0) {
83,592✔
585
    pDst->nFuncs = pSrc->nFuncs;
83,592✔
586
    pDst->funcColIds = (col_id_t *)taosMemoryMalloc(pSrc->nFuncs * sizeof(col_id_t));
83,592✔
587
    if (pDst->funcColIds == NULL) {
83,592✔
588
      return terrno;
×
589
    }
590
    memcpy(pDst->funcColIds, pSrc->funcColIds, pSrc->nFuncs * sizeof(col_id_t));
83,592✔
591

592
    pDst->funcIds = (func_id_t *)taosMemoryMalloc(pSrc->nFuncs * sizeof(func_id_t));
83,592✔
593
    if (pDst->funcIds == NULL) {
83,592✔
594
      return terrno;
×
595
    }
596
    memcpy(pDst->funcIds, pSrc->funcIds, pSrc->nFuncs * sizeof(func_id_t));
83,592✔
597
  } else {
598
    pDst->nFuncs = 0;
×
599
    pDst->funcColIds = NULL;
×
600
    pDst->funcIds = NULL;
×
601
  }
602

603
  return TSDB_CODE_SUCCESS;
83,592✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
398,639,874✔
607
  if (pSchema) {
398,639,874✔
608
    taosMemoryFreeClear(pSchema->pSchema);
398,651,333✔
609
  }
610
}
398,632,500✔
611

612
/**
613
 * @param type 0x01 free name
614
 */
615
void metaFreeRsmaParam(SRSmaParam *pParam, int8_t type) {
127,798✔
616
  if (pParam) {
127,798✔
617
    if ((type & 0x01)) {
127,798✔
618
      taosMemoryFreeClear(pParam->name);
127,798✔
619
    }
620
    taosMemoryFreeClear(pParam->funcColIds);
126,974✔
621
    taosMemoryFreeClear(pParam->funcIds);
126,974✔
622
  }
623
}
126,150✔
624

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
234,517,617✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
234,517,617✔
627
    return;
91,302✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
234,433,042✔
631

632
  if ((*ppEntry)->type < 0) {
234,468,974✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
234,376,757✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
194,282,029✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
194,260,838✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
194,263,121✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
126,974✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
40,147,797✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
30,057,806✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
30,058,974✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
10,092,861✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
10,092,861✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
10,092,861✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
234,414,657✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
234,390,336✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
234,409,279✔
655

656
  taosMemoryFreeClear(*ppEntry);
234,366,192✔
657
  return;
234,422,486✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
234,418,231✔
661
  int32_t code = TSDB_CODE_SUCCESS;
234,418,231✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
234,418,231✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
234,446,346✔
668
  if (NULL == *ppEntry) {
234,359,279✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
234,371,242✔
673
  (*ppEntry)->type = pEntry->type;
234,386,785✔
674
  (*ppEntry)->uid = pEntry->uid;
234,417,734✔
675

676
  if (pEntry->type < 0) {
234,436,987✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
234,427,696✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
234,424,315✔
682
    if (NULL == (*ppEntry)->name) {
234,428,843✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
234,414,672✔
690
    (*ppEntry)->flags = pEntry->flags;
194,254,050✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
194,260,350✔
693
    if (code) {
194,279,352✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
194,279,352✔
699
    if (code) {
194,308,265✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
194,308,265✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
83,592✔
705
      if (code) {
83,592✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
194,307,542✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
194,295,286✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
40,151,036✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
30,058,858✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
30,058,869✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
30,059,631✔
716

717
    // comment
718
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
30,058,869✔
719
    if (pEntry->ctbEntry.commentLen > 0) {
30,058,869✔
720
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
9,651✔
721
      if (NULL == (*ppEntry)->ctbEntry.comment) {
9,651✔
722
        code = terrno;
×
723
        metaCloneEntryFree(ppEntry);
×
724
        return code;
×
725
      }
726
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
9,651✔
727
    }
728

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
30,058,869✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
30,057,345✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
30,055,810✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
30,056,572✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
10,092,861✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
10,092,861✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
10,092,861✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
10,092,861✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
10,092,861✔
743

744
    // schema
745
    code = metaCloneSchema(&pEntry->ntbEntry.schemaRow, &(*ppEntry)->ntbEntry.schemaRow);
10,092,861✔
746
    if (code) {
10,092,861✔
747
      metaCloneEntryFree(ppEntry);
×
748
      return code;
×
749
    }
750

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
10,092,861✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
10,092,861✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
14,511✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
14,511✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
14,511✔
761
    }
762
  } else {
763
    return TSDB_CODE_INVALID_PARA;
×
764
  }
765

766
  if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
234,453,845✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,434,842✔
768
    if (code) {
1,410,937✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
232,988,158✔
774
    if (code) {
232,991,421✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
234,402,358✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
234,432,909✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
11,206,812✔
782
    if (!(*ppEntry)->pExtSchemas) {
11,200,978✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
11,187,588✔
788
  }
789

790
  return code;
234,415,677✔
791
}
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