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

taosdata / TDengine / #4898

26 Dec 2025 09:58AM UTC coverage: 65.061% (-0.7%) from 65.717%
#4898

push

travis-ci

web-flow
feat: support encryption of configuration files, data files and metadata files (#33801)

350 of 1333 new or added lines in 31 files covered. (26.26%)

2796 existing lines in 159 files now uncovered.

184024 of 282850 relevant lines covered (65.06%)

113940470.33 hits per line

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

92.39
/source/client/wrapper/src/wrapperDriver.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 "wrapper.h"
17
#include "wrapperHint.h"
18

19
#ifdef WINDOWS
20
#define DRIVER_NATIVE_NAME    "taosnative.dll"
21
#define DRIVER_WSBSOCKET_NAME "taosws.dll"
22
#elif defined(DARWIN)
23
#define DRIVER_NATIVE_NAME    "libtaosnative.dylib"
24
#define DRIVER_WSBSOCKET_NAME "libtaosws.dylib"
25
#else
26
#define DRIVER_NATIVE_NAME    "libtaosnative.so"
27
#define DRIVER_WSBSOCKET_NAME "libtaosws.so"
28
#endif
29

30
#define LOAD_FUNC(fptr, fname)                \
31
  funcName = fname;                           \
32
  fptr = taosLoadDllFunc(tsDriver, funcName); \
33
  if (fptr == NULL) goto _OVER;
34

35
#ifdef WEBSOCKET
36
EDriverType tsDriverType = DRIVER_NATIVE;  // todo simon
37
#else
38
EDriverType tsDriverType = DRIVER_NATIVE;
39
#endif
40

41
void *tsDriver = NULL;
42

43
static int32_t taosGetDevelopPath(char *driverPath, const char *driverName) {
1,066,987✔
44
  char    appPath[PATH_MAX] = {0};
1,066,987✔
45
  int32_t ret = taosAppPath(appPath, PATH_MAX);
1,066,987✔
46
  if (ret == 0) {
1,066,987✔
47
    snprintf(driverPath, PATH_MAX, "%s%s..%slib%s%s", appPath, TD_DIRSEP, TD_DIRSEP, TD_DIRSEP, driverName);
1,066,987✔
48
    ret = taosRealPath(driverPath, NULL, PATH_MAX);
1,066,987✔
49
  }
50

51
  return ret;
1,066,987✔
52
}
53

54
void taosDriverEnvInit() {
1,067,918✔
55
  const char *driver = getenv("TDENGINE_DRIVER");
1,067,918✔
56
  if (driver) {
1,067,918✔
UNCOV
57
    if (strcasecmp(driver, STR_NATIVE) == 0) {
×
UNCOV
58
      tsDriverType = DRIVER_NATIVE;
×
UNCOV
59
    } else if (strcasecmp(driver, STR_WEBSOCKET) == 0) {
×
UNCOV
60
      tsDriverType = DRIVER_WEBSOCKET;
×
61
    }
62
  }
63
}
1,067,918✔
64

65
int32_t taosDriverInit(EDriverType driverType) {
1,066,987✔
66
  int32_t     code = -1;
1,066,987✔
67
  char        driverPath[PATH_MAX + 32] = {0};
1,066,987✔
68
  const char *driverName = NULL;
1,066,987✔
69
  const char *funcName = NULL;
1,066,987✔
70

71
  if (driverType == DRIVER_NATIVE) {
1,066,987✔
72
    driverName = DRIVER_NATIVE_NAME;
1,065,154✔
73
  } else {
74
    driverName = DRIVER_WSBSOCKET_NAME;
1,833✔
75
  }
76

77
  // load from develop build path
78
  if (tsDriver == NULL && taosGetDevelopPath(driverPath, driverName) == 0) {
1,066,987✔
79
    tsDriver = taosLoadDll(driverPath);
787,295✔
80
  }  
81

82
  // load from system path
83
  if (tsDriver == NULL) {
1,066,987✔
84
    tsDriver = taosLoadDll(driverName);
279,692✔
85
  }
86

87
// load from install path on mac
88
#if defined(DARWIN)
89
  if (tsDriver == NULL) {
90
    snprintf(driverPath, PATH_MAX, "/usr/local/lib/%s", driverName);
91
    tsDriver = taosLoadDll(driverPath);
92
  }
93
#endif
94

95
  if (tsDriver == NULL) {
1,066,987✔
UNCOV
96
    printf("failed to load %s since %s [0x%X]\r\n", driverName, terrstr(), terrno);
×
UNCOV
97
    showWrapperHint(terrno);
×
UNCOV
98
    return code;
×
99
  }
100

101
  LOAD_FUNC(fp_taos_set_config, "taos_set_config");
1,066,987✔
102

103
  LOAD_FUNC(fp_taos_init, "taos_init");
1,066,987✔
104
  LOAD_FUNC(fp_taos_cleanup, "taos_cleanup");
1,066,987✔
105
  LOAD_FUNC(fp_taos_options, "taos_options");
1,066,987✔
106
  LOAD_FUNC(fp_taos_set_option, "taos_set_option");
1,066,987✔
107
  LOAD_FUNC(fp_taos_options_connection, "taos_options_connection");
1,066,987✔
108
  LOAD_FUNC(fp_taos_connect, "taos_connect");
1,066,987✔
109
  LOAD_FUNC(fp_taos_connect_totp, "taos_connect_totp");
1,066,987✔
110
  LOAD_FUNC(fp_taos_connect_token, "taos_connect_token");
1,066,987✔
111
  LOAD_FUNC(fp_taos_connect_test, "taos_connect_test");
1,066,987✔
112
  LOAD_FUNC(fp_taos_connect_auth, "taos_connect_auth");
1,066,987✔
113
  LOAD_FUNC(fp_taos_connect_with, "taos_connect_with");
1,066,987✔
114
  LOAD_FUNC(fp_taos_connect_with_dsn, "taos_connect_with_dsn");
1,066,987✔
115
  LOAD_FUNC(fp_taos_close, "taos_close");
1,066,987✔
116

117
  LOAD_FUNC(fp_taos_data_type, "taos_data_type");
1,066,987✔
118

119
  LOAD_FUNC(fp_taos_stmt_init, "taos_stmt_init");
1,066,987✔
120
  LOAD_FUNC(fp_taos_stmt_init_with_reqid, "taos_stmt_init_with_reqid");
1,066,987✔
121
  LOAD_FUNC(fp_taos_stmt_init_with_options, "taos_stmt_init_with_options");
1,066,987✔
122
  LOAD_FUNC(fp_taos_stmt_prepare, "taos_stmt_prepare");
1,066,987✔
123
  LOAD_FUNC(fp_taos_stmt_set_tbname_tags, "taos_stmt_set_tbname_tags");
1,066,987✔
124
  LOAD_FUNC(fp_taos_stmt_set_tbname, "taos_stmt_set_tbname");
1,066,987✔
125
  LOAD_FUNC(fp_taos_stmt_set_tags, "taos_stmt_set_tags");
1,066,987✔
126
  LOAD_FUNC(fp_taos_stmt_set_sub_tbname, "taos_stmt_set_sub_tbname");
1,066,987✔
127
  LOAD_FUNC(fp_taos_stmt_get_tag_fields, "taos_stmt_get_tag_fields");
1,066,987✔
128
  LOAD_FUNC(fp_taos_stmt_get_col_fields, "taos_stmt_get_col_fields");
1,066,987✔
129
  LOAD_FUNC(fp_taos_stmt_reclaim_fields, "taos_stmt_reclaim_fields");
1,066,987✔
130

131
  LOAD_FUNC(fp_taos_stmt_is_insert, "taos_stmt_is_insert");
1,066,987✔
132
  LOAD_FUNC(fp_taos_stmt_num_params, "taos_stmt_num_params");
1,066,987✔
133
  LOAD_FUNC(fp_taos_stmt_get_param, "taos_stmt_get_param");
1,066,987✔
134
  LOAD_FUNC(fp_taos_stmt_bind_param, "taos_stmt_bind_param");
1,066,987✔
135
  LOAD_FUNC(fp_taos_stmt_bind_param_batch, "taos_stmt_bind_param_batch");
1,066,987✔
136
  LOAD_FUNC(fp_taos_stmt_bind_single_param_batch, "taos_stmt_bind_single_param_batch");
1,066,987✔
137
  LOAD_FUNC(fp_taos_stmt_add_batch, "taos_stmt_add_batch");
1,066,987✔
138
  LOAD_FUNC(fp_taos_stmt_execute, "taos_stmt_execute");
1,066,987✔
139
  LOAD_FUNC(fp_taos_stmt_use_result, "taos_stmt_use_result");
1,066,987✔
140
  LOAD_FUNC(fp_taos_stmt_close, "taos_stmt_close");
1,066,987✔
141
  LOAD_FUNC(fp_taos_stmt_errstr, "taos_stmt_errstr");
1,066,987✔
142
  LOAD_FUNC(fp_taos_stmt_affected_rows, "taos_stmt_affected_rows");
1,066,987✔
143
  LOAD_FUNC(fp_taos_stmt_affected_rows_once, "taos_stmt_affected_rows_once");
1,066,987✔
144

145
  LOAD_FUNC(fp_taos_stmt2_init, "taos_stmt2_init");
1,066,987✔
146
  LOAD_FUNC(fp_taos_stmt2_prepare, "taos_stmt2_prepare");
1,066,987✔
147
  LOAD_FUNC(fp_taos_stmt2_bind_param, "taos_stmt2_bind_param");
1,066,987✔
148
  LOAD_FUNC(fp_taos_stmt2_bind_param_a, "taos_stmt2_bind_param_a");
1,066,987✔
149
  LOAD_FUNC(fp_taos_stmt2_exec, "taos_stmt2_exec");
1,066,987✔
150
  LOAD_FUNC(fp_taos_stmt2_close, "taos_stmt2_close");
1,066,987✔
151
  LOAD_FUNC(fp_taos_stmt2_is_insert, "taos_stmt2_is_insert");
1,066,987✔
152
  LOAD_FUNC(fp_taos_stmt2_get_fields, "taos_stmt2_get_fields");
1,066,987✔
153
  LOAD_FUNC(fp_taos_stmt2_free_fields, "taos_stmt2_free_fields");
1,066,987✔
154
  LOAD_FUNC(fp_taos_stmt2_result, "taos_stmt2_result");
1,066,987✔
155
  LOAD_FUNC(fp_taos_stmt2_error, "taos_stmt2_error");
1,066,987✔
156

157
  LOAD_FUNC(fp_taos_query, "taos_query");
1,066,987✔
158
  LOAD_FUNC(fp_taos_query_with_reqid, "taos_query_with_reqid");
1,066,987✔
159

160
  LOAD_FUNC(fp_taos_fetch_row, "taos_fetch_row");
1,066,987✔
161
  LOAD_FUNC(fp_taos_result_precision, "taos_result_precision");
1,066,987✔
162
  LOAD_FUNC(fp_taos_free_result, "taos_free_result");
1,066,987✔
163
  LOAD_FUNC(fp_taos_kill_query, "taos_kill_query");
1,066,987✔
164
  LOAD_FUNC(fp_taos_field_count, "taos_field_count");
1,066,987✔
165
  LOAD_FUNC(fp_taos_num_fields, "taos_num_fields");
1,066,987✔
166
  LOAD_FUNC(fp_taos_affected_rows, "taos_affected_rows");
1,066,987✔
167
  LOAD_FUNC(fp_taos_affected_rows64, "taos_affected_rows64");
1,066,987✔
168

169
  LOAD_FUNC(fp_taos_fetch_fields, "taos_fetch_fields");
1,066,987✔
170
  LOAD_FUNC(fp_taos_fetch_fields_e, "taos_fetch_fields_e");
1,066,987✔
171
  LOAD_FUNC(fp_taos_select_db, "taos_select_db");
1,066,987✔
172
  LOAD_FUNC(fp_taos_print_row, "taos_print_row");
1,066,987✔
173
  LOAD_FUNC(fp_taos_print_row_with_size, "taos_print_row_with_size");
1,066,987✔
174
  LOAD_FUNC(fp_taos_stop_query, "taos_stop_query");
1,066,987✔
175
  LOAD_FUNC(fp_taos_is_null, "taos_is_null");
1,066,987✔
176
  LOAD_FUNC(fp_taos_is_null_by_column, "taos_is_null_by_column");
1,066,987✔
177
  LOAD_FUNC(fp_taos_is_update_query, "taos_is_update_query");
1,066,987✔
178
  LOAD_FUNC(fp_taos_fetch_block, "taos_fetch_block");
1,066,987✔
179
  LOAD_FUNC(fp_taos_fetch_block_s, "taos_fetch_block_s");
1,066,987✔
180
  LOAD_FUNC(fp_taos_fetch_raw_block, "taos_fetch_raw_block");
1,066,987✔
181
  LOAD_FUNC(fp_taos_get_column_data_offset, "taos_get_column_data_offset");
1,066,987✔
182
  LOAD_FUNC(fp_taos_validate_sql, "taos_validate_sql");
1,066,987✔
183
  LOAD_FUNC(fp_taos_reset_current_db, "taos_reset_current_db");
1,066,987✔
184

185
  LOAD_FUNC(fp_taos_fetch_lengths, "taos_fetch_lengths");
1,066,987✔
186
  LOAD_FUNC(fp_taos_result_block, "taos_result_block");
1,066,987✔
187

188
  LOAD_FUNC(fp_taos_get_server_info, "taos_get_server_info");
1,066,987✔
189
  LOAD_FUNC(fp_taos_get_client_info, "taos_get_client_info");
1,066,987✔
190
  LOAD_FUNC(fp_taos_get_current_db, "taos_get_current_db");
1,066,987✔
191
  LOAD_FUNC(fp_taos_get_connection_info, "taos_get_connection_info");
1,066,987✔
192

193
  LOAD_FUNC(fp_taos_errstr, "taos_errstr");
1,066,987✔
194
  LOAD_FUNC(fp_taos_errno, "taos_errno");
1,066,987✔
195

196
  LOAD_FUNC(fp_taos_query_a, "taos_query_a");
1,066,987✔
197
  LOAD_FUNC(fp_taos_query_a_with_reqid, "taos_query_a_with_reqid");
1,066,987✔
198
  LOAD_FUNC(fp_taos_fetch_rows_a, "taos_fetch_rows_a");
1,066,987✔
199
  LOAD_FUNC(fp_taos_fetch_raw_block_a, "taos_fetch_raw_block_a");
1,066,987✔
200
  LOAD_FUNC(fp_taos_get_raw_block, "taos_get_raw_block");
1,066,987✔
201

202
  LOAD_FUNC(fp_taos_get_db_route_info, "taos_get_db_route_info");
1,066,987✔
203
  LOAD_FUNC(fp_taos_get_table_vgId, "taos_get_table_vgId");
1,066,987✔
204
  LOAD_FUNC(fp_taos_get_tables_vgId, "taos_get_tables_vgId");
1,066,987✔
205

206
  LOAD_FUNC(fp_taos_load_table_info, "taos_load_table_info");
1,066,987✔
207

208
  LOAD_FUNC(fp_taos_set_hb_quit, "taos_set_hb_quit");
1,066,987✔
209

210
  LOAD_FUNC(fp_taos_set_notify_cb, "taos_set_notify_cb");
1,066,987✔
211

212
  LOAD_FUNC(fp_taos_fetch_whitelist_a, "taos_fetch_whitelist_a");
1,066,987✔
213

214
  LOAD_FUNC(fp_taos_fetch_whitelist_dual_stack_a, "taos_fetch_whitelist_dual_stack_a");
1,066,987✔
215
  LOAD_FUNC(fp_taos_fetch_ip_whitelist_a, "taos_fetch_ip_whitelist_a");
1,066,987✔
216
  LOAD_FUNC(fp_taos_fetch_datetime_whitelist_a, "taos_fetch_datetime_whitelist_a");
1,066,987✔
217

218
  LOAD_FUNC(fp_taos_set_conn_mode, "taos_set_conn_mode");
1,066,987✔
219

220
  LOAD_FUNC(fp_taos_schemaless_insert, "taos_schemaless_insert");
1,066,987✔
221
  LOAD_FUNC(fp_taos_schemaless_insert_with_reqid, "taos_schemaless_insert_with_reqid");
1,066,987✔
222
  LOAD_FUNC(fp_taos_schemaless_insert_raw, "taos_schemaless_insert_raw");
1,066,987✔
223
  LOAD_FUNC(fp_taos_schemaless_insert_raw_with_reqid, "taos_schemaless_insert_raw_with_reqid");
1,066,987✔
224
  LOAD_FUNC(fp_taos_schemaless_insert_ttl, "taos_schemaless_insert_ttl");
1,066,987✔
225
  LOAD_FUNC(fp_taos_schemaless_insert_ttl_with_reqid, "taos_schemaless_insert_ttl_with_reqid");
1,066,987✔
226
  LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl, "taos_schemaless_insert_raw_ttl");
1,066,987✔
227
  LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl_with_reqid, "taos_schemaless_insert_raw_ttl_with_reqid");
1,066,987✔
228
  LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key,
1,066,987✔
229
            "taos_schemaless_insert_raw_ttl_with_reqid_tbname_key");
230
  LOAD_FUNC(fp_taos_schemaless_insert_ttl_with_reqid_tbname_key, "taos_schemaless_insert_ttl_with_reqid_tbname_key");
1,066,987✔
231

232
  LOAD_FUNC(fp_tmq_conf_new, "tmq_conf_new");
1,066,987✔
233
  LOAD_FUNC(fp_tmq_conf_set, "tmq_conf_set");
1,066,987✔
234
  LOAD_FUNC(fp_tmq_conf_destroy, "tmq_conf_destroy");
1,066,987✔
235
  LOAD_FUNC(fp_tmq_conf_set_auto_commit_cb, "tmq_conf_set_auto_commit_cb");
1,066,987✔
236

237
  LOAD_FUNC(fp_tmq_list_new, "tmq_list_new");
1,066,987✔
238
  LOAD_FUNC(fp_tmq_list_append, "tmq_list_append");
1,066,987✔
239
  LOAD_FUNC(fp_tmq_list_destroy, "tmq_list_destroy");
1,066,987✔
240
  LOAD_FUNC(fp_tmq_list_get_size, "tmq_list_get_size");
1,066,987✔
241
  LOAD_FUNC(fp_tmq_list_to_c_array, "tmq_list_to_c_array");
1,066,987✔
242

243
  LOAD_FUNC(fp_tmq_consumer_new, "tmq_consumer_new");
1,066,987✔
244
  LOAD_FUNC(fp_tmq_subscribe, "tmq_subscribe");
1,066,987✔
245
  LOAD_FUNC(fp_tmq_unsubscribe, "tmq_unsubscribe");
1,066,987✔
246
  LOAD_FUNC(fp_tmq_subscription, "tmq_subscription");
1,066,987✔
247
  LOAD_FUNC(fp_tmq_consumer_poll, "tmq_consumer_poll");
1,066,987✔
248
  LOAD_FUNC(fp_tmq_consumer_close, "tmq_consumer_close");
1,066,987✔
249
  LOAD_FUNC(fp_tmq_commit_sync, "tmq_commit_sync");
1,066,987✔
250
  LOAD_FUNC(fp_tmq_commit_async, "tmq_commit_async");
1,066,987✔
251
  LOAD_FUNC(fp_tmq_commit_offset_sync, "tmq_commit_offset_sync");
1,066,987✔
252
  LOAD_FUNC(fp_tmq_commit_offset_async, "tmq_commit_offset_async");
1,066,987✔
253
  LOAD_FUNC(fp_tmq_get_topic_assignment, "tmq_get_topic_assignment");
1,066,987✔
254
  LOAD_FUNC(fp_tmq_free_assignment, "tmq_free_assignment");
1,066,987✔
255
  LOAD_FUNC(fp_tmq_offset_seek, "tmq_offset_seek");
1,066,987✔
256
  LOAD_FUNC(fp_tmq_position, "tmq_position");
1,066,987✔
257
  LOAD_FUNC(fp_tmq_committed, "tmq_committed");
1,066,987✔
258

259
  LOAD_FUNC(fp_tmq_get_connect, "tmq_get_connect");
1,066,987✔
260
  LOAD_FUNC(fp_tmq_get_table_name, "tmq_get_table_name");
1,066,987✔
261
  LOAD_FUNC(fp_tmq_get_res_type, "tmq_get_res_type");
1,066,987✔
262
  LOAD_FUNC(fp_tmq_get_topic_name, "tmq_get_topic_name");
1,066,987✔
263
  LOAD_FUNC(fp_tmq_get_db_name, "tmq_get_db_name");
1,066,987✔
264
  LOAD_FUNC(fp_tmq_get_vgroup_id, "tmq_get_vgroup_id");
1,066,987✔
265
  LOAD_FUNC(fp_tmq_get_vgroup_offset, "tmq_get_vgroup_offset");
1,066,987✔
266
  LOAD_FUNC(fp_tmq_err2str, "tmq_err2str");
1,066,987✔
267

268
  LOAD_FUNC(fp_tmq_get_raw, "tmq_get_raw");
1,066,987✔
269
  LOAD_FUNC(fp_tmq_write_raw, "tmq_write_raw");
1,066,987✔
270
  LOAD_FUNC(fp_taos_write_raw_block, "taos_write_raw_block");
1,066,987✔
271
  LOAD_FUNC(fp_taos_write_raw_block_with_reqid, "taos_write_raw_block_with_reqid");
1,066,987✔
272
  LOAD_FUNC(fp_taos_write_raw_block_with_fields, "taos_write_raw_block_with_fields");
1,066,987✔
273
  LOAD_FUNC(fp_taos_write_raw_block_with_fields_with_reqid, "taos_write_raw_block_with_fields_with_reqid");
1,066,987✔
274
  LOAD_FUNC(fp_tmq_free_raw, "tmq_free_raw");
1,066,987✔
275

276
  LOAD_FUNC(fp_tmq_get_json_meta, "tmq_get_json_meta");
1,066,987✔
277
  LOAD_FUNC(fp_tmq_free_json_meta, "tmq_free_json_meta");
1,066,987✔
278

279
  LOAD_FUNC(fp_taos_check_server_status, "taos_check_server_status");
1,066,987✔
280
  LOAD_FUNC(fp_taos_write_crashinfo, "taos_write_crashinfo");
1,066,987✔
281
  LOAD_FUNC(fp_getBuildInfo, "getBuildInfo");
1,066,987✔
282

283
  LOAD_FUNC(fp_taos_connect_is_alive, "taos_connect_is_alive");
1,066,987✔
284

285
  code = 0;
1,066,987✔
286

287
_OVER:
1,066,987✔
288
  if (code != 0) {
1,066,987✔
289
    printf("failed to load function %s from %s since %s [0x%X]\r\n", funcName, driverPath, terrstr(), terrno);
×
290
    showWrapperHint(terrno);
×
UNCOV
291
    taosDriverCleanup();
×
292
  }
293

294
  return code;
1,066,987✔
295
}
296

UNCOV
297
void taosDriverCleanup() {
×
UNCOV
298
  if (tsDriver != NULL) {
×
UNCOV
299
    taosCloseDll(tsDriver);
×
UNCOV
300
    tsDriver = NULL;
×
301
  }
UNCOV
302
}
×
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