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

taosdata / TDengine / #3610

12 Feb 2025 09:54AM UTC coverage: 54.713% (-8.4%) from 63.066%
#3610

push

travis-ci

web-flow
Merge pull request #29745 from taosdata/fix/TD33664-3.0

fix: --version show information check for 3.0

120957 of 286549 branches covered (42.21%)

Branch coverage included in aggregate %.

190849 of 283342 relevant lines covered (67.36%)

4969786.97 hits per line

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

51.8
/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) {
5,405✔
22
  int32_t  code = 0;
5,405✔
23
  SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
5,405!
24
  if (NULL == schema) {
5,405!
25
    code = terrno;
×
26
    TAOS_RETURN(code);
×
27
  }
28

29
  for (int32_t i = 0; i < colNum; ++i) {
71,346✔
30
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
65,941✔
31

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

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

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

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

50
  size_t               size = 0;
1,081✔
51
  const SSysTableMeta *pSysDbTableMeta = NULL;
1,081✔
52
  getPerfDbMeta(&pSysDbTableMeta, &size);
1,081✔
53

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

58
    TAOS_CHECK_RETURN(mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas));
5,405!
59

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

66
  TAOS_RETURN(code);
1,081✔
67
}
68

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

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

83
  *pRsp = *meta;
34✔
84

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

92
  memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
34✔
93
  TAOS_RETURN(code);
34✔
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

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

136
  return mndPerfsInitMeta(pMnode->perfsMeta);
1,081✔
137
}
138

139
void mndCleanupPerfs(SMnode *pMnode) {
1,080✔
140
  if (NULL == pMnode->perfsMeta) {
1,080!
141
    return;
×
142
  }
143

144
  void *pIter = taosHashIterate(pMnode->perfsMeta, NULL);
1,080✔
145
  while (pIter) {
6,480✔
146
    STableMetaRsp *meta = (STableMetaRsp *)pIter;
5,400✔
147

148
    taosMemoryFreeClear(meta->pSchemas);
5,400!
149

150
    pIter = taosHashIterate(pMnode->perfsMeta, pIter);
5,400✔
151
  }
152

153
  taosHashCleanup(pMnode->perfsMeta);
1,080✔
154
  pMnode->perfsMeta = NULL;
1,080✔
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