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

taosdata / TDengine / #5037

29 Apr 2026 11:44AM UTC coverage: 73.159% (+0.1%) from 73.055%
#5037

push

travis-ci

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

1565 of 1828 new or added lines in 18 files covered. (85.61%)

546 existing lines in 125 files now uncovered.

277521 of 379338 relevant lines covered (73.16%)

138223876.68 hits per line

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

78.92
/source/dnode/vnode/src/meta/metaEntry.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "meta.h"
17
#include "osMemPool.h"
18
#include "osMemory.h"
19
#include "tencode.h"
20
#include "tmsg.h"
21

22
bool schemasHasTypeMod(const SSchema *pSchema, int32_t nCols) {
1,511,481,166✔
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;
178,180,459✔
26
    }
27
  }
28
  return false;
1,330,723,553✔
29
}
30

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

36
  if (pME->type == TSDB_SUPER_TABLE) {
1,928,930,452✔
37
    return &pME->stbEntry.schemaRow;
1,295,133,189✔
38
  }
39

40
  if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
634,370,165✔
41
    return &pME->ntbEntry.schemaRow;
430,138,431✔
42
  }
43

44
  return NULL;
204,312,717✔
45
}
46

47
static int32_t metaGetEntryRowSchemaNum(const SMetaEntry *pME) {
225,394,070✔
48
  const SSchemaWrapper *pSchema = metaGetEntryRowSchema(pME);
225,394,070✔
49
  return pSchema == NULL ? 0 : pSchema->nCols;
225,417,374✔
50
}
51

52
static int32_t metaEncodeExtSchema(SEncoder* pCoder, const SMetaEntry* pME) {
230,743,490✔
53
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
230,743,490✔
54
  bool                  hasTypeMods = false;
230,720,410✔
55

56
  if (pME->pExtSchemas == NULL || pSchWrapper == NULL) {
230,720,410✔
57
    return 0;
217,107,371✔
58
  }
59

60
  hasTypeMods = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
13,703,317✔
61
  for (int32_t i = 0; i < pSchWrapper->nCols && hasTypeMods; ++i) {
1,522,966,351✔
62
    TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->pExtSchemas[i].typeMod));
2,147,483,647✔
63
  }
64
  return 0;
13,501,541✔
65
}
66

67
int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
2,129,843✔
68
  const SColRefWrapper *pw = &pME->colRef;
2,129,843✔
69
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
4,262,901✔
70
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
4,263,544✔
71
  uTrace("encode cols:%d", pw->nCols);
2,131,772✔
72

73
  for (int32_t i = 0; i < pw->nCols; i++) {
492,570,962✔
74
    SColRef *p = &pw->pColRef[i];
490,439,833✔
75
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
980,881,595✔
76
    TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
980,881,595✔
77
    if (p->hasRef) {
490,440,476✔
78
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
649,903,012✔
79
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
649,903,012✔
80
      TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
649,903,655✔
81
    }
82
  }
83

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

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

104
  if (pSchWrapper == NULL) {
1,422,695,382✔
105
    return 0;
×
106
  }
107

108
  hasExtSchema = schemasHasTypeMod(pSchWrapper->pSchema, pSchWrapper->nCols);
1,422,695,382✔
109
  if (hasExtSchema && pSchWrapper->nCols > 0) {
1,424,323,877✔
110
    pME->pExtSchemas = (SExtSchema*)tDecoderMalloc(pDecoder, sizeof(SExtSchema) * pSchWrapper->nCols);
326,066,874✔
111
    if (pME->pExtSchemas == NULL) {
163,030,511✔
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,261,288,039✔
120
  }
121

122
  return 0;
1,424,710,813✔
123
}
124

125
SExtSchema* metaGetSExtSchema(const SMetaEntry *pME) {
49,195,999✔
126
  const SSchemaWrapper *pSchWrapper = metaGetEntryRowSchema(pME);
49,195,999✔
127
  bool                  hasTypeMods = false;
49,230,354✔
128

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

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

135
  if (hasTypeMods) {
49,200,221✔
136
    SExtSchema *ret = taosMemoryMalloc(sizeof(SExtSchema) * pSchWrapper->nCols);
37,143✔
137
    if (ret != NULL) {
37,143✔
138
      memcpy(ret, pME->pExtSchemas, pSchWrapper->nCols * sizeof(SExtSchema));
37,143✔
139
    }
140
    return ret;
37,143✔
141
  }
142
  return NULL;
49,163,078✔
143
}
144

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

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

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

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

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

175
  func_id_t *pFuncIds = (*rsmaSchema)->funcIds;
29,489✔
176
  int32_t    i = 0, j = 0;
29,489✔
177
  for (i = 0; i < nCols; ++i) {
223,160✔
178
    while (j < pParam->nFuncs) {
352,274✔
179
      if (pParam->funcColIds[j] == pSchema[i].colId) {
337,928✔
180
        pFuncIds[i] = pParam->funcIds[j];
157,806✔
181
        break;
157,806✔
182
      }
183
      if (pParam->funcColIds[j] > pSchema[i].colId) {
180,122✔
184
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
35,865✔
185
        break;
35,865✔
186
      }
187
      ++j;
144,257✔
188
    }
189
    if (j >= pParam->nFuncs) {
208,017✔
190
      for (; i < nCols; ++i) {
28,692✔
191
        pFuncIds[i] = 36;  // use last if not specified, fmGetFuncId("last") = 36
14,346✔
192
      }
193
      break;
14,346✔
194
    }
195
  }
196
  pFuncIds[0] = 0;  // Primary TS column has no function
29,489✔
197

198
  return 0;
29,489✔
199
}
200

201
int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
65,020,991✔
202
  SColRefWrapper *pWrapper = &pME->colRef;
65,020,991✔
203
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
130,098,006✔
204
  if (pWrapper->nCols == 0) {
65,049,902✔
205
    return 0;
×
206
  }
207

208
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
130,083,622✔
209
  uDebug("decode cols:%d", pWrapper->nCols);
65,045,710✔
210
  pWrapper->pColRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColRef));
130,081,469✔
211
  if (pWrapper->pColRef == NULL) {
65,038,792✔
212
    return terrno;
×
213
  }
214

215
  for (int i = 0; i < pWrapper->nCols; i++) {
1,102,887,921✔
216
    SColRef *p = &pWrapper->pColRef[i];
1,037,896,710✔
217
    TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
2,075,818,940✔
218
    TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
2,075,899,431✔
219
    if (p->hasRef) {
1,037,991,778✔
220
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
567,830,738✔
221
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
567,829,458✔
222
      TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
567,846,918✔
223
    }
224
  }
225

226
  // Decode tag references (backward compatible)
227
  pWrapper->nTagRefs = 0;
64,924,254✔
228
  pWrapper->pTagRef = NULL;
65,065,702✔
229
  if (!tDecodeIsEnd(pDecoder)) {
65,067,194✔
230
    TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
130,115,796✔
231
    if (pWrapper->nTagRefs > 0) {
65,055,462✔
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;
65,027,920✔
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,910✔
270
  if (pSrc->nCols > 0) {
1,329,910✔
271
    pDst->nCols = pSrc->nCols;
1,331,839✔
272
    pDst->version = pSrc->version;
1,332,482✔
273
    pDst->pColRef = (SColRef*)taosMemoryCalloc(pSrc->nCols, sizeof(SColRef));
1,330,553✔
274
    if (NULL == pDst->pColRef) {
1,324,123✔
275
      return terrno;
×
276
    }
277
    memcpy(pDst->pColRef, pSrc->pColRef, pSrc->nCols * sizeof(SColRef));
1,326,052✔
278
  }
279
  return 0;
1,331,839✔
280
}
281

282
static int32_t metaEncodeComprEntryImpl(SEncoder *pCoder, SColCmprWrapper *pw) {
52,373,711✔
283
  int32_t code = 0;
52,373,711✔
284
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
104,783,336✔
285
  TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
104,765,901✔
286
  uTrace("encode cols:%d", pw->nCols);
52,356,276✔
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,578,178✔
294
}
295
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
52,187,221✔
296
  const SColCmprWrapper *pw = &pME->colCmpr;
52,187,221✔
297
  return metaEncodeComprEntryImpl(pCoder, (SColCmprWrapper *)pw);
52,284,885✔
298
}
299
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
1,423,782,777✔
300
  SColCmprWrapper *pWrapper = &pME->colCmpr;
1,423,782,777✔
301
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
2,147,483,647✔
302
  if (pWrapper->nCols == 0) {
1,423,468,731✔
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,423,159,556✔
308
  pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
2,147,483,647✔
309
  if (pWrapper->pColCmpr == NULL) {
1,423,508,837✔
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,425,181,247✔
319
}
320
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
321
                                                            SSchemaWrapper *pSchema) {
322
  pCmpr->nCols = pSchema->nCols;
305,126✔
323

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

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

334
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
1,523,442✔
335
    SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
1,218,316✔
336
    SSchema  *pColSchema = &pSchema->pSchema[i];
1,218,737✔
337
    pColCmpr->id = pColSchema->colId;
1,218,316✔
338
    pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
1,219,158✔
339
  }
340
  return 0;
305,126✔
341
}
342

343
static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pDst) {
224,076,741✔
344
  if (pSrc->nCols > 0) {
224,076,741✔
345
    pDst->nCols = pSrc->nCols;
197,915,899✔
346
    pDst->version = pSrc->version;
197,933,675✔
347
    pDst->pColCmpr = (SColCmpr *)taosMemoryCalloc(pSrc->nCols, sizeof(SColCmpr));
197,873,134✔
348
    if (NULL == pDst->pColCmpr) {
197,890,645✔
349
      return terrno;
×
350
    }
351
    memcpy(pDst->pColCmpr, pSrc->pColCmpr, pSrc->nCols * sizeof(SColCmpr));
197,844,274✔
352
  }
353
  return 0;
224,095,827✔
354
}
355

356
static void metaCloneColRefFree(SColRefWrapper *pColRef) {
225,340,087✔
357
  if (pColRef) {
225,340,087✔
358
    taosMemoryFreeClear(pColRef->pColRef);
225,370,180✔
359
  }
360
}
225,356,794✔
361

362
static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
225,377,551✔
363
  if (pCmpr) {
225,377,551✔
364
    taosMemoryFreeClear(pCmpr->pColCmpr);
225,393,538✔
365
  }
366
}
225,441,493✔
367

368
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
236,449,959✔
369
  TAOS_CHECK_RETURN(tStartEncode(pCoder));
236,449,959✔
370
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
472,983,265✔
371
  TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
472,857,019✔
372
  TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
472,829,763✔
373

374
  if (pME->type > 0) {
236,449,025✔
375
    if (pME->name == NULL) {
230,748,249✔
376
      return TSDB_CODE_INVALID_PARA;
×
377
    }
378

379
    TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
461,402,681✔
380

381
    if (pME->type == TSDB_SUPER_TABLE) {
230,656,928✔
382
      TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
57,417,879✔
383
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
57,605,977✔
384
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
57,607,865✔
385
      if (TABLE_IS_ROLLUP(pME->flags)) {
28,735,013✔
386
        TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
117,690✔
387
      }
388
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
201,959,760✔
389
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
354,654,606✔
390
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
354,653,601✔
391
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
354,638,824✔
392
      if (pME->ctbEntry.commentLen > 0) {
177,327,799✔
393
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
31,220✔
394
      }
395
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
354,609,598✔
396
      TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
177,285,689✔
397
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
24,673,221✔
398
      TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
49,346,863✔
399
      TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
49,346,221✔
400
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
49,346,421✔
401
      if (pME->ntbEntry.commentLen > 0) {
24,673,421✔
402
        TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
43,444✔
403
      }
404
      TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
49,346,642✔
405
      TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
49,346,863✔
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) {
230,752,792✔
413
      TAOS_CHECK_RETURN(meteEncodeColRefEntry(pCoder, pME));
2,266,752✔
414
    } else {
415
      if (pME->type == TSDB_SUPER_TABLE && TABLE_IS_COL_COMPRESSED(pME->flags)) {
228,555,696✔
416
        TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
28,749,833✔
417
      } else if (pME->type == TSDB_NORMAL_TABLE) {
199,858,710✔
418
        if (pME->colCmpr.nCols != 0) {
23,786,893✔
419
          TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
23,482,188✔
420
        } else {
421
          metaWarn("meta/entry: failed to get compress cols, type:%d", pME->type);
304,705✔
422
          SColCmprWrapper colCmprs = {0};
304,705✔
423
          int32_t code = metatInitDefaultSColCmprWrapper(NULL, &colCmprs, (SSchemaWrapper *)&pME->ntbEntry.schemaRow);
305,126✔
424
          if (code != 0) {
305,126✔
425
            taosMemoryFree(colCmprs.pColCmpr);
×
426
            TAOS_CHECK_RETURN(code);
×
427
          }
428
          code = metaEncodeComprEntryImpl(pCoder, &colCmprs);
305,126✔
429
          taosMemoryFree(colCmprs.pColCmpr);
305,126✔
430
          TAOS_CHECK_RETURN(code);
305,126✔
431
        }
432
      }
433
    }
434
    TAOS_CHECK_RETURN(metaEncodeExtSchema(pCoder, pME));
230,747,847✔
435
  }
436
  if (pME->type == TSDB_SUPER_TABLE) {
236,339,473✔
437
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->stbEntry.keep));
57,352,466✔
438
    TAOS_CHECK_RETURN(tEncodeI64v(pCoder, pME->stbEntry.ownerId));
57,149,622✔
439
    TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->stbEntry.securityLevel));
57,261,804✔
440
  } else if (pME->type == TSDB_NORMAL_TABLE) {
207,633,650✔
441
    TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.ownerId));
47,574,628✔
442
  }
443

444
  tEndEncode(pCoder);
236,337,200✔
445
  return 0;
236,299,672✔
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,190✔
456
    return 0;
346,190✔
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,083,060,473✔
464
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
2,084,077,981✔
465
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
2,084,152,788✔
466
      if (TABLE_IS_ROLLUP(pME->flags)) {
1,042,012,068✔
467
        TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
366,571✔
468
      }
469
    } else if (pME->type == TSDB_CHILD_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,409,129,140✔
470
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
2,033,703,363✔
471
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
2,034,174,409✔
472
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
2,033,412,206✔
473
      if (pME->ctbEntry.commentLen > 0) {
1,016,341,943✔
474
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
53,964✔
475
      }
476
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
2,033,377,554✔
477
      TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
1,017,015,653✔
478
    } else if (pME->type == TSDB_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_NORMAL_TABLE) {
393,172,440✔
479
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
786,822,636✔
480
      TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
787,020,808✔
481
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
786,676,378✔
482
      if (pME->ntbEntry.commentLen > 0) {
393,171,107✔
483
        TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
80,106✔
484
      }
485
      TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
785,996,249✔
486
      TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
786,379,114✔
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,042,254,159✔
499
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
1,042,139,661✔
500

501
        if (pME->colCmpr.nCols == 0) {
1,042,251,467✔
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,409,212,407✔
509
      if (!tDecodeIsEnd(pCoder)) {
382,625,012✔
510
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
382,638,567✔
511
        TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
382,639,188✔
512
        if (pME->colCmpr.nCols == 0) {
382,742,182✔
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);
101✔
517
        TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
101✔
518
      }
519
      TABLE_SET_COL_COMPRESSED(pME->flags);
382,643,283✔
520
    } else if (pME->type == TSDB_VIRTUAL_NORMAL_TABLE || pME->type == TSDB_VIRTUAL_CHILD_TABLE) {
1,026,445,675✔
521
      if (!tDecodeIsEnd(pCoder)) {
65,051,126✔
522
        uDebug("set type: %d, tableName:%s", pME->type, pME->name);
65,056,724✔
523
        TAOS_CHECK_RETURN(meteDecodeColRefEntry(pCoder, pME));
65,058,561✔
524
      } else {
UNCOV
525
        uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
×
UNCOV
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,424,323,861✔
533
    } else {
534
      pME->pExtSchemas = NULL;
1,027,302,284✔
535
    }
536
  }
537
  if (pME->type == TSDB_SUPER_TABLE) {
2,147,483,647✔
538
    if (!tDecodeIsEnd(pCoder)) {
1,041,248,296✔
539
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->stbEntry.keep));
2,083,060,888✔
540
    }
541
    if (!tDecodeIsEnd(pCoder)) {
1,040,503,140✔
542
      TAOS_CHECK_RETURN(tDecodeI64v(pCoder, &pME->stbEntry.ownerId));
2,081,235,168✔
543
    }
544
    if (!tDecodeIsEnd(pCoder)) {
1,040,954,117✔
545
      TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->stbEntry.securityLevel));
2,082,245,402✔
546
    }
547
  } else if (pME->type == TSDB_NORMAL_TABLE) {
1,408,921,358✔
548
    if (!tDecodeIsEnd(pCoder)) {
382,514,972✔
549
      TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.ownerId));
765,066,244✔
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) {
387,273,769✔
561
  if (pSrc == NULL || pDst == NULL) {
387,273,769✔
562
    return TSDB_CODE_INVALID_PARA;
×
563
  }
564

565
  pDst->nCols = pSrc->nCols;
387,329,318✔
566
  pDst->version = pSrc->version;
387,338,383✔
567
  pDst->pSchema = (SSchema *)taosMemoryMalloc(pSrc->nCols * sizeof(SSchema));
387,304,055✔
568
  if (pDst->pSchema == NULL) {
387,121,027✔
569
    return terrno;
×
570
  }
571
  memcpy(pDst->pSchema, pSrc->pSchema, pSrc->nCols * sizeof(SSchema));
387,189,015✔
572
  return TSDB_CODE_SUCCESS;
387,344,686✔
573
}
574

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

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

603
  return TSDB_CODE_SUCCESS;
80,643✔
604
}
605

606
static void metaCloneSchemaFree(SSchemaWrapper *pSchema) {
387,233,597✔
607
  if (pSchema) {
387,233,597✔
608
    taosMemoryFreeClear(pSchema->pSchema);
387,261,852✔
609
  }
610
}
387,284,641✔
611

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

625
void metaCloneEntryFree(SMetaEntry **ppEntry) {
225,452,590✔
626
  if (ppEntry == NULL || *ppEntry == NULL) {
225,452,590✔
627
    return;
85,898✔
628
  }
629

630
  taosMemoryFreeClear((*ppEntry)->name);
225,389,066✔
631

632
  if ((*ppEntry)->type < 0) {
225,408,757✔
633
    taosMemoryFreeClear(*ppEntry);
×
634
    return;
×
635
  }
636

637
  if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
225,348,719✔
638
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
188,867,215✔
639
    metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
188,840,481✔
640
    if (TABLE_IS_ROLLUP((*ppEntry)->flags)) {
188,854,157✔
641
      metaFreeRsmaParam(&(*ppEntry)->stbEntry.rsmaParam, 1);
122,461✔
642
    }
643
  } else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
36,534,559✔
644
    taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
26,988,893✔
645
    taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
26,989,985✔
646
  } else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_NORMAL_TABLE == (*ppEntry)->type) {
9,550,706✔
647
    metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
9,550,706✔
648
    taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
9,550,913✔
649
  } else {
650
    return;
×
651
  }
652
  metaCloneColCmprFree(&(*ppEntry)->colCmpr);
225,407,374✔
653
  taosMemoryFreeClear((*ppEntry)->pExtSchemas);
225,390,721✔
654
  metaCloneColRefFree(&(*ppEntry)->colRef);
225,360,670✔
655

656
  taosMemoryFreeClear(*ppEntry);
225,329,084✔
657
  return;
225,388,613✔
658
}
659

660
int32_t metaCloneEntry(const SMetaEntry *pEntry, SMetaEntry **ppEntry) {
225,390,870✔
661
  int32_t code = TSDB_CODE_SUCCESS;
225,390,870✔
662

663
  if (NULL == pEntry || NULL == ppEntry) {
225,390,870✔
664
    return TSDB_CODE_INVALID_PARA;
×
665
  }
666

667
  *ppEntry = (SMetaEntry *)taosMemoryCalloc(1, sizeof(SMetaEntry));
225,457,019✔
668
  if (NULL == *ppEntry) {
225,322,513✔
669
    return terrno;
×
670
  }
671

672
  (*ppEntry)->version = pEntry->version;
225,365,755✔
673
  (*ppEntry)->type = pEntry->type;
225,391,304✔
674
  (*ppEntry)->uid = pEntry->uid;
225,352,448✔
675

676
  if (pEntry->type < 0) {
225,406,978✔
677
    return TSDB_CODE_SUCCESS;
×
678
  }
679

680
  if (pEntry->name) {
225,376,091✔
681
    (*ppEntry)->name = tstrdup(pEntry->name);
225,408,758✔
682
    if (NULL == (*ppEntry)->name) {
225,430,974✔
683
      code = terrno;
×
684
      metaCloneEntryFree(ppEntry);
×
685
      return code;
×
686
    }
687
  }
688

689
  if (pEntry->type == TSDB_SUPER_TABLE) {
225,427,652✔
690
    (*ppEntry)->flags = pEntry->flags;
188,873,917✔
691

692
    code = metaCloneSchema(&pEntry->stbEntry.schemaRow, &(*ppEntry)->stbEntry.schemaRow);
188,820,715✔
693
    if (code) {
188,885,973✔
694
      metaCloneEntryFree(ppEntry);
×
695
      return code;
×
696
    }
697

698
    code = metaCloneSchema(&pEntry->stbEntry.schemaTag, &(*ppEntry)->stbEntry.schemaTag);
188,885,973✔
699
    if (code) {
188,909,376✔
700
      metaCloneEntryFree(ppEntry);
×
701
      return code;
×
702
    }
703
    if (TABLE_IS_ROLLUP(pEntry->flags)) {
188,909,376✔
704
      code = metaCloneRsmaParam(&pEntry->stbEntry.rsmaParam, &(*ppEntry)->stbEntry.rsmaParam);
80,643✔
705
      if (code) {
80,643✔
706
        metaCloneEntryFree(ppEntry);
×
707
        return code;
×
708
      }
709
    }
710
    (*ppEntry)->stbEntry.keep = pEntry->stbEntry.keep;
188,907,861✔
711
    (*ppEntry)->stbEntry.ownerId = pEntry->stbEntry.ownerId;
188,874,103✔
712
  } else if (pEntry->type == TSDB_CHILD_TABLE || pEntry->type == TSDB_VIRTUAL_CHILD_TABLE) {
36,542,445✔
713
    (*ppEntry)->ctbEntry.btime = pEntry->ctbEntry.btime;
26,992,811✔
714
    (*ppEntry)->ctbEntry.ttlDays = pEntry->ctbEntry.ttlDays;
26,994,877✔
715
    (*ppEntry)->ctbEntry.suid = pEntry->ctbEntry.suid;
26,994,063✔
716

717
    // comment
718
    (*ppEntry)->ctbEntry.commentLen = pEntry->ctbEntry.commentLen;
26,997,422✔
719
    if (pEntry->ctbEntry.commentLen > 0) {
26,999,275✔
720
      (*ppEntry)->ctbEntry.comment = taosMemoryMalloc(pEntry->ctbEntry.commentLen + 1);
9,223✔
721
      if (NULL == (*ppEntry)->ctbEntry.comment) {
9,223✔
722
        code = terrno;
×
723
        metaCloneEntryFree(ppEntry);
×
724
        return code;
×
725
      }
726
      memcpy((*ppEntry)->ctbEntry.comment, pEntry->ctbEntry.comment, pEntry->ctbEntry.commentLen + 1);
9,223✔
727
    }
728

729
    // tags
730
    STag *pTags = (STag *)pEntry->ctbEntry.pTags;
26,994,877✔
731
    (*ppEntry)->ctbEntry.pTags = taosMemoryCalloc(1, pTags->len);
26,988,954✔
732
    if (NULL == (*ppEntry)->ctbEntry.pTags) {
26,993,387✔
733
      code = terrno;
×
734
      metaCloneEntryFree(ppEntry);
×
735
      return code;
×
736
    }
737
    memcpy((*ppEntry)->ctbEntry.pTags, pEntry->ctbEntry.pTags, pTags->len);
26,990,052✔
738
  } else if (pEntry->type == TSDB_NORMAL_TABLE || pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
9,550,276✔
739
    (*ppEntry)->ntbEntry.btime = pEntry->ntbEntry.btime;
9,550,913✔
740
    (*ppEntry)->ntbEntry.ttlDays = pEntry->ntbEntry.ttlDays;
9,550,485✔
741
    (*ppEntry)->ntbEntry.ncid = pEntry->ntbEntry.ncid;
9,550,276✔
742
    (*ppEntry)->ntbEntry.ownerId = pEntry->ntbEntry.ownerId;
9,550,485✔
743

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

751
    // comment
752
    (*ppEntry)->ntbEntry.commentLen = pEntry->ntbEntry.commentLen;
9,550,692✔
753
    if (pEntry->ntbEntry.commentLen > 0) {
9,550,276✔
754
      (*ppEntry)->ntbEntry.comment = taosMemoryMalloc(pEntry->ntbEntry.commentLen + 1);
13,459✔
755
      if (NULL == (*ppEntry)->ntbEntry.comment) {
13,459✔
756
        code = terrno;
×
757
        metaCloneEntryFree(ppEntry);
×
758
        return code;
×
759
      }
760
      memcpy((*ppEntry)->ntbEntry.comment, pEntry->ntbEntry.comment, pEntry->ntbEntry.commentLen + 1);
13,459✔
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) {
225,426,232✔
767
    code = metaCloneColRef(&pEntry->colRef, &(*ppEntry)->colRef);
1,416,887✔
768
    if (code) {
1,332,482✔
769
      metaCloneEntryFree(ppEntry);
×
770
      return code;
×
771
    }
772
  } else {
773
    code = metaCloneColCmpr(&pEntry->colCmpr, &(*ppEntry)->colCmpr);
224,046,699✔
774
    if (code) {
224,085,952✔
775
      metaCloneEntryFree(ppEntry);
×
776
      return code;
×
777
    }
778
  }
779
  int32_t numOfExtSchema = metaGetEntryRowSchemaNum(pEntry);
225,418,434✔
780
  if (pEntry->pExtSchemas && numOfExtSchema > 0) {
225,411,724✔
781
    (*ppEntry)->pExtSchemas = taosMemoryCalloc(numOfExtSchema, sizeof(SExtSchema));
10,855,996✔
782
    if (!(*ppEntry)->pExtSchemas) {
10,847,077✔
783
      code = terrno;
×
784
      metaCloneEntryFree(ppEntry);
×
785
      return code;
×
786
    }
787
    memcpy((*ppEntry)->pExtSchemas, pEntry->pExtSchemas, sizeof(SExtSchema) * numOfExtSchema);
10,850,323✔
788
  }
789

790
  return code;
225,379,890✔
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