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

taosdata / TDengine / #3720

26 Mar 2025 06:20AM UTC coverage: 30.242% (-31.7%) from 61.936%
#3720

push

travis-ci

web-flow
feat(taosBenchmark): supports decimal data type (#30456)

* feat: taosBenchmark supports decimal data type

* build: decimal script not use pytest.sh

* fix: fix typo for decimal script

* test: insertBasic.py debug

71234 of 313946 branches covered (22.69%)

Branch coverage included in aggregate %.

38 of 423 new or added lines in 8 files covered. (8.98%)

120240 existing lines in 447 files now uncovered.

118188 of 312400 relevant lines covered (37.83%)

1450220.33 hits per line

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

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

28
  for (int32_t i = 0; i < colNum; ++i) {
7,220✔
29
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
6,460✔
30
    schema[i].type = pSrc[i].type;
6,460✔
31
    schema[i].colId = i + 1;
6,460✔
32
    schema[i].bytes = pSrc[i].bytes;
6,460✔
33
    if (pSrc[i].sysInfo) {
6,460✔
34
      schema[i].flags |= COL_IS_SYSINFO;
3,200✔
35
    }
36
  }
37

38
  *pDst = schema;
760✔
39
  TAOS_RETURN(code);
760✔
40
}
41

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

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

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

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

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

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

69
  TAOS_RETURN(code);
20✔
70
}
71

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

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

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

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

99
  *pRsp = *pMeta;
16✔
100

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

108
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
16✔
109
  TAOS_RETURN(code);
16✔
110
}
111

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

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

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

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

141
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
×
142

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

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

154
  return mndInsInitMeta(pMnode->infosMeta);
20✔
155
}
156

157
void mndCleanupInfos(SMnode *pMnode) {
20✔
158
  if (NULL == pMnode->infosMeta) {
20!
159
    return;
×
160
  }
161

162
  STableMetaRsp *pMeta = taosHashIterate(pMnode->infosMeta, NULL);
20✔
163
  while (pMeta) {
780✔
164
    taosMemoryFreeClear(pMeta->pSchemas);
760!
165
    pMeta = taosHashIterate(pMnode->infosMeta, pMeta);
760✔
166
  }
167

168
  taosHashCleanup(pMnode->infosMeta);
20✔
169
  pMnode->infosMeta = NULL;
20✔
170
}
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