• 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/mnode/impl/src/mndPerfSchema.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
#define _DEFAULT_SOURCE
17
#include "mndInt.h"
18
#include "systable.h"
19

20
// connection/application/
UNCOV
21
int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
×
UNCOV
22
  int32_t  code = 0;
×
UNCOV
23
  SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
×
UNCOV
24
  if (NULL == schema) {
×
25
    code = terrno;
×
26
    TAOS_RETURN(code);
×
27
  }
28

UNCOV
29
  for (int32_t i = 0; i < colNum; ++i) {
×
UNCOV
30
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
×
31

UNCOV
32
    schema[i].type = pSrc[i].type;
×
UNCOV
33
    schema[i].colId = i + 1;
×
UNCOV
34
    schema[i].bytes = pSrc[i].bytes;
×
35
  }
36

UNCOV
37
  *pDst = schema;
×
UNCOV
38
  TAOS_RETURN(code);
×
39
}
40

UNCOV
41
int32_t mndPerfsInitMeta(SHashObj *hash) {
×
UNCOV
42
  int32_t       code = 0;
×
UNCOV
43
  STableMetaRsp meta = {0};
×
44

UNCOV
45
  tstrncpy(meta.dbFName, TSDB_PERFORMANCE_SCHEMA_DB, sizeof(meta.dbFName));
×
UNCOV
46
  meta.tableType = TSDB_SYSTEM_TABLE;
×
UNCOV
47
  meta.sversion = 1;
×
UNCOV
48
  meta.tversion = 1;
×
49

UNCOV
50
  size_t               size = 0;
×
UNCOV
51
  const SSysTableMeta *pSysDbTableMeta = NULL;
×
UNCOV
52
  getPerfDbMeta(&pSysDbTableMeta, &size);
×
53

UNCOV
54
  for (int32_t i = 0; i < size; ++i) {
×
UNCOV
55
    tstrncpy(meta.tbName, pSysDbTableMeta[i].name, sizeof(meta.tbName));
×
UNCOV
56
    meta.numOfColumns = pSysDbTableMeta[i].colNum;
×
57

UNCOV
58
    TAOS_CHECK_RETURN(mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas));
×
59

UNCOV
60
    if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
×
61
      code = terrno;
×
62
      TAOS_RETURN(code);
×
63
    }
64
  }
65

UNCOV
66
  TAOS_RETURN(code);
×
67
}
68

UNCOV
69
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
×
UNCOV
70
  int32_t code = 0;
×
UNCOV
71
  if (NULL == pMnode->perfsMeta) {
×
72
    code = TSDB_CODE_APP_ERROR;
×
73
    TAOS_RETURN(code);
×
74
  }
75

UNCOV
76
  STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
×
UNCOV
77
  if (NULL == meta) {
×
UNCOV
78
    mError("invalid performance schema table name:%s", tbName);
×
UNCOV
79
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
UNCOV
80
    TAOS_RETURN(code);
×
81
  }
82

UNCOV
83
  *pRsp = *meta;
×
84

UNCOV
85
  pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
×
UNCOV
86
  if (pRsp->pSchemas == NULL) {
×
87
    code = terrno;
×
88
    pRsp->pSchemas = NULL;
×
89
    TAOS_RETURN(code);
×
90
  }
91

UNCOV
92
  memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
×
UNCOV
93
  TAOS_RETURN(code);
×
94
}
95

96
int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
×
97
  int32_t code = 0;
×
98
  if (NULL == pMnode->perfsMeta) {
×
99
    code = TSDB_CODE_APP_ERROR;
×
100
    TAOS_RETURN(code);
×
101
  }
102

103
  STableMetaRsp *pMeta = taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
×
104
  if (NULL == pMeta) {
×
105
    mError("invalid performance schema table name:%s", tbName);
×
106
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
107
    TAOS_RETURN(code);
×
108
  }
109

110
  tstrncpy(pRsp->tbName, pMeta->tbName, sizeof(pRsp->tbName));
×
111
  tstrncpy(pRsp->stbName, pMeta->stbName, sizeof(pRsp->stbName));
×
112
  tstrncpy(pRsp->dbFName, pMeta->dbFName, sizeof(pRsp->dbFName));
×
113
  pRsp->numOfTags = pMeta->numOfTags;
×
114
  pRsp->numOfColumns = pMeta->numOfColumns;
×
115
  pRsp->tableType = pMeta->tableType;
×
116

117
  pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
×
118
  if (pRsp->pSchemas == NULL) {
×
119
    code = terrno;
×
120
    pRsp->pSchemas = NULL;
×
121
    TAOS_RETURN(code);
×
122
  }
123

124
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
×
125
  TAOS_RETURN(code);
×
126
}
127

UNCOV
128
int32_t mndInitPerfs(SMnode *pMnode) {
×
UNCOV
129
  int32_t code = 0;
×
UNCOV
130
  pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
×
UNCOV
131
  if (pMnode->perfsMeta == NULL) {
×
132
    code = terrno;
×
133
    TAOS_RETURN(code);
×
134
  }
135

UNCOV
136
  return mndPerfsInitMeta(pMnode->perfsMeta);
×
137
}
138

UNCOV
139
void mndCleanupPerfs(SMnode *pMnode) {
×
UNCOV
140
  if (NULL == pMnode->perfsMeta) {
×
141
    return;
×
142
  }
143

UNCOV
144
  void *pIter = taosHashIterate(pMnode->perfsMeta, NULL);
×
UNCOV
145
  while (pIter) {
×
UNCOV
146
    STableMetaRsp *meta = (STableMetaRsp *)pIter;
×
147

UNCOV
148
    taosMemoryFreeClear(meta->pSchemas);
×
149

UNCOV
150
    pIter = taosHashIterate(pMnode->perfsMeta, pIter);
×
151
  }
152

UNCOV
153
  taosHashCleanup(pMnode->perfsMeta);
×
UNCOV
154
  pMnode->perfsMeta = NULL;
×
155
}
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