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

taosdata / TDengine / #3774

28 Mar 2025 06:51AM UTC coverage: 62.934% (+2.6%) from 60.312%
#3774

push

travis-ci

web-flow
fix(tdb): disable page recycling (#30529)

154142 of 313582 branches covered (49.16%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2163 existing lines in 136 files now uncovered.

240434 of 313390 relevant lines covered (76.72%)

17901958.9 hits per line

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

58.48
/source/dnode/mnode/impl/src/mndInfoSchema.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
static int32_t mndInitInfosTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
69,388✔
21
  int32_t  code = 0;
69,388✔
22
  SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
69,388!
23
  if (NULL == schema) {
69,388!
24
    code = terrno;
×
25
    TAOS_RETURN(code);
×
26
  }
27

28
  for (int32_t i = 0; i < colNum; ++i) {
659,186✔
29
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
589,798✔
30
    schema[i].type = pSrc[i].type;
589,798✔
31
    schema[i].colId = i + 1;
589,798✔
32
    schema[i].bytes = pSrc[i].bytes;
589,798✔
33
    if (pSrc[i].sysInfo) {
589,798✔
34
      schema[i].flags |= COL_IS_SYSINFO;
281,204✔
35
    }
36
  }
37

38
  *pDst = schema;
69,388✔
39
  TAOS_RETURN(code);
69,388✔
40
}
41

42
static int32_t mndInsInitMeta(SHashObj *hash) {
1,826✔
43
  int32_t       code = 0;
1,826✔
44
  STableMetaRsp meta = {0};
1,826✔
45

46
  tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName));
1,826✔
47
  meta.tableType = TSDB_SYSTEM_TABLE;
1,826✔
48
  meta.sversion = 1;
1,826✔
49
  meta.tversion = 1;
1,826✔
50
  meta.virtualStb = false;
1,826✔
51

52
  size_t               size = 0;
1,826✔
53
  const SSysTableMeta *pInfosTableMeta = NULL;
1,826✔
54
  getInfosDbMeta(&pInfosTableMeta, &size);
1,826✔
55

56
  for (int32_t i = 0; i < size; ++i) {
71,214✔
57
    tstrncpy(meta.tbName, pInfosTableMeta[i].name, sizeof(meta.tbName));
69,388✔
58
    meta.numOfColumns = pInfosTableMeta[i].colNum;
69,388✔
59
    meta.sysInfo = pInfosTableMeta[i].sysInfo;
69,388✔
60

61
    TAOS_CHECK_RETURN(mndInitInfosTableSchema(pInfosTableMeta[i].schema, pInfosTableMeta[i].colNum, &meta.pSchemas));
69,388!
62

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

69
  TAOS_RETURN(code);
1,826✔
70
}
71

72
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, bool sysinfo,
112,977✔
73
                               STableMetaRsp *pRsp) {
74
  int32_t code = 0;
112,977✔
75
  if (NULL == pMnode->infosMeta) {
112,977!
76
    code = TSDB_CODE_APP_ERROR;
×
77
    TAOS_RETURN(code);
×
78
  }
79

80
  STableMetaRsp *pMeta = NULL;
112,977✔
81
  if (strcmp(tbName, TSDB_INS_TABLE_USERS_FULL) == 0) {
112,977!
82
    pMeta = taosHashGet(pMnode->infosMeta, TSDB_INS_TABLE_USERS_FULL, strlen(tbName));
×
83
  } else {
84
    pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
112,977✔
85
  }
86

87
  if (NULL == pMeta) {
112,977✔
88
    mError("invalid information schema table name:%s", tbName);
78!
89
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
78✔
90
    TAOS_RETURN(code);
78✔
91
  }
92

93
  bool isShowAnodes = (strcmp(tbName, TSDB_INS_TABLE_ANODES) == 0 || strcmp(tbName, TSDB_INS_TABLE_ANODES_FULL) == 0);
112,899✔
94

95
  if (!isShowAnodes && !sysinfo && pMeta->sysInfo) {
112,899✔
96
    mError("no permission to get schema of table name:%s", tbName);
25!
97
    code = TSDB_CODE_PAR_PERMISSION_DENIED;
25✔
98
    TAOS_RETURN(code);
25✔
99
  }
100

101
  *pRsp = *pMeta;
112,874✔
102

103
  pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
112,874!
104
  if (pRsp->pSchemas == NULL) {
112,874!
105
    code = terrno;
×
UNCOV
106
    pRsp->pSchemas = NULL;
×
UNCOV
107
    TAOS_RETURN(code);
×
108
  }
109

110
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
112,874✔
111
  TAOS_RETURN(code);
112,874✔
112
}
113

114
int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
×
115
  int32_t code = 0;
×
116
  if (NULL == pMnode->infosMeta) {
×
UNCOV
117
    code = TSDB_CODE_APP_ERROR;
×
UNCOV
118
    TAOS_RETURN(code);
×
119
  }
120

121
  STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
×
122
  if (NULL == pMeta) {
×
123
    mError("invalid information schema table name:%s", tbName);
×
UNCOV
124
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
UNCOV
125
    TAOS_RETURN(code);
×
126
  }
127

128
  tstrncpy(pRsp->tbName, pMeta->tbName, sizeof(pRsp->tbName));
×
129
  tstrncpy(pRsp->stbName, pMeta->stbName, sizeof(pRsp->stbName));
×
130
  tstrncpy(pRsp->dbFName, pMeta->dbFName, sizeof(pRsp->dbFName));
×
131
  pRsp->numOfTags = pMeta->numOfTags;
×
132
  pRsp->numOfColumns = pMeta->numOfColumns;
×
UNCOV
133
  pRsp->tableType = pMeta->tableType;
×
134
  pRsp->virtualStb = pMeta->virtualStb;
×
135

136
  pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
×
137
  if (pRsp->pSchemas == NULL) {
×
138
    code = terrno;
×
UNCOV
139
    pRsp->pSchemas = NULL;
×
UNCOV
140
    TAOS_RETURN(code);
×
141
  }
142

143
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
×
144

145
  pRsp->pSchemaExt = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchemaExt));
×
UNCOV
146
  pRsp->pColRefs = taosMemCalloc(pMeta->numOfColumns, sizeof(SColRef));
×
UNCOV
147
  TAOS_RETURN(code);
×
148
}
149

150
int32_t mndInitInfos(SMnode *pMnode) {
1,826✔
151
  pMnode->infosMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
1,826✔
152
  if (pMnode->infosMeta == NULL) {
1,826!
UNCOV
153
    TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
154
  }
155

156
  return mndInsInitMeta(pMnode->infosMeta);
1,826✔
157
}
158

159
void mndCleanupInfos(SMnode *pMnode) {
1,825✔
160
  if (NULL == pMnode->infosMeta) {
1,825!
UNCOV
161
    return;
×
162
  }
163

164
  STableMetaRsp *pMeta = taosHashIterate(pMnode->infosMeta, NULL);
1,825✔
165
  while (pMeta) {
71,175✔
166
    taosMemoryFreeClear(pMeta->pSchemas);
69,350!
167
    pMeta = taosHashIterate(pMnode->infosMeta, pMeta);
69,350✔
168
  }
169

170
  taosHashCleanup(pMnode->infosMeta);
1,825✔
171
  pMnode->infosMeta = NULL;
1,825✔
172
}
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