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

taosdata / TDengine / #5017

09 Apr 2026 02:37PM UTC coverage: 72.248% (-0.05%) from 72.299%
#5017

push

travis-ci

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

merge: from main to 3.0 branch

499 of 655 new or added lines in 34 files covered. (76.18%)

821 existing lines in 156 files now uncovered.

257359 of 356215 relevant lines covered (72.25%)

132044878.66 hits per line

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

78.6
/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
static bool schemasHasTypeMod(const SSchema *pSchema, int32_t nCols) {
1,277,911,685✔
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;
158,494,015✔
26
    }
27
  }
28
  return false;
1,116,656,767✔
29
}
30

31
static const SSchemaWrapper *metaGetEntryRowSchema(const SMetaEntry *pME) {
1,699,003,040✔
32
  if (pME == NULL) {
1,699,003,040✔
NEW
33
    return NULL;
×
34
  }
35

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,699,003,040✔
37
    return &pME->stbEntry.schemaRow;
1,181,968,564✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
517,240,355✔
41
    return &pME->ntbEntry.schemaRow;
321,821,032✔
42
  }
43

44
  return NULL;
195,361,664✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
215,240,715✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
215,240,715✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
215,267,424✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
218,714,845✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
218,714,845✔
54
  bool                  hasTypeMods = false;
218,732,856✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
218,732,856✔
57
    return 0;
205,825,831✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
12,911,684✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,446,937,510✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
12,852,151✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
451,436,552✔
74
    SColRef *p = &pw->pColRef[i];
449,394,958✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
898,789,916✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
898,789,291✔
77
    if (p->hasRef) {
449,394,333✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
595,431,099✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
595,430,474✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
595,431,099✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,221,467,686✔
UNCOV
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,221,467,686✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,221,723,830✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
297,493,897✔
111
    if (pME->pExtSchemas == NULL) {
148,749,872✔
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,072,973,865✔
120
  }
121

122
  return 0;
1,221,758,687✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
43,386,205✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
43,386,205✔
127
  bool                  hasTypeMods = false;
43,417,496✔
128

129
  if (pSchWrapper == NULL) {
43,417,496✔
UNCOV
130
    return NULL;
×
131
  }
132

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

135
  if (hasTypeMods) {
43,367,665✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
28,795✔
137
    if (ret != NULL) {
28,795✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
28,795✔
139
    }
140
    return ret;
28,795✔
141
  }
142
  return NULL;
43,338,870✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
28,231✔
176
  int32_t    i = 0, j = 0;
28,231✔
177
  for (i = 0; i < nCols; ++i) {
213,640✔
178
    while (j < pParam->nFuncs) {
337,246✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
323,512✔
180
        pFuncIds[i] = pParam->funcIds[j];
151,074✔
181
        break;
151,074✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
172,438✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
34,335✔
185
        break;
34,335✔
186
      }
187
      ++j;
138,103✔
188
    }
189
    if (j >= pParam->nFuncs) {
199,143✔
190
      for (; i < nCols; ++i) {
27,468✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
13,734✔
192
      }
193
      break;
13,734✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
28,231✔
197

198
  return 0;
28,231✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
40,231,996✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
40,231,996✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
80,471,434✔
204
  if (pWrapper->nCols == 0) {
40,235,717✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
80,463,940✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
40,233,244✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
80,465,460✔
211
  if (pWrapper->pColRef == NULL) {
40,234,485✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
677,525,473✔
216
    SColRef *p = &pWrapper->pColRef[i];
637,296,838✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,274,602,601✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,274,622,574✔
219
    if (p->hasRef) {
637,316,733✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
361,618,062✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
361,615,122✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
361,620,637✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
40,214,336✔
228
  pWrapper->pTagRef = NULL;
40,238,871✔
229
  if (!tDecodeIsEnd(pDecoder)) {
40,238,871✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
80,475,742✔
231
    if (pWrapper->nTagRefs > 0) {
40,236,871✔
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;
40,232,640✔
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,298,894✔
270
  if (pSrc->nCols > 0) {
1,298,894✔
271
    pDst->nCols = pSrc->nCols;
1,298,894✔
272
    pDst->version = pSrc->version;
1,298,269✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,298,894✔
274
    if (NULL == pDst->pColRef) {
1,298,269✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,298,269✔
278
  }
279
  return 0;
1,298,894✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
49,126,112✔
283
  int32_t code = 0;
49,126,112✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
98,228,844✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
98,243,889✔
286
  uTrace("encode cols:%d", pw->nCols);
49,141,157✔
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;
49,191,450✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
48,900,770✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
48,900,770✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
48,940,588✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,221,711,223✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,221,711,223✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,221,768,964✔
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,221,783,639✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,221,913,461✔
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,222,182,233✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
261,180✔
323

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

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

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

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
213,969,976✔
344
  if (pSrc->nCols > 0) {
213,969,976✔
345
    pDst->nCols = pSrc->nCols;
188,121,586✔
346
    pDst->version = pSrc->version;
188,120,667✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
188,078,546✔
348
    if (NULL == pDst->pColCmpr) {
188,090,799✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
188,070,844✔
352
  }
353
  return 0;
213,951,615✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
215,245,602✔
357
  if (pColRef) {
215,245,602✔
358
    taosMemoryFreeClear(pColRef->pColRef);
215,258,658✔
359
  }
360
}
215,255,654✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
215,250,850✔
363
  if (pCmpr) {
215,250,850✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
215,260,435✔
365
  }
366
}
215,279,251✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
224,097,219✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
224,097,219✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
448,195,004✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
448,144,259✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
448,153,490✔
373

374
  if (pME->type > 0) {
224,097,226✔
375
    if (pME->name == NULL) {
218,724,595✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
437,432,193✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
218,719,633✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
53,676,724✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
53,724,389✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
53,744,503✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
26,846,706✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
112,779✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
191,854,108✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
337,398,958✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
337,416,320✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
337,434,141✔
392
      if (pME->ctbEntry.commentLen > 0) {
168,720,923✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
30,184✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
337,413,545✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
168,702,667✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
23,172,558✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
46,345,116✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
46,345,116✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
46,345,116✔
401
      if (pME->ntbEntry.commentLen > 0) {
23,172,558✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
19,144✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
46,345,116✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
46,345,116✔
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) {
218,713,383✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,150,097✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
216,595,736✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
26,855,568✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
189,864,675✔
418
        if (pME->colCmpr.nCols != 0) {
22,319,132✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
22,057,952✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
261,180✔
422
          SColCmprWrapper colCmprs = {0};
261,180✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
261,180✔
424
          if (code != 0) {
261,180✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
261,180✔
429
          taosMemoryFree(colCmprs.pColCmpr);
261,180✔
430
          TAOS_CHECK_RETURN(code);
261,180✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
218,747,843✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
224,102,813✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
53,686,051✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
53,618,736✔
439
  } else if (pME->type == TSDB_NORMAL_TABLE) {
197,208,432✔
440
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
44,638,264✔
441
  }
442

443
  tEndEncode(pCoder);
224,029,601✔
444
  return 0;
224,079,152✔
445
}
446

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

453
  if (headerOnly) {
2,115,437,612✔
454
    tEndDecode(pCoder);
350,438✔
455
    return 0;
350,438✔
456
  }
457

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

461
    if (pME->type == TSDB_SUPER_TABLE) {
2,115,009,423✔
462
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
1,883,748,079✔
463
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,883,870,637✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,883,662,381✔
465
      if (TABLE_IS_ROLLUP(pME->flags)) {
941,795,065✔
466
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
350,299✔
467
      }
468
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,172,628,094✔
469
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,771,715,338✔
470
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,771,818,509✔
471
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,771,551,182✔
472
      if (pME->ctbEntry.commentLen > 0) {
885,641,333✔
473
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
52,242✔
474
      }
475
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,771,596,274✔
476
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
885,904,448✔
477
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
287,111,397✔
478
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
574,341,430✔
479
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
574,417,063✔
480
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
574,331,035✔
481
      if (pME->ntbEntry.commentLen > 0) {
287,120,641✔
482
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
39,822✔
483
      }
484
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
574,279,083✔
485
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
574,348,483✔
486
    } else if (pME->type == TSDB_TSMA_TABLE) {
×
487
      pME->smaEntry.tsma = tDecoderMalloc(pCoder, sizeof(STSma));
×
488
      if (!pME->smaEntry.tsma) {
×
489
        return terrno;
×
490
      }
491
      TAOS_CHECK_RETURN(tDecodeTSma(pCoder, pME->smaEntry.tsma, true));
×
492
    } else {
493
      metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
×
494
      return TSDB_CODE_INVALID_PARA;
×
495
    }
496
    if (pME->type == TSDB_SUPER_TABLE) {
2,114,583,816✔
497
      if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
941,920,144✔
498
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
941,895,209✔
499

500
        if (pME->colCmpr.nCols == 0) {
941,806,401✔
501
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
×
502
        }
503
      } else {
504
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
×
505
        TABLE_SET_COL_COMPRESSED(pME->flags);
×
506
      }
507
    } else if (pME->type == TSDB_NORMAL_TABLE) {
1,172,522,582✔
508
      if (!tDecodeIsEnd(pCoder)) {
280,065,262✔
509
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
280,101,131✔
510
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
280,101,381✔
511
        if (pME->colCmpr.nCols == 0) {
280,074,821✔
512
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
513
        }
514
      } else {
UNCOV
515
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
516
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
517
      }
518
      TABLE_SET_COL_COMPRESSED(pME->flags);
280,085,206✔
519
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
892,484,821✔
520
      if (!tDecodeIsEnd(pCoder)) {
40,235,119✔
521
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
40,235,717✔
522
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
40,235,717✔
523
      } else {
UNCOV
524
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
525
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
×
526
           TAOS_CHECK_RETURN(metatInitDefaultSColRefWrapper(pCoder, &pME->colRef, &pME->ntbEntry.schemaRow));
×
527
        }
528
      }
529
    }
530
    if (!tDecodeIsEnd(pCoder)) {
2,114,721,746✔
531
      TAOS_CHECK_RETURN(metaDecodeExtSchemas(pCoder, pME));
1,222,028,183✔
532
    } else {
533
      pME->pExtSchemas = NULL;
892,693,563✔
534
    }
535
  }
536
  if (pME->type == TSDB_SUPER_TABLE) {
2,114,483,353✔
537
    if (!tDecodeIsEnd(pCoder)) {
941,730,507✔
538
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,883,497,370✔
539
    }
540
    if (!tDecodeIsEnd(pCoder)) {
941,682,417✔
541
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,883,330,340✔
542
    }
543
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,172,434,509✔
544
    if (!tDecodeIsEnd(pCoder)) {
280,078,817✔
545
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
560,195,811✔
546
    }
547
  }
548

549

550
  tEndDecode(pCoder);
2,114,180,326✔
551
  return 0;
2,114,459,292✔
552
}
553

554
int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { return metaDecodeEntryImpl(pCoder, pME, false); }
2,114,564,898✔
555

556
static int32_t metaCloneSchema(const SSchemaWrapper *pSrc, SSchemaWrapper *pDst) {
367,983,761✔
557
  if (pSrc == NULL || pDst == NULL) {
367,983,761✔
558
    return TSDB_CODE_INVALID_PARA;
×
559
  }
560

561
  pDst->nCols = pSrc->nCols;
368,011,698✔
562
  pDst->version = pSrc->version;
367,995,496✔
563
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
367,997,248✔
564
  if (pDst->pSchema == NULL) {
367,884,353✔
565
    return terrno;
×
566
  }
567
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
367,907,985✔
568
  return TSDB_CODE_SUCCESS;
368,017,028✔
569
}
570

571
static int32_t metaCloneRsmaParam(const SRSmaParam *pSrc, SRSmaParam *pDst) {
77,145✔
572
  if (pSrc == NULL || pDst == NULL) {
77,145✔
573
    return TSDB_CODE_INVALID_PARA;
×
574
  }
575
  memcpy(pDst, pSrc, sizeof(SRSmaParam));
77,145✔
576
  pDst->name = tstrdup(pSrc->name);
77,145✔
577
  if (pDst->name == NULL) {
77,145✔
578
    return terrno;
×
579
  }
580
  if (pSrc->nFuncs > 0) {
77,145✔
581
    pDst->nFuncs = pSrc->nFuncs;
77,145✔
582
    pDst->funcColIds = (col_id_t *)taosMemoryMalloc(pSrc->nFuncs * sizeof(col_id_t));
77,145✔
583
    if (pDst->funcColIds == NULL) {
77,145✔
584
      return terrno;
×
585
    }
586
    memcpy(pDst->funcColIds, pSrc->funcColIds, pSrc->nFuncs * sizeof(col_id_t));
77,145✔
587

588
    pDst->funcIds = (func_id_t *)taosMemoryMalloc(pSrc->nFuncs * sizeof(func_id_t));
77,145✔
589
    if (pDst->funcIds == NULL) {
77,145✔
590
      return terrno;
×
591
    }
592
    memcpy(pDst->funcIds, pSrc->funcIds, pSrc->nFuncs * sizeof(func_id_t));
77,145✔
593
  } else {
594
    pDst->nFuncs = 0;
×
595
    pDst->funcColIds = NULL;
×
596
    pDst->funcIds = NULL;
×
597
  }
598

599
  return TSDB_CODE_SUCCESS;
77,145✔
600
}
601

602
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
367,929,352✔
603
  if (pSchema) {
367,929,352✔
604
    taosMemoryFreeClear(pSchema->pSchema);
367,945,999✔
605
  }
606
}
367,946,124✔
607

608
/**
609
 * @param type 0x01 free name
610
 */
611
void metaFreeRsmaParam(SRSmaParam *pParam, int8_t type) {
117,625✔
612
  if (pParam) {
117,625✔
613
    if ((type & 0x01)) {
117,625✔
614
      taosMemoryFreeClear(pParam->name);
117,625✔
615
    }
616
    taosMemoryFreeClear(pParam->funcColIds);
117,625✔
617
    taosMemoryFreeClear(pParam->funcIds);
117,625✔
618
  }
619
}
117,625✔
620

621
void metaCloneEntryFree(SMetaEntry **ppEntry) {
215,333,533✔
622
  if (ppEntry == NULL || *ppEntry == NULL) {
215,333,533✔
623
    return;
81,983✔
624
  }
625

626
  taosMemoryFreeClear((*ppEntry)->name);
215,258,677✔
627

628
  if ((*ppEntry)->type < 0) {
215,260,400✔
629
    taosMemoryFreeClear(*ppEntry);
×
630
    return;
×
631
  }
632

633
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
215,231,205✔
634
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
179,370,805✔
635
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
179,341,914✔
636
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
179,356,927✔
637
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
117,625✔
638
    }
639
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
35,879,499✔
640
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
26,649,034✔
641
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
26,651,090✔
642
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,232,565✔
643
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,232,565✔
644
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,232,565✔
645
  } else {
646
    return;
×
647
  }
648
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
215,248,682✔
649
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
215,232,417✔
650
  metaCloneColRefFree(&(*ppEntry)->colRef);
215,229,228✔
651

652
  taosMemoryFreeClear(*ppEntry);
215,179,772✔
653
  return;
215,229,014✔
654
}
655

656
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
215,237,292✔
657
  int32_t code = TSDB_CODE_SUCCESS;
215,237,292✔
658

659
  if (NULL == pEntry || NULL == ppEntry) {
215,237,292✔
660
    return TSDB_CODE_INVALID_PARA;
16✔
661
  }
662

663
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
215,272,292✔
664
  if (NULL == *ppEntry) {
215,206,120✔
665
    return terrno;
×
666
  }
667

668
  (*ppEntry)->version = pEntry->version;
215,215,363✔
669
  (*ppEntry)->type = pEntry->type;
215,265,870✔
670
  (*ppEntry)->uid = pEntry->uid;
215,255,006✔
671

672
  if (pEntry->type < 0) {
215,232,250✔
673
    return TSDB_CODE_SUCCESS;
×
674
  }
675

676
  if (pEntry->name) {
215,248,472✔
677
    (*ppEntry)->name = tstrdup(pEntry->name);
215,269,927✔
678
    if (NULL == (*ppEntry)->name) {
215,270,418✔
UNCOV
679
      code = terrno;
×
680
      metaCloneEntryFree(ppEntry);
×
681
      return code;
×
682
    }
683
  }
684

685
  if (pEntry->type == TSDB_SUPER_TABLE) {
215,264,009✔
686
    (*ppEntry)->flags = pEntry->flags;
179,386,368✔
687

688
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
179,364,896✔
689
    if (code) {
179,387,467✔
690
      metaCloneEntryFree(ppEntry);
×
691
      return code;
×
692
    }
693

694
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
179,387,467✔
695
    if (code) {
179,401,810✔
696
      metaCloneEntryFree(ppEntry);
×
697
      return code;
×
698
    }
699
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
179,401,810✔
700
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
77,145✔
701
      if (code) {
77,145✔
702
        metaCloneEntryFree(ppEntry);
×
703
        return code;
×
704
      }
705
    }
706
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
179,398,675✔
707
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
179,393,592✔
708
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
35,883,655✔
709
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
26,651,790✔
710
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
26,651,090✔
711
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
26,651,790✔
712

713
    // comment
714
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
26,651,790✔
715
    if (pEntry->ctbEntry.commentLen > 0) {
26,651,165✔
716
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
8,915✔
717
      if (NULL == (*ppEntry)->ctbEntry.comment) {
8,915✔
718
        code = terrno;
×
719
        metaCloneEntryFree(ppEntry);
×
720
        return code;
×
721
      }
722
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
8,915✔
723
    }
724

725
    // tags
726
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
26,651,790✔
727
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
26,651,090✔
728
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
26,651,090✔
729
      code = terrno;
×
730
      metaCloneEntryFree(ppEntry);
×
731
      return code;
×
732
    }
733
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
26,651,090✔
734
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,232,565✔
735
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,232,565✔
736
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,232,565✔
737
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,232,565✔
738
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,232,565✔
739

740
    // schema
741
    code = metaCloneSchema(&pEntry->ntbEntry.schemaRow, &(*ppEntry)->ntbEntry.schemaRow);
9,232,565✔
742
    if (code) {
9,232,565✔
743
      metaCloneEntryFree(ppEntry);
×
744
      return code;
×
745
    }
746

747
    // comment
748
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,232,565✔
749
    if (pEntry->ntbEntry.commentLen > 0) {
9,232,565✔
750
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
6,155✔
751
      if (NULL == (*ppEntry)->ntbEntry.comment) {
6,155✔
752
        code = terrno;
×
753
        metaCloneEntryFree(ppEntry);
×
754
        return code;
×
755
      }
756
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
6,155✔
757
    }
758
  } else {
759
    return TSDB_CODE_INVALID_PARA;
×
760
  }
761

762
  if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
215,266,104✔
763
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,296,342✔
764
    if (code) {
1,298,894✔
765
      metaCloneEntryFree(ppEntry);
×
766
      return code;
×
767
    }
768
  } else {
769
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
213,970,489✔
770
    if (code) {
213,941,349✔
UNCOV
771
      metaCloneEntryFree(ppEntry);
×
772
      return code;
×
773
    }
774
  }
775
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
215,240,243✔
776
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
215,255,615✔
777
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,168,319✔
778
    if (!(*ppEntry)->pExtSchemas) {
10,162,396✔
779
      code = terrno;
×
780
      metaCloneEntryFree(ppEntry);
×
781
      return code;
×
782
    }
783
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,163,738✔
784
  }
785

786
  return code;
215,257,144✔
787
}
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