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

taosdata / TDengine / #5038

29 Apr 2026 11:44AM UTC coverage: 73.151% (-0.008%) from 73.159%
#5038

push

travis-ci

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

1554 of 1828 new or added lines in 18 files covered. (85.01%)

7333 existing lines in 152 files now uncovered.

277490 of 379338 relevant lines covered (73.15%)

134410214.73 hits per line

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

79.11
/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,387,589,744✔
23
  for (int32_t i = 0; i < nCols; i++) {
2,147,483,647✔
24
    if (HAS_TYPE_MOD(pSchema + i)) {
2,147,483,647✔
25
      return true;
171,281,044✔
26
    }
27
  }
28
  return false;
1,215,499,482✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,779,198,493✔
37
    return &pME->stbEntry.schemaRow;
1,233,649,287✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
545,787,106✔
41
    return &pME->ntbEntry.schemaRow;
353,063,571✔
42
  }
43

44
  return NULL;
192,818,668✔
45
}
46

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

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
216,557,193✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
216,557,193✔
54
  bool                  hasTypeMods = false;
216,565,121✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
216,565,121✔
57
    return 0;
203,385,580✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,220,243✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,366,895,132✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,014,218✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
474,167,664✔
74
    SColRef *p = &pw->pColRef[i];
472,044,534✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
944,089,068✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
944,089,068✔
77
    if (p->hasRef) {
472,044,534✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
625,486,204✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
625,486,204✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
625,486,204✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,300,786,937✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,300,786,937✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,301,210,592✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
313,707,365✔
111
    if (pME->pExtSchemas == NULL) {
156,856,193✔
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,144,356,830✔
120
  }
121

122
  return 0;
1,301,340,551✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
48,460,374✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
48,460,374✔
127
  bool                  hasTypeMods = false;
48,481,935✔
128

129
  if (pSchWrapper == NULL) {
48,481,935✔
130
    return NULL;
×
131
  }
132

133
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
48,481,935✔
134

135
  if (hasTypeMods) {
48,457,035✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
37,204✔
137
    if (ret != NULL) {
37,204✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
37,204✔
139
    }
140
    return ret;
37,204✔
141
  }
142
  return NULL;
48,419,831✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
29,341✔
176
  int32_t    i = 0, j = 0;
29,341✔
177
  for (i = 0; i < nCols; ++i) {
222,040✔
178
    while (j < pParam->nFuncs) {
350,506✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
336,232✔
180
        pFuncIds[i] = pParam->funcIds[j];
157,014✔
181
        break;
157,014✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
179,218✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
35,685✔
185
        break;
35,685✔
186
      }
187
      ++j;
143,533✔
188
    }
189
    if (j >= pParam->nFuncs) {
206,973✔
190
      for (; i < nCols; ++i) {
28,548✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,274✔
192
      }
193
      break;
14,274✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
29,341✔
197

198
  return 0;
29,341✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
43,266,323✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
43,266,323✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
86,554,647✔
204
  if (pWrapper->nCols == 0) {
43,279,926✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
86,546,878✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
43,281,805✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
86,554,793✔
211
  if (pWrapper->pColRef == NULL) {
43,274,731✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
722,302,272✔
216
    SColRef *p = &pWrapper->pColRef[i];
679,034,515✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,358,087,426✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,358,135,458✔
219
    if (p->hasRef) {
679,083,410✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
386,413,549✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
386,412,240✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
386,413,249✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
43,251,943✔
228
  pWrapper->pTagRef = NULL;
43,285,035✔
229
  if (!tDecodeIsEnd(pDecoder)) {
43,284,389✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
86,552,380✔
231
    if (pWrapper->nTagRefs > 0) {
43,279,650✔
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;
43,273,836✔
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,346,690✔
270
  if (pSrc->nCols > 0) {
1,346,690✔
271
    pDst->nCols = pSrc->nCols;
1,346,690✔
272
    pDst->version = pSrc->version;
1,347,336✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,346,044✔
274
    if (NULL == pDst->pColRef) {
1,346,690✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,346,690✔
278
  }
279
  return 0;
1,347,336✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
51,581,298✔
283
  int32_t code = 0;
51,581,298✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
103,124,103✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
103,149,645✔
286
  uTrace("encode cols:%d", pw->nCols);
51,606,840✔
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,654,978✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
51,315,272✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
51,315,272✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
51,358,503✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,300,928,186✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,300,928,186✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,300,923,430✔
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,300,714,365✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,300,964,573✔
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,301,462,070✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
303,702✔
323

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

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

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

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
211,959,715✔
344
  if (pSrc->nCols > 0) {
211,959,715✔
345
    pDst->nCols = pSrc->nCols;
184,026,012✔
346
    pDst->version = pSrc->version;
184,023,280✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
183,985,515✔
348
    if (NULL == pDst->pColCmpr) {
184,003,547✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
183,969,093✔
352
  }
353
  return 0;
211,973,382✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
213,300,351✔
357
  if (pColRef) {
213,300,351✔
358
    taosMemoryFreeClear(pColRef->pColRef);
213,310,019✔
359
  }
360
}
213,309,469✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
213,298,341✔
363
  if (pCmpr) {
213,298,341✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
213,311,469✔
365
  }
366
}
213,282,526✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
222,025,448✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
222,025,448✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
444,092,820✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
444,043,202✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
444,012,691✔
373

374
  if (pME->type > 0) {
222,003,852✔
375
    if (pME->name == NULL) {
216,570,468✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
433,127,933✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
216,557,291✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
56,249,589✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
56,343,094✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
56,330,194✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
28,125,799✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
119,389✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
188,418,306✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
328,115,633✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
328,097,690✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
328,089,481✔
392
      if (pME->ctbEntry.commentLen > 0) {
164,055,451✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
31,440✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
328,096,622✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
164,050,000✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
24,375,262✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
48,750,524✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
48,750,524✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
48,750,524✔
401
      if (pME->ntbEntry.commentLen > 0) {
24,375,262✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,920✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
48,750,524✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
48,750,524✔
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) {
216,583,773✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,234,688✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
214,382,623✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
28,143,953✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
186,354,325✔
418
        if (pME->colCmpr.nCols != 0) {
23,487,888✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
23,184,186✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
303,702✔
422
          SColCmprWrapper colCmprs = {0};
303,702✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
303,702✔
424
          if (code != 0) {
303,702✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
303,702✔
429
          taosMemoryFree(colCmprs.pColCmpr);
303,702✔
430
          TAOS_CHECK_RETURN(code);
303,702✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
216,591,463✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
222,000,982✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
56,308,596✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
56,197,868✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
56,195,107✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
193,854,686✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
46,975,776✔
442
  }
443

444
  tEndEncode(pCoder);
221,987,042✔
445
  return 0;
222,005,078✔
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);
338,458✔
456
    return 0;
338,458✔
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,990,822,642✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,990,920,908✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,990,717,157✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
995,301,787✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
364,661✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,226,797,372✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,827,743,768✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,827,791,617✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,827,473,993✔
473
      if (pME->ctbEntry.commentLen > 0) {
913,587,107✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
54,450✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,827,477,425✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
913,895,808✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
313,303,006✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
626,821,013✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
626,959,591✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
626,849,209✔
482
      if (pME->ntbEntry.commentLen > 0) {
313,368,516✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
81,090✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
626,619,634✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
626,728,696✔
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)) {
995,445,922✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
995,398,771✔
500

501
        if (pME->colCmpr.nCols == 0) {
995,293,491✔
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,226,757,322✔
509
      if (!tDecodeIsEnd(pCoder)) {
305,843,824✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
305,868,898✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
305,869,360✔
512
        if (pME->colCmpr.nCols == 0) {
305,864,920✔
513
          TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
514
        }
515
      } else {
UNCOV
516
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
×
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
305,883,173✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
920,853,696✔
521
      if (!tDecodeIsEnd(pCoder)) {
43,281,651✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
43,279,101✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
43,280,689✔
524
      } else {
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
2,550✔
526
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
2,550✔
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,301,264,319✔
533
    } else {
534
      pME->pExtSchemas = NULL;
921,165,814✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
995,208,416✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,990,383,679✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
995,134,355✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,990,252,546✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
995,222,293✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
1,990,511,586✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,226,719,365✔
548
    if (!tDecodeIsEnd(pCoder)) {
305,838,183✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
611,724,812✔
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) {
359,479,832✔
561
  if (pSrc == NULL || pDst == NULL) {
359,479,832✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
359,510,124✔
566
  pDst->version = pSrc->version;
359,502,817✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
359,496,223✔
568
  if (pDst->pSchema == NULL) {
359,349,573✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
359,393,412✔
572
  return TSDB_CODE_SUCCESS;
359,518,818✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
80,181✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
359,448,987✔
607
  if (pSchema) {
359,448,987✔
608
    taosMemoryFreeClear(pSchema->pSchema);
359,457,311✔
609
  }
610
}
359,464,940✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
213,390,021✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
213,390,021✔
627
    return;
87,170✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
213,313,607✔
631

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

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
213,298,576✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
174,954,425✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
174,918,596✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
174,942,329✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
122,547✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
38,345,688✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
28,762,844✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
28,761,552✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,585,513✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,585,513✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,585,513✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
213,302,892✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
213,281,365✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
213,278,170✔
655

656
  taosMemoryFreeClear(*ppEntry);
213,225,429✔
657
  return;
213,280,258✔
658
}
659

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

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

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
213,312,401✔
668
  if (NULL == *ppEntry) {
213,224,160✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
213,252,089✔
673
  (*ppEntry)->type = pEntry->type;
213,286,878✔
674
  (*ppEntry)->uid = pEntry->uid;
213,286,395✔
675

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

680
  if (pEntry->name) {
213,256,700✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
213,305,729✔
682
    if (NULL == (*ppEntry)->name) {
213,311,016✔
683
      code = terrno;
19✔
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
213,292,086✔
690
    (*ppEntry)->flags = pEntry->flags;
174,964,090✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
174,942,240✔
693
    if (code) {
174,963,935✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
174,963,935✔
699
    if (code) {
174,975,637✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
174,975,637✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
80,181✔
705
      if (code) {
80,181✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
174,971,075✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
174,961,817✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
38,346,250✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
28,761,429✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
28,760,783✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
28,761,429✔
716

717
    // comment
718
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
28,762,160✔
719
    if (pEntry->ctbEntry.commentLen > 0) {
28,761,429✔
720
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
9,285✔
721
      if (NULL == (*ppEntry)->ctbEntry.comment) {
9,285✔
722
        code = terrno;
×
723
        metaCloneEntryFree(ppEntry);
×
724
        return code;
×
725
      }
726
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
9,285✔
727
    }
728

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
28,760,783✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
28,760,137✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
28,761,429✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
28,761,429✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,585,513✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,585,513✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,585,513✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,585,513✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,585,513✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,585,513✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,585,513✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,605✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,605✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,605✔
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,297,855✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,372,022✔
768
    if (code) {
1,347,336✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
211,952,623✔
774
    if (code) {
211,970,905✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
213,318,241✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
213,303,447✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,368,918✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,363,028✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,368,296✔
788
  }
789

790
  return code;
213,295,064✔
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