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

taosdata / TDengine / #4829

30 Oct 2025 09:25AM UTC coverage: 49.734% (-11.3%) from 61.071%
#4829

push

travis-ci

web-flow
Merge pull request #33435 from taosdata/3.0

merge 3.0

123072 of 323930 branches covered (37.99%)

Branch coverage included in aggregate %.

7 of 25 new or added lines in 3 files covered. (28.0%)

35232 existing lines in 327 files now uncovered.

172062 of 269495 relevant lines covered (63.85%)

70709785.06 hits per line

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

48.33
/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/
21
int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
608,445✔
22
  int32_t  code = 0;
608,445✔
23
  SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
608,445!
24
  if (NULL == schema) {
608,445!
25
    code = terrno;
×
26
    TAOS_RETURN(code);
×
27
  }
28

29
  for (int32_t i = 0; i < colNum; ++i) {
8,396,541✔
30
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
7,788,096!
31

32
    schema[i].type = pSrc[i].type;
7,788,096✔
33
    schema[i].colId = i + 1;
7,788,096✔
34
    schema[i].bytes = pSrc[i].bytes;
7,788,096✔
35
  }
36

37
  *pDst = schema;
608,445✔
38
  TAOS_RETURN(code);
608,445✔
39
}
40

41
int32_t mndPerfsInitMeta(SHashObj *hash) {
121,689✔
42
  int32_t       code = 0;
121,689✔
43
  STableMetaRsp meta = {0};
121,689✔
44

45
  tstrncpy(meta.dbFName, TSDB_PERFORMANCE_SCHEMA_DB, sizeof(meta.dbFName));
121,689✔
46
  meta.tableType = TSDB_SYSTEM_TABLE;
121,689✔
47
  meta.sversion = 1;
121,689✔
48
  meta.tversion = 1;
121,689✔
49
  meta.rversion = 1;
121,689✔
50
  meta.virtualStb = false;
121,689✔
51

52
  size_t               size = 0;
121,689✔
53
  const SSysTableMeta *pSysDbTableMeta = NULL;
121,689✔
54
  getPerfDbMeta(&pSysDbTableMeta, &size);
121,689✔
55

56
  for (int32_t i = 0; i < size; ++i) {
730,134✔
57
    tstrncpy(meta.tbName, pSysDbTableMeta[i].name, sizeof(meta.tbName));
608,445!
58
    meta.numOfColumns = pSysDbTableMeta[i].colNum;
608,445✔
59

60
    TAOS_CHECK_RETURN(mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas));
608,445!
61

62
    if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
608,445!
63
      code = terrno;
×
64
      TAOS_RETURN(code);
×
65
    }
66
  }
67

68
  TAOS_RETURN(code);
121,689✔
69
}
70

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

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

85
  *pRsp = *meta;
800✔
86

87
  pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
800!
88
  if (pRsp->pSchemas == NULL) {
800!
89
    code = terrno;
×
90
    pRsp->pSchemas = NULL;
×
91
    TAOS_RETURN(code);
×
92
  }
93

94
  memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
800!
95
  TAOS_RETURN(code);
800✔
96
}
97

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

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

UNCOV
112
  tstrncpy(pRsp->tbName, pMeta->tbName, sizeof(pRsp->tbName));
×
UNCOV
113
  tstrncpy(pRsp->stbName, pMeta->stbName, sizeof(pRsp->stbName));
×
UNCOV
114
  tstrncpy(pRsp->dbFName, pMeta->dbFName, sizeof(pRsp->dbFName));
×
UNCOV
115
  pRsp->numOfTags = pMeta->numOfTags;
×
UNCOV
116
  pRsp->numOfColumns = pMeta->numOfColumns;
×
UNCOV
117
  pRsp->tableType = pMeta->tableType;
×
UNCOV
118
  pRsp->virtualStb = pMeta->virtualStb;
×
119

UNCOV
120
  pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
×
UNCOV
121
  if (pRsp->pSchemas == NULL) {
×
122
    code = terrno;
×
123
    pRsp->pSchemas = NULL;
×
124
    TAOS_RETURN(code);
×
125
  }
126

UNCOV
127
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
×
UNCOV
128
  TAOS_RETURN(code);
×
129
}
130

131
int32_t mndInitPerfs(SMnode *pMnode) {
121,689✔
132
  int32_t code = 0;
121,689✔
133
  pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
121,689✔
134
  if (pMnode->perfsMeta == NULL) {
121,689!
135
    code = terrno;
×
136
    TAOS_RETURN(code);
×
137
  }
138

139
  return mndPerfsInitMeta(pMnode->perfsMeta);
121,689✔
140
}
141

142
void mndCleanupPerfs(SMnode *pMnode) {
121,620✔
143
  if (NULL == pMnode->perfsMeta) {
121,620!
144
    return;
×
145
  }
146

147
  void *pIter = taosHashIterate(pMnode->perfsMeta, NULL);
121,620✔
148
  while (pIter) {
729,720✔
149
    STableMetaRsp *meta = (STableMetaRsp *)pIter;
608,100✔
150

151
    taosMemoryFreeClear(meta->pSchemas);
608,100!
152

153
    pIter = taosHashIterate(pMnode->perfsMeta, pIter);
608,100✔
154
  }
155

156
  taosHashCleanup(pMnode->perfsMeta);
121,620✔
157
  pMnode->perfsMeta = NULL;
121,620✔
158
}
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