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

taosdata / TDengine / #5032

24 Apr 2026 11:25AM UTC coverage: 73.076% (+0.2%) from 72.876%
#5032

push

travis-ci

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

merge: from main to 3.0 branch[manual-only]

1344 of 1975 new or added lines in 48 files covered. (68.05%)

527 existing lines in 138 files now uncovered.

275965 of 377640 relevant lines covered (73.08%)

132797765.0 hits per line

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

78.53
/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,330,707,147✔
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;
168,113,574✔
26
    }
27
  }
28
  return false;
1,155,969,223✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,714,737,808✔
37
    return &pME->stbEntry.schemaRow;
1,192,349,028✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
522,574,024✔
41
    return &pME->ntbEntry.schemaRow;
334,785,502✔
42
  }
43

44
  return NULL;
187,757,353✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
208,168,201✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
208,168,201✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
208,185,385✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
213,413,063✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
213,413,063✔
54
  bool                  hasTypeMods = false;
213,434,069✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
213,434,069✔
57
    return 0;
200,395,399✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,037,973✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,370,585,578✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,491,085✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
471,543,900✔
74
    SColRef *p = &pw->pColRef[i];
469,454,404✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
938,908,168✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
938,910,088✔
77
    if (p->hasRef) {
469,455,684✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
622,084,548✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
622,085,188✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
622,085,188✔
81
    }
82
  }
83

84
  // Encode tag references
85
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nTagRefs));
4,178,992✔
86
  for (int32_t i = 0; i < pw->nTagRefs; i++) {
2,090,136✔
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,090,136✔
98
}
99

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

104
  if (pSchWrapper == NULL) {
1,249,314,566✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,249,314,566✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,249,515,298✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
307,775,575✔
111
    if (pME->pExtSchemas == NULL) {
153,892,890✔
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,095,618,737✔
120
  }
121

122
  return 0;
1,249,568,254✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
43,700,962✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
43,700,962✔
127
  bool                  hasTypeMods = false;
43,712,549✔
128

129
  if (pSchWrapper == NULL) {
43,712,549✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
43,712,549✔
134

135
  if (hasTypeMods) {
43,696,860✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
36,605✔
137
    if (ret != NULL) {
36,605✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
36,605✔
139
    }
140
    return ret;
36,605✔
141
  }
142
  return NULL;
43,660,255✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
28,749✔
176
  int32_t    i = 0, j = 0;
28,749✔
177
  for (i = 0; i < nCols; ++i) {
217,560✔
178
    while (j < pParam->nFuncs) {
343,434✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
329,448✔
180
        pFuncIds[i] = pParam->funcIds[j];
153,846✔
181
        break;
153,846✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
175,602✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
34,965✔
185
        break;
34,965✔
186
      }
187
      ++j;
140,637✔
188
    }
189
    if (j >= pParam->nFuncs) {
202,797✔
190
      for (; i < nCols; ++i) {
27,972✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
13,986✔
192
      }
193
      break;
13,986✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
28,749✔
197

198
  return 0;
28,749✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
42,876,886✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
42,876,886✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
85,758,945✔
204
  if (pWrapper->nCols == 0) {
42,878,219✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
85,756,388✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
42,881,411✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
85,759,210✔
211
  if (pWrapper->pColRef == NULL) {
42,878,895✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
711,271,520✔
216
    SColRef *p = &pWrapper->pColRef[i];
668,397,118✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,336,808,378✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,336,823,984✔
219
    if (p->hasRef) {
668,414,885✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
380,934,069✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
380,927,398✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
380,931,266✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
42,852,766✔
228
  pWrapper->pTagRef = NULL;
42,886,497✔
229
  if (!tDecodeIsEnd(pDecoder)) {
42,885,857✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
85,766,598✔
231
    if (pWrapper->nTagRefs > 0) {
42,880,741✔
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;
42,876,296✔
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,327,049✔
270
  if (pSrc->nCols > 0) {
1,327,049✔
271
    pDst->nCols = pSrc->nCols;
1,327,689✔
272
    pDst->version = pSrc->version;
1,327,689✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,326,409✔
274
    if (NULL == pDst->pColRef) {
1,326,409✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,326,409✔
278
  }
279
  return 0;
1,327,689✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
50,652,223✔
283
  int32_t code = 0;
50,652,223✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
101,268,935✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
101,279,162✔
286
  uTrace("encode cols:%d", pw->nCols);
50,662,450✔
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;
50,721,434✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
50,397,670✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
50,397,670✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
50,455,635✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,249,452,123✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,249,452,123✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,249,407,635✔
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,249,485,289✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,249,661,304✔
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,249,984,056✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
266,162✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,319,454✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,053,292✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,053,292✔
337
    pColCmpr->id = pColSchema->colId;
1,053,292✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,053,292✔
339
  }
340
  return 0;
266,162✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
206,852,204✔
344
  if (pSrc->nCols > 0) {
206,852,204✔
345
    pDst->nCols = pSrc->nCols;
181,795,369✔
346
    pDst->version = pSrc->version;
181,786,167✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
181,772,948✔
348
    if (NULL == pDst->pColCmpr) {
181,750,717✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
181,753,103✔
352
  }
353
  return 0;
206,842,590✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
208,166,174✔
357
  if (pColRef) {
208,166,174✔
358
    taosMemoryFreeClear(pColRef->pColRef);
208,177,972✔
359
  }
360
}
208,176,494✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
208,154,050✔
363
  if (pCmpr) {
208,154,050✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
208,178,044✔
365
  }
366
}
208,156,411✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
219,197,747✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
219,197,747✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
438,385,133✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
438,287,112✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
438,291,413✔
373

374
  if (pME->type > 0) {
219,173,434✔
375
    if (pME->name == NULL) {
213,415,574✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
426,824,292✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
213,421,049✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
55,102,808✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
55,139,998✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
55,170,376✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
27,554,274✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
117,284✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
185,831,887✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
323,705,415✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
323,721,886✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
323,739,773✔
392
      if (pME->ctbEntry.commentLen > 0) {
161,869,133✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
30,948✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
323,691,932✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
161,845,452✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
23,996,018✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
47,992,036✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
47,992,036✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
47,992,036✔
401
      if (pME->ntbEntry.commentLen > 0) {
23,996,018✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,236✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
47,992,036✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
47,992,036✔
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) {
213,379,964✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,145,573✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
211,246,441✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
27,560,981✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
183,796,734✔
418
        if (pME->colCmpr.nCols != 0) {
23,123,670✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
22,857,508✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
266,162✔
422
          SColCmprWrapper colCmprs = {0};
266,162✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
266,162✔
424
          if (code != 0) {
266,162✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
266,162✔
429
          taosMemoryFree(colCmprs.pColCmpr);
266,162✔
430
          TAOS_CHECK_RETURN(code);
266,162✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
213,449,864✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
219,221,133✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
55,098,452✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
55,020,804✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
55,003,028✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
191,582,250✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
46,247,340✔
442
  }
443

444
  tEndEncode(pCoder);
219,107,780✔
445
  return 0;
219,165,094✔
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);
339,242✔
456
    return 0;
339,242✔
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));
1,916,435,400✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,916,554,722✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,916,398,915✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
958,067,608✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
356,805✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,198,245,721✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,799,246,577✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,799,387,224✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,799,281,669✔
473
      if (pME->ctbEntry.commentLen > 0) {
899,596,621✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
53,552✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,799,265,793✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
899,698,795✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
298,811,905✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
597,781,914✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
597,874,587✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
597,783,906✔
482
      if (pME->ntbEntry.commentLen > 0) {
298,845,091✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
79,766✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
597,707,983✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
597,771,192✔
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)) {
958,181,603✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
958,085,626✔
500

501
        if (pME->colCmpr.nCols == 0) {
958,324,566✔
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,198,202,336✔
509
      if (!tDecodeIsEnd(pCoder)) {
291,607,429✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
291,618,941✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
291,618,941✔
512
        if (pME->colCmpr.nCols == 0) {
291,543,099✔
513
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
514
        }
515
      } else {
UNCOV
516
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
291,576,433✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
906,691,615✔
521
      if (!tDecodeIsEnd(pCoder)) {
42,885,212✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
42,885,212✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
42,885,212✔
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,249,820,102✔
533
    } else {
534
      pME->pExtSchemas = NULL;
906,868,111✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
957,953,592✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,916,280,205✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
958,014,975✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,916,125,245✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
957,923,373✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
1,916,133,384✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,198,241,565✔
548
    if (!tDecodeIsEnd(pCoder)) {
291,561,739✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
583,170,912✔
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) {
355,106,971✔
561
  if (pSrc == NULL || pDst == NULL) {
355,106,971✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
355,130,263✔
566
  pDst->version = pSrc->version;
355,122,580✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
355,100,581✔
568
  if (pDst->pSchema == NULL) {
355,003,374✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
355,061,676✔
572
  return TSDB_CODE_SUCCESS;
355,095,053✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
78,639✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
355,043,441✔
607
  if (pSchema) {
355,043,441✔
608
    taosMemoryFreeClear(pSchema->pSchema);
355,064,390✔
609
  }
610
}
355,061,821✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
208,253,713✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
208,253,713✔
627
    return;
85,548✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
208,177,273✔
631

632
  if ((*ppEntry)->type < 0) {
208,165,575✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
208,096,074✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
172,786,061✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
172,787,304✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
172,775,575✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
119,901✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
35,354,338✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
25,886,497✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
25,886,497✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,471,872✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,471,872✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,471,872✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
208,133,652✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
208,128,102✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
208,147,991✔
655

656
  taosMemoryFreeClear(*ppEntry);
208,111,475✔
657
  return;
208,165,213✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
208,161,831✔
661
  int32_t code = TSDB_CODE_SUCCESS;
208,161,831✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
208,161,831✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
208,190,081✔
668
  if (NULL == *ppEntry) {
208,094,963✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
208,128,970✔
673
  (*ppEntry)->type = pEntry->type;
208,137,185✔
674
  (*ppEntry)->uid = pEntry->uid;
208,151,373✔
675

676
  if (pEntry->type < 0) {
208,187,632✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
208,173,220✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
208,145,645✔
682
    if (NULL == (*ppEntry)->name) {
208,179,847✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
208,194,026✔
690
    (*ppEntry)->flags = pEntry->flags;
172,796,414✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
172,806,313✔
693
    if (code) {
172,831,237✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
172,831,237✔
699
    if (code) {
172,846,049✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
172,846,049✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
78,639✔
705
      if (code) {
78,639✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
172,848,651✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
172,808,661✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
35,357,238✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
25,885,366✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
25,887,211✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
25,887,211✔
716

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

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
25,885,292✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
25,886,646✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
25,884,578✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
25,882,658✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,471,872✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,471,872✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,471,872✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,471,872✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,471,872✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,471,872✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,471,872✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,393✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,393✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,393✔
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) {
208,200,908✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,344,639✔
768
    if (code) {
1,327,689✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
206,824,240✔
774
    if (code) {
206,822,897✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
208,150,586✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
208,150,594✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,245,808✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,231,450✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,227,769✔
788
  }
789

790
  return code;
208,173,888✔
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