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

taosdata / TDengine / #5040

29 Apr 2026 11:44AM UTC coverage: 73.13% (-0.02%) from 73.153%
#5040

push

travis-ci

web-flow
feat(statewindow): support multi columns (#35136)

1567 of 1828 new or added lines in 18 files covered. (85.72%)

7264 existing lines in 119 files now uncovered.

277409 of 379338 relevant lines covered (73.13%)

134373925.48 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,330,770,496✔
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;
170,680,827✔
26
    }
27
  }
28
  return false;
1,158,567,941✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,724,744,776✔
37
    return &pME->stbEntry.schemaRow;
1,193,246,050✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
531,748,273✔
41
    return &pME->ntbEntry.schemaRow;
338,566,666✔
42
  }
43

44
  return NULL;
193,301,776✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
213,948,166✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
213,948,166✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
213,960,616✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
218,419,357✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
218,419,357✔
54
  bool                  hasTypeMods = false;
218,427,455✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
218,427,455✔
57
    return 0;
205,149,097✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,313,649✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,427,828,621✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,237,991✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
491,512,850✔
74
    SColRef *p = &pw->pColRef[i];
489,386,700✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
978,774,692✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
978,775,984✔
77
    if (p->hasRef) {
489,387,992✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
648,588,488✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
648,588,488✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
648,588,488✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,247,688,232✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,247,688,232✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,248,126,828✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
312,304,293✔
111
    if (pME->pExtSchemas == NULL) {
156,151,272✔
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,091,974,182✔
120
  }
121

122
  return 0;
1,248,249,443✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
44,588,734✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
44,588,734✔
127
  bool                  hasTypeMods = false;
44,606,332✔
128

129
  if (pSchWrapper == NULL) {
44,606,332✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
44,606,332✔
134

135
  if (hasTypeMods) {
44,586,381✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
37,097✔
137
    if (ret != NULL) {
37,097✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
37,097✔
139
    }
140
    return ret;
37,097✔
141
  }
142
  return NULL;
44,549,284✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
29,378✔
176
  int32_t    i = 0, j = 0;
29,378✔
177
  for (i = 0; i < nCols; ++i) {
222,320✔
178
    while (j < pParam->nFuncs) {
350,948✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
336,656✔
180
        pFuncIds[i] = pParam->funcIds[j];
157,212✔
181
        break;
157,212✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
179,444✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
35,730✔
185
        break;
35,730✔
186
      }
187
      ++j;
143,714✔
188
    }
189
    if (j >= pParam->nFuncs) {
207,234✔
190
      for (; i < nCols; ++i) {
28,584✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,292✔
192
      }
193
      break;
14,292✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
29,378✔
197

198
  return 0;
29,378✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
42,472,158✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
42,472,158✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
84,959,027✔
204
  if (pWrapper->nCols == 0) {
42,478,550✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
84,946,869✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
42,475,357✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
84,941,186✔
211
  if (pWrapper->pColRef == NULL) {
42,470,161✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
728,379,249✔
216
    SColRef *p = &pWrapper->pColRef[i];
685,923,782✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,371,847,985✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,371,862,164✔
219
    if (p->hasRef) {
685,945,650✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
389,361,564✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
389,367,891✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
389,374,170✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
42,447,165✔
228
  pWrapper->pTagRef = NULL;
42,480,487✔
229
  if (!tDecodeIsEnd(pDecoder)) {
42,483,718✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
84,957,100✔
231
    if (pWrapper->nTagRefs > 0) {
42,478,550✔
232
      pWrapper->pTagRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nTagRefs * sizeof(SColRef));
×
233
      if (pWrapper->pTagRef == NULL) {
×
234
        return terrno;
×
235
      }
236

237
      for (int i = 0; i < pWrapper->nTagRefs; i++) {
×
238
        SColRef *p = &pWrapper->pTagRef[i];
×
239
        TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
×
240
        TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
×
241
        if (p->hasRef) {
×
242
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
×
243
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
×
244
          TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
×
245
        }
246
      }
247
    }
248
  }
249

250
  return 0;
42,472,089✔
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,345,000✔
270
  if (pSrc->nCols > 0) {
1,345,000✔
271
    pDst->nCols = pSrc->nCols;
1,345,646✔
272
    pDst->version = pSrc->version;
1,348,876✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,346,938✔
274
    if (NULL == pDst->pColRef) {
1,344,354✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,345,000✔
278
  }
279
  return 0;
1,345,646✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
51,677,293✔
283
  int32_t code = 0;
51,677,293✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
103,310,000✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
103,323,322✔
286
  uTrace("encode cols:%d", pw->nCols);
51,690,615✔
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;
51,780,289✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
51,432,295✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
51,432,295✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
51,463,182✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,247,809,906✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,247,809,906✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,247,815,880✔
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,247,690,557✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,247,910,943✔
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,248,387,044✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
298,357✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,486,220✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,187,844✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,187,844✔
337
    pColCmpr->id = pColSchema->colId;
1,187,844✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,187,844✔
339
  }
340
  return 0;
298,376✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
212,596,359✔
344
  if (pSrc->nCols > 0) {
212,596,359✔
345
    pDst->nCols = pSrc->nCols;
185,921,057✔
346
    pDst->version = pSrc->version;
185,923,459✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
185,899,563✔
348
    if (NULL == pDst->pColCmpr) {
185,903,251✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
185,875,161✔
352
  }
353
  return 0;
212,620,289✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
213,930,873✔
357
  if (pColRef) {
213,930,873✔
358
    taosMemoryFreeClear(pColRef->pColRef);
213,950,037✔
359
  }
360
}
213,949,295✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
213,929,474✔
363
  if (pCmpr) {
213,929,474✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
213,950,991✔
365
  }
366
}
213,914,880✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
224,055,545✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
224,055,545✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
448,141,779✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
448,074,146✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
448,046,006✔
373

374
  if (pME->type > 0) {
224,030,874✔
375
    if (pME->name == NULL) {
218,448,977✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
436,827,063✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
218,398,687✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
56,141,113✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
56,266,333✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
56,230,735✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
28,060,123✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
119,526✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
190,325,698✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
331,605,034✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
331,583,961✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
331,579,762✔
392
      if (pME->ctbEntry.commentLen > 0) {
165,803,112✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
31,308✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
331,586,156✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
165,789,069✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
24,539,186✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
49,078,372✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
49,078,372✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
49,078,372✔
401
      if (pME->ntbEntry.commentLen > 0) {
24,539,186✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,756✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
49,078,372✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
49,078,372✔
406
    } else if (pME->type == TSDB_TSMA_TABLE) {
×
407
      TAOS_CHECK_RETURN(tEncodeTSma(pCoder, pME->smaEntry.tsma));
×
408
    } else {
409
      metaError("meta/entry: invalide table type: %" PRId8 " encode failed.", pME->type);
×
410
      return TSDB_CODE_INVALID_PARA;
×
411
    }
412
    if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
218,430,534✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,252,405✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
216,221,696✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
28,083,913✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
188,245,535✔
418
        if (pME->colCmpr.nCols != 0) {
23,649,344✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
23,350,968✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
298,376✔
422
          SColCmprWrapper colCmprs = {0};
298,376✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
298,376✔
424
          if (code != 0) {
298,376✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
298,376✔
429
          taosMemoryFree(colCmprs.pColCmpr);
298,376✔
430
          TAOS_CHECK_RETURN(code);
298,376✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
218,441,585✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
224,005,305✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
56,179,887✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
56,070,111✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
56,096,173✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
195,910,925✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
47,298,688✔
442
  }
443

444
  tEndEncode(pCoder);
224,008,199✔
445
  return 0;
224,017,148✔
446
}
447

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

454
  if (headerOnly) {
2,147,483,647✔
455
    tEndDecode(pCoder);
339,668✔
456
    return 0;
339,668✔
457
  }
458

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

462
    if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
463
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
1,907,090,177✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,907,202,474✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,907,034,152✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
953,465,873✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
364,832✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,223,670,518✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,844,064,628✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,844,192,606✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,843,895,061✔
473
      if (pME->ctbEntry.commentLen > 0) {
921,794,510✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
54,222✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,843,936,275✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
922,094,083✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
302,122,391✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
604,444,071✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
604,547,886✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
604,411,249✔
482
      if (pME->ntbEntry.commentLen > 0) {
302,135,218✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
80,784✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
604,117,812✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
604,280,211✔
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)) {
953,595,943✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
953,582,807✔
500

501
        if (pME->colCmpr.nCols == 0) {
953,452,616✔
502
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
×
503
        }
504
      } else {
UNCOV
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,223,746,212✔
509
      if (!tDecodeIsEnd(pCoder)) {
294,584,167✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
294,623,142✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
294,623,371✔
512
        if (pME->colCmpr.nCols == 0) {
294,584,280✔
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);
×
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
294,637,488✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
929,108,714✔
521
      if (!tDecodeIsEnd(pCoder)) {
42,479,851✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
42,479,841✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
42,479,841✔
524
      } else {
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
10✔
526
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
10✔
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,248,155,323✔
533
    } else {
534
      pME->pExtSchemas = NULL;
929,373,342✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
953,363,350✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,906,674,674✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
953,309,807✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,906,551,825✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
953,374,387✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
1,906,842,520✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,223,691,510✔
548
    if (!tDecodeIsEnd(pCoder)) {
294,614,010✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
589,280,345✔
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) {
363,278,210✔
561
  if (pSrc == NULL || pDst == NULL) {
363,278,210✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
363,315,873✔
566
  pDst->version = pSrc->version;
363,312,974✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
363,298,087✔
568
  if (pDst->pSchema == NULL) {
363,154,591✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
363,188,545✔
572
  return TSDB_CODE_SUCCESS;
363,316,701✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
80,274✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
363,233,323✔
607
  if (pSchema) {
363,233,323✔
608
    taosMemoryFreeClear(pSchema->pSchema);
363,257,102✔
609
  }
610
}
363,261,890✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
214,023,039✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
214,023,039✔
627
    return;
87,277✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
213,949,685✔
631

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

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
213,931,186✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
176,847,478✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
176,817,210✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
176,828,672✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
122,688✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
37,095,748✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
27,508,357✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
27,509,954✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,592,233✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,592,233✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,592,233✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
213,945,144✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
213,910,611✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
213,908,603✔
655

656
  taosMemoryFreeClear(*ppEntry);
213,863,788✔
657
  return;
213,909,713✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
213,916,523✔
661
  int32_t code = TSDB_CODE_SUCCESS;
213,916,523✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
213,916,523✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
213,963,000✔
668
  if (NULL == *ppEntry) {
213,876,991✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
213,901,230✔
673
  (*ppEntry)->type = pEntry->type;
213,937,551✔
674
  (*ppEntry)->uid = pEntry->uid;
213,927,430✔
675

676
  if (pEntry->type < 0) {
213,939,161✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
213,909,152✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
213,965,837✔
682
    if (NULL == (*ppEntry)->name) {
213,950,002✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
213,929,945✔
690
    (*ppEntry)->flags = pEntry->flags;
176,865,651✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
176,830,644✔
693
    if (code) {
176,856,513✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
176,856,513✔
699
    if (code) {
176,867,300✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
176,867,300✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
80,274✔
705
      if (code) {
80,274✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
176,864,955✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
176,859,673✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
37,099,876✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
27,507,784✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
27,507,222✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
27,506,505✔
716

717
    // comment
718
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
27,510,023✔
719
    if (pEntry->ctbEntry.commentLen > 0) {
27,509,722✔
720
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
9,246✔
721
      if (NULL == (*ppEntry)->ctbEntry.comment) {
9,246✔
722
        code = terrno;
×
723
        metaCloneEntryFree(ppEntry);
×
724
        return code;
×
725
      }
726
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
9,246✔
727
    }
728

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
27,510,111✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
27,505,957✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
27,507,744✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
27,506,218✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,592,233✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,592,233✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,592,233✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,592,233✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,592,233✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,592,233✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,592,233✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,554✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,554✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,554✔
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) {
213,955,377✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,379,783✔
768
    if (code) {
1,344,354✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
212,605,231✔
774
    if (code) {
212,616,260✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
213,960,614✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
213,948,730✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,466,328✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,456,276✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,463,658✔
788
  }
789

790
  return code;
213,940,977✔
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