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

taosdata / TDengine / #3961

29 Apr 2025 09:40AM UTC coverage: 62.291% (-0.2%) from 62.445%
#3961

push

travis-ci

web-flow
Merge pull request #30938 from taosdata/fix/taosdCmdArgs

fix: taosd cmd args

154880 of 317399 branches covered (48.8%)

Branch coverage included in aggregate %.

1 of 4 new or added lines in 1 file covered. (25.0%)

1209 existing lines in 154 files now uncovered.

239982 of 316504 relevant lines covered (75.82%)

6306221.95 hits per line

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

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

28
  for (int32_t i = 0; i < colNum; ++i) {
716,398✔
29
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
641,196✔
30
    schema[i].type = pSrc[i].type;
641,196✔
31
    schema[i].colId = i + 1;
641,196✔
32
    schema[i].bytes = pSrc[i].bytes;
641,196✔
33
    if (pSrc[i].sysInfo) {
641,196✔
34
      schema[i].flags |= COL_IS_SYSINFO;
286,955✔
35
    }
36
  }
37

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

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

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

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

56
  for (int32_t i = 0; i < size; ++i) {
77,181✔
57
    tstrncpy(meta.tbName, pInfosTableMeta[i].name, sizeof(meta.tbName));
75,202✔
58
    meta.numOfColumns = pInfosTableMeta[i].colNum;
75,202✔
59
    meta.sysInfo = pInfosTableMeta[i].sysInfo;
75,202✔
60

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

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

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

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

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

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

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

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

101
  *pRsp = *pMeta;
2,297✔
102

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

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

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

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

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

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

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

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

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

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

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

164
  STableMetaRsp *pMeta = taosHashIterate(pMnode->infosMeta, NULL);
1,978✔
165
  while (pMeta) {
77,142✔
166
    taosMemoryFreeClear(pMeta->pSchemas);
75,164!
167
    pMeta = taosHashIterate(pMnode->infosMeta, pMeta);
75,164✔
168
  }
169

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