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

taosdata / TDengine / #3653

14 Mar 2025 08:10AM UTC coverage: 22.565% (-41.0%) from 63.596%
#3653

push

travis-ci

web-flow
feat(keep): support keep on super table level. (#30097)

* Feat: support use keep while create super table.

* Test(keep): add test for create super table with keep option.

* Feat(keep): Add tmsg for create keep.

* Feat(keep): support alter table option keep.

* Fix(keep): Add baisc test for alter table option.

* Fix(keep): memory leek.

* Feat(keep): add keep to metaEntry&metaCache and fix earliestTs with stn keep.

* Test(keep): add some cases for select with stb keep.

* Fix: fix ci core while alter stb.

* Feat(keep): delete expired data in super table level.

* Feat: remove get stb keep while query.

* Fix : build error.

* Revert "Fix : build error."

This reverts commit 0ed66e4e8.

* Revert "Feat(keep): delete expired data in super table level."

This reverts commit 36330f6b4.

* Fix : build errors.

* Feat : support restart taosd.

* Fix : alter table comment problems.

* Test : add tests for super table keep.

* Fix: change sdb stb reserve size.

* Test: add more tests.

* Feat: Disable normal tables and sub tables from setting the keep parameter

* Fix: add more checks to avoid unknown address.

* Docs: Add docs for stable keep.

* Fix: some review changes.

* Fix: review errors.

49248 of 302527 branches covered (16.28%)

Branch coverage included in aggregate %.

53 of 99 new or added lines in 12 files covered. (53.54%)

155872 existing lines in 443 files now uncovered.

87359 of 302857 relevant lines covered (28.84%)

570004.22 hits per line

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

24.16
/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) {
316✔
25
  switch (type) {
316!
26
    case OP_TYPE_ADD:
16✔
27
      return "+";
16✔
28
    case OP_TYPE_SUB:
16✔
29
      return "-";
16✔
30
    case OP_TYPE_MULTI:
16✔
31
      return "*";
16✔
32
    case OP_TYPE_DIV:
14✔
33
      return "/";
14✔
34
    case OP_TYPE_REM:
14✔
35
      return "%";
14✔
36
    case OP_TYPE_MINUS:
18✔
37
      return "-";
18✔
38
    case OP_TYPE_BIT_AND:
16✔
39
      return "&";
16✔
40
    case OP_TYPE_BIT_OR:
16✔
41
      return "|";
16✔
42
    case OP_TYPE_GREATER_THAN:
20✔
43
      return ">";
20✔
44
    case OP_TYPE_GREATER_EQUAL:
20✔
45
      return ">=";
20✔
46
    case OP_TYPE_LOWER_THAN:
20✔
47
      return "<";
20✔
48
    case OP_TYPE_LOWER_EQUAL:
20✔
49
      return "<=";
20✔
50
    case OP_TYPE_EQUAL:
20✔
51
      return "=";
20✔
52
    case OP_TYPE_NOT_EQUAL:
20✔
53
      return "<>";
20✔
UNCOV
54
    case OP_TYPE_IN:
×
UNCOV
55
      return "IN";
×
56
    case OP_TYPE_NOT_IN:
×
57
      return "NOT IN";
×
58
    case OP_TYPE_LIKE:
10✔
59
      return "LIKE";
10✔
60
    case OP_TYPE_NOT_LIKE:
10✔
61
      return "NOT LIKE";
10✔
62
    case OP_TYPE_MATCH:
10✔
63
      return "MATCH";
10✔
64
    case OP_TYPE_NMATCH:
10✔
65
      return "NMATCH";
10✔
66
    case OP_TYPE_IS_NULL:
10✔
67
      return "IS NULL";
10✔
68
    case OP_TYPE_IS_NOT_NULL:
10✔
69
      return "IS NOT NULL";
10✔
70
    case OP_TYPE_IS_TRUE:
10✔
71
      return "IS TRUE";
10✔
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

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

UNCOV
108
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
×
UNCOV
109
  switch (pNode->type) {
×
UNCOV
110
    case QUERY_NODE_COLUMN: {
×
UNCOV
111
      SColumnNode *colNode = (SColumnNode *)pNode;
×
UNCOV
112
      if (colNode->dbName[0]) {
×
UNCOV
113
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName);
×
114
      }
115

UNCOV
116
      if (colNode->tableAlias[0]) {
×
UNCOV
117
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias);
×
UNCOV
118
      } else if (colNode->tableName[0]) {
×
119
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName);
×
120
      }
121

UNCOV
122
      if (colNode->tableAlias[0]) {
×
UNCOV
123
        *len += tsnprintf(buf + *len, bufSize - *len, "`%s`", colNode->node.userAlias);
×
124
      } else {
UNCOV
125
        *len += tsnprintf(buf + *len, bufSize - *len, "%s", colNode->node.userAlias);
×
126
      }
127

UNCOV
128
      return TSDB_CODE_SUCCESS;
×
129
    }
UNCOV
130
    case QUERY_NODE_VALUE: {
×
UNCOV
131
      SValueNode *colNode = (SValueNode *)pNode;
×
UNCOV
132
      char       *t = nodesGetStrValueFromNode(colNode);
×
UNCOV
133
      if (NULL == t) {
×
134
        nodesError("fail to get str value from valueNode");
×
135
        NODES_ERR_RET(TSDB_CODE_APP_ERROR);
×
136
      }
137

UNCOV
138
      int32_t tlen = strlen(t);
×
UNCOV
139
      if (tlen > 32) {
×
140
        *len += tsnprintf(buf + *len, bufSize - *len, "%.*s...%s", 32, t, t + tlen - 1);
×
141
      } else {
UNCOV
142
        *len += tsnprintf(buf + *len, bufSize - *len, "%s", t);
×
143
      }
UNCOV
144
      taosMemoryFree(t);
×
145

UNCOV
146
      return TSDB_CODE_SUCCESS;
×
147
    }
UNCOV
148
    case QUERY_NODE_OPERATOR: {
×
UNCOV
149
      SOperatorNode *pOpNode = (SOperatorNode *)pNode;
×
UNCOV
150
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
×
UNCOV
151
      if (pOpNode->pLeft) {
×
UNCOV
152
        NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len));
×
153
      }
154

UNCOV
155
      *len += tsnprintf(buf + *len, bufSize - *len, " %s ", operatorTypeStr(pOpNode->opType));
×
156

UNCOV
157
      if (pOpNode->pRight) {
×
UNCOV
158
        NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len));
×
159
      }
160

UNCOV
161
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
×
162

UNCOV
163
      return TSDB_CODE_SUCCESS;
×
164
    }
UNCOV
165
    case QUERY_NODE_LOGIC_CONDITION: {
×
UNCOV
166
      SLogicConditionNode *pLogicNode = (SLogicConditionNode *)pNode;
×
UNCOV
167
      SNode               *node = NULL;
×
UNCOV
168
      bool                 first = true;
×
169

UNCOV
170
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
×
171

UNCOV
172
      FOREACH(node, pLogicNode->pParameterList) {
×
UNCOV
173
        if (!first) {
×
UNCOV
174
          *len += tsnprintf(buf + *len, bufSize - *len, " %s ", logicConditionTypeStr(pLogicNode->condType));
×
175
        }
UNCOV
176
        NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
×
UNCOV
177
        first = false;
×
178
      }
179

UNCOV
180
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
×
181

UNCOV
182
      return TSDB_CODE_SUCCESS;
×
183
    }
UNCOV
184
    case QUERY_NODE_FUNCTION: {
×
UNCOV
185
      SFunctionNode *pFuncNode = (SFunctionNode *)pNode;
×
UNCOV
186
      SNode         *node = NULL;
×
UNCOV
187
      bool           first = true;
×
188

UNCOV
189
      *len += tsnprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
×
190

UNCOV
191
      FOREACH(node, pFuncNode->pParameterList) {
×
UNCOV
192
        if (!first) {
×
UNCOV
193
          *len += tsnprintf(buf + *len, bufSize - *len, ", ");
×
194
        }
UNCOV
195
        NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
×
UNCOV
196
        first = false;
×
197
      }
198

UNCOV
199
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
×
200

UNCOV
201
      return TSDB_CODE_SUCCESS;
×
202
    }
UNCOV
203
    case QUERY_NODE_NODE_LIST: {
×
UNCOV
204
      SNodeListNode *pListNode = (SNodeListNode *)pNode;
×
UNCOV
205
      SNode         *node = NULL;
×
UNCOV
206
      bool           first = true;
×
UNCOV
207
      int32_t        num = 0;
×
208

UNCOV
209
      *len += tsnprintf(buf + *len, bufSize - *len, "(");
×
210

UNCOV
211
      FOREACH(node, pListNode->pNodeList) {
×
UNCOV
212
        if (!first) {
×
UNCOV
213
          *len += tsnprintf(buf + *len, bufSize - *len, ", ");
×
UNCOV
214
          if (++num >= 10) {
×
215
            *len += tsnprintf(buf + *len, bufSize - *len, "...");
×
216
            break;
×
217
          }
218
        }
UNCOV
219
        NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
×
UNCOV
220
        first = false;
×
221
      }
222

UNCOV
223
      *len += tsnprintf(buf + *len, bufSize - *len, ")");
×
224

UNCOV
225
      return TSDB_CODE_SUCCESS;
×
226
    }
227
    default:
×
228
      break;
×
229
  }
230

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