• 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

0.0
/tools/shell/src/shellUtil.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 _BSD_SOURCE
17
#define _GNU_SOURCE
18
#define _XOPEN_SOURCE
19
#define _DEFAULT_SOURCE
20

21
#include "shellInt.h"
22

UNCOV
23
bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
×
UNCOV
24
  regex_t regex = {0};
×
UNCOV
25
  char    msgbuf[100] = {0};
×
26

27
  /* Compile regular expression */
UNCOV
28
  if (regcomp(&regex, reg, cflags) != 0) {
×
29
    fprintf(stderr, "Fail to compile regex");
×
30
    shellExit();
×
31
  }
32

33
  /* Execute regular expression */
UNCOV
34
  int32_t reti = regexec(&regex, s, 0, NULL, 0);
×
UNCOV
35
  if (!reti) {
×
UNCOV
36
    regfree(&regex);
×
UNCOV
37
    return true;
×
UNCOV
38
  } else if (reti == REG_NOMATCH) {
×
UNCOV
39
    regfree(&regex);
×
UNCOV
40
    return false;
×
41
  } else {
42
    regerror(reti, &regex, msgbuf, sizeof(msgbuf));
×
43
    fprintf(stderr, "Regex match failed: %s\r\n", msgbuf);
×
44
    regfree(&regex);
×
45
    shellExit();
×
46
  }
47

48
  return false;
×
49
}
50

UNCOV
51
int32_t shellCheckIntSize() {
×
52
  if (sizeof(int8_t) != 1) {
53
    printf("int8 size is %d(!= 1)", (int)sizeof(int8_t));
54
    return -1;
55
  }
56
  if (sizeof(int16_t) != 2) {
57
    printf("int16 size is %d(!= 2)", (int)sizeof(int16_t));
58
    return -1;
59
  }
60
  if (sizeof(int32_t) != 4) {
61
    printf("int32 size is %d(!= 4)", (int)sizeof(int32_t));
62
    return -1;
63
  }
64
  if (sizeof(int64_t) != 8) {
65
    printf("int64 size is %d(!= 8)", (int)sizeof(int64_t));
66
    return -1;
67
  }
UNCOV
68
  return 0;
×
69
}
70

71
void shellPrintVersion() { printf("%s\r\n", shell.info.programVersion); }
×
72

UNCOV
73
void shellGenerateAuth() {
×
UNCOV
74
  char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
×
UNCOV
75
  taosEncryptPass_c((uint8_t *)shell.args.password, strlen(shell.args.password), secretEncrypt);
×
UNCOV
76
  printf("%s\r\n", secretEncrypt);
×
UNCOV
77
  fflush(stdout);
×
UNCOV
78
}
×
79

UNCOV
80
void shellDumpConfig() {
×
UNCOV
81
  SConfig *pCfg = taosGetCfg();
×
UNCOV
82
  if (pCfg == NULL) {
×
83
    printf("read global config failed!\r\n");
×
84
  } else {
UNCOV
85
    cfgDumpCfg(pCfg, 1, true);
×
86
  }
UNCOV
87
  fflush(stdout);
×
UNCOV
88
}
×
89

UNCOV
90
void shellCheckServerStatus() {
×
91
  TSDB_SERVER_STATUS code;
92

93
  do {
×
UNCOV
94
    char details[1024] = {0};
×
UNCOV
95
    code = taos_check_server_status(shell.args.host, shell.args.port, details, 1024);
×
UNCOV
96
    switch (code) {
×
UNCOV
97
      case TSDB_SRV_STATUS_UNAVAILABLE:
×
UNCOV
98
        printf("0: unavailable\r\n");
×
UNCOV
99
        break;
×
100
      case TSDB_SRV_STATUS_NETWORK_OK:
×
101
        printf("1: network ok\r\n");
×
102
        break;
×
UNCOV
103
      case TSDB_SRV_STATUS_SERVICE_OK:
×
UNCOV
104
        printf("2: service ok\r\n");
×
UNCOV
105
        break;
×
106
      case TSDB_SRV_STATUS_SERVICE_DEGRADED:
×
107
        printf("3: service degraded\r\n");
×
108
        break;
×
109
      case TSDB_SRV_STATUS_EXTING:
×
110
        printf("4: exiting\r\n");
×
111
        break;
×
112
    }
UNCOV
113
    if (strlen(details) != 0) {
×
114
      printf("%s\r\n\r\n", details);
×
115
    }
UNCOV
116
    fflush(stdout);
×
UNCOV
117
    if (code == TSDB_SRV_STATUS_NETWORK_OK && shell.args.is_startup) {
×
118
      taosMsleep(1000);
×
119
    } else {
120
      break;
121
    }
122
  } while (1);
UNCOV
123
}
×
124
#ifdef WEBSOCKET
125
char dsn[1024] = "ws://localhost:6041";
UNCOV
126
void shellCheckConnectMode() {
×
UNCOV
127
        if (shell.args.dsn) {
×
UNCOV
128
                shell.args.cloud = true;
×
UNCOV
129
                shell.args.restful = false;
×
UNCOV
130
                return;
×
131
        }
UNCOV
132
        if (shell.args.cloud) {
×
UNCOV
133
                shell.args.dsn = getenv("TDENGINE_CLOUD_DSN");
×
UNCOV
134
                if (shell.args.dsn && strlen(shell.args.dsn) > 4) {
×
135
                        shell.args.cloud = true;
×
136
      shell.args.local = false;
×
137
                        shell.args.restful = false;
×
138
                        return;
×
139
                }
140

UNCOV
141
    shell.args.dsn = getenv("TDENGINE_DSN");
×
UNCOV
142
                if (shell.args.dsn && strlen(shell.args.dsn) > 4) {
×
143
                        shell.args.cloud = true;
×
144
      shell.args.local = true;
×
145
                        shell.args.restful = false;
×
146
                        return;
×
147
                }
148
        }
149

UNCOV
150
  if (shell.args.restful) {
×
UNCOV
151
    if (!shell.args.host) {
×
UNCOV
152
      shell.args.host = "localhost";
×
153
    }
UNCOV
154
    if (!shell.args.port) {
×
UNCOV
155
      shell.args.port = 6041;
×
156
    }
UNCOV
157
    shell.args.dsn = dsn;
×
UNCOV
158
    snprintf(shell.args.dsn, 1024, "ws://%s:%d",
×
159
        shell.args.host, shell.args.port);
160
  }
UNCOV
161
  shell.args.cloud = false;
×
UNCOV
162
  return;
×
163

164
}
165
#endif
166

UNCOV
167
void shellExit() {
×
UNCOV
168
  if (shell.conn != NULL) {
×
UNCOV
169
    taos_close(shell.conn);
×
UNCOV
170
    shell.conn = NULL;
×
171
  }
UNCOV
172
  shell.exit = true;
×
UNCOV
173
  taos_cleanup();
×
UNCOV
174
}
×
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