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

taosdata / TDengine / #3621

22 Feb 2025 11:44AM UTC coverage: 2.037% (-61.5%) from 63.573%
#3621

push

travis-ci

web-flow
Merge pull request #29874 from taosdata/merge/mainto3.0

merge: from main to 3.0 branch

4357 of 287032 branches covered (1.52%)

Branch coverage included in aggregate %.

0 of 174 new or added lines in 18 files covered. (0.0%)

213359 existing lines in 469 files now uncovered.

7260 of 283369 relevant lines covered (2.56%)

23737.72 hits per line

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

0.0
/source/dnode/vnode/src/meta/metaTable.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

18
extern SDmNotifyHandle dmNotifyHdl;
19

20
int32_t metaAddTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pRsp);
21
int32_t metaDropTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pRsp);
22
int32_t metaAlterTableColumnName(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pRsp);
23
int32_t metaAlterTableColumnBytes(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pRsp);
24
int32_t metaUpdateTableTagValue(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq);
25
int32_t metaUpdateTableMultiTagValue(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq);
26
int32_t metaUpdateTableOptions2(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq);
27
int32_t metaUpdateTableColCompress2(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq);
28

29
int32_t metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
30

31
int32_t    metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
32
static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs);
33
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl);
34
void       metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey);
35
// opt ins_tables query
36
static int metaDeleteBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
37
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
38

UNCOV
39
int32_t updataTableColCmpr(SColCmprWrapper *pWp, SSchema *pSchema, int8_t add, uint32_t compress) {
×
UNCOV
40
  int32_t nCols = pWp->nCols;
×
UNCOV
41
  int32_t ver = pWp->version;
×
UNCOV
42
  if (add) {
×
UNCOV
43
    SColCmpr *p = taosMemoryRealloc(pWp->pColCmpr, sizeof(SColCmpr) * (nCols + 1));
×
UNCOV
44
    if (p == NULL) {
×
45
      return terrno;
×
46
    }
UNCOV
47
    pWp->pColCmpr = p;
×
48

UNCOV
49
    SColCmpr *pCol = p + nCols;
×
UNCOV
50
    pCol->id = pSchema->colId;
×
UNCOV
51
    pCol->alg = compress;
×
UNCOV
52
    pWp->nCols = nCols + 1;
×
UNCOV
53
    pWp->version = ver;
×
54
  } else {
UNCOV
55
    for (int32_t i = 0; i < nCols; i++) {
×
UNCOV
56
      SColCmpr *pOCmpr = &pWp->pColCmpr[i];
×
UNCOV
57
      if (pOCmpr->id == pSchema->colId) {
×
UNCOV
58
        int32_t left = (nCols - i - 1) * sizeof(SColCmpr);
×
UNCOV
59
        if (left) {
×
UNCOV
60
          memmove(pWp->pColCmpr + i, pWp->pColCmpr + i + 1, left);
×
61
        }
UNCOV
62
        nCols--;
×
UNCOV
63
        break;
×
64
      }
65
    }
UNCOV
66
    pWp->nCols = nCols;
×
UNCOV
67
    pWp->version = ver;
×
68
  }
UNCOV
69
  return 0;
×
70
}
71

UNCOV
72
int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) {
×
UNCOV
73
  pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
×
UNCOV
74
  if (NULL == pMetaRsp->pSchemas) {
×
75
    return terrno;
×
76
  }
77

UNCOV
78
  pMetaRsp->pSchemaExt = taosMemoryMalloc(pSchema->nCols * sizeof(SSchemaExt));
×
UNCOV
79
  if (pMetaRsp->pSchemaExt == NULL) {
×
80
    taosMemoryFree(pMetaRsp->pSchemas);
×
81
    return terrno;
×
82
  }
83

UNCOV
84
  tstrncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN);
×
UNCOV
85
  pMetaRsp->numOfColumns = pSchema->nCols;
×
UNCOV
86
  pMetaRsp->tableType = TSDB_NORMAL_TABLE;
×
UNCOV
87
  pMetaRsp->sversion = pSchema->version;
×
UNCOV
88
  pMetaRsp->tuid = uid;
×
89

UNCOV
90
  memcpy(pMetaRsp->pSchemas, pSchema->pSchema, pSchema->nCols * sizeof(SSchema));
×
91

UNCOV
92
  return 0;
×
93
}
94

UNCOV
95
int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema) {
×
UNCOV
96
  int32_t code = 0;
×
97

98
#ifdef USE_INVERTED_INDEX
UNCOV
99
  if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
×
100
    return TSDB_CODE_INVALID_PARA;
×
101
  }
UNCOV
102
  void       *data = pCtbEntry->ctbEntry.pTags;
×
UNCOV
103
  const char *tagName = pSchema->name;
×
104

UNCOV
105
  tb_uid_t    suid = pCtbEntry->ctbEntry.suid;
×
UNCOV
106
  tb_uid_t    tuid = pCtbEntry->uid;
×
UNCOV
107
  const void *pTagData = pCtbEntry->ctbEntry.pTags;
×
UNCOV
108
  int32_t     nTagData = 0;
×
109

UNCOV
110
  SArray *pTagVals = NULL;
×
UNCOV
111
  code = tTagToValArray((const STag *)data, &pTagVals);
×
UNCOV
112
  if (code) {
×
113
    return code;
×
114
  }
115

UNCOV
116
  SIndexMultiTerm *terms = indexMultiTermCreate();
×
UNCOV
117
  if (terms == NULL) {
×
118
    return terrno;
×
119
  }
120

UNCOV
121
  int16_t nCols = taosArrayGetSize(pTagVals);
×
UNCOV
122
  for (int i = 0; i < nCols; i++) {
×
UNCOV
123
    STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
×
UNCOV
124
    char     type = pTagVal->type;
×
125

UNCOV
126
    char   *key = pTagVal->pKey;
×
UNCOV
127
    int32_t nKey = strlen(key);
×
128

UNCOV
129
    SIndexTerm *term = NULL;
×
UNCOV
130
    if (type == TSDB_DATA_TYPE_NULL) {
×
UNCOV
131
      term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
×
UNCOV
132
    } else if (type == TSDB_DATA_TYPE_NCHAR) {
×
UNCOV
133
      if (pTagVal->nData > 0) {
×
UNCOV
134
        char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
×
UNCOV
135
        if (val == NULL) {
×
136
          TAOS_CHECK_GOTO(terrno, NULL, _exception);
×
137
        }
UNCOV
138
        int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE, NULL);
×
UNCOV
139
        if (len < 0) {
×
140
          TAOS_CHECK_GOTO(len, NULL, _exception);
×
141
        }
UNCOV
142
        memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
×
UNCOV
143
        type = TSDB_DATA_TYPE_VARCHAR;
×
UNCOV
144
        term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, val, len);
×
UNCOV
145
        taosMemoryFree(val);
×
UNCOV
146
      } else if (pTagVal->nData == 0) {
×
UNCOV
147
        term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, pTagVal->pData, 0);
×
148
      }
UNCOV
149
    } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
UNCOV
150
      double val = *(double *)(&pTagVal->i64);
×
UNCOV
151
      int    len = sizeof(val);
×
UNCOV
152
      term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len);
×
UNCOV
153
    } else if (type == TSDB_DATA_TYPE_BOOL) {
×
UNCOV
154
      int val = *(int *)(&pTagVal->i64);
×
UNCOV
155
      int len = sizeof(val);
×
UNCOV
156
      term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len);
×
157
    }
158

UNCOV
159
    if (term != NULL) {
×
UNCOV
160
      int32_t ret = indexMultiTermAdd(terms, term);
×
UNCOV
161
      if (ret < 0) {
×
162
        metaError("vgId:%d, failed to add term to multi term, uid: %" PRId64 ", key: %s, type: %d, ret: %d",
×
163
                  TD_VID(pMeta->pVnode), tuid, key, type, ret);
164
      }
165
    } else {
166
      code = terrno;
×
167
      goto _exception;
×
168
    }
169
  }
UNCOV
170
  code = indexJsonPut(pMeta->pTagIvtIdx, terms, tuid);
×
UNCOV
171
  indexMultiTermDestroy(terms);
×
172

UNCOV
173
  taosArrayDestroy(pTagVals);
×
174
#endif
UNCOV
175
  return code;
×
176
_exception:
×
177
  indexMultiTermDestroy(terms);
×
178
  taosArrayDestroy(pTagVals);
×
179
  return code;
×
180
}
UNCOV
181
int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema) {
×
182
#ifdef USE_INVERTED_INDEX
UNCOV
183
  if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
×
184
    return TSDB_CODE_INVALID_PARA;
×
185
  }
UNCOV
186
  void       *data = pCtbEntry->ctbEntry.pTags;
×
UNCOV
187
  const char *tagName = pSchema->name;
×
188

UNCOV
189
  tb_uid_t    suid = pCtbEntry->ctbEntry.suid;
×
UNCOV
190
  tb_uid_t    tuid = pCtbEntry->uid;
×
UNCOV
191
  const void *pTagData = pCtbEntry->ctbEntry.pTags;
×
UNCOV
192
  int32_t     nTagData = 0;
×
193

UNCOV
194
  SArray *pTagVals = NULL;
×
UNCOV
195
  int32_t code = tTagToValArray((const STag *)data, &pTagVals);
×
UNCOV
196
  if (code) {
×
197
    return code;
×
198
  }
199

UNCOV
200
  SIndexMultiTerm *terms = indexMultiTermCreate();
×
UNCOV
201
  if (terms == NULL) {
×
202
    return terrno;
×
203
  }
204

UNCOV
205
  int16_t nCols = taosArrayGetSize(pTagVals);
×
UNCOV
206
  for (int i = 0; i < nCols; i++) {
×
UNCOV
207
    STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
×
UNCOV
208
    char     type = pTagVal->type;
×
209

UNCOV
210
    char   *key = pTagVal->pKey;
×
UNCOV
211
    int32_t nKey = strlen(key);
×
212

UNCOV
213
    SIndexTerm *term = NULL;
×
UNCOV
214
    if (type == TSDB_DATA_TYPE_NULL) {
×
215
      term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
×
UNCOV
216
    } else if (type == TSDB_DATA_TYPE_NCHAR) {
×
UNCOV
217
      if (pTagVal->nData > 0) {
×
UNCOV
218
        char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
×
UNCOV
219
        if (val == NULL) {
×
220
          TAOS_CHECK_GOTO(terrno, NULL, _exception);
×
221
        }
UNCOV
222
        int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE, NULL);
×
UNCOV
223
        if (len < 0) {
×
224
          TAOS_CHECK_GOTO(len, NULL, _exception);
×
225
        }
UNCOV
226
        memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
×
UNCOV
227
        type = TSDB_DATA_TYPE_VARCHAR;
×
UNCOV
228
        term = indexTermCreate(suid, DEL_VALUE, type, key, nKey, val, len);
×
UNCOV
229
        taosMemoryFree(val);
×
230
      } else if (pTagVal->nData == 0) {
×
231
        term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, pTagVal->pData, 0);
×
232
      }
UNCOV
233
    } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
UNCOV
234
      double val = *(double *)(&pTagVal->i64);
×
UNCOV
235
      int    len = sizeof(val);
×
UNCOV
236
      term = indexTermCreate(suid, DEL_VALUE, type, key, nKey, (const char *)&val, len);
×
UNCOV
237
    } else if (type == TSDB_DATA_TYPE_BOOL) {
×
UNCOV
238
      int val = *(int *)(&pTagVal->i64);
×
UNCOV
239
      int len = sizeof(val);
×
UNCOV
240
      term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len);
×
241
    }
UNCOV
242
    if (term != NULL) {
×
UNCOV
243
      int32_t ret = indexMultiTermAdd(terms, term);
×
UNCOV
244
      if (ret < 0) {
×
245
        metaError("vgId:%d, failed to add term to multi term, uid: %" PRId64 ", key: %s, type: %d, ret: %d",
×
246
                  TD_VID(pMeta->pVnode), tuid, key, type, ret);
247
      }
248
    } else {
249
      code = terrno;
×
250
      goto _exception;
×
251
    }
252
  }
UNCOV
253
  code = indexJsonPut(pMeta->pTagIvtIdx, terms, tuid);
×
UNCOV
254
  indexMultiTermDestroy(terms);
×
UNCOV
255
  taosArrayDestroy(pTagVals);
×
256
#endif
UNCOV
257
  return code;
×
258
_exception:
×
259
  indexMultiTermDestroy(terms);
×
260
  taosArrayDestroy(pTagVals);
×
261
  return code;
×
262
}
263

UNCOV
264
static int32_t metaDropTables(SMeta *pMeta, SArray *tbUids) {
×
UNCOV
265
  int32_t code = 0;
×
UNCOV
266
  if (taosArrayGetSize(tbUids) == 0) return TSDB_CODE_SUCCESS;
×
267

UNCOV
268
  int64_t    nCtbDropped = 0;
×
UNCOV
269
  SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
×
UNCOV
270
  if (suidHash == NULL) {
×
271
    return terrno;
×
272
  }
273

UNCOV
274
  metaWLock(pMeta);
×
UNCOV
275
  for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
×
UNCOV
276
    tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUids, i);
×
UNCOV
277
    tb_uid_t suid = 0;
×
UNCOV
278
    int8_t   sysTbl = 0;
×
279
    int      type;
UNCOV
280
    code = metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
×
UNCOV
281
    if (code) return code;
×
UNCOV
282
    if (!sysTbl && type == TSDB_CHILD_TABLE && suid != 0 && suidHash) {
×
UNCOV
283
      int64_t *pVal = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t));
×
UNCOV
284
      if (pVal) {
×
UNCOV
285
        nCtbDropped = *pVal + 1;
×
286
      } else {
UNCOV
287
        nCtbDropped = 1;
×
288
      }
UNCOV
289
      code = tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t));
×
UNCOV
290
      if (code) return code;
×
291
    }
292
    /*
293
    if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
294
      tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL);
295
    }
296
    */
UNCOV
297
    metaDebug("batch drop table:%" PRId64, uid);
×
298
  }
UNCOV
299
  metaULock(pMeta);
×
300

301
  // update timeseries
UNCOV
302
  void   *pCtbDropped = NULL;
×
UNCOV
303
  int32_t iter = 0;
×
UNCOV
304
  while ((pCtbDropped = tSimpleHashIterate(suidHash, pCtbDropped, &iter))) {
×
UNCOV
305
    tb_uid_t    *pSuid = tSimpleHashGetKey(pCtbDropped, NULL);
×
UNCOV
306
    int32_t      nCols = 0;
×
UNCOV
307
    SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
×
UNCOV
308
    if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
×
UNCOV
309
      pStats->numOfTimeSeries -= *(int64_t *)pCtbDropped * (nCols - 1);
×
310
    }
311
  }
UNCOV
312
  tSimpleHashCleanup(suidHash);
×
313

UNCOV
314
  pMeta->changed = true;
×
UNCOV
315
  return 0;
×
316
}
317

UNCOV
318
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
×
UNCOV
319
  int32_t code = 0;
×
320
  // 1, tranverse table's
321
  // 2, validate table name using vnodeValidateTableHash
322
  // 3, push invalidated table's uid into uidList
323

324
  TBC *pCur;
UNCOV
325
  code = tdbTbcOpen(pMeta->pTbDb, &pCur, NULL);
×
UNCOV
326
  if (code < 0) {
×
327
    return code;
×
328
  }
329

UNCOV
330
  code = tdbTbcMoveToFirst(pCur);
×
UNCOV
331
  if (code) {
×
332
    tdbTbcClose(pCur);
×
333
    return code;
×
334
  }
335

UNCOV
336
  void *pData = NULL, *pKey = NULL;
×
UNCOV
337
  int   nData = 0, nKey = 0;
×
338

UNCOV
339
  while (1) {
×
UNCOV
340
    int32_t ret = tdbTbcNext(pCur, &pKey, &nKey, &pData, &nData);
×
UNCOV
341
    if (ret < 0) {
×
UNCOV
342
      break;
×
343
    }
344

UNCOV
345
    SMetaEntry me = {0};
×
UNCOV
346
    SDecoder   dc = {0};
×
UNCOV
347
    tDecoderInit(&dc, pData, nData);
×
UNCOV
348
    code = metaDecodeEntry(&dc, &me);
×
UNCOV
349
    if (code < 0) {
×
350
      tDecoderClear(&dc);
×
351
      return code;
×
352
    }
353

UNCOV
354
    if (me.type != TSDB_SUPER_TABLE) {
×
355
      char tbFName[TSDB_TABLE_FNAME_LEN + 1];
UNCOV
356
      snprintf(tbFName, sizeof(tbFName), "%s.%s", pMeta->pVnode->config.dbname, me.name);
×
UNCOV
357
      tbFName[TSDB_TABLE_FNAME_LEN] = '\0';
×
UNCOV
358
      int32_t ret = vnodeValidateTableHash(pMeta->pVnode, tbFName);
×
UNCOV
359
      if (ret < 0 && terrno == TSDB_CODE_VND_HASH_MISMATCH) {
×
UNCOV
360
        if (taosArrayPush(uidList, &me.uid) == NULL) {
×
361
          code = terrno;
×
362
          break;
×
363
        }
364
      }
365
    }
UNCOV
366
    tDecoderClear(&dc);
×
367
  }
UNCOV
368
  tdbFree(pData);
×
UNCOV
369
  tdbFree(pKey);
×
UNCOV
370
  tdbTbcClose(pCur);
×
371

UNCOV
372
  return 0;
×
373
}
374

UNCOV
375
int32_t metaTrimTables(SMeta *pMeta, int64_t version) {
×
UNCOV
376
  int32_t code = 0;
×
377

UNCOV
378
  SArray *tbUids = taosArrayInit(8, sizeof(int64_t));
×
UNCOV
379
  if (tbUids == NULL) {
×
380
    return terrno;
×
381
  }
382

UNCOV
383
  code = metaFilterTableByHash(pMeta, tbUids);
×
UNCOV
384
  if (code != 0) {
×
385
    goto end;
×
386
  }
UNCOV
387
  if (TARRAY_SIZE(tbUids) == 0) {
×
UNCOV
388
    goto end;
×
389
  }
390

UNCOV
391
  metaInfo("vgId:%d, trim %ld tables", TD_VID(pMeta->pVnode), taosArrayGetSize(tbUids));
×
UNCOV
392
  code = metaDropTables(pMeta, tbUids);
×
UNCOV
393
  if (code) goto end;
×
394

UNCOV
395
end:
×
UNCOV
396
  taosArrayDestroy(tbUids);
×
397

UNCOV
398
  return code;
×
399
}
400

UNCOV
401
int metaTtlFindExpired(SMeta *pMeta, int64_t timePointMs, SArray *tbUids, int32_t ttlDropMaxCount) {
×
UNCOV
402
  metaRLock(pMeta);
×
403

UNCOV
404
  int ret = ttlMgrFindExpired(pMeta->pTtlMgr, timePointMs, tbUids, ttlDropMaxCount);
×
405

UNCOV
406
  metaULock(pMeta);
×
407

UNCOV
408
  if (ret != 0) {
×
409
    metaError("ttl failed to find expired table, ret:%d", ret);
×
410
  }
411

UNCOV
412
  return ret;
×
413
}
414

UNCOV
415
static int metaBuildBtimeIdxKey(SBtimeIdxKey *btimeKey, const SMetaEntry *pME) {
×
416
  int64_t btime;
UNCOV
417
  if (pME->type == TSDB_CHILD_TABLE) {
×
UNCOV
418
    btime = pME->ctbEntry.btime;
×
UNCOV
419
  } else if (pME->type == TSDB_NORMAL_TABLE) {
×
UNCOV
420
    btime = pME->ntbEntry.btime;
×
421
  } else {
422
    return TSDB_CODE_FAILED;
×
423
  }
424

UNCOV
425
  btimeKey->btime = btime;
×
UNCOV
426
  btimeKey->uid = pME->uid;
×
UNCOV
427
  return 0;
×
428
}
429

UNCOV
430
static int metaBuildNColIdxKey(SNcolIdxKey *ncolKey, const SMetaEntry *pME) {
×
UNCOV
431
  if (pME->type == TSDB_NORMAL_TABLE) {
×
UNCOV
432
    ncolKey->ncol = pME->ntbEntry.schemaRow.nCols;
×
UNCOV
433
    ncolKey->uid = pME->uid;
×
434
  } else {
435
    return TSDB_CODE_FAILED;
×
436
  }
UNCOV
437
  return 0;
×
438
}
439

UNCOV
440
static void metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
×
UNCOV
441
  if (pME->type != TSDB_CHILD_TABLE && pME->type != TSDB_NORMAL_TABLE) return;
×
442

UNCOV
443
  STtlDelTtlCtx ctx = {.uid = pME->uid, .pTxn = pMeta->txn};
×
UNCOV
444
  if (pME->type == TSDB_CHILD_TABLE) {
×
UNCOV
445
    ctx.ttlDays = pME->ctbEntry.ttlDays;
×
446
  } else {
UNCOV
447
    ctx.ttlDays = pME->ntbEntry.ttlDays;
×
448
  }
449

UNCOV
450
  int32_t ret = ttlMgrDeleteTtl(pMeta->pTtlMgr, &ctx);
×
UNCOV
451
  if (ret < 0) {
×
452
    metaError("vgId:%d, failed to delete ttl for table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pME->name,
×
453
              pME->uid, tstrerror(ret));
454
  }
UNCOV
455
  return;
×
456
}
457

UNCOV
458
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl) {
×
UNCOV
459
  void      *pData = NULL;
×
UNCOV
460
  int        nData = 0;
×
UNCOV
461
  int        rc = 0;
×
UNCOV
462
  SMetaEntry e = {0};
×
UNCOV
463
  SDecoder   dc = {0};
×
UNCOV
464
  int32_t    ret = 0;
×
465

UNCOV
466
  rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData);
×
UNCOV
467
  if (rc < 0) {
×
468
    return rc;
×
469
  }
UNCOV
470
  int64_t version = ((SUidIdxVal *)pData)[0].version;
×
471

UNCOV
472
  rc = tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData);
×
UNCOV
473
  if (rc < 0) {
×
474
    tdbFree(pData);
×
475
    return rc;
×
476
  }
477

UNCOV
478
  tDecoderInit(&dc, pData, nData);
×
UNCOV
479
  rc = metaDecodeEntry(&dc, &e);
×
UNCOV
480
  if (rc < 0) {
×
481
    tDecoderClear(&dc);
×
482
    return rc;
×
483
  }
484

UNCOV
485
  if (type) *type = e.type;
×
486

UNCOV
487
  if (e.type == TSDB_CHILD_TABLE) {
×
UNCOV
488
    if (pSuid) *pSuid = e.ctbEntry.suid;
×
UNCOV
489
    void *tData = NULL;
×
UNCOV
490
    int   tLen = 0;
×
491

UNCOV
492
    if (tdbTbGet(pMeta->pUidIdx, &e.ctbEntry.suid, sizeof(tb_uid_t), &tData, &tLen) == 0) {
×
UNCOV
493
      STbDbKey tbDbKey = {.uid = e.ctbEntry.suid, .version = ((SUidIdxVal *)tData)[0].version};
×
UNCOV
494
      if (tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &tData, &tLen) == 0) {
×
UNCOV
495
        SDecoder   tdc = {0};
×
UNCOV
496
        SMetaEntry stbEntry = {0};
×
497

UNCOV
498
        tDecoderInit(&tdc, tData, tLen);
×
UNCOV
499
        int32_t ret = metaDecodeEntry(&tdc, &stbEntry);
×
UNCOV
500
        if (ret < 0) {
×
501
          tDecoderClear(&tdc);
×
502
          metaError("vgId:%d, failed to decode child table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
×
503
                    e.ctbEntry.suid, tstrerror(ret));
504
          return ret;
×
505
        }
506

UNCOV
507
        if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
×
508

UNCOV
509
        SSchema        *pTagColumn = NULL;
×
UNCOV
510
        SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
×
UNCOV
511
        if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
×
512
          pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
×
513
          ret = metaDelJsonVarFromIdx(pMeta, &e, pTagColumn);
×
514
          if (ret < 0) {
×
515
            metaError("vgId:%d, failed to delete json var from idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode),
×
516
                      e.name, e.uid, tstrerror(ret));
517
          }
518
        } else {
UNCOV
519
          for (int i = 0; i < pTagSchema->nCols; i++) {
×
UNCOV
520
            pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[i];
×
UNCOV
521
            if (!IS_IDX_ON(pTagColumn)) continue;
×
UNCOV
522
            STagIdxKey *pTagIdxKey = NULL;
×
523
            int32_t     nTagIdxKey;
524

UNCOV
525
            const void *pTagData = NULL;
×
UNCOV
526
            int32_t     nTagData = 0;
×
527

UNCOV
528
            STagVal tagVal = {.cid = pTagColumn->colId};
×
UNCOV
529
            if (tTagGet((const STag *)e.ctbEntry.pTags, &tagVal)) {
×
UNCOV
530
              if (IS_VAR_DATA_TYPE(pTagColumn->type)) {
×
531
                pTagData = tagVal.pData;
×
532
                nTagData = (int32_t)tagVal.nData;
×
533
              } else {
UNCOV
534
                pTagData = &(tagVal.i64);
×
UNCOV
535
                nTagData = tDataTypes[pTagColumn->type].bytes;
×
536
              }
537
            } else {
538
              if (!IS_VAR_DATA_TYPE(pTagColumn->type)) {
×
539
                nTagData = tDataTypes[pTagColumn->type].bytes;
×
540
              }
541
            }
542

UNCOV
543
            if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
×
544
                                    &pTagIdxKey, &nTagIdxKey) == 0) {
UNCOV
545
              ret = tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn);
×
UNCOV
546
              if (ret < 0) {
×
547
                metaError("vgId:%d, failed to delete tag idx key:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode),
×
548
                          e.name, e.uid, tstrerror(ret));
549
              }
550
            }
UNCOV
551
            metaDestroyTagIdxKey(pTagIdxKey);
×
UNCOV
552
            pTagIdxKey = NULL;
×
553
          }
554
        }
UNCOV
555
        tDecoderClear(&tdc);
×
556
      }
UNCOV
557
      tdbFree(tData);
×
558
    }
559
  }
560

UNCOV
561
  ret = tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn);
×
UNCOV
562
  if (ret < 0) {
×
563
    metaError("vgId:%d, failed to delete table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
564
              tstrerror(ret));
565
  }
UNCOV
566
  ret = tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn);
×
UNCOV
567
  if (ret < 0) {
×
568
    metaError("vgId:%d, failed to delete name idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
569
              tstrerror(ret));
570
  }
UNCOV
571
  ret = tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn);
×
UNCOV
572
  if (ret < 0) {
×
573
    metaError("vgId:%d, failed to delete uid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
574
              tstrerror(ret));
575
  }
576

UNCOV
577
  if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteBtimeIdx(pMeta, &e);
×
UNCOV
578
  if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e);
×
579

UNCOV
580
  if (e.type != TSDB_SUPER_TABLE) metaDeleteTtl(pMeta, &e);
×
581

UNCOV
582
  if (e.type == TSDB_CHILD_TABLE) {
×
583
    ret =
UNCOV
584
        tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
×
UNCOV
585
    if (ret < 0) {
×
586
      metaError("vgId:%d, failed to delete ctb idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
587
                tstrerror(ret));
588
    }
589

UNCOV
590
    --pMeta->pVnode->config.vndStats.numOfCTables;
×
UNCOV
591
    metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0);
×
UNCOV
592
    ret = metaUidCacheClear(pMeta, e.ctbEntry.suid);
×
UNCOV
593
    if (ret < 0) {
×
594
      metaError("vgId:%d, failed to clear uid cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
×
595
                e.ctbEntry.suid, tstrerror(ret));
596
    }
UNCOV
597
    ret = metaTbGroupCacheClear(pMeta, e.ctbEntry.suid);
×
UNCOV
598
    if (ret < 0) {
×
599
      metaError("vgId:%d, failed to clear group cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
×
600
                e.ctbEntry.suid, tstrerror(ret));
601
    }
602
    /*
603
    if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
604
      tsdbCacheDropTable(pMeta->pVnode->pTsdb, e.uid, e.ctbEntry.suid, NULL);
605
    }
606
    */
UNCOV
607
  } else if (e.type == TSDB_NORMAL_TABLE) {
×
608
    // drop schema.db (todo)
609

UNCOV
610
    --pMeta->pVnode->config.vndStats.numOfNTables;
×
UNCOV
611
    pMeta->pVnode->config.vndStats.numOfNTimeSeries -= e.ntbEntry.schemaRow.nCols - 1;
×
612

613
    /*
614
    if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
615
      tsdbCacheDropTable(pMeta->pVnode->pTsdb, e.uid, -1, &e.ntbEntry.schemaRow);
616
    }
617
    */
618
  } else if (e.type == TSDB_SUPER_TABLE) {
×
619
    ret = tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn);
×
620
    if (ret < 0) {
×
621
      metaError("vgId:%d, failed to delete suid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
622
                tstrerror(ret));
623
    }
624
    // drop schema.db (todo)
625

626
    ret = metaStatsCacheDrop(pMeta, uid);
×
627
    if (ret < 0) {
×
628
      metaError("vgId:%d, failed to drop stats cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
629
                tstrerror(ret));
630
    }
631
    ret = metaUidCacheClear(pMeta, uid);
×
632
    if (ret < 0) {
×
633
      metaError("vgId:%d, failed to clear uid cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
634
                tstrerror(ret));
635
    }
636
    ret = metaTbGroupCacheClear(pMeta, uid);
×
637
    if (ret < 0) {
×
638
      metaError("vgId:%d, failed to clear group cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
×
639
                e.uid, tstrerror(ret));
640
    }
641
    --pMeta->pVnode->config.vndStats.numOfSTables;
×
642
  }
643

UNCOV
644
  ret = metaCacheDrop(pMeta, uid);
×
UNCOV
645
  if (ret < 0) {
×
UNCOV
646
    metaError("vgId:%d, failed to drop cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
×
647
              tstrerror(ret));
648
  }
649

UNCOV
650
  tDecoderClear(&dc);
×
UNCOV
651
  tdbFree(pData);
×
652

UNCOV
653
  return 0;
×
654
}
655

UNCOV
656
static int metaDeleteBtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
×
UNCOV
657
  SBtimeIdxKey btimeKey = {0};
×
UNCOV
658
  if (metaBuildBtimeIdxKey(&btimeKey, pME) < 0) {
×
659
    return 0;
×
660
  }
UNCOV
661
  return tdbTbDelete(pMeta->pBtimeIdx, &btimeKey, sizeof(btimeKey), pMeta->txn);
×
662
}
663

UNCOV
664
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
×
UNCOV
665
  SNcolIdxKey ncolKey = {0};
×
UNCOV
666
  if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
×
667
    return 0;
×
668
  }
UNCOV
669
  return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), pMeta->txn);
×
670
}
671

UNCOV
672
int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pMetaRsp) {
×
UNCOV
673
  pMeta->changed = true;
×
UNCOV
674
  switch (pReq->action) {
×
UNCOV
675
    case TSDB_ALTER_TABLE_ADD_COLUMN:
×
676
    case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION:
UNCOV
677
      return metaAddTableColumn(pMeta, version, pReq, pMetaRsp);
×
UNCOV
678
    case TSDB_ALTER_TABLE_DROP_COLUMN:
×
UNCOV
679
      return metaDropTableColumn(pMeta, version, pReq, pMetaRsp);
×
UNCOV
680
    case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
×
UNCOV
681
      return metaAlterTableColumnBytes(pMeta, version, pReq, pMetaRsp);
×
UNCOV
682
    case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
×
UNCOV
683
      return metaAlterTableColumnName(pMeta, version, pReq, pMetaRsp);
×
UNCOV
684
    case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:
×
UNCOV
685
      return metaUpdateTableTagValue(pMeta, version, pReq);
×
UNCOV
686
    case TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL:
×
UNCOV
687
      return metaUpdateTableMultiTagValue(pMeta, version, pReq);
×
UNCOV
688
    case TSDB_ALTER_TABLE_UPDATE_OPTIONS:
×
UNCOV
689
      return metaUpdateTableOptions2(pMeta, version, pReq);
×
UNCOV
690
    case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS:
×
UNCOV
691
      return metaUpdateTableColCompress2(pMeta, version, pReq);
×
692
    default:
×
693
      return terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
×
694
      break;
695
  }
696
}
697

698
static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs) {
×
699
  if (!tsTtlChangeOnWrite) return 0;
×
700

701
  if (changeTimeMs <= 0) {
×
702
    metaWarn("Skip to change ttl deletetion time on write, uid: %" PRId64, uid);
×
703
    return TSDB_CODE_VERSION_NOT_COMPATIBLE;
×
704
  }
705

706
  STtlUpdCtimeCtx ctx = {.uid = uid, .changeTimeMs = changeTimeMs, .pTxn = pMeta->txn};
×
707

708
  return ttlMgrUpdateChangeTime(pMeta->pTtlMgr, &ctx);
×
709
}
710

UNCOV
711
int metaUpdateChangeTimeWithLock(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs) {
×
UNCOV
712
  if (!tsTtlChangeOnWrite) return 0;
×
713

714
  metaWLock(pMeta);
×
715
  int ret = metaUpdateChangeTime(pMeta, uid, changeTimeMs);
×
716
  metaULock(pMeta);
×
717
  return ret;
×
718
}
719

UNCOV
720
int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid,
×
721
                        STagIdxKey **ppTagIdxKey, int32_t *nTagIdxKey) {
UNCOV
722
  if (IS_VAR_DATA_TYPE(type)) {
×
UNCOV
723
    *nTagIdxKey = sizeof(STagIdxKey) + nTagData + VARSTR_HEADER_SIZE + sizeof(tb_uid_t);
×
724
  } else {
UNCOV
725
    *nTagIdxKey = sizeof(STagIdxKey) + nTagData + sizeof(tb_uid_t);
×
726
  }
727

UNCOV
728
  *ppTagIdxKey = (STagIdxKey *)taosMemoryMalloc(*nTagIdxKey);
×
UNCOV
729
  if (*ppTagIdxKey == NULL) {
×
730
    return terrno;
×
731
  }
732

UNCOV
733
  (*ppTagIdxKey)->suid = suid;
×
UNCOV
734
  (*ppTagIdxKey)->cid = cid;
×
UNCOV
735
  (*ppTagIdxKey)->isNull = (pTagData == NULL) ? 1 : 0;
×
UNCOV
736
  (*ppTagIdxKey)->type = type;
×
737

738
  // refactor
UNCOV
739
  if (IS_VAR_DATA_TYPE(type)) {
×
UNCOV
740
    memcpy((*ppTagIdxKey)->data, (uint16_t *)&nTagData, VARSTR_HEADER_SIZE);
×
UNCOV
741
    if (pTagData != NULL) memcpy((*ppTagIdxKey)->data + VARSTR_HEADER_SIZE, pTagData, nTagData);
×
UNCOV
742
    *(tb_uid_t *)((*ppTagIdxKey)->data + VARSTR_HEADER_SIZE + nTagData) = uid;
×
743
  } else {
UNCOV
744
    if (pTagData != NULL) memcpy((*ppTagIdxKey)->data, pTagData, nTagData);
×
UNCOV
745
    *(tb_uid_t *)((*ppTagIdxKey)->data + nTagData) = uid;
×
746
  }
747

UNCOV
748
  return 0;
×
749
}
750

UNCOV
751
void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
×
UNCOV
752
  if (pTagIdxKey) taosMemoryFree(pTagIdxKey);
×
UNCOV
753
}
×
754

UNCOV
755
static void colCompressDebug(SHashObj *pColCmprObj) {
×
UNCOV
756
  void *p = taosHashIterate(pColCmprObj, NULL);
×
UNCOV
757
  while (p) {
×
UNCOV
758
    uint32_t cmprAlg = *(uint32_t *)p;
×
UNCOV
759
    col_id_t colId = *(col_id_t *)taosHashGetKey(p, NULL);
×
UNCOV
760
    p = taosHashIterate(pColCmprObj, p);
×
761

762
    uint8_t l1, l2, lvl;
UNCOV
763
    tcompressDebug(cmprAlg, &l1, &l2, &lvl);
×
764

UNCOV
765
    const char *l1str = columnEncodeStr(l1);
×
UNCOV
766
    const char *l2str = columnCompressStr(l2);
×
UNCOV
767
    const char *lvlstr = columnLevelStr(lvl);
×
UNCOV
768
    metaDebug("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr);
×
769
  }
UNCOV
770
  return;
×
771
}
772

UNCOV
773
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
×
UNCOV
774
  int rc = 0;
×
775

UNCOV
776
  SHashObj *pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
×
UNCOV
777
  if (pColCmprObj == NULL) {
×
778
    pColCmprObj = NULL;
×
779
    return TSDB_CODE_OUT_OF_MEMORY;
×
780
  }
781

UNCOV
782
  void      *pData = NULL;
×
UNCOV
783
  int        nData = 0;
×
UNCOV
784
  SMetaEntry e = {0};
×
UNCOV
785
  SDecoder   dc = {0};
×
786

UNCOV
787
  *ppColCmprObj = NULL;
×
788

UNCOV
789
  metaRLock(pMeta);
×
UNCOV
790
  rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData);
×
UNCOV
791
  if (rc < 0) {
×
792
    taosHashClear(pColCmprObj);
×
793
    metaULock(pMeta);
×
794
    return TSDB_CODE_FAILED;
×
795
  }
UNCOV
796
  int64_t version = ((SUidIdxVal *)pData)[0].version;
×
UNCOV
797
  rc = tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData);
×
UNCOV
798
  if (rc < 0) {
×
799
    metaULock(pMeta);
×
800
    taosHashClear(pColCmprObj);
×
801
    metaError("failed to get table entry");
×
802
    return rc;
×
803
  }
804

UNCOV
805
  tDecoderInit(&dc, pData, nData);
×
UNCOV
806
  rc = metaDecodeEntry(&dc, &e);
×
UNCOV
807
  if (rc < 0) {
×
808
    tDecoderClear(&dc);
×
809
    tdbFree(pData);
×
810
    metaULock(pMeta);
×
811
    taosHashClear(pColCmprObj);
×
812
    return rc;
×
813
  }
UNCOV
814
  if (useCompress(e.type)) {
×
UNCOV
815
    SColCmprWrapper *p = &e.colCmpr;
×
UNCOV
816
    for (int32_t i = 0; i < p->nCols; i++) {
×
UNCOV
817
      SColCmpr *pCmpr = &p->pColCmpr[i];
×
UNCOV
818
      rc = taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg));
×
UNCOV
819
      if (rc < 0) {
×
820
        tDecoderClear(&dc);
×
821
        tdbFree(pData);
×
822
        metaULock(pMeta);
×
823
        taosHashClear(pColCmprObj);
×
824
        return rc;
×
825
      }
826
    }
827
  } else {
828
    tDecoderClear(&dc);
×
829
    tdbFree(pData);
×
830
    metaULock(pMeta);
×
831
    taosHashClear(pColCmprObj);
×
832
    return 0;
×
833
  }
UNCOV
834
  tDecoderClear(&dc);
×
UNCOV
835
  tdbFree(pData);
×
UNCOV
836
  metaULock(pMeta);
×
837

UNCOV
838
  *ppColCmprObj = pColCmprObj;
×
UNCOV
839
  colCompressDebug(pColCmprObj);
×
840

UNCOV
841
  return 0;
×
842
}
843
// refactor later
UNCOV
844
void *metaGetIdx(SMeta *pMeta) { return pMeta->pTagIdx; }
×
UNCOV
845
void *metaGetIvtIdx(SMeta *pMeta) { return pMeta->pTagIvtIdx; }
×
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