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

taosdata / TDengine / #5042

29 Apr 2026 11:44AM UTC coverage: 73.17% (+0.06%) from 73.109%
#5042

push

travis-ci

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

1557 of 1828 new or added lines in 18 files covered. (85.18%)

7203 existing lines in 131 files now uncovered.

277560 of 379338 relevant lines covered (73.17%)

137140549.71 hits per line

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

78.53
/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,494,301,464✔
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;
176,823,910✔
26
    }
27
  }
28
  return false;
1,315,184,033✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,898,390,243✔
37
    return &pME->stbEntry.schemaRow;
1,264,941,447✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
634,124,778✔
41
    return &pME->ntbEntry.schemaRow;
434,756,770✔
42
  }
43

44
  return NULL;
199,449,817✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
220,014,494✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
220,014,494✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
220,047,794✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
222,389,779✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
222,389,779✔
54
  bool                  hasTypeMods = false;
222,415,099✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
222,415,099✔
57
    return 0;
209,071,935✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,396,236✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,452,601,658✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,253,313✔
65
}
66

67
int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
2,130,906✔
68
  const SColRefWrapper *pw = &pME->colRef;
2,130,906✔
69
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
4,259,886✔
70
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
4,257,318✔
71
  uTrace("encode cols:%d", pw->nCols);
2,128,338✔
72

73
  for (int32_t i = 0; i < pw->nCols; i++) {
491,810,590✔
74
    SColRef *p = &pw->pColRef[i];
489,680,968✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
979,365,146✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
979,370,924✔
77
    if (p->hasRef) {
489,686,104✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
648,887,672✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
648,887,030✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
648,887,672✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,405,969,077✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,405,969,077✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,407,571,526✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
324,257,598✔
111
    if (pME->pExtSchemas == NULL) {
162,124,529✔
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,245,438,512✔
120
  }
121

122
  return 0;
1,407,989,599✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
49,165,173✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
49,165,173✔
127
  bool                  hasTypeMods = false;
49,187,900✔
128

129
  if (pSchWrapper == NULL) {
49,187,900✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
49,187,900✔
134

135
  if (hasTypeMods) {
49,180,591✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
37,183✔
137
    if (ret != NULL) {
37,183✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
37,183✔
139
    }
140
    return ret;
37,183✔
141
  }
142
  return NULL;
49,143,408✔
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) {
67,836,282✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
67,836,282✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
135,715,145✔
204
  if (pWrapper->nCols == 0) {
67,854,900✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
135,682,589✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
67,857,664✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
135,716,194✔
211
  if (pWrapper->pColRef == NULL) {
67,862,728✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
1,152,156,810✔
216
    SColRef *p = &pWrapper->pColRef[i];
1,084,358,537✔
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,084,424,868✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
590,940,636✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
590,930,575✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
590,944,637✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
67,737,676✔
228
  pWrapper->pTagRef = NULL;
67,883,562✔
229
  if (!tDecodeIsEnd(pDecoder)) {
67,887,476✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
135,753,474✔
231
    if (pWrapper->nTagRefs > 0) {
67,874,782✔
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;
67,850,542✔
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,329,223✔
270
  if (pSrc->nCols > 0) {
1,329,223✔
271
    pDst->nCols = pSrc->nCols;
1,328,581✔
272
    pDst->version = pSrc->version;
1,329,223✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,326,655✔
274
    if (NULL == pDst->pColRef) {
1,327,939✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,327,297✔
278
  }
279
  return 0;
1,329,223✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
52,267,624✔
283
  int32_t code = 0;
52,267,624✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
104,581,288✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
104,574,286✔
286
  uTrace("encode cols:%d", pw->nCols);
52,260,622✔
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;
52,483,042✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
52,080,112✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
52,080,112✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
52,165,078✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,407,031,863✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,407,031,863✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,406,686,513✔
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,406,133,854✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,406,797,899✔
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,408,492,950✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
303,970✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,520,912✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,216,942✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,216,942✔
337
    pColCmpr->id = pColSchema->colId;
1,216,942✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,216,942✔
339
  }
340
  return 0;
303,970✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
218,680,069✔
344
  if (pSrc->nCols > 0) {
218,680,069✔
345
    pDst->nCols = pSrc->nCols;
189,195,600✔
346
    pDst->version = pSrc->version;
189,207,423✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
189,164,461✔
348
    if (NULL == pDst->pColCmpr) {
189,163,395✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
189,131,653✔
352
  }
353
  return 0;
218,726,416✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
219,981,345✔
357
  if (pColRef) {
219,981,345✔
358
    taosMemoryFreeClear(pColRef->pColRef);
220,014,238✔
359
  }
360
}
220,013,633✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
219,987,682✔
363
  if (pCmpr) {
219,987,682✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
220,015,866✔
365
  }
366
}
220,070,866✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
227,632,365✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
227,632,365✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
455,380,331✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
455,274,295✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
455,244,203✔
373

374
  if (pME->type > 0) {
227,660,485✔
375
    if (pME->name == NULL) {
222,418,082✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
444,798,407✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
222,377,516✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
57,024,576✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
57,175,161✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
57,138,328✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
28,487,447✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
119,584✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
193,848,239✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
338,203,156✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
338,195,746✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
338,169,127✔
392
      if (pME->ctbEntry.commentLen > 0) {
169,089,232✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
31,212✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
338,156,100✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
169,064,223✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
24,792,850✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
49,585,700✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
49,585,700✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
49,585,700✔
401
      if (pME->ntbEntry.commentLen > 0) {
24,792,850✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,724✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
49,585,700✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
49,585,700✔
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) {
222,400,825✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,302,898✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
220,176,644✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
28,526,142✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
191,719,821✔
418
        if (pME->colCmpr.nCols != 0) {
23,908,178✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
23,604,208✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
303,970✔
422
          SColCmprWrapper colCmprs = {0};
303,970✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
303,970✔
424
          if (code != 0) {
303,970✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
303,970✔
429
          taosMemoryFree(colCmprs.pColCmpr);
303,970✔
430
          TAOS_CHECK_RETURN(code);
303,970✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
222,428,362✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
227,576,328✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
56,929,350✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
56,744,157✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
56,815,830✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
199,066,054✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
47,816,356✔
442
  }
443

444
  tEndEncode(pCoder);
227,534,964✔
445
  return 0;
227,503,870✔
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);
422,188✔
456
    return 0;
422,188✔
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,040,799,569✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
2,041,852,793✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
2,041,831,092✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
1,020,781,131✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
365,440✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,398,053,552✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
2,001,914,559✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
2,002,484,462✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
2,001,731,863✔
473
      if (pME->ctbEntry.commentLen > 0) {
1,000,501,574✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
54,008✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
2,001,692,850✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
1,001,164,233✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
397,975,958✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
796,551,358✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
796,766,748✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
796,391,272✔
482
      if (pME->ntbEntry.commentLen > 0) {
398,013,588✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
80,642✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
795,770,667✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
796,166,030✔
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,021,081,592✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
1,020,952,421✔
500

501
        if (pME->colCmpr.nCols == 0) {
1,021,117,536✔
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,398,199,683✔
509
      if (!tDecodeIsEnd(pCoder)) {
387,072,881✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
387,099,390✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
387,099,390✔
512
        if (pME->colCmpr.nCols == 0) {
387,194,952✔
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);
387,070,926✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,011,009,369✔
521
      if (!tDecodeIsEnd(pCoder)) {
67,877,770✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
67,885,892✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
67,885,892✔
524
      } else {
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
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,407,760,806✔
533
    } else {
534
      pME->pExtSchemas = NULL;
1,011,850,065✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
1,019,998,867✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
2,040,558,600✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
1,019,246,718✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
2,038,673,763✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
1,019,878,026✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
2,039,920,121✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,397,928,767✔
548
    if (!tDecodeIsEnd(pCoder)) {
386,945,996✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
773,994,798✔
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) {
369,746,529✔
561
  if (pSrc == NULL || pDst == NULL) {
369,746,529✔
UNCOV
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
369,798,003✔
566
  pDst->version = pSrc->version;
369,801,922✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
369,787,620✔
568
  if (pDst->pSchema == NULL) {
369,616,482✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
369,680,283✔
572
  return TSDB_CODE_SUCCESS;
369,830,800✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
80,310✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
369,708,114✔
607
  if (pSchema) {
369,708,114✔
608
    taosMemoryFreeClear(pSchema->pSchema);
369,726,270✔
609
  }
610
}
369,789,725✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
220,077,383✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
220,077,383✔
627
    return;
85,637✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
220,020,046✔
631

632
  if ((*ppEntry)->type < 0) {
220,026,699✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
219,981,002✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
180,066,865✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
180,067,617✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
180,067,265✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
122,747✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
39,961,403✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
30,363,182✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
30,358,019✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,613,983✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,614,398✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,614,398✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
220,041,311✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
220,038,701✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
220,002,493✔
655

656
  taosMemoryFreeClear(*ppEntry);
219,983,720✔
657
  return;
220,029,779✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
219,996,451✔
661
  int32_t code = TSDB_CODE_SUCCESS;
219,996,451✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
219,996,451✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
220,077,844✔
668
  if (NULL == *ppEntry) {
219,976,658✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
220,015,781✔
673
  (*ppEntry)->type = pEntry->type;
220,034,704✔
674
  (*ppEntry)->uid = pEntry->uid;
220,004,308✔
675

676
  if (pEntry->type < 0) {
220,060,407✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
220,030,382✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
220,058,713✔
682
    if (NULL == (*ppEntry)->name) {
220,052,923✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
220,043,363✔
690
    (*ppEntry)->flags = pEntry->flags;
180,075,428✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
180,037,872✔
693
    if (code) {
180,100,349✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
180,100,349✔
699
    if (code) {
180,120,251✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
180,120,251✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
80,310✔
705
      if (code) {
80,310✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
180,121,862✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
180,089,271✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
39,962,622✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
30,353,912✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
30,355,187✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
30,353,822✔
716

717
    // comment
718
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
30,365,594✔
719
    if (pEntry->ctbEntry.commentLen > 0) {
30,360,028✔
720
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
9,219✔
721
      if (NULL == (*ppEntry)->ctbEntry.comment) {
9,219✔
722
        code = terrno;
×
723
        metaCloneEntryFree(ppEntry);
×
724
        return code;
×
725
      }
726
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
9,219✔
727
    }
728

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
30,360,265✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
30,348,196✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
30,358,505✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
30,352,609✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,614,398✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,614,398✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,614,398✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,614,398✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,614,398✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,614,398✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,614,398✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,543✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,543✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,543✔
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) {
220,061,948✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,406,151✔
768
    if (code) {
1,329,223✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
218,682,984✔
774
    if (code) {
218,712,872✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
220,042,095✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
220,047,470✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,558,467✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,554,336✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,550,752✔
788
  }
789

790
  return code;
219,992,939✔
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