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

taosdata / TDengine / #5050

12 May 2026 05:36AM UTC coverage: 73.398% (+0.09%) from 73.313%
#5050

push

travis-ci

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

90 of 101 new or added lines in 2 files covered. (89.11%)

489 existing lines in 125 files now uncovered.

281602 of 383662 relevant lines covered (73.4%)

138099127.08 hits per line

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

78.92
/source/dnode/vnode/src/meta/metaEntry.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "meta.h"
17
#include "osMemPool.h"
18
#include "osMemory.h"
19
#include "tencode.h"
20
#include "tmsg.h"
21

22
bool schemasHasTypeMod(const SSchema *pSchema, int32_t nCols) {
1,582,523,280✔
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;
189,066,173✔
26
    }
27
  }
28
  return false;
1,388,061,442✔
29
}
30

31
static const SSchemaWrapper *metaGetEntryRowSchema(const SMetaEntry *pME) {
2,007,633,346✔
32
  if (pME == NULL) {
2,007,633,346✔
33
    return NULL;
×
34
  }
35

36
  if (pME->type == TSDB_SUPER_TABLE) {
2,007,633,346✔
37
    return &pME->stbEntry.schemaRow;
1,339,864,990✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
668,108,206✔
41
    return &pME->ntbEntry.schemaRow;
460,018,157✔
42
  }
43

44
  return NULL;
208,115,318✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
230,598,182✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
230,598,182✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
230,637,429✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
235,869,519✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
235,869,519✔
54
  bool                  hasTypeMods = false;
235,924,707✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
235,924,707✔
57
    return 0;
221,210,967✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
14,753,261✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,433,960,487✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
14,833,338✔
65
}
66

67
int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
2,243,104✔
68
  const SColRefWrapper *pw = &pME->colRef;
2,243,104✔
69
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
4,486,208✔
70
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
4,484,864✔
71
  uTrace("encode cols:%d", pw->nCols);
2,242,432✔
72

73
  for (int32_t i = 0; i < pw->nCols; i++) {
517,937,538✔
74
    SColRef *p = &pw->pColRef[i];
515,697,122✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
1,031,394,916✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
1,031,395,588✔
77
    if (p->hasRef) {
515,697,122✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
683,391,664✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
683,390,992✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
683,389,648✔
81
    }
82
  }
83

84
  // Encode tag references
85
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nTagRefs));
4,483,520✔
86
  for (int32_t i = 0; i < pw->nTagRefs; i++) {
2,243,104✔
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,241,760✔
98
}
99

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

104
  if (pSchWrapper == NULL) {
1,487,705,293✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,487,705,293✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,488,346,780✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
345,267,291✔
111
    if (pME->pExtSchemas == NULL) {
172,623,921✔
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,315,708,335✔
120
  }
121

122
  return 0;
1,488,820,052✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
52,525,636✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
52,525,636✔
127
  bool                  hasTypeMods = false;
52,579,611✔
128

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

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

135
  if (hasTypeMods) {
52,502,208✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
39,893✔
137
    if (ret != NULL) {
39,893✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
39,893✔
139
    }
140
    return ret;
39,893✔
141
  }
142
  return NULL;
52,462,315✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
30,636✔
176
  int32_t    i = 0, j = 0;
30,636✔
177
  for (i = 0; i < nCols; ++i) {
231,840✔
178
    while (j < pParam->nFuncs) {
365,976✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
351,072✔
180
        pFuncIds[i] = pParam->funcIds[j];
163,944✔
181
        break;
163,944✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
187,128✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
37,260✔
185
        break;
37,260✔
186
      }
187
      ++j;
149,868✔
188
    }
189
    if (j >= pParam->nFuncs) {
216,108✔
190
      for (; i < nCols; ++i) {
29,808✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,904✔
192
      }
193
      break;
14,904✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
30,636✔
197

198
  return 0;
30,636✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
71,525,949✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
71,525,949✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
143,098,870✔
204
  if (pWrapper->nCols == 0) {
71,543,309✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
143,072,448✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
71,544,659✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
143,083,822✔
211
  if (pWrapper->pColRef == NULL) {
71,542,393✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
1,217,150,562✔
216
    SColRef *p = &pWrapper->pColRef[i];
1,145,650,311✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
2,147,483,647✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
2,147,483,647✔
219
    if (p->hasRef) {
1,145,711,316✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
623,971,355✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
623,955,741✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
623,985,286✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
71,391,878✔
228
  pWrapper->pTagRef = NULL;
71,576,827✔
229
  if (!tDecodeIsEnd(pDecoder)) {
71,568,974✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
143,129,576✔
231
    if (pWrapper->nTagRefs > 0) {
71,558,654✔
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;
71,532,954✔
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,394,541✔
270
  if (pSrc->nCols > 0) {
1,394,541✔
271
    pDst->nCols = pSrc->nCols;
1,394,541✔
272
    pDst->version = pSrc->version;
1,395,885✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,394,541✔
274
    if (NULL == pDst->pColRef) {
1,394,541✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,395,213✔
278
  }
279
  return 0;
1,394,541✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
56,214,450✔
283
  int32_t code = 0;
56,214,450✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
112,446,720✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
112,667,237✔
286
  uTrace("encode cols:%d", pw->nCols);
56,434,967✔
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;
56,529,005✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
56,138,215✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
56,138,215✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
56,172,834✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,488,852,347✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,488,852,347✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,488,766,093✔
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,488,863,062✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,488,088,938✔
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,490,799,535✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
328,994✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,641,726✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,312,712✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,312,712✔
337
    pColCmpr->id = pColSchema->colId;
1,312,712✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,312,712✔
339
  }
340
  return 0;
329,014✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
229,221,577✔
344
  if (pSrc->nCols > 0) {
229,221,577✔
345
    pDst->nCols = pSrc->nCols;
200,550,511✔
346
    pDst->version = pSrc->version;
200,547,101✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
200,526,902✔
348
    if (NULL == pDst->pColCmpr) {
200,506,828✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
200,495,078✔
352
  }
353
  return 0;
229,233,994✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
230,526,559✔
357
  if (pColRef) {
230,526,559✔
358
    taosMemoryFreeClear(pColRef->pColRef);
230,548,099✔
359
  }
360
}
230,556,616✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
230,564,477✔
363
  if (pCmpr) {
230,564,477✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
230,589,617✔
365
  }
366
}
230,655,472✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
241,785,989✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
241,785,989✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
483,738,967✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
483,664,479✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
483,670,083✔
373

374
  if (pME->type > 0) {
241,845,651✔
375
    if (pME->name == NULL) {
235,880,108✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
471,852,463✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
236,000,587✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
62,378,197✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
62,448,113✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
62,418,002✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
31,149,643✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
124,322✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
204,660,956✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
357,050,053✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
357,059,060✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
357,070,530✔
392
      if (pME->ctbEntry.commentLen > 0) {
178,544,161✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
32,524✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
357,054,645✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
178,526,356✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
26,165,474✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
52,330,948✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
52,330,948✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
52,330,948✔
401
      if (pME->ntbEntry.commentLen > 0) {
26,165,474✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
46,348✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
52,330,948✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
52,330,948✔
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) {
235,838,393✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,457,166✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
233,590,767✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
31,267,358✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
202,410,197✔
418
        if (pME->colCmpr.nCols != 0) {
25,233,810✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
24,904,796✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
329,014✔
422
          SColCmprWrapper colCmprs = {0};
329,014✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
329,014✔
424
          if (code != 0) {
329,014✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
329,014✔
429
          taosMemoryFree(colCmprs.pColCmpr);
329,014✔
430
          TAOS_CHECK_RETURN(code);
329,014✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
235,983,003✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
241,847,171✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
62,303,263✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
62,179,006✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
62,124,280✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
210,542,079✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
50,467,620✔
442
  }
443

444
  tEndEncode(pCoder);
241,604,999✔
445
  return 0;
241,642,297✔
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);
375,948✔
456
    return 0;
375,948✔
457
  }
458

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

462
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
463
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
2,147,483,647✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
2,147,483,647✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
2,147,483,647✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
1,080,215,554✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
381,148✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,458,057,553✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
2,075,114,194✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
2,075,743,611✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
2,074,886,719✔
473
      if (pME->ctbEntry.commentLen > 0) {
1,037,018,908✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
56,226✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
2,074,941,068✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
1,037,889,051✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
421,357,247✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
843,278,273✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
843,537,580✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
843,224,325✔
482
      if (pME->ntbEntry.commentLen > 0) {
421,454,252✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
85,260✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
842,977,797✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
843,344,737✔
487
    } else if (pME->type == TSDB_TSMA_TABLE) {
×
488
      pME->smaEntry.tsma = tDecoderMalloc(pCoder, sizeof(STSma));
×
489
      if (!pME->smaEntry.tsma) {
×
490
        return terrno;
×
491
      }
492
      TAOS_CHECK_RETURN(tDecodeTSma(pCoder, pME->smaEntry.tsma, true));
×
493
    } else {
494
      metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
×
495
      return TSDB_CODE_INVALID_PARA;
×
496
    }
497
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
498
      if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
1,080,418,143✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
1,080,220,100✔
500

501
        if (pME->colCmpr.nCols == 0) {
1,080,714,972✔
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,458,063,612✔
509
      if (!tDecodeIsEnd(pCoder)) {
409,788,759✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
409,793,844✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
409,794,099✔
512
        if (pME->colCmpr.nCols == 0) {
409,935,299✔
513
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
514
        }
515
      } else {
516
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
2,818✔
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
2,818✔
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
409,776,361✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,048,328,603✔
521
      if (!tDecodeIsEnd(pCoder)) {
71,559,159✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
71,564,352✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
71,565,186✔
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,489,952,015✔
533
    } else {
534
      pME->pExtSchemas = NULL;
1,048,752,102✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
1,077,583,695✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
2,147,483,647✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
1,079,256,018✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
2,147,483,647✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
1,078,823,070✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
2,147,483,647✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,457,588,717✔
548
    if (!tDecodeIsEnd(pCoder)) {
409,520,941✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
819,307,674✔
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) {
392,006,251✔
561
  if (pSrc == NULL || pDst == NULL) {
392,006,251✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
392,061,319✔
566
  pDst->version = pSrc->version;
392,055,386✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
392,094,101✔
568
  if (pDst->pSchema == NULL) {
391,925,614✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
391,951,995✔
572
  return TSDB_CODE_SUCCESS;
392,135,837✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
83,190✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
392,008,678✔
607
  if (pSchema) {
392,008,678✔
608
    taosMemoryFreeClear(pSchema->pSchema);
392,043,711✔
609
  }
610
}
392,047,512✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
230,689,581✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
230,689,581✔
627
    return;
90,261✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
230,618,498✔
631

632
  if ((*ppEntry)->type < 0) {
230,677,474✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
230,561,072✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
191,026,863✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
190,999,193✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
191,021,953✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
128,450✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
39,604,615✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
29,567,078✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
29,564,579✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
10,045,064✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
10,045,064✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
10,045,064✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
230,640,023✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
230,600,384✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
230,623,357✔
655

656
  taosMemoryFreeClear(*ppEntry);
230,555,740✔
657
  return;
230,572,257✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
230,593,714✔
661
  int32_t code = TSDB_CODE_SUCCESS;
230,593,714✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
230,593,714✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
230,668,223✔
668
  if (NULL == *ppEntry) {
230,524,898✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
230,557,837✔
673
  (*ppEntry)->type = pEntry->type;
230,556,285✔
674
  (*ppEntry)->uid = pEntry->uid;
230,597,009✔
675

676
  if (pEntry->type < 0) {
230,610,129✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
230,592,055✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
230,603,038✔
682
    if (NULL == (*ppEntry)->name) {
230,649,404✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
230,579,031✔
690
    (*ppEntry)->flags = pEntry->flags;
190,995,080✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
191,001,217✔
693
    if (code) {
191,035,296✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
191,035,296✔
699
    if (code) {
191,080,197✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
191,080,197✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
84,018✔
705
      if (code) {
83,190✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
191,079,512✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
191,053,920✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
39,609,495✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
29,562,308✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
29,564,512✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
29,566,317✔
716

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

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
29,566,236✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
29,558,277✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
29,570,871✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
29,566,745✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
10,045,064✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
10,045,064✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
10,045,064✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
10,045,064✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
10,045,064✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
10,045,064✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
10,045,064✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
14,348✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
14,348✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
14,348✔
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) {
230,630,892✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,391,639✔
768
    if (code) {
1,394,541✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
229,233,717✔
774
    if (code) {
229,206,531✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
230,601,072✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
230,631,835✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
11,828,686✔
782
    if (!(*ppEntry)->pExtSchemas) {
11,825,596✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
11,821,881✔
788
  }
789

790
  return code;
230,596,718✔
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