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

taosdata / TDengine / #4948

04 Feb 2026 09:05AM UTC coverage: 66.866% (-0.006%) from 66.872%
#4948

push

travis-ci

web-flow
enh(keeper): password information desensitization processing (#34458)

Close https://project.feishu.cn/taosdata_td/feature/detail/6600039687

Commits:

* feat: add String method to TDengineRestful for safe string representation

* feat: replace hardcoded credentials with test utility functions in tests

* feat: update test workflows to use environment variables for credentials

* test: fix failed test case

* chore: setup tmate

* feat: streamline test execution by setting environment variables for credentials

* feat: enhance test utility functions to return default values if environment variables are not set

205522 of 307364 relevant lines covered (66.87%)

124991068.44 hits per line

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

67.84
/source/libs/nodes/src/nodesToSQLFuncs.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
#include "cmdnodes.h"
17
#include "nodesUtil.h"
18
#include "plannodes.h"
19
#include "querynodes.h"
20
#include "taos.h"
21
#include "taoserror.h"
22
#include "thash.h"
23

24
const char *operatorTypeStr(EOperatorType type) {
130,339,066✔
25
  switch (type) {
130,339,066✔
26
    case OP_TYPE_ADD:
294,633✔
27
      return "+";
294,633✔
28
    case OP_TYPE_SUB:
×
29
      return "-";
×
30
    case OP_TYPE_MULTI:
×
31
      return "*";
×
32
    case OP_TYPE_DIV:
×
33
      return "/";
×
34
    case OP_TYPE_REM:
×
35
      return "%";
×
36
    case OP_TYPE_MINUS:
×
37
      return "-";
×
38
    case OP_TYPE_BIT_AND:
×
39
      return "&";
×
40
    case OP_TYPE_BIT_OR:
×
41
      return "|";
×
42
    case OP_TYPE_GREATER_THAN:
15,352,703✔
43
      return ">";
15,352,703✔
44
    case OP_TYPE_GREATER_EQUAL:
24,938,141✔
45
      return ">=";
24,938,141✔
46
    case OP_TYPE_LOWER_THAN:
10,971,288✔
47
      return "<";
10,971,288✔
48
    case OP_TYPE_LOWER_EQUAL:
23,199,938✔
49
      return "<=";
23,199,938✔
50
    case OP_TYPE_EQUAL:
27,762,434✔
51
      return "=";
27,762,434✔
52
    case OP_TYPE_NOT_EQUAL:
953,979✔
53
      return "<>";
953,979✔
54
    case OP_TYPE_IN:
1,131,013✔
55
      return "IN";
1,131,013✔
56
    case OP_TYPE_NOT_IN:
942,607✔
57
      return "NOT IN";
942,607✔
58
    case OP_TYPE_LIKE:
2,288,514✔
59
      return "LIKE";
2,288,514✔
60
    case OP_TYPE_NOT_LIKE:
×
61
      return "NOT LIKE";
×
62
    case OP_TYPE_MATCH:
10,369,538✔
63
      return "MATCH";
10,369,538✔
64
    case OP_TYPE_NMATCH:
524,802✔
65
      return "NMATCH";
524,802✔
66
    case OP_TYPE_IS_NULL:
3,560,581✔
67
      return "IS NULL";
3,560,581✔
68
    case OP_TYPE_IS_NOT_NULL:
8,056,751✔
69
      return "IS NOT NULL";
8,056,751✔
70
    case OP_TYPE_IS_TRUE:
×
71
      return "IS TRUE";
×
72
    case OP_TYPE_IS_FALSE:
×
73
      return "IS FALSE";
×
74
    case OP_TYPE_IS_UNKNOWN:
×
75
      return "IS UNKNOWN";
×
76
    case OP_TYPE_IS_NOT_TRUE:
×
77
      return "IS NOT TRUE";
×
78
    case OP_TYPE_IS_NOT_FALSE:
×
79
      return "IS NOT FALSE";
×
80
    case OP_TYPE_IS_NOT_UNKNOWN:
×
81
      return "IS NOT UNKNOWN";
×
82
    case OP_TYPE_JSON_GET_VALUE:
×
83
      return "=>";
×
84
    case OP_TYPE_JSON_CONTAINS:
×
85
      return "CONTAINS";
×
86
    case OP_TYPE_ASSIGN:
×
87
      return "=";
×
88
    default:
×
89
      break;
×
90
  }
91
  return "UNKNOWN";
×
92
}
93

94
const char *logicConditionTypeStr(ELogicConditionType type) {
862,291✔
95
  switch (type) {
862,291✔
96
    case LOGIC_COND_TYPE_AND:
576,315✔
97
      return "AND";
576,315✔
98
    case LOGIC_COND_TYPE_OR:
285,976✔
99
      return "OR";
285,976✔
100
    case LOGIC_COND_TYPE_NOT:
×
101
      return "NOT";
×
102
    default:
×
103
      break;
×
104
  }
105
  return "UNKNOWN";
×
106
}
107

108
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
14,354,370✔
109
  return nodesNodeToSQLFormat(pNode, buf, bufSize, len, false);
14,354,370✔
110
}
111

112
int32_t nodesNodeToSQLFormat(SNode *pNode, char *buf, int32_t bufSize, int32_t *len, bool longFormat) {
45,585,937✔
113
  switch (pNode->type) {
45,585,937✔
114
    case QUERY_NODE_COLUMN: {
13,402,754✔
115
      SColumnNode *colNode = (SColumnNode *)pNode;
13,402,754✔
116
      if (colNode->dbName[0]) {
13,402,754✔
117
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName);
12,617,407✔
118
      }
119

120
      if (colNode->tableAlias[0]) {
13,402,754✔
121
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias);
12,633,701✔
122
      } else if (colNode->tableName[0]) {
769,053✔
123
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName);
×
124
      }
125

126
      if (colNode->tableAlias[0]) {
13,402,754✔
127
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`", colNode->node.userAlias);
12,633,701✔
128
      } else {
129
        *len += tsnprintf(buf + *len, bufSize - *len, "%s", colNode->node.userAlias);
769,053✔
130
      }
131

132
      return TSDB_CODE_SUCCESS;
13,402,754✔
133
    }
134
    case QUERY_NODE_VALUE: {
5,668,128✔
135
      SValueNode *colNode = (SValueNode *)pNode;
5,668,128✔
136
      char       *t = nodesGetStrValueFromNode(colNode);
5,668,128✔
137
      if (NULL == t) {
5,668,128✔
138
        nodesError("fail to get str value from valueNode");
×
139
        NODES_ERR_RET(TSDB_CODE_APP_ERROR);
×
140
      }
141

142
      int32_t tlen = strlen(t);
5,668,128✔
143
      if (longFormat) {
5,668,128✔
144
        *len += tsnprintf(buf + *len, bufSize - *len, "%s", t);
5,668,128✔
145
      } else {
146
        if (tlen > 32) {
×
147
          *len += tsnprintf(buf + *len, bufSize - *len, "%.*s...%s", 32, t, t + tlen - 1);
×
148
        } else {
149
          *len += tsnprintf(buf + *len, bufSize - *len, "%s", t);
×
150
        }
151
      }
152

153
      taosMemoryFree(t);
5,668,128✔
154

155
      return TSDB_CODE_SUCCESS;
5,668,128✔
156
    }
157
    case QUERY_NODE_OPERATOR: {
15,546,329✔
158
      SOperatorNode *pOpNode = (SOperatorNode *)pNode;
15,546,329✔
159
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
15,546,329✔
160
      if (pOpNode->pLeft) {
15,546,329✔
161
        NODES_ERR_RET(nodesNodeToSQLFormat(pOpNode->pLeft, buf, bufSize, len, true));
15,546,329✔
162
      }
163

164
      *len += tsnprintf(buf + *len, bufSize - *len, " %s ", operatorTypeStr(pOpNode->opType));
15,546,329✔
165

166
      if (pOpNode->pRight) {
15,546,329✔
167
        NODES_ERR_RET(nodesNodeToSQLFormat(pOpNode->pRight, buf, bufSize, len, true));
13,600,652✔
168
      }
169

170
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
15,546,329✔
171

172
      return TSDB_CODE_SUCCESS;
15,546,329✔
173
    }
174
    case QUERY_NODE_LOGIC_CONDITION: {
862,291✔
175
      SLogicConditionNode *pLogicNode = (SLogicConditionNode *)pNode;
862,291✔
176
      SNode               *node = NULL;
862,291✔
177
      bool                 first = true;
862,291✔
178

179
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
862,291✔
180

181
      FOREACH(node, pLogicNode->pParameterList) {
2,586,873✔
182
        if (!first) {
1,724,582✔
183
          *len += tsnprintf(buf + *len, bufSize - *len, " %s ", logicConditionTypeStr(pLogicNode->condType));
862,291✔
184
        }
185
        NODES_ERR_RET(nodesNodeToSQLFormat(node, buf, bufSize, len, true));
1,724,582✔
186
        first = false;
1,724,582✔
187
      }
188

189
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
862,291✔
190

191
      return TSDB_CODE_SUCCESS;
862,291✔
192
    }
193
    case QUERY_NODE_FUNCTION: {
262,206✔
194
      SFunctionNode *pFuncNode = (SFunctionNode *)pNode;
262,206✔
195
      SNode         *node = NULL;
262,206✔
196
      bool           first = true;
262,206✔
197

198
      *len += tsnprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
262,206✔
199

200
      FOREACH(node, pFuncNode->pParameterList) {
563,724✔
201
        if (!first) {
301,518✔
202
          *len += tsnprintf(buf + *len, bufSize - *len, ", ");
39,312✔
203
        }
204
        NODES_ERR_RET(nodesNodeToSQLFormat(node, buf, bufSize, len, true));
301,518✔
205
        first = false;
301,518✔
206
      }
207

208
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
262,206✔
209

210
      return TSDB_CODE_SUCCESS;
262,206✔
211
    }
212
    case QUERY_NODE_NODE_LIST: {
7,435✔
213
      SNodeListNode *pListNode = (SNodeListNode *)pNode;
7,435✔
214
      SNode         *node = NULL;
7,435✔
215
      bool           first = true;
7,435✔
216
      int32_t        num = 0;
7,435✔
217

218
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
7,435✔
219

220
      FOREACH(node, pListNode->pNodeList) {
30,726✔
221
        if (!first) {
23,291✔
222
          *len += tsnprintf(buf + *len, bufSize - *len, ", ");
15,856✔
223
          if (!longFormat) {
15,856✔
224
            if (++num >= 10) {
×
225
              *len += tsnprintf(buf + *len, bufSize - *len, "...");
×
226
              break;
×
227
            }
228
          }
229
        }
230
        NODES_ERR_RET(nodesNodeToSQLFormat(node, buf, bufSize, len, true));
23,291✔
231
        first = false;
23,291✔
232
      }
233

234
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
7,435✔
235

236
      return TSDB_CODE_SUCCESS;
7,435✔
237
    }
238
    case QUERY_NODE_REMOTE_VALUE: {
7,943,925✔
239
      SRemoteValueNode* pRemote = (SRemoteValueNode*)pNode;
7,943,925✔
240
      *len += tsnprintf(buf + *len, bufSize - *len, "$(InitPlan %d)", pRemote->subQIdx + 1);
7,943,925✔
241
      return TSDB_CODE_SUCCESS;
7,943,925✔
242
    }
243
    case QUERY_NODE_REMOTE_VALUE_LIST: {
1,892,869✔
244
      SRemoteValueListNode* pRemote = (SRemoteValueListNode*)pNode;
1,892,869✔
245
      *len += tsnprintf(buf + *len, bufSize - *len, "$(InitPlan %d)", pRemote->subQIdx + 1);
1,892,869✔
246
      return TSDB_CODE_SUCCESS;
1,892,869✔
247
    }
248
    default:
×
249
      break;
×
250
  }
251

252
  nodesError("nodesNodeToSQL unknown node = %s", nodesNodeName(pNode->type));
×
253
  NODES_RET(TSDB_CODE_APP_ERROR);
×
254
}
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