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

taosdata / TDengine / #5025

17 Apr 2026 01:15AM UTC coverage: 73.009% (+0.06%) from 72.954%
#5025

push

travis-ci

web-flow
fix: replace \s with [[:space:]] in shell regex for macOS BSD compat (#35162)

6 of 7 new or added lines in 2 files covered. (85.71%)

2432 existing lines in 145 files now uncovered.

273326 of 374375 relevant lines covered (73.01%)

130781443.02 hits per line

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

78.4
/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,343,590,470✔
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;
171,292,673✔
26
    }
27
  }
28
  return false;
1,169,312,068✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,727,696,730✔
37
    return &pME->stbEntry.schemaRow;
1,200,417,776✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
527,514,525✔
41
    return &pME->ntbEntry.schemaRow;
338,952,790✔
42
  }
43

44
  return NULL;
188,537,461✔
45
}
46

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

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
212,870,691✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
212,870,691✔
54
  bool                  hasTypeMods = false;
212,881,888✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
212,881,888✔
57
    return 0;
199,707,195✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,178,498✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,443,789,101✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,246,311✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
478,352,386✔
74
    SColRef *p = &pw->pColRef[i];
476,295,118✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
952,590,236✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
952,590,236✔
77
    if (p->hasRef) {
476,295,118✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
631,235,052✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
631,235,052✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
631,235,052✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,259,269,348✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,259,269,348✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,259,452,681✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
313,703,805✔
111
    if (pME->pExtSchemas == NULL) {
156,851,884✔
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,102,597,861✔
120
  }
121

122
  return 0;
1,259,450,292✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
46,736,992✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
46,736,992✔
127
  bool                  hasTypeMods = false;
46,756,429✔
128

129
  if (pSchWrapper == NULL) {
46,756,429✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
46,756,429✔
134

135
  if (hasTypeMods) {
46,730,736✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
36,078✔
137
    if (ret != NULL) {
36,078✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
36,078✔
139
    }
140
    return ret;
36,078✔
141
  }
142
  return NULL;
46,694,658✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
28,786✔
176
  int32_t    i = 0, j = 0;
28,786✔
177
  for (i = 0; i < nCols; ++i) {
217,840✔
178
    while (j < pParam->nFuncs) {
343,876✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
329,872✔
180
        pFuncIds[i] = pParam->funcIds[j];
154,044✔
181
        break;
154,044✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
175,828✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
35,010✔
185
        break;
35,010✔
186
      }
187
      ++j;
140,818✔
188
    }
189
    if (j >= pParam->nFuncs) {
203,058✔
190
      for (; i < nCols; ++i) {
28,008✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,004✔
192
      }
193
      break;
14,004✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
28,786✔
197

198
  return 0;
28,786✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
41,352,969✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
41,352,969✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
82,714,072✔
204
  if (pWrapper->nCols == 0) {
41,355,471✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
82,709,071✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
41,356,730✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
82,709,602✔
211
  if (pWrapper->pColRef == NULL) {
41,355,218✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
702,009,675✔
216
    SColRef *p = &pWrapper->pColRef[i];
660,655,450✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,321,340,579✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,321,359,168✔
219
    if (p->hasRef) {
660,682,402✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
375,706,878✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
375,701,746✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
375,708,794✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
41,340,892✔
228
  pWrapper->pTagRef = NULL;
41,362,318✔
229
  if (!tDecodeIsEnd(pDecoder)) {
41,361,084✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
82,718,211✔
231
    if (pWrapper->nTagRefs > 0) {
41,356,523✔
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;
41,350,205✔
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,306,384✔
270
  if (pSrc->nCols > 0) {
1,306,384✔
271
    pDst->nCols = pSrc->nCols;
1,306,384✔
272
    pDst->version = pSrc->version;
1,306,384✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,306,384✔
274
    if (NULL == pDst->pColRef) {
1,305,754✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,305,754✔
278
  }
279
  return 0;
1,306,384✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
50,301,487✔
283
  int32_t code = 0;
50,301,487✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
100,595,508✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
100,606,108✔
286
  uTrace("encode cols:%d", pw->nCols);
50,312,087✔
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,372,495✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
50,082,182✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
50,082,182✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
50,125,748✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,259,315,266✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,259,315,266✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,259,371,110✔
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,259,301,320✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,259,423,890✔
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,259,806,118✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
261,066✔
323

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

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

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

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
207,476,567✔
344
  if (pSrc->nCols > 0) {
207,476,567✔
345
    pDst->nCols = pSrc->nCols;
181,429,108✔
346
    pDst->version = pSrc->version;
181,426,881✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
181,404,798✔
348
    if (NULL == pDst->pColCmpr) {
181,392,189✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
181,386,748✔
352
  }
353
  return 0;
207,459,785✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
208,770,708✔
357
  if (pColRef) {
208,770,708✔
358
    taosMemoryFreeClear(pColRef->pColRef);
208,782,203✔
359
  }
360
}
208,778,939✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
208,768,724✔
363
  if (pCmpr) {
208,768,724✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
208,782,951✔
365
  }
366
}
208,786,714✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
218,321,427✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
218,321,427✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
436,660,133✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
436,647,127✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
436,657,431✔
373

374
  if (pME->type > 0) {
218,327,813✔
375
    if (pME->name == NULL) {
212,887,684✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
425,772,834✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
212,890,521✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
54,759,222✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
54,823,108✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
54,862,333✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
27,401,373✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
117,336✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
185,463,219✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
323,328,777✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
323,337,278✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
323,350,759✔
392
      if (pME->ctbEntry.commentLen > 0) {
161,675,899✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
30,452✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
323,338,068✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
161,662,652✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
23,808,298✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
47,616,596✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
47,616,596✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
47,616,596✔
401
      if (pME->ntbEntry.commentLen > 0) {
23,808,298✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
42,692✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
47,616,596✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
47,616,596✔
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) {
212,855,952✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,123,795✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
210,763,348✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
27,423,930✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
183,407,501✔
418
        if (pME->colCmpr.nCols != 0) {
22,949,090✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
22,688,024✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
261,066✔
422
          SColCmprWrapper colCmprs = {0};
261,066✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
261,066✔
424
          if (code != 0) {
261,066✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
261,066✔
429
          taosMemoryFree(colCmprs.pColCmpr);
261,066✔
430
          TAOS_CHECK_RETURN(code);
261,066✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
212,895,704✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
218,327,602✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
54,752,033✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
54,725,125✔
439
  } else if (pME->type == TSDB_NORMAL_TABLE) {
190,887,651✔
440
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
45,898,180✔
441
  }
442

443
  tEndEncode(pCoder);
218,281,920✔
444
  return 0;
218,314,724✔
445
}
446

447
int metaDecodeEntryImpl(SDecoder *pCoder, SMetaEntry *pME, bool headerOnly) {
2,147,483,647✔
448
  TAOS_CHECK_RETURN(tStartDecode(pCoder));
2,147,483,647✔
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,147,483,647✔
454
    tEndDecode(pCoder);
345,464✔
455
    return 0;
345,464✔
456
  }
457

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

461
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
462
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
1,933,213,726✔
463
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,933,344,285✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,933,196,539✔
465
      if (TABLE_IS_ROLLUP(pME->flags)) {
966,539,730✔
466
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
355,634✔
467
      }
468
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,186,373,655✔
469
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,773,097,083✔
470
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,773,102,831✔
471
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,772,977,096✔
472
      if (pME->ctbEntry.commentLen > 0) {
886,429,455✔
473
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
52,676✔
474
      }
475
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,772,911,381✔
476
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
886,560,008✔
477
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
300,050,755✔
478
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
600,310,976✔
479
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
600,443,069✔
480
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
600,327,272✔
481
      if (pME->ntbEntry.commentLen > 0) {
300,101,932✔
482
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
78,710✔
483
      }
484
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
600,212,629✔
485
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
600,375,464✔
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,147,483,647✔
497
      if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
966,640,303✔
498
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
966,613,596✔
499

500
        if (pME->colCmpr.nCols == 0) {
966,549,196✔
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,186,320,534✔
508
      if (!tDecodeIsEnd(pCoder)) {
292,988,194✔
509
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
293,022,090✔
510
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
293,022,314✔
511
        if (pME->colCmpr.nCols == 0) {
293,014,662✔
512
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
513
        }
514
      } else {
515
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
516
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
517
      }
518
      TABLE_SET_COL_COMPRESSED(pME->flags);
293,041,973✔
519
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
893,325,839✔
520
      if (!tDecodeIsEnd(pCoder)) {
41,358,564✔
521
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
41,360,435✔
522
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
41,360,435✔
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,147,483,647✔
531
      TAOS_CHECK_RETURN(metaDecodeExtSchemas(pCoder, pME));
1,259,645,935✔
532
    } else {
533
      pME->pExtSchemas = NULL;
893,514,525✔
534
    }
535
  }
536
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
537
    if (!tDecodeIsEnd(pCoder)) {
966,462,419✔
538
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,932,949,665✔
539
    }
540
    if (!tDecodeIsEnd(pCoder)) {
966,474,386✔
541
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,932,861,984✔
542
    }
543
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,186,176,691✔
544
    if (!tDecodeIsEnd(pCoder)) {
293,017,751✔
545
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
586,058,853✔
546
    }
547
  }
548

549

550
  tEndDecode(pCoder);
2,147,483,647✔
551
  return 0;
2,147,483,647✔
552
}
553

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

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

561
  pDst->nCols = pSrc->nCols;
354,459,258✔
562
  pDst->version = pSrc->version;
354,446,548✔
563
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
354,451,988✔
564
  if (pDst->pSchema == NULL) {
354,345,907✔
565
    return terrno;
×
566
  }
567
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
354,339,024✔
568
  return TSDB_CODE_SUCCESS;
354,465,687✔
569
}
570

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

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

599
  return TSDB_CODE_SUCCESS;
78,666✔
600
}
601

602
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
354,423,034✔
603
  if (pSchema) {
354,423,034✔
604
    taosMemoryFreeClear(pSchema->pSchema);
354,437,350✔
605
  }
606
}
354,417,956✔
607

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

621
void metaCloneEntryFree(SMetaEntry **ppEntry) {
208,862,054✔
622
  if (ppEntry == NULL || *ppEntry == NULL) {
208,862,054✔
623
    return;
84,082✔
624
  }
625

626
  taosMemoryFreeClear((*ppEntry)->name);
208,784,068✔
627

628
  if ((*ppEntry)->type < 0) {
208,783,743✔
629
    taosMemoryFreeClear(*ppEntry);
×
630
    return;
×
631
  }
632

633
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
208,767,503✔
634
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
172,533,777✔
635
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
172,519,390✔
636
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
172,527,546✔
637
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
119,944✔
638
    }
639
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
36,241,283✔
640
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
26,864,195✔
641
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
26,863,565✔
642
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,380,427✔
643
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,380,427✔
644
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,380,427✔
645
  } else {
646
    return;
×
647
  }
648
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
208,772,812✔
649
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
208,759,599✔
650
  metaCloneColRefFree(&(*ppEntry)->colRef);
208,759,033✔
651

652
  taosMemoryFreeClear(*ppEntry);
208,741,517✔
653
  return;
208,759,172✔
654
}
655

656
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
208,767,911✔
657
  int32_t code = TSDB_CODE_SUCCESS;
208,767,911✔
658

659
  if (NULL == pEntry || NULL == ppEntry) {
208,767,911✔
660
    return TSDB_CODE_INVALID_PARA;
×
661
  }
662

663
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
208,788,066✔
664
  if (NULL == *ppEntry) {
208,724,632✔
665
    return terrno;
×
666
  }
667

668
  (*ppEntry)->version = pEntry->version;
208,749,620✔
669
  (*ppEntry)->type = pEntry->type;
208,782,799✔
670
  (*ppEntry)->uid = pEntry->uid;
208,782,800✔
671

672
  if (pEntry->type < 0) {
208,780,387✔
673
    return TSDB_CODE_SUCCESS;
×
674
  }
675

676
  if (pEntry->name) {
208,762,201✔
677
    (*ppEntry)->name = tstrdup(pEntry->name);
208,774,282✔
678
    if (NULL == (*ppEntry)->name) {
208,786,196✔
679
      code = terrno;
×
680
      metaCloneEntryFree(ppEntry);
×
681
      return code;
×
682
    }
683
  }
684

685
  if (pEntry->type == TSDB_SUPER_TABLE) {
208,792,166✔
686
    (*ppEntry)->flags = pEntry->flags;
172,544,016✔
687

688
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
172,538,033✔
689
    if (code) {
172,536,868✔
690
      metaCloneEntryFree(ppEntry);
×
691
      return code;
×
692
    }
693

694
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
172,536,868✔
695
    if (code) {
172,551,280✔
696
      metaCloneEntryFree(ppEntry);
×
697
      return code;
×
698
    }
699
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
172,551,280✔
700
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
78,666✔
701
      if (code) {
78,666✔
702
        metaCloneEntryFree(ppEntry);
×
703
        return code;
×
704
      }
705
    }
706
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
172,548,553✔
707
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
172,542,389✔
708
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
36,241,535✔
709
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
26,862,883✔
710
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
26,861,809✔
711
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
26,862,581✔
712

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

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

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

747
    // comment
748
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,380,427✔
749
    if (pEntry->ntbEntry.commentLen > 0) {
9,380,427✔
750
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,223✔
751
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,223✔
752
        code = terrno;
×
753
        metaCloneEntryFree(ppEntry);
×
754
        return code;
×
755
      }
756
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,223✔
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) {
208,780,020✔
763
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,307,774✔
764
    if (code) {
1,306,384✔
765
      metaCloneEntryFree(ppEntry);
×
766
      return code;
×
767
    }
768
  } else {
769
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
207,476,619✔
770
    if (code) {
207,454,385✔
771
      metaCloneEntryFree(ppEntry);
×
772
      return code;
×
773
    }
774
  }
775
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
208,760,769✔
776
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
208,778,066✔
777
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,393,742✔
778
    if (!(*ppEntry)->pExtSchemas) {
10,381,604✔
779
      code = terrno;
×
780
      metaCloneEntryFree(ppEntry);
×
781
      return code;
×
782
    }
783
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,388,367✔
784
  }
785

786
  return code;
208,776,325✔
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