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

taosdata / TDengine / #5039

29 Apr 2026 11:44AM UTC coverage: 73.153% (+0.002%) from 73.151%
#5039

push

travis-ci

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

1566 of 1828 new or added lines in 18 files covered. (85.67%)

7270 existing lines in 141 files now uncovered.

277497 of 379338 relevant lines covered (73.15%)

133293066.15 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,361,720,597✔
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,469,539✔
26
    }
27
  }
28
  return false;
1,187,956,308✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,752,932,663✔
37
    return &pME->stbEntry.schemaRow;
1,209,271,739✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
543,972,794✔
41
    return &pME->ntbEntry.schemaRow;
351,936,978✔
42
  }
43

44
  return NULL;
192,183,849✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
212,680,413✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
212,680,413✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
212,688,285✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
216,585,816✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
216,585,816✔
54
  bool                  hasTypeMods = false;
216,602,031✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
216,602,031✔
57
    return 0;
203,412,987✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,215,719✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,391,096,869✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,153,779✔
65
}
66

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

73
  for (int32_t i = 0; i < pw->nCols; i++) {
476,469,290✔
74
    SColRef *p = &pw->pColRef[i];
474,354,883✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
948,710,409✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
948,711,052✔
77
    if (p->hasRef) {
474,355,526✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
628,561,076✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
628,561,076✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
628,561,076✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,275,766,468✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,275,766,468✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,276,233,452✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
314,087,788✔
111
    if (pME->pExtSchemas == NULL) {
157,046,715✔
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,119,189,434✔
120
  }
121

122
  return 0;
1,276,294,059✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
47,949,602✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
47,949,602✔
127
  bool                  hasTypeMods = false;
47,997,862✔
128

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

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

135
  if (hasTypeMods) {
47,931,807✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
37,072✔
137
    if (ret != NULL) {
37,072✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
37,072✔
139
    }
140
    return ret;
37,072✔
141
  }
142
  return NULL;
47,894,735✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
29,008✔
176
  int32_t    i = 0, j = 0;
29,008✔
177
  for (i = 0; i < nCols; ++i) {
219,520✔
178
    while (j < pParam->nFuncs) {
346,528✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
332,416✔
180
        pFuncIds[i] = pParam->funcIds[j];
155,232✔
181
        break;
155,232✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
177,184✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
35,280✔
185
        break;
35,280✔
186
      }
187
      ++j;
141,904✔
188
    }
189
    if (j >= pParam->nFuncs) {
204,624✔
190
      for (; i < nCols; ++i) {
28,224✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,112✔
192
      }
193
      break;
14,112✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
29,008✔
197

198
  return 0;
29,008✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
42,762,080✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
42,762,080✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
85,548,113✔
204
  if (pWrapper->nCols == 0) {
42,776,980✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
85,547,868✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
42,777,961✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
85,542,902✔
211
  if (pWrapper->pColRef == NULL) {
42,767,988✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
719,242,574✔
216
    SColRef *p = &pWrapper->pColRef[i];
676,490,157✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
1,352,975,876✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
1,352,993,721✔
219
    if (p->hasRef) {
676,506,258✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
384,634,834✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
384,628,276✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
384,644,932✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
42,730,242✔
228
  pWrapper->pTagRef = NULL;
42,776,974✔
229
  if (!tDecodeIsEnd(pDecoder)) {
42,777,617✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
85,547,752✔
231
    if (pWrapper->nTagRefs > 0) {
42,777,209✔
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,764,747✔
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,339,471✔
270
  if (pSrc->nCols > 0) {
1,339,471✔
271
    pDst->nCols = pSrc->nCols;
1,339,471✔
272
    pDst->version = pSrc->version;
1,339,471✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,338,828✔
274
    if (NULL == pDst->pColRef) {
1,338,828✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,338,828✔
278
  }
279
  return 0;
1,340,114✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
51,096,700✔
283
  int32_t code = 0;
51,096,700✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
102,161,668✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
102,173,666✔
286
  uTrace("encode cols:%d", pw->nCols);
51,108,698✔
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,177,895✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
50,832,079✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
50,832,079✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
50,879,237✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,275,805,007✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,275,805,007✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,275,878,670✔
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,275,632,635✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,275,989,880✔
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,276,546,246✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
301,165✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,507,694✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,206,548✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,206,548✔
337
    pColCmpr->id = pColSchema->colId;
1,206,548✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,206,548✔
339
  }
340
  return 0;
301,146✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
211,331,513✔
344
  if (pSrc->nCols > 0) {
211,331,513✔
345
    pDst->nCols = pSrc->nCols;
184,527,283✔
346
    pDst->version = pSrc->version;
184,538,192✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
184,515,588✔
348
    if (NULL == pDst->pColCmpr) {
184,517,793✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
184,491,586✔
352
  }
353
  return 0;
211,344,215✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
212,659,194✔
357
  if (pColRef) {
212,659,194✔
358
    taosMemoryFreeClear(pColRef->pColRef);
212,668,067✔
359
  }
360
}
212,673,110✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
212,657,648✔
363
  if (pCmpr) {
212,657,648✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
212,671,745✔
365
  }
366
}
212,661,853✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
222,176,064✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
222,176,064✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
444,352,575✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
444,312,661✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
444,310,370✔
373

374
  if (pME->type > 0) {
222,163,224✔
375
    if (pME->name == NULL) {
216,613,340✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
433,180,964✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
216,574,320✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
55,492,403✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
55,606,223✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
55,565,595✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
27,728,074✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
117,940✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
188,824,604✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
329,134,921✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
329,115,704✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
329,104,111✔
392
      if (pME->ctbEntry.commentLen > 0) {
164,560,918✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
31,180✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
329,107,576✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
164,551,125✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
24,272,202✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
48,544,404✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
48,544,404✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
48,544,404✔
401
      if (pME->ntbEntry.commentLen > 0) {
24,272,202✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,612✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
48,544,404✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
48,544,404✔
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,596,903✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,214,850✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
214,420,377✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
27,760,244✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
186,746,939✔
418
        if (pME->colCmpr.nCols != 0) {
23,386,478✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
23,085,332✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
301,146✔
422
          SColCmprWrapper colCmprs = {0};
301,146✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
301,146✔
424
          if (code != 0) {
301,146✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
301,146✔
429
          taosMemoryFree(colCmprs.pColCmpr);
301,146✔
430
          TAOS_CHECK_RETURN(code);
301,146✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
216,618,526✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
222,151,039✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
55,531,346✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
55,431,779✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
55,455,612✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
194,381,020✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
46,772,956✔
442
  }
443

444
  tEndEncode(pCoder);
222,150,160✔
445
  return 0;
222,171,990✔
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);
346,356✔
456
    return 0;
346,356✔
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,942,466,552✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
1,942,641,082✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
1,942,333,828✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
971,058,167✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
360,448✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,182,199,783✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
1,740,249,260✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
1,740,351,334✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
1,740,037,334✔
473
      if (pME->ctbEntry.commentLen > 0) {
869,863,349✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
53,972✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
1,740,062,139✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
870,177,172✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
312,464,125✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
625,170,476✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
625,288,309✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
625,167,241✔
482
      if (pME->ntbEntry.commentLen > 0) {
312,520,669✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
80,474✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
624,874,370✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
625,019,565✔
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)) {
971,270,887✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
971,268,895✔
500

501
        if (pME->colCmpr.nCols == 0) {
971,111,696✔
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));
19✔
506
        TABLE_SET_COL_COMPRESSED(pME->flags);
×
507
      }
508
    } else if (pME->type == TSDB_NORMAL_TABLE) {
1,182,125,544✔
509
      if (!tDecodeIsEnd(pCoder)) {
304,989,427✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
305,051,865✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
305,052,097✔
512
        if (pME->colCmpr.nCols == 0) {
305,001,139✔
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);
305,056,930✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
877,058,937✔
521
      if (!tDecodeIsEnd(pCoder)) {
42,772,545✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
42,775,117✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
42,775,911✔
524
      } else {
UNCOV
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
526
        if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
38✔
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,276,241,535✔
533
    } else {
534
      pME->pExtSchemas = NULL;
877,362,890✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
971,024,511✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
1,941,956,457✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
970,875,390✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
1,941,815,834✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
971,007,310✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
1,942,137,958✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,182,019,298✔
548
    if (!tDecodeIsEnd(pCoder)) {
305,016,105✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
610,118,568✔
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) {
360,547,100✔
561
  if (pSrc == NULL || pDst == NULL) {
360,547,100✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
360,581,906✔
566
  pDst->version = pSrc->version;
360,574,485✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
360,550,347✔
568
  if (pDst->pSchema == NULL) {
360,438,176✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
360,464,539✔
572
  return TSDB_CODE_SUCCESS;
360,576,539✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
79,212✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
360,507,262✔
607
  if (pSchema) {
360,507,262✔
608
    taosMemoryFreeClear(pSchema->pSchema);
360,521,395✔
609
  }
610
}
360,519,583✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
212,751,888✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
212,751,888✔
627
    return;
86,802✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
212,673,111✔
631

632
  if ((*ppEntry)->type < 0) {
212,640,625✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
212,651,557✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
175,508,076✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
175,482,534✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
175,479,896✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
120,276✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
37,157,286✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
27,620,897✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
27,620,943✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,537,488✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,537,488✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,537,488✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
212,658,930✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
212,646,801✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
212,642,308✔
655

656
  taosMemoryFreeClear(*ppEntry);
212,599,303✔
657
  return;
212,613,723✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
212,637,737✔
661
  int32_t code = TSDB_CODE_SUCCESS;
212,637,737✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
212,637,737✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
212,680,861✔
668
  if (NULL == *ppEntry) {
212,588,934✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
212,618,259✔
673
  (*ppEntry)->type = pEntry->type;
212,651,951✔
674
  (*ppEntry)->uid = pEntry->uid;
212,652,471✔
675

676
  if (pEntry->type < 0) {
212,663,828✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
212,629,733✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
212,667,991✔
682
    if (NULL == (*ppEntry)->name) {
212,673,159✔
UNCOV
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
212,664,238✔
690
    (*ppEntry)->flags = pEntry->flags;
175,518,852✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
175,493,604✔
693
    if (code) {
175,513,208✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
175,513,208✔
699
    if (code) {
175,528,427✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
175,528,427✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
79,212✔
705
      if (code) {
79,212✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
175,529,919✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
175,525,611✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
37,157,730✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
27,622,023✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
27,620,960✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
27,620,019✔
716

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

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
27,621,603✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
27,620,317✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
27,620,960✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
27,619,674✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,537,068✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,537,488✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,537,488✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,537,068✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,537,488✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,537,488✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,537,488✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,509✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,509✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,509✔
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) {
212,677,600✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,369,029✔
768
    if (code) {
1,340,114✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
211,336,032✔
774
    if (code) {
211,342,348✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
212,682,462✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
212,667,953✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,372,179✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,368,857✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,369,307✔
788
  }
789

790
  return code;
212,668,774✔
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