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

taosdata / TDengine / #5020

10 Apr 2026 06:58AM UTC coverage: 72.28% (+0.03%) from 72.254%
#5020

push

travis-ci

web-flow
merge: from main to 3.0 #35103

77 of 116 new or added lines in 3 files covered. (66.38%)

2742 existing lines in 124 files now uncovered.

257507 of 356263 relevant lines covered (72.28%)

135195138.8 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,413,878,995✔
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;
165,014,110✔
26
    }
27
  }
28
  return false;
1,246,139,299✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,823,353,503✔
37
    return &pME->stbEntry.schemaRow;
1,223,217,369✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
600,596,154✔
41
    return &pME->ntbEntry.schemaRow;
410,886,638✔
42
  }
43

44
  return NULL;
189,751,293✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
209,486,895✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
209,486,895✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
209,498,891✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
212,313,470✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
212,313,470✔
54
  bool                  hasTypeMods = false;
212,338,047✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
212,338,047✔
57
    return 0;
199,514,036✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
12,854,678✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,397,807,477✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
12,506,870✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
473,086,157✔
74
    SColRef *p = &pw->pColRef[i];
471,028,361✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
942,056,722✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
942,056,722✔
77
    if (p->hasRef) {
471,028,361✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
624,145,324✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
624,144,699✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
624,142,824✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,353,416,674✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,353,416,674✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,354,239,683✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
310,648,283✔
111
    if (pME->pExtSchemas == NULL) {
155,322,013✔
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,198,902,986✔
120
  }
121

122
  return 0;
1,354,592,427✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
47,012,365✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
47,012,365✔
127
  bool                  hasTypeMods = false;
47,068,342✔
128

129
  if (pSchWrapper == NULL) {
47,068,342✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
47,068,342✔
134

135
  if (hasTypeMods) {
47,005,916✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
28,732✔
137
    if (ret != NULL) {
28,732✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
28,732✔
139
    }
140
    return ret;
28,732✔
141
  }
142
  return NULL;
46,977,184✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
28,379✔
176
  int32_t    i = 0, j = 0;
28,379✔
177
  for (i = 0; i < nCols; ++i) {
214,760✔
178
    while (j < pParam->nFuncs) {
339,014✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
325,208✔
180
        pFuncIds[i] = pParam->funcIds[j];
151,866✔
181
        break;
151,866✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
173,342✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
34,515✔
185
        break;
34,515✔
186
      }
187
      ++j;
138,827✔
188
    }
189
    if (j >= pParam->nFuncs) {
200,187✔
190
      for (; i < nCols; ++i) {
27,612✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
13,806✔
192
      }
193
      break;
13,806✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
28,379✔
197

198
  return 0;
28,379✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
63,825,900✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
63,825,900✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
127,675,609✔
204
  if (pWrapper->nCols == 0) {
63,829,244✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
127,666,333✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
63,845,075✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
127,681,424✔
211
  if (pWrapper->pColRef == NULL) {
63,837,964✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
1,093,181,445✔
216
    SColRef *p = &pWrapper->pColRef[i];
1,029,393,117✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
2,058,853,744✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
2,058,932,039✔
219
    if (p->hasRef) {
1,029,485,528✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
559,533,298✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
559,533,306✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
559,527,413✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
63,715,430✔
228
  pWrapper->pTagRef = NULL;
63,863,918✔
229
  if (!tDecodeIsEnd(pDecoder)) {
63,860,871✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
127,709,608✔
231
    if (pWrapper->nTagRefs > 0) {
63,849,206✔
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;
63,830,717✔
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,289,906✔
270
  if (pSrc->nCols > 0) {
1,289,906✔
271
    pDst->nCols = pSrc->nCols;
1,289,906✔
272
    pDst->version = pSrc->version;
1,290,531✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,289,281✔
274
    if (NULL == pDst->pColRef) {
1,287,406✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,286,781✔
278
  }
279
  return 0;
1,291,156✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
49,521,657✔
283
  int32_t code = 0;
49,521,657✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
99,120,100✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
99,293,784✔
286
  uTrace("encode cols:%d", pw->nCols);
49,695,341✔
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,817,131✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
49,504,527✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
49,504,527✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
49,523,860✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,354,777,350✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,354,777,350✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,354,711,120✔
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,354,722,804✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,354,799,360✔
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,356,371,546✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
260,806✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,295,638✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,034,790✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,034,790✔
337
    pColCmpr->id = pColSchema->colId;
1,034,790✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,034,790✔
339
  }
340
  return 0;
260,848✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
208,224,905✔
344
  if (pSrc->nCols > 0) {
208,224,905✔
345
    pDst->nCols = pSrc->nCols;
181,006,548✔
346
    pDst->version = pSrc->version;
181,007,665✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
180,949,300✔
348
    if (NULL == pDst->pColCmpr) {
180,950,320✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
180,919,415✔
352
  }
353
  return 0;
208,215,835✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
209,432,902✔
357
  if (pColRef) {
209,432,902✔
358
    taosMemoryFreeClear(pColRef->pColRef);
209,461,077✔
359
  }
360
}
209,466,120✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
209,466,351✔
363
  if (pCmpr) {
209,466,351✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
209,468,496✔
365
  }
366
}
209,489,807✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
217,464,742✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
217,464,742✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
435,078,553✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
434,976,206✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
434,947,156✔
373

374
  if (pME->type > 0) {
217,491,008✔
375
    if (pME->name == NULL) {
212,282,932✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
424,700,180✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
212,376,078✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
54,040,667✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
54,173,147✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
54,177,540✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
27,024,580✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
115,724✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
185,286,075✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
323,466,195✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
323,488,553✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
323,508,335✔
392
      if (pME->ctbEntry.commentLen > 0) {
161,752,977✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
30,100✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
323,437,127✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
161,708,557✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
23,565,142✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
47,130,075✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
47,130,075✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
47,130,075✔
401
      if (pME->ntbEntry.commentLen > 0) {
23,564,933✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
19,108✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
47,130,284✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
47,130,075✔
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,261,308✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,223,627✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
210,152,365✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
27,076,142✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
183,233,592✔
418
        if (pME->colCmpr.nCols != 0) {
22,709,707✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
22,449,068✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
260,848✔
422
          SColCmprWrapper colCmprs = {0};
260,848✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
260,848✔
424
          if (code != 0) {
260,848✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
260,848✔
429
          taosMemoryFree(colCmprs.pColCmpr);
260,848✔
430
          TAOS_CHECK_RETURN(code);
260,848✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
212,404,091✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
217,509,958✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
54,035,079✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
53,908,521✔
439
  } else if (pME->type == TSDB_NORMAL_TABLE) {
190,399,727✔
440
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
45,419,832✔
441
  }
442

443
  tEndEncode(pCoder);
217,371,357✔
444
  return 0;
217,288,390✔
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);
365,614✔
455
    return 0;
365,614✔
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,979,030,038✔
463
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,980,134,045✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,980,183,793✔
465
      if (TABLE_IS_ROLLUP(pME->flags)) {
990,041,649✔
466
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
349,874✔
467
      }
468
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,304,307,757✔
469
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,858,467,407✔
470
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,859,029,593✔
471
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,858,341,514✔
472
      if (pME->ctbEntry.commentLen > 0) {
928,829,459✔
473
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
52,068✔
474
      }
475
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,858,373,065✔
476
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
929,539,281✔
477
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
375,870,362✔
478
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
752,353,336✔
479
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
752,572,291✔
480
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
752,255,674✔
481
      if (pME->ntbEntry.commentLen > 0) {
375,968,929✔
482
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
39,702✔
483
      }
484
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
751,898,303✔
485
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
752,261,157✔
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)) {
990,175,437✔
498
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
990,028,564✔
499

500
        if (pME->colCmpr.nCols == 0) {
990,329,225✔
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,304,438,730✔
508
      if (!tDecodeIsEnd(pCoder)) {
365,591,001✔
509
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
365,641,377✔
510
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
365,641,849✔
511
        if (pME->colCmpr.nCols == 0) {
365,634,213✔
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);
365,575,324✔
519
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
938,968,983✔
520
      if (!tDecodeIsEnd(pCoder)) {
63,844,340✔
521
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
63,846,306✔
522
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
63,846,558✔
523
      } else {
524
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
525
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
5✔
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,355,650,393✔
532
    } else {
533
      pME->pExtSchemas = NULL;
939,468,011✔
534
    }
535
  }
536
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
537
    if (!tDecodeIsEnd(pCoder)) {
989,214,078✔
538
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,979,115,254✔
539
    }
540
    if (!tDecodeIsEnd(pCoder)) {
988,412,093✔
541
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,978,067,531✔
542
    }
543
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,303,889,832✔
544
    if (!tDecodeIsEnd(pCoder)) {
365,377,016✔
545
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
730,940,344✔
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) {
353,727,055✔
557
  if (pSrc == NULL || pDst == NULL) {
353,727,055✔
558
    return TSDB_CODE_INVALID_PARA;
×
559
  }
560

561
  pDst->nCols = pSrc->nCols;
353,773,702✔
562
  pDst->version = pSrc->version;
353,779,272✔
563
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
353,760,688✔
564
  if (pDst->pSchema == NULL) {
353,573,837✔
565
    return terrno;
×
566
  }
567
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
353,632,563✔
568
  return TSDB_CODE_SUCCESS;
353,811,383✔
569
}
570

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

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

599
  return TSDB_CODE_SUCCESS;
77,589✔
600
}
601

602
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
353,705,435✔
603
  if (pSchema) {
353,705,435✔
604
    taosMemoryFreeClear(pSchema->pSchema);
353,721,977✔
605
  }
606
}
353,778,579✔
607

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

621
void metaCloneEntryFree(SMetaEntry **ppEntry) {
209,582,728✔
622
  if (ppEntry == NULL || *ppEntry == NULL) {
209,582,728✔
623
    return;
81,115✔
624
  }
625

626
  taosMemoryFreeClear((*ppEntry)->name);
209,524,801✔
627

628
  if ((*ppEntry)->type < 0) {
209,520,548✔
629
    taosMemoryFreeClear(*ppEntry);
×
630
    return;
×
631
  }
632

633
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
209,419,060✔
634
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
172,281,100✔
635
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
172,250,658✔
636
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
172,252,041✔
637
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
118,301✔
638
    }
639
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
37,226,505✔
640
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
28,024,196✔
641
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
28,022,115✔
642
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,201,609✔
643
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,201,609✔
644
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,201,609✔
645
  } else {
646
    return;
×
647
  }
648
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
209,477,535✔
649
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
209,457,860✔
650
  metaCloneColRefFree(&(*ppEntry)->colRef);
209,489,796✔
651

652
  taosMemoryFreeClear(*ppEntry);
209,405,011✔
653
  return;
209,465,449✔
654
}
655

656
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
209,486,543✔
657
  int32_t code = TSDB_CODE_SUCCESS;
209,486,543✔
658

659
  if (NULL == pEntry || NULL == ppEntry) {
209,486,543✔
660
    return TSDB_CODE_INVALID_PARA;
×
661
  }
662

663
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
209,542,864✔
664
  if (NULL == *ppEntry) {
209,400,120✔
665
    return terrno;
×
666
  }
667

668
  (*ppEntry)->version = pEntry->version;
209,429,612✔
669
  (*ppEntry)->type = pEntry->type;
209,474,892✔
670
  (*ppEntry)->uid = pEntry->uid;
209,453,148✔
671

672
  if (pEntry->type < 0) {
209,448,686✔
673
    return TSDB_CODE_SUCCESS;
×
674
  }
675

676
  if (pEntry->name) {
209,501,045✔
677
    (*ppEntry)->name = tstrdup(pEntry->name);
209,496,703✔
678
    if (NULL == (*ppEntry)->name) {
209,522,629✔
679
      code = terrno;
×
680
      metaCloneEntryFree(ppEntry);
×
681
      return code;
×
682
    }
683
  }
684

685
  if (pEntry->type == TSDB_SUPER_TABLE) {
209,519,400✔
686
    (*ppEntry)->flags = pEntry->flags;
172,267,817✔
687

688
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
172,224,778✔
689
    if (code) {
172,287,600✔
690
      metaCloneEntryFree(ppEntry);
×
691
      return code;
×
692
    }
693

694
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
172,287,600✔
695
    if (code) {
172,320,214✔
696
      metaCloneEntryFree(ppEntry);
×
697
      return code;
×
698
    }
699
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
172,320,214✔
700
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
77,589✔
701
      if (code) {
77,589✔
702
        metaCloneEntryFree(ppEntry);
×
703
        return code;
×
704
      }
705
    }
706
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
172,318,917✔
707
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
172,275,493✔
708
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
37,226,358✔
709
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
28,027,286✔
710
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
28,027,596✔
711
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
28,028,365✔
712

713
    // comment
714
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
28,028,046✔
715
    if (pEntry->ctbEntry.commentLen > 0) {
28,024,752✔
716
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
8,891✔
717
      if (NULL == (*ppEntry)->ctbEntry.comment) {
8,891✔
718
        code = terrno;
×
719
        metaCloneEntryFree(ppEntry);
×
720
        return code;
×
721
      }
722
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
8,891✔
723
    }
724

725
    // tags
726
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
28,022,481✔
727
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
28,024,011✔
728
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
28,026,783✔
729
      code = terrno;
×
730
      metaCloneEntryFree(ppEntry);
×
731
      return code;
×
732
    }
733
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
28,025,667✔
734
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,200,934✔
735
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,201,609✔
736
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,200,934✔
737
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,201,609✔
738
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,200,934✔
739

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

747
    // comment
748
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,201,609✔
749
    if (pEntry->ntbEntry.commentLen > 0) {
9,201,609✔
750
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
6,143✔
751
      if (NULL == (*ppEntry)->ntbEntry.comment) {
6,143✔
752
        code = terrno;
×
753
        metaCloneEntryFree(ppEntry);
×
754
        return code;
×
755
      }
756
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
6,143✔
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) {
209,522,968✔
763
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,341,048✔
764
    if (code) {
1,291,156✔
765
      metaCloneEntryFree(ppEntry);
×
766
      return code;
×
767
    }
768
  } else {
769
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
208,203,026✔
770
    if (code) {
208,196,711✔
771
      metaCloneEntryFree(ppEntry);
×
772
      return code;
×
773
    }
774
  }
775
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
209,487,867✔
776
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
209,493,649✔
777
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,117,777✔
778
    if (!(*ppEntry)->pExtSchemas) {
10,109,125✔
779
      code = terrno;
×
780
      metaCloneEntryFree(ppEntry);
×
781
      return code;
×
782
    }
783
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,106,045✔
784
  }
785

786
  return code;
209,514,244✔
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