new-libtaos-with-ws (#29971)

* enh: rename libtaos.so to libtaosinternal.so

* enh: let python system-test work

* enh: shell for libinternal.so

* enh: refact script

* enh: wrapper for libtaosinternal

* enh: rename some files

* enh: let shell support internal driver

* enh: minor changes

* enh: minor changes

* add intenal.h

* enh: remove unused codes

* enh: minor changs

* feat: mac os issues

* enh: let python test use internal connection

* enh: let nettest work

* enh: let taosc -C work

* enh: test shell in mac os

* enh: minor changes

* enh: let libtaosinternal.so work in linux

* enh: update install script

* enh: for ci

* enh: for windows compile

* enh: minor changes

* enh: compile in windows

* enh: minor changes

* enh: taosinternal work in windows

* enh: add taos_internal_static

* enh: rollback os_for_wrapper

* fix: conflicts

* fix: conflicts

* fix: compile errors

* fix: conflicts

* enh: rename taosinternal to taosnative

* enh: rename taosinternal to taosnative

* fix: compile error

* enh: remove taosnative.h

* fix: compile errors

* enh: set default shell options

* fix: compile errors

* fix: compile errors

* debug: switch taosws branch to feat/new-libtaos-with-ws

* enh: taosBenchmark remove WEBSOCKET finished

* fix: CMakeLists.txt remove WEBSOCKET

* fix: compile errors

* fix: taosBenchmark delete restful code

* .gitignore remove taos-tools folder

* fix: remove taosdump WEBSOCKET MACRO

* fix: build error for taosdump

* fix: build project passed

* fix: support -Z for connect mode

* fix: build error

* fix: build error fixed

* fix: add -Z options

* fix: native and websocket with string

* fix: -Z option core

* fix: build unit test

* fix: build error

* fix: add colon for array

* fix: unit test can not include fun

* fix: CTest pointer null is nullptr

* fix: include pub.h

* fix: taosdump add -Z --driver options

* fix: taosdump support -Z with pub.h pub.c

* fix: toolsGetTimeDay move to pub.c

* fix: restore pub.c only simple fun

* fix: add error tips

* fix: tmfree remove from taosdump

* fix: remove double declare taos variant

* fix: taos support -Z option

* enh: configDir set with main fun

* fix: add g_arguments.configDir

* fix: show tips add cfgdir

* fix: g_argument is pointer

* fix: configDir is global var

* fix: declare g_configDir in benchMain.c

* fix: taos version not show on websocket

* stmt2 websocket prepare with supertable

* stmt2 websocket prepare build

* fix: stmt and stmt2 prepare add db name

* fix: remove -R --restful test case

* fix: taosBenchmark adjust priority cmd > json > evn

* fix: add connect mode test case connMode.py

* fix: clear evn and add host port check

* fix: army/test.py modify start taosAdapter is default

* change: system-test/test.py default start taosAdapter

* fix: add taosAdapter variant to system-test/test.py

* fix: -y must put behind other options

* fix: remove rest sml and add -N normal case

* fix: add -c work cfg test case

* del: queryMain.py remove rest query

* fix: remove groups have a blank append bug

* fix: caseBase.py add db in sql query

* fix: query_json.py remove rest test

* fix: taosBenchmark uniform dsn describe

* fix: add pub.h pub.c to tools public

* fix: case remove restful interface

* fix: build error

* fix: taosDriverCleanup no arg call

* fix: taosdump add test conn mode case taosdumpCommandline.py

* fix: modify insertFullType.json db name

* fix: taosdump connMode test case taosDumpCommandline.py passed

* enh: priority cmd > env > json

* fix: taosCli remove is_native variant

* fix: password is not pointer

* fix: comment -o test case

* fix: solve fun return code check

* fix: windows unresolved strcasecmp

* fix: remove coverHostToServAddr

* fix: forbid check ODR violation

* ci: trigger pr run

* fix: build error not del >>>>>3.0

* fix: support json dbinfo->vgroups have blank space

* fix: solve conflict with merge

* fix: with TrimCaseCmp fun to compare vgroups

* fix: del vgroups support blank code

* feat: wrapper add taos_fetch_fields_e

* fix: move jni from libtaosnative.so to libtaos.so

* fix: move clientTmqConnector.c for jni

* fix: fix assert check with del comment code

* fix: taosBenchmark add prepare stmt debug log

* fix: stmt2 already have debug log on preapare

* fix:  (double)LLONG_MAX force covert

* fix: stmt insert normal table with websocket

* fix: normal table with stmt too many ?

* fix: taosdump stmt_prepare with child tbname

* fix: build error add int code

* feat: stmtPrepare with child table to do

* taos -a options move to native test case

* fix:unit test benchmarkTest passed

* fix: query_json-with-sqlfile.py case no check results

* fix: queryMain.py case lost, put in tasks again

---------

Co-authored-by: Shengliang Guan <slguan@taosdata.com>
This commit is contained in:
Alex Duan 2025-03-20 22:54:29 +08:00 committed by GitHub
parent 455cade3cc
commit c133489917
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
151 changed files with 4007 additions and 6129 deletions

1
.gitignore vendored
View File

@ -59,7 +59,6 @@ tools/upx*
html/
/.vs
/CMakeFiles/3.10.2
/CMakeCache.txt
/Makefile
/*.cmake
/src/cq/test/CMakeFiles/cqtest.dir/*.cmake

View File

@ -361,6 +361,7 @@ def pre_test_build_win() {
pip3 install taospy==2.7.21
pip3 install taos-ws-py==0.3.8
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taosnative.dll C:\\Windows\\System32
'''
return 1
}
@ -379,7 +380,9 @@ def run_win_test() {
bat '''
echo "windows test ..."
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taosnative.dll C:\\Windows\\System32
ls -l C:\\Windows\\System32\\taos.dll
ls -l C:\\Windows\\System32\\taosnative.dll
time /t
cd %WIN_SYSTEM_TEST_ROOT%
echo "testing ..."

View File

@ -97,14 +97,10 @@ ELSE()
SET(TD_TAOS_TOOLS TRUE)
ENDIF()
SET(TAOS_LIB taos)
SET(TAOS_LIB taos)
SET(TAOS_LIB_STATIC taos_static)
IF(${TD_WINDOWS})
SET(TAOS_LIB_PLATFORM_SPEC taos_static)
ELSE()
SET(TAOS_LIB_PLATFORM_SPEC taos)
ENDIF()
SET(TAOS_NATIVE_LIB taosnative)
SET(TAOS_NATIVE_LIB_STATIC taosnative_static)
# build TSZ by default
IF("${TSZ_ENABLED}" MATCHES "false")

View File

@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
GIT_TAG main
GIT_TAG feat/new-libtaos-with-ws
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -682,7 +682,7 @@ The basic API is used to establish database connections and provide a runtime en
- **Interface Description**: Cleans up the runtime environment, should be called before the application exits.
- `int taos_options(TSDB_OPTION option, const void * arg, ...)`
- **Interface Description**: Sets client options, currently supports locale (`TSDB_OPTION_LOCALE`), character set (`TSDB_OPTION_CHARSET`), timezone (`TSDB_OPTION_TIMEZONE`), and configuration file path (`TSDB_OPTION_CONFIGDIR`). Locale, character set, and timezone default to the current settings of the operating system.
- **Interface Description**: Sets client options, currently supports locale (`TSDB_OPTION_LOCALE`), character set (`TSDB_OPTION_CHARSET`), timezone (`TSDB_OPTION_TIMEZONE`), configuration file path (`TSDB_OPTION_CONFIGDIR`), and driver type (`TSDB_OPTION_DRIVER`). Locale, character set, and timezone default to the current settings of the operating system. The driver type can be either the native interface(`native`) or the WebSocket interface(`websocket`), with the default being `websocket`.
- **Parameter Description**:
- `option`: [Input] Setting item type.
- `arg`: [Input] Setting item value.

View File

@ -41,6 +41,8 @@ This document details the server error codes that may be encountered when using
| 0x80000107 | Ref ID is removed | The referenced ref resource has been released | Preserve the scene and logs, report issue on github |
| 0x80000108 | Invalid Ref ID | Invalid ref ID | Preserve the scene and logs, report issue on github |
| 0x8000010A | Ref is not there | ref information does not exist | Preserve the scene and logs, report issue on github |
| 0x8000010B | Driver was not loaded | libtaosnative.so or libtaosws.so was not found in the system path | Reinstall the client driver |
| 0x8000010C | Function was not loaded from the driver | some function defined in libtaos.so are not implemented in libtaosnative.so or libtaosws.so | Reinstall the client driver |
| 0x80000110 | Unexpected generic error | System internal error | Preserve the scene and logs, report issue on github |
| 0x80000111 | Action in progress | Operation in progress | 1. Wait for the operation to complete 2. Cancel the operation if necessary 3. If it exceeds a reasonable time and still not completed, preserve the scene and logs, or contact customer support |
| 0x80000112 | Out of range | Configuration parameter exceeds allowed value range | Change the parameter |

View File

@ -680,7 +680,7 @@ TDengine 客户端驱动的版本号与 TDengine 服务端的版本号是一一
- **接口说明**:清理运行环境,应用退出前应调用。
- `int taos_options(TSDB_OPTION option, const void * arg, ...)`
- **接口说明**:设置客户端选项,支持区域设置(`TSDB_OPTION_LOCALE`)、字符集设置(`TSDB_OPTION_CHARSET`)、时区设置(`TSDB_OPTION_TIMEZONE`)、配置文件路径设置(`TSDB_OPTION_CONFIGDIR`)。区域设置、字符集、时区默认为操作系统当前设置。
- **接口说明**:设置客户端选项,支持区域设置(`TSDB_OPTION_LOCALE`)、字符集设置(`TSDB_OPTION_CHARSET`)、时区设置(`TSDB_OPTION_TIMEZONE`)、配置文件路径设置(`TSDB_OPTION_CONFIGDIR`、驱动类型设置(`TSDB_OPTION_DRIVER`。区域设置、字符集、时区默认为操作系统当前设置。驱动类型可选内部原生接口(`native`)和 WebSocket 接口(`websocket`),默认为 `websocket`。
- **参数说明**
- `option`[入参] 设置项类型。
- `arg`[入参] 设置项值。

View File

@ -44,6 +44,8 @@ description: TDengine 服务端的错误码列表和详细说明
| 0x80000107 | Ref ID is removed | 引用的 ref 资源已经释放 | 保留现场和日志github 上报 issue |
| 0x80000108 | Invalid Ref ID | 无效 ref ID | 保留现场和日志github 上报 issue |
| 0x8000010A | Ref is not there | ref 信息不存在 | 保留现场和日志github 上报 issue |
| 0x8000010B | Driver was not loaded | 未在系统路径中找到 libtaosnative.so 或 libtaosws.so | 重新安装客户端驱动 |
| 0x8000010C | Function was not loaded from the driver | 在 libtaos.so 中定义的一些函数在 libtaosnative.so 或 libtaosws.so 中未实现 | 保留现场和日志github 上报 issue |
| 0x80000110 | Unexpected generic error | 系统内部错误 | 保留现场和日志github 上报 issue |
| 0x80000111 | Action in progress | 操作进行中 | 1.等待操作完成 2.根据需要取消操作 3.当超出合理时间仍然未完成可保留现场和日志,或联系客户支持 |
| 0x80000112 | Out of range | 配置参数超出允许值范围 | 更改参数 |

View File

@ -42,27 +42,27 @@ IF(TD_LINUX)
)
target_link_libraries(tmq
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
target_link_libraries(stream_demo
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
target_link_libraries(schemaless
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
target_link_libraries(prepare
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
target_link_libraries(demo
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
target_link_libraries(asyncdemo
${TAOS_LIB}
${TAOS_NATIVE_LIB}
)
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)

View File

@ -62,6 +62,7 @@ typedef enum {
TSDB_OPTION_CONFIGDIR,
TSDB_OPTION_SHELL_ACTIVITY_TIMER,
TSDB_OPTION_USE_ADAPTER,
TSDB_OPTION_DRIVER,
TSDB_MAX_OPTIONS
} TSDB_OPTION;
@ -155,11 +156,14 @@ typedef enum {
TAOS_NOTIFY_USER_DROPPED = 2,
} TAOS_NOTIFY_TYPE;
/* -- implemented in the native interface, for internal component only, the API may change -- */
#define RET_MSG_LENGTH 1024
typedef struct setConfRet {
SET_CONF_RET_CODE retCode;
char retMsg[RET_MSG_LENGTH];
} setConfRet;
DLL_EXPORT setConfRet taos_set_config(const char *config); // implemented in the native interface
/* -- end -- */
typedef struct TAOS_VGROUP_HASH_INFO {
int32_t vgId;
@ -182,14 +186,13 @@ typedef struct TAOS_STMT_OPTIONS {
bool singleTableBindOnce;
} TAOS_STMT_OPTIONS;
DLL_EXPORT void taos_cleanup(void);
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
DLL_EXPORT int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...);
DLL_EXPORT setConfRet taos_set_config(const char *config);
DLL_EXPORT int taos_init(void);
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
DLL_EXPORT void taos_close(TAOS *taos);
DLL_EXPORT int taos_init(void);
DLL_EXPORT void taos_cleanup(void);
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
DLL_EXPORT int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...);
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
DLL_EXPORT void taos_close(TAOS *taos);
DLL_EXPORT const char *taos_data_type(int type);
@ -220,6 +223,7 @@ DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
/* -- implemented in the native interface, for internal component only, the API may change -- */
typedef void TAOS_STMT2;
typedef struct TAOS_STMT2_OPTION {
@ -257,6 +261,7 @@ DLL_EXPORT int taos_stmt2_get_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_AL
DLL_EXPORT void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields);
DLL_EXPORT TAOS_RES *taos_stmt2_result(TAOS_STMT2 *stmt);
DLL_EXPORT char *taos_stmt2_error(TAOS_STMT2 *stmt);
/* -- end -- */
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
DLL_EXPORT TAOS_RES *taos_query_with_reqid(TAOS *taos, const char *sql, int64_t reqId);
@ -313,9 +318,11 @@ DLL_EXPORT void taos_set_hb_quit(int8_t quitByKill);
DLL_EXPORT int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type);
/* -- implemented in the native interface, for internal component only, the API may change -- */
typedef void (*__taos_async_whitelist_fn_t)(void *param, int code, TAOS *taos, int numOfWhiteLists,
uint64_t *pWhiteLists);
DLL_EXPORT void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param);
/* ---- end ---- */
typedef enum {
TAOS_CONN_MODE_BI = 0,
@ -414,7 +421,7 @@ DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES *res);
DLL_EXPORT const char *tmq_err2str(int32_t code);
/* ------------------------------ TAOSX INTERFACE -----------------------------------*/
/* -- implemented in the native interface, for internal component(TAOSX) only, the API may change -- */
typedef struct tmq_raw_data {
void *raw;
uint32_t raw_len;
@ -435,8 +442,9 @@ DLL_EXPORT void tmq_free_raw(tmq_raw_data raw);
// Returning null means error. Returned result need to be freed by tmq_free_json_meta
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res);
DLL_EXPORT void tmq_free_json_meta(char *jsonMeta);
/* ---------------------------- TAOSX END -------------------------------- */
/* ---- end ---- */
/* -- implemented in the native interface, for internal component only, the API may change -- */
typedef enum {
TSDB_SRV_STATUS_UNAVAILABLE = 0,
TSDB_SRV_STATUS_NETWORK_OK = 1,
@ -446,7 +454,10 @@ typedef enum {
} TSDB_SERVER_STATUS;
DLL_EXPORT TSDB_SERVER_STATUS taos_check_server_status(const char *fqdn, int port, char *details, int maxlen);
DLL_EXPORT void taos_write_crashinfo(int signum, void *sigInfo, void *context);
DLL_EXPORT char *getBuildInfo();
/* ---- end ---- */
#ifdef __cplusplus
}
#endif

View File

@ -54,6 +54,7 @@ extern "C" {
#include <sys/wait.h>
#if defined(DARWIN)
#include <pwd.h>
#else
#if !defined(TD_ASTRA)
#include <argp.h>

View File

@ -112,7 +112,9 @@ bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
char *taosGetDirEntryName(TdDirEntryPtr pDirEntry);
int32_t taosCloseDir(TdDirPtr *ppDir);
int taosGetDirSize(const char *path, int64_t *size);
int32_t taosAppPath(char *path, int32_t maxLen);
int32_t taosGetDirSize(const char *path, int64_t *size);
#ifdef __cplusplus
}
#endif

View File

@ -46,10 +46,12 @@ int32_t taosEOFCmd(TdCmdPtr pCmd);
void taosCloseCmd(TdCmdPtr *ppCmd);
void *taosLoadDll(const char *filename);
void *taosLoadDll(const char *fileName);
void taosCloseDll(void *handle);
void *taosLoadDllFunc(void *handle, const char *funcName);
int32_t taosSetConsoleEcho(bool on);
int32_t taosSetTerminalMode();

View File

@ -117,6 +117,8 @@ int32_t taosGetErrSize();
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) // internal
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109) // internal
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A) // internal
#define TSDB_CODE_DLL_NOT_LOAD TAOS_DEF_ERROR_CODE(0, 0x010B)
#define TSDB_CODE_DLL_FUNC_NOT_LOAD TAOS_DEF_ERROR_CODE(0, 0x010C)
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110) //
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111) // internal

View File

@ -152,10 +152,14 @@ function check_lib_path() {
# check all links
check_link ${lib_link_dir}/libtaos.so
check_link ${lib_link_dir}/libtaos.so.1
check_link ${lib_link_dir}/libtaosnative.so
check_link ${lib_link_dir}/libtaosnative.so.1
if [[ -d ${lib64_link_dir} ]]; then
check_link ${lib64_link_dir}/libtaos.so
check_link ${lib64_link_dir}/libtaos.so.1
check_link ${lib64_link_dir}/libtaosnative.so
check_link ${lib64_link_dir}/libtaosnative.so.1
fi
echo -e "Check lib path:\033[32mOK\033[0m!"
}

View File

@ -80,4 +80,5 @@ fi
# there can not libtaos.so*, otherwise ln -s error
${csudo}rm -f ${install_main_dir}/driver/libtaos.* || :
${csudo}rm -f ${install_main_dir}/driver/libtaosnative.* || :
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}rm -f ${install_main_dir}/driver/libtaosws.so || :

View File

@ -44,6 +44,8 @@ else
${csudo}rm -f ${inc_link_dir}/taosws.h || :
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :

View File

@ -31,6 +31,7 @@ mkdir -p ${pkg_dir}
cd ${pkg_dir}
libfile="libtaos.so.${tdengine_ver}"
nativelibfile="libtaosnative.so.${tdengine_ver}"
wslibfile="libtaosws.so"
# create install dir
@ -120,11 +121,12 @@ fi
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
cp ${compile_dir}/build/lib/${nativelibfile} ${pkg_dir}${install_home_path}/driver
[ -f ${compile_dir}/build/lib/${wslibfile} ] && cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||:
cp ${compile_dir}/../include/client/taos.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../include/common/taosdef.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../include/util/taoserror.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../include/util/tdef.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../include/util/tdef.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../include/libs/function/taosudf.h ${pkg_dir}${install_home_path}/include
[ -f ${compile_dir}/build/include/taosws.h ] && cp ${compile_dir}/build/include/taosws.h ${pkg_dir}${install_home_path}/include ||:
cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples

View File

@ -44,6 +44,7 @@ echo version: %{_version}
echo buildroot: %{buildroot}
libfile="libtaos.so.%{_version}"
nativelibfile="libtaosnative.so.%{_version}"
wslibfile="libtaosws.so"
# create install path, and cp file
@ -112,11 +113,12 @@ if [ -f %{_compiledir}/build/bin/taosadapter ]; then
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin
fi
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/build/lib/${nativelibfile} %{buildroot}%{homepath}/driver
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
cp %{_compiledir}/../include/client/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/common/taosdef.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/util/taoserror.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/util/tdef.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/util/tdef.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include
[ -f %{_compiledir}/build/include/taosws.h ] && cp %{_compiledir}/build/include/taosws.h %{buildroot}%{homepath}/include ||:
#cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
@ -246,6 +248,8 @@ if [ $1 -eq 0 ];then
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
${csudo}rm -f ${inc_link_dir}/taows.h || :
${csudo}rm -f ${lib_link_dir}/libtaos.so || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.so || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.so || :
${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :

View File

@ -271,17 +271,23 @@ function install_lib() {
# Remove links
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
#${csudo}rm -rf ${v15_java_app_dir} || :
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
${csudo}ln -sf ${install_main_dir}/driver/libtaosnative.* ${lib_link_dir}/libtaosnative.so.1
${csudo}ln -sf ${lib_link_dir}/libtaosnative.so.1 ${lib_link_dir}/libtaosnative.so
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || :
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
${csudo}ln -sf ${install_main_dir}/driver/libtaosnative.* ${lib64_link_dir}/libtaosnative.so.1 || :
${csudo}ln -sf ${lib64_link_dir}/libtaosnative.so.1 ${lib64_link_dir}/libtaosnative.so || :
[ -f ${install_main_dir}/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
fi

View File

@ -134,6 +134,7 @@ function install_bin() {
function clean_lib() {
sudo rm -f /usr/lib/libtaos.* || :
sudo rm -f /usr/lib/libtaosnative.* || :
[ -f /usr/lib/libtaosws.so ] && sudo rm -f /usr/lib/libtaosws.so || :
[ -f /usr/lib64/libtaosws.so ] && sudo rm -f /usr/lib64/libtaosws.so || :
sudo rm -rf ${lib_dir} || :
@ -143,6 +144,8 @@ function install_lib() {
# Remove links
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
@ -154,18 +157,24 @@ function install_lib() {
if [ "$osType" != "Darwin" ]; then
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
${csudo}ln -s ${install_main_dir}/driver/libtaosnative.* ${lib_link_dir}/libtaosnative.so.1
${csudo}ln -s ${lib_link_dir}/libtaosnative.so.1 ${lib_link_dir}/libtaosnative.so
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so ||:
if [ -d "${lib64_link_dir}" ]; then
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
${csudo}ln -s ${install_main_dir}/driver/libtaosnative.* ${lib64_link_dir}/libtaosnative.so.1 || :
${csudo}ln -s ${lib64_link_dir}/libtaosnative.so.1 ${lib64_link_dir}/libtaosnative.so || :
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
fi
else
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib
${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
${csudo}ln -s ${install_main_dir}/driver/libtaosnative.* ${lib_link_dir}/libtaosnative.1.dylib
${csudo}ln -s ${lib_link_dir}/libtaosnative.1.dylib ${lib_link_dir}/libtaosnative.dylib
[ -f ${install_main_dir}/driver/libtaosws.dylib ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.dylib ${lib_link_dir}/libtaosws.dylib ||:
fi
@ -178,7 +187,7 @@ function install_lib() {
}
function install_header() {
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/tdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || :
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosws.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/tdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || :
${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h

View File

@ -66,6 +66,9 @@ copy %source_dir%\\include\\libs\\function\\taosudf.h %target_dir%\\include > nu
copy %binary_dir%\\build\\lib\\taos.lib %target_dir%\\driver > nul
copy %binary_dir%\\build\\lib\\taos_static.lib %target_dir%\\driver > nul
copy %binary_dir%\\build\\lib\\taos.dll %target_dir%\\driver > nul
copy %binary_dir%\\build\\lib\\taosnative.lib %target_dir%\\driver > nul
copy %binary_dir%\\build\\lib\\taosnative_static.lib %target_dir%\\driver > nul
copy %binary_dir%\\build\\lib\\taosnative.dll %target_dir%\\driver > nul
copy %binary_dir%\\build\\bin\\taos.exe %target_dir% > nul
if exist %binary_dir%\\build\\bin\\taosBenchmark.exe (
copy %binary_dir%\\build\\bin\\taosBenchmark.exe %target_dir% > nul
@ -149,12 +152,14 @@ call :check_svc taoskeeper
if exist c:\\windows\\sysnative (
echo x86
copy /y C:\\TDengine\\driver\\taos.dll %windir%\\sysnative > nul
copy /y C:\\TDengine\\driver\\taosnative.dll %windir%\\sysnative > nul
if exist C:\\TDengine\\driver\\taosws.dll (
copy /y C:\\TDengine\\driver\\taosws.dll %windir%\\sysnative > nul
)
) else (
echo x64
copy /y C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 > nul
copy /y C:\\TDengine\\driver\\taosnative.dll C:\\Windows\\System32 > nul
if exist C:\\TDengine\\driver\\taosws.dll (
copy /y C:\\TDengine\\driver\\taosws.dll C:\\Windows\\System32 > nul
)

View File

@ -313,9 +313,11 @@ function install_avro() {
function install_lib() {
# Remove links
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
if [ "$osType" != "Darwin" ]; then
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
fi
@ -324,6 +326,10 @@ function install_lib() {
${install_main_dir}/driver &&
${csudo}chmod 777 ${install_main_dir}/driver/libtaos.so.${verNumber}
${csudo}cp ${binary_dir}/build/lib/libtaosnative.so.${verNumber} \
${install_main_dir}/driver &&
${csudo}chmod 777 ${install_main_dir}/driver/libtaosnative.so.${verNumber}
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 > /dev/null 2>&1
${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so > /dev/null 2>&1
if [ -d "${lib64_link_dir}" ]; then
@ -331,6 +337,13 @@ function install_lib() {
${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so > /dev/null 2>&1
fi
${csudo}ln -sf ${install_main_dir}/driver/libtaosnative.* ${lib_link_dir}/libtaosnative.so.1 > /dev/null 2>&1
${csudo}ln -sf ${lib_link_dir}/libtaosnative.so.1 ${lib_link_dir}/libtaosnative.so > /dev/null 2>&1
if [ -d "${lib64_link_dir}" ]; then
${csudo}ln -sf ${install_main_dir}/driver/libtaosnative.* ${lib64_link_dir}/libtaosnative.so.1 > /dev/null 2>&1
${csudo}ln -sf ${lib64_link_dir}/libtaosnative.so.1 ${lib64_link_dir}/libtaosnative.so > /dev/null 2>&1
fi
if [ -f ${binary_dir}/build/lib/libtaosws.so ]; then
${csudo}cp ${binary_dir}/build/lib/libtaosws.so \
${install_main_dir}/driver &&
@ -342,11 +355,19 @@ function install_lib() {
${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
${csudo}cp -Rf ${binary_dir}/build/lib/libtaosnative.${verNumber}.dylib \
${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
${csudo}ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \
${lib_link_dir}/libtaos.1.dylib > /dev/null 2>&1 || :
${csudo}ln -sf ${install_main_dir}/driver/libtaosnative.${verNumber}.dylib \
${lib_link_dir}/libtaosnative.1.dylib > /dev/null 2>&1 || :
${csudo}ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib > /dev/null 2>&1 || :
${csudo}ln -sf ${lib_link_dir}/libtaosnative.1.dylib ${lib_link_dir}/libtaosnative.dylib > /dev/null 2>&1 || :
if [ -f ${binary_dir}/build/lib/libtaosws.dylib ]; then
${csudo}cp ${binary_dir}/build/lib/libtaosws.dylib \
${install_main_dir}/driver &&

View File

@ -79,10 +79,12 @@ if [ "$osType" != "Darwin" ]; then
${script_dir}/get_client.sh"
fi
lib_files="${build_dir}/lib/libtaos.so.${version}"
nativelib_files="${build_dir}/lib/libtaosnative.so.${version}"
wslib_files="${build_dir}/lib/libtaosws.so"
else
bin_files="${build_dir}/bin/${clientName} ${script_dir}/remove_client.sh"
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
nativelib_files="${build_dir}/lib/libtaosnative.${version}.dylib"
wslib_files="${build_dir}/lib/libtaosws.dylib"
fi
@ -224,6 +226,7 @@ fi
# Copy driver
mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver
cp ${nativelib_files} ${install_dir}/driver
# Copy connector
connector_dir="${code_dir}/connector"

View File

@ -108,9 +108,11 @@ fi
if [ "$osType" == "Darwin" ]; then
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
nativelib_files="${build_dir}/lib/libtaosnative.${version}.dylib"
wslib_files="${build_dir}/lib/libtaosws.dylib"
else
lib_files="${build_dir}/lib/libtaos.so.${version}"
nativelib_files="${build_dir}/lib/libtaosnative.so.${version}"
wslib_files="${build_dir}/lib/libtaosws.so"
fi
header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/util/tdef.h ${code_dir}/include/libs/function/taosudf.h"
@ -332,7 +334,7 @@ if [[ $dbName == "taos" ]]; then
fi
# Copy driver
mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt
mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && cp ${nativelib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt
[ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver || :
# Copy connector && taosx

View File

@ -205,18 +205,24 @@ function install_lib() {
log_print "start install lib from ${lib_dir} to ${lib_link_dir}"
${csudo}rm -f ${lib_link_dir}/libtaos* || :
${csudo}rm -f ${lib64_link_dir}/libtaos* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative* || :
[ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || :
[ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.${lib_file_ext_1} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib_link_dir}/libtaos.${lib_file_ext_1} ${lib_link_dir}/libtaos.${lib_file_ext} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib_dir}/libtaosnative.* ${lib_link_dir}/libtaosnative.${lib_file_ext_1} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib_link_dir}/libtaosnative.${lib_file_ext_1} ${lib_link_dir}/libtaosnative.${lib_file_ext} 2>>${install_log_path} || return 1
[ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||:
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.${lib_file_ext} ]]; then
${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.${lib_file_ext_1} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib64_link_dir}/libtaos.${lib_file_ext_1} ${lib64_link_dir}/libtaos.${lib_file_ext} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib_dir}/libtaosnative.* ${lib64_link_dir}/libtaosnative.${lib_file_ext_1} 2>>${install_log_path} || return 1
${csudo}ln -s ${lib64_link_dir}/libtaosnative.${lib_file_ext_1} ${lib64_link_dir}/libtaosnative.${lib_file_ext} 2>>${install_log_path} || return 1
[ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} 2>>${install_log_path}
fi

View File

@ -168,8 +168,10 @@ ${csudo}rm -f ${inc_link_dir}/tdef.h || :
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
${csudo}rm -f ${inc_link_dir}/taosws.h || :
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
${csudo}rm -f ${log_link_dir} || :

View File

@ -180,9 +180,11 @@ remove_bin() {
function clean_lib() {
# Remove link
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
[ -f ${lib_link_dir}/libtaosnative.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
[ -f ${lib64_link_dir}/libtaosnative.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
#${csudo}rm -rf ${v15_java_app_dir} || :
}

View File

@ -73,9 +73,11 @@ function clean_lib() {
# Remove link
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
[ -f ${lib_link_dir}/libtaosnative.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosnative.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
[ -f ${lib64_link_dir}/libtaosnative.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosnative.* || :
#${csudo}rm -rf ${v15_java_app_dir} || :
}

View File

@ -5,19 +5,19 @@ if(TD_ENTERPRISE)
endif()
if(TD_WINDOWS)
add_library(${TAOS_LIB} SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in)
add_library(${TAOS_NATIVE_LIB} SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taosnative.rc.in)
else()
add_library(${TAOS_LIB} SHARED ${CLIENT_SRC})
add_library(${TAOS_NATIVE_LIB} SHARED ${CLIENT_SRC})
endif()
if(${TD_DARWIN})
target_compile_options(${TAOS_LIB} PRIVATE -Wno-error=deprecated-non-prototype)
target_compile_options(${TAOS_NATIVE_LIB} PRIVATE -Wno-error=deprecated-non-prototype)
endif()
INCLUDE_DIRECTORIES(jni)
target_include_directories(
${TAOS_LIB}
${TAOS_NATIVE_LIB}
PUBLIC "${TD_SOURCE_DIR}/include/client"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
@ -26,46 +26,38 @@ if(${TAOSD_INTEGRATED})
set(TAOSD_MODULE "taosd")
endif()
target_link_libraries(
${TAOS_LIB}
${TAOS_NATIVE_LIB}
INTERFACE api
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry ${TAOSD_MODULE} decimal
)
if(TD_WINDOWS)
INCLUDE_DIRECTORIES(jni/windows)
INCLUDE_DIRECTORIES(jni/windows/win32)
INCLUDE_DIRECTORIES(jni/windows/win32/bridge)
else()
INCLUDE_DIRECTORIES(jni/linux)
endif()
set_target_properties(
${TAOS_LIB}
${TAOS_NATIVE_LIB}
PROPERTIES
CLEAN_DIRECT_OUTPUT
1
)
set_target_properties(
${TAOS_LIB}
${TAOS_NATIVE_LIB}
PROPERTIES
VERSION ${TD_VER_NUMBER}
SOVERSION 1
)
add_library(${TAOS_LIB_STATIC} STATIC ${CLIENT_SRC})
add_library(${TAOS_NATIVE_LIB_STATIC} STATIC ${CLIENT_SRC})
if(${TD_DARWIN})
target_compile_options(${TAOS_LIB_STATIC} PRIVATE -Wno-error=deprecated-non-prototype)
target_compile_options(${TAOS_NATIVE_LIB_STATIC} PRIVATE -Wno-error=deprecated-non-prototype)
endif()
target_include_directories(
${TAOS_LIB_STATIC}
${TAOS_NATIVE_LIB_STATIC}
PUBLIC "${TD_SOURCE_DIR}/include/client"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
target_link_libraries(
${TAOS_LIB_STATIC}
${TAOS_NATIVE_LIB_STATIC}
INTERFACE api
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry decimal
)
@ -73,3 +65,5 @@ target_link_libraries(
if(${BUILD_TEST})
ADD_SUBDIRECTORY(test)
endif(${BUILD_TEST})
ADD_SUBDIRECTORY(wrapper)

View File

@ -922,7 +922,7 @@ void tscStopCrashReport() {
}
}
void tscWriteCrashInfo(int signum, void *sigInfo, void *context) {
void taos_write_crashinfo(int signum, void *sigInfo, void *context) {
writeCrashLogToFile(signum, sigInfo, CUS_PROMPT, lastClusterId, appInfo.startTime);
}
#endif

View File

@ -15,10 +15,10 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Native C Driver for TDengine"
VALUE "FileDescription", "C Driver for TDengine"
VALUE "FileVersion", "${TD_VER_NUMBER}"
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
VALUE "LegalCopyright", "Copyright (C) 2025 TAOS Data"
VALUE "OriginalFilename", ""
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
VALUE "ProductVersion", "${TD_VER_NUMBER}"

View File

@ -0,0 +1,31 @@
1 VERSIONINFO
FILEVERSION ${TD_VER_NUMBER}
PRODUCTVERSION ${TD_VER_NUMBER}
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Internal C Driver for TDengine"
VALUE "FileVersion", "${TD_VER_NUMBER}"
VALUE "InternalName", "taosnative.dll(${TD_VER_CPUTYPE})"
VALUE "LegalCopyright", "Copyright (C) 2025 TAOS Data"
VALUE "OriginalFilename", ""
VALUE "ProductName", "taosnative.dll(${TD_VER_CPUTYPE})"
VALUE "ProductVersion", "${TD_VER_NUMBER}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -8,49 +8,49 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE(clientTest clientTests.cpp)
TARGET_LINK_LIBRARIES(
clientTest
os util common transport parser catalog scheduler gtest ${TAOS_LIB_STATIC} qcom executor function
os util common transport parser catalog scheduler gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor function
)
ADD_EXECUTABLE(connectOptionsTest connectOptionsTest.cpp)
TARGET_LINK_LIBRARIES(
connectOptionsTest
os util common transport parser catalog scheduler gtest ${TAOS_LIB_STATIC} qcom executor function
os util common transport parser catalog scheduler gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor function
)
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
TARGET_LINK_LIBRARIES(
tmqTest
PUBLIC os util common transport parser catalog scheduler function gtest ${TAOS_LIB_STATIC} qcom
PUBLIC os util common transport parser catalog scheduler function gtest ${TAOS_NATIVE_LIB_STATIC} qcom
)
ADD_EXECUTABLE(smlTest smlTest.cpp)
TARGET_LINK_LIBRARIES(
smlTest
PUBLIC os util common transport parser catalog scheduler function gtest ${TAOS_LIB_STATIC} qcom geometry
PUBLIC os util common transport parser catalog scheduler function gtest ${TAOS_NATIVE_LIB_STATIC} qcom geometry
)
#ADD_EXECUTABLE(clientMonitorTest clientMonitorTests.cpp)
#TARGET_LINK_LIBRARIES(
# clientMonitorTest
# PUBLIC os util common transport monitor parser catalog scheduler function gtest ${TAOS_LIB_STATIC} qcom executor
# PUBLIC os util common transport monitor parser catalog scheduler function gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor
#)
ADD_EXECUTABLE(userOperTest ../../../tests/script/api/passwdTest.c)
TARGET_LINK_LIBRARIES(
userOperTest
PUBLIC ${TAOS_LIB}
PUBLIC ${TAOS_NATIVE_LIB}
)
ADD_EXECUTABLE(stmt2Test stmt2Test.cpp)
TARGET_LINK_LIBRARIES(
stmt2Test
os util common transport parser catalog scheduler gtest ${TAOS_LIB_STATIC} qcom executor function
os util common transport parser catalog scheduler gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor function
)
ADD_EXECUTABLE(stmtTest stmtTest.cpp)
TARGET_LINK_LIBRARIES(
stmtTest
os util common transport parser catalog scheduler gtest ${TAOS_LIB_STATIC} qcom executor function
os util common transport parser catalog scheduler gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor function
)
TARGET_INCLUDE_DIRECTORIES(

View File

@ -0,0 +1,67 @@
aux_source_directory(src WRAPPER_SRC)
if(TD_WINDOWS)
add_library(${TAOS_LIB} SHARED ${WRAPPER_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/../src/taos.rc.in)
else()
add_library(${TAOS_LIB} SHARED ${WRAPPER_SRC})
endif()
if(${TD_DARWIN})
target_compile_options(${TAOS_LIB} PRIVATE -Wno-error=deprecated-non-prototype)
endif()
# jni include
INCLUDE_DIRECTORIES(jni)
if(TD_WINDOWS)
INCLUDE_DIRECTORIES(jni/windows)
INCLUDE_DIRECTORIES(jni/windows/win32)
INCLUDE_DIRECTORIES(jni/windows/win32/bridge)
else()
INCLUDE_DIRECTORIES(jni/linux)
endif()
target_include_directories(
${TAOS_LIB}
PUBLIC "${TD_SOURCE_DIR}/include/client"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
target_link_libraries(
${TAOS_LIB}
PUBLIC os util
)
set_target_properties(
${TAOS_LIB}
PROPERTIES
CLEAN_DIRECT_OUTPUT
1
)
set_target_properties(
${TAOS_LIB}
PROPERTIES
VERSION ${TD_VER_NUMBER}
SOVERSION 1
)
add_library(${TAOS_LIB_STATIC} STATIC ${WRAPPER_SRC})
if(${TD_DARWIN})
target_compile_options(${TAOS_LIB_STATIC} PRIVATE -Wno-error=deprecated-non-prototype)
endif()
target_include_directories(
${TAOS_LIB_STATIC}
PUBLIC "${TD_SOURCE_DIR}/include/client"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
target_link_libraries(
${TAOS_LIB_STATIC}
PUBLIC os util
)
# if(${BUILD_TEST})
# ADD_SUBDIRECTORY(test)
# endif(${BUILD_TEST})

View File

@ -0,0 +1,232 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_WRAPPER_H
#define TDENGINE_WRAPPER_H
#include "os.h"
#include "taos.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
DRIVER_NATIVE = 0,
DRIVER_WEBSOCKET = 1,
DRIVER_MAX = 2,
} EDriverType;
extern EDriverType tsDriverType;
extern void *tsDriver;
extern int32_t taosDriverInit(EDriverType driverType);
extern void taosDriverCleanup();
extern setConfRet (*fp_taos_set_config)(const char *config);
extern int (*fp_taos_init)(void);
extern void (*fp_taos_cleanup)(void);
extern int (*fp_taos_options)(TSDB_OPTION option, const void *arg, ...);
extern int (*fp_taos_options_connection)(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...);
extern TAOS *(*fp_taos_connect)(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
extern TAOS *(*fp_taos_connect_auth)(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
extern void (*fp_taos_close)(TAOS *taos);
extern const char *(*fp_taos_data_type)(int type);
extern TAOS_STMT *(*fp_taos_stmt_init)(TAOS *taos);
extern TAOS_STMT *(*fp_taos_stmt_init_with_reqid)(TAOS *taos, int64_t reqid);
extern TAOS_STMT *(*fp_taos_stmt_init_with_options)(TAOS *taos, TAOS_STMT_OPTIONS *options);
extern int (*fp_taos_stmt_prepare)(TAOS_STMT *stmt, const char *sql, unsigned long length);
extern int (*fp_taos_stmt_set_tbname_tags)(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags);
extern int (*fp_taos_stmt_set_tbname)(TAOS_STMT *stmt, const char *name);
extern int (*fp_taos_stmt_set_tags)(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags);
extern int (*fp_taos_stmt_set_sub_tbname)(TAOS_STMT *stmt, const char *name);
extern int (*fp_taos_stmt_get_tag_fields)(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
extern int (*fp_taos_stmt_get_col_fields)(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
extern void (*fp_taos_stmt_reclaim_fields)(TAOS_STMT *stmt, TAOS_FIELD_E *fields);
extern int (*fp_taos_stmt_is_insert)(TAOS_STMT *stmt, int *insert);
extern int (*fp_taos_stmt_num_params)(TAOS_STMT *stmt, int *nums);
extern int (*fp_taos_stmt_get_param)(TAOS_STMT *stmt, int idx, int *type, int *bytes);
extern int (*fp_taos_stmt_bind_param)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
extern int (*fp_taos_stmt_bind_param_batch)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
extern int (*fp_taos_stmt_bind_single_param_batch)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx);
extern int (*fp_taos_stmt_add_batch)(TAOS_STMT *stmt);
extern int (*fp_taos_stmt_execute)(TAOS_STMT *stmt);
extern TAOS_RES *(*fp_taos_stmt_use_result)(TAOS_STMT *stmt);
extern int (*fp_taos_stmt_close)(TAOS_STMT *stmt);
extern char *(*fp_taos_stmt_errstr)(TAOS_STMT *stmt);
extern int (*fp_taos_stmt_affected_rows)(TAOS_STMT *stmt);
extern int (*fp_taos_stmt_affected_rows_once)(TAOS_STMT *stmt);
extern TAOS_STMT2 *(*fp_taos_stmt2_init)(TAOS *taos, TAOS_STMT2_OPTION *option);
extern int (*fp_taos_stmt2_prepare)(TAOS_STMT2 *stmt, const char *sql, unsigned long length);
extern int (*fp_taos_stmt2_bind_param)(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx);
extern int (*fp_taos_stmt2_bind_param_a)(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx,
__taos_async_fn_t fp, void *param);
extern int (*fp_taos_stmt2_exec)(TAOS_STMT2 *stmt, int *affected_rows);
extern int (*fp_taos_stmt2_close)(TAOS_STMT2 *stmt);
extern int (*fp_taos_stmt2_is_insert)(TAOS_STMT2 *stmt, int *insert);
extern int (*fp_taos_stmt2_get_fields)(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields);
extern void (*fp_taos_stmt2_free_fields)(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields);
extern TAOS_RES *(*fp_taos_stmt2_result)(TAOS_STMT2 *stmt);
extern char *(*fp_taos_stmt2_error)(TAOS_STMT2 *stmt);
extern TAOS_RES *(*fp_taos_query)(TAOS *taos, const char *sql);
extern TAOS_RES *(*fp_taos_query_with_reqid)(TAOS *taos, const char *sql, int64_t reqId);
extern TAOS_ROW (*fp_taos_fetch_row)(TAOS_RES *res);
extern int (*fp_taos_result_precision)(TAOS_RES *res); // get the time precision of result
extern void (*fp_taos_free_result)(TAOS_RES *res);
extern void (*fp_taos_kill_query)(TAOS *taos);
extern int (*fp_taos_field_count)(TAOS_RES *res);
extern int (*fp_taos_num_fields)(TAOS_RES *res);
extern int (*fp_taos_affected_rows)(TAOS_RES *res);
extern int64_t (*fp_taos_affected_rows64)(TAOS_RES *res);
extern TAOS_FIELD *(*fp_taos_fetch_fields)(TAOS_RES *res);
extern TAOS_FIELD_E *(*fp_taos_fetch_fields_e)(TAOS_RES *res);
extern int (*fp_taos_select_db)(TAOS *taos, const char *db);
extern int (*fp_taos_print_row)(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
extern int (*fp_taos_print_row_with_size)(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
extern void (*fp_taos_stop_query)(TAOS_RES *res);
extern bool (*fp_taos_is_null)(TAOS_RES *res, int32_t row, int32_t col);
extern int (*fp_taos_is_null_by_column)(TAOS_RES *res, int columnIndex, bool result[], int *rows);
extern bool (*fp_taos_is_update_query)(TAOS_RES *res);
extern int (*fp_taos_fetch_block)(TAOS_RES *res, TAOS_ROW *rows);
extern int (*fp_taos_fetch_block_s)(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows);
extern int (*fp_taos_fetch_raw_block)(TAOS_RES *res, int *numOfRows, void **pData);
extern int *(*fp_taos_get_column_data_offset)(TAOS_RES *res, int columnIndex);
extern int (*fp_taos_validate_sql)(TAOS *taos, const char *sql);
extern void (*fp_taos_reset_current_db)(TAOS *taos);
extern int *(*fp_taos_fetch_lengths)(TAOS_RES *res);
extern TAOS_ROW *(*fp_taos_result_block)(TAOS_RES *res);
extern const char *(*fp_taos_get_server_info)(TAOS *taos);
extern const char *(*fp_taos_get_client_info)();
extern int (*fp_taos_get_current_db)(TAOS *taos, char *database, int len, int *required);
extern const char *(*fp_taos_errstr)(TAOS_RES *res);
extern int (*fp_taos_errno)(TAOS_RES *res);
extern void (*fp_taos_query_a)(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param);
extern void (*fp_taos_query_a_with_reqid)(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param,
int64_t reqid);
extern void (*fp_taos_fetch_rows_a)(TAOS_RES *res, __taos_async_fn_t fp, void *param);
extern void (*fp_taos_fetch_raw_block_a)(TAOS_RES *res, __taos_async_fn_t fp, void *param);
extern const void *(*fp_taos_get_raw_block)(TAOS_RES *res);
extern int (*fp_taos_get_db_route_info)(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo);
extern int (*fp_taos_get_table_vgId)(TAOS *taos, const char *db, const char *table, int *vgId);
extern int (*fp_taos_get_tables_vgId)(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId);
extern int (*fp_taos_load_table_info)(TAOS *taos, const char *tableNameList);
extern void (*fp_taos_set_hb_quit)(int8_t quitByKill);
extern int (*fp_taos_set_notify_cb)(TAOS *taos, __taos_notify_fn_t fp, void *param, int type);
extern void (*fp_taos_fetch_whitelist_a)(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param);
extern int (*fp_taos_set_conn_mode)(TAOS *taos, int mode, int value);
extern TAOS_RES *(*fp_taos_schemaless_insert)(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
extern TAOS_RES *(*fp_taos_schemaless_insert_with_reqid)(TAOS *taos, char *lines[], int numLines, int protocol,
int precision, int64_t reqid);
extern TAOS_RES *(*fp_taos_schemaless_insert_raw)(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision);
extern TAOS_RES *(*fp_taos_schemaless_insert_raw_with_reqid)(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int64_t reqid);
extern TAOS_RES *(*fp_taos_schemaless_insert_ttl)(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int32_t ttl);
extern TAOS_RES *(*fp_taos_schemaless_insert_ttl_with_reqid)(TAOS *taos, char *lines[], int numLines, int protocol,
int precision, int32_t ttl, int64_t reqid);
extern TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl)(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int32_t ttl);
extern TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl_with_reqid)(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int32_t ttl,
int64_t reqid);
extern TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key)(TAOS *taos, char *lines, int len,
int32_t *totalRows, int protocol,
int precision, int32_t ttl, int64_t reqid,
char *tbnameKey);
extern TAOS_RES *(*fp_taos_schemaless_insert_ttl_with_reqid_tbname_key)(TAOS *taos, char *lines[], int numLines,
int protocol, int precision, int32_t ttl,
int64_t reqid, char *tbnameKey);
extern tmq_conf_t *(*fp_tmq_conf_new)();
extern tmq_conf_res_t (*fp_tmq_conf_set)(tmq_conf_t *conf, const char *key, const char *value);
extern void (*fp_tmq_conf_destroy)(tmq_conf_t *conf);
extern void (*fp_tmq_conf_set_auto_commit_cb)(tmq_conf_t *conf, tmq_commit_cb *cb, void *param);
extern tmq_list_t *(*fp_tmq_list_new)();
extern int32_t (*fp_tmq_list_append)(tmq_list_t *, const char *);
extern void (*fp_tmq_list_destroy)(tmq_list_t *);
extern int32_t (*fp_tmq_list_get_size)(const tmq_list_t *);
extern char **(*fp_tmq_list_to_c_array)(const tmq_list_t *);
extern tmq_t *(*fp_tmq_consumer_new)(tmq_conf_t *conf, char *errstr, int32_t errstrLen);
extern int32_t (*fp_tmq_subscribe)(tmq_t *tmq, const tmq_list_t *topic_list);
extern int32_t (*fp_tmq_unsubscribe)(tmq_t *tmq);
extern int32_t (*fp_tmq_subscription)(tmq_t *tmq, tmq_list_t **topics);
extern TAOS_RES *(*fp_tmq_consumer_poll)(tmq_t *tmq, int64_t timeout);
extern int32_t (*fp_tmq_consumer_close)(tmq_t *tmq);
extern int32_t (*fp_tmq_commit_sync)(tmq_t *tmq, const TAOS_RES *msg);
extern void (*fp_tmq_commit_async)(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param);
extern int32_t (*fp_tmq_commit_offset_sync)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset);
extern void (*fp_tmq_commit_offset_async)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset,
tmq_commit_cb *cb, void *param);
extern int32_t (*fp_tmq_get_topic_assignment)(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,
int32_t *numOfAssignment);
extern void (*fp_tmq_free_assignment)(tmq_topic_assignment *pAssignment);
extern int32_t (*fp_tmq_offset_seek)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset);
extern int64_t (*fp_tmq_position)(tmq_t *tmq, const char *pTopicName, int32_t vgId);
extern int64_t (*fp_tmq_committed)(tmq_t *tmq, const char *pTopicName, int32_t vgId);
extern TAOS *(*fp_tmq_get_connect)(tmq_t *tmq);
extern const char *(*fp_tmq_get_table_name)(TAOS_RES *res);
extern tmq_res_t (*fp_tmq_get_res_type)(TAOS_RES *res);
extern const char *(*fp_tmq_get_topic_name)(TAOS_RES *res);
extern const char *(*fp_tmq_get_db_name)(TAOS_RES *res);
extern int32_t (*fp_tmq_get_vgroup_id)(TAOS_RES *res);
extern int64_t (*fp_tmq_get_vgroup_offset)(TAOS_RES *res);
extern const char *(*fp_tmq_err2str)(int32_t code);
extern int32_t (*fp_tmq_get_raw)(TAOS_RES *res, tmq_raw_data *raw);
extern int32_t (*fp_tmq_write_raw)(TAOS *taos, tmq_raw_data raw);
extern int (*fp_taos_write_raw_block)(TAOS *taos, int numOfRows, char *pData, const char *tbname);
extern int (*fp_taos_write_raw_block_with_reqid)(TAOS *taos, int numOfRows, char *pData, const char *tbname,
int64_t reqid);
extern int (*fp_taos_write_raw_block_with_fields)(TAOS *taos, int rows, char *pData, const char *tbname,
TAOS_FIELD *fields, int numFields);
extern int (*fp_taos_write_raw_block_with_fields_with_reqid)(TAOS *taos, int rows, char *pData, const char *tbname,
TAOS_FIELD *fields, int numFields, int64_t reqid);
extern void (*fp_tmq_free_raw)(tmq_raw_data raw);
extern char *(*fp_tmq_get_json_meta)(TAOS_RES *res);
extern void (*fp_tmq_free_json_meta)(char *jsonMeta);
extern TSDB_SERVER_STATUS (*fp_taos_check_server_status)(const char *fqdn, int port, char *details, int maxlen);
extern void (*fp_taos_write_crashinfo)(int signum, void *sigInfo, void *context);
extern char *(*fp_getBuildInfo)();
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_CLIENT_WRAPPER_H

View File

@ -14,107 +14,6 @@
extern "C" {
#endif
/*
* AWT native interface (new in JDK 1.3)
*
* The AWT native interface allows a native C or C++ application a means
* by which to access native structures in AWT. This is to facilitate moving
* legacy C and C++ applications to Java and to target the needs of the
* community who, at present, wish to do their own native rendering to canvases
* for performance reasons. Standard extensions such as Java3D also require a
* means to access the underlying native data structures of AWT.
*
* There may be future extensions to this API depending on demand.
*
* A VM does not have to implement this API in order to pass the JCK.
* It is recommended, however, that this API is implemented on VMs that support
* standard extensions, such as Java3D.
*
* Since this is a native API, any program which uses it cannot be considered
* 100% pure java.
*/
/*
* AWT Native Drawing Surface (JAWT_DrawingSurface).
*
* For each platform, there is a native drawing surface structure. This
* platform-specific structure can be found in jawt_md.h. It is recommended
* that additional platforms follow the same model. It is also recommended
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
*
*******************
* EXAMPLE OF USAGE:
*******************
*
* In Win32, a programmer wishes to access the HWND of a canvas to perform
* native rendering into it. The programmer has declared the paint() method
* for their canvas subclass to be native:
*
*
* MyCanvas.java:
*
* import java.awt.*;
*
* public class MyCanvas extends Canvas {
*
* static {
* System.loadLibrary("mylib");
* }
*
* public native void paint(Graphics g);
* }
*
*
* myfile.c:
*
* #include "jawt_md.h"
* #include <assert.h>
*
* JNIEXPORT void JNICALL
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
* {
* JAWT awt;
* JAWT_DrawingSurface* ds;
* JAWT_DrawingSurfaceInfo* dsi;
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
* jboolean result;
* jint lock;
*
* // Get the AWT
* awt.version = JAWT_VERSION_1_3;
* result = JAWT_GetAWT(env, &awt);
* assert(result != JNI_FALSE);
*
* // Get the drawing surface
* ds = awt.GetDrawingSurface(env, canvas);
* assert(ds != NULL);
*
* // Lock the drawing surface
* lock = ds->Lock(ds);
* assert((lock & JAWT_LOCK_ERROR) == 0);
*
* // Get the drawing surface info
* dsi = ds->GetDrawingSurfaceInfo(ds);
*
* // Get the platform-specific drawing info
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
*
* //////////////////////////////
* // !!! DO PAINTING HERE !!! //
* //////////////////////////////
*
* // Free the drawing surface info
* ds->FreeDrawingSurfaceInfo(dsi);
*
* // Unlock the drawing surface
* ds->Unlock(ds);
*
* // Free the drawing surface
* awt.FreeDrawingSurface(ds);
* }
*
*/
/*
* JAWT_Rectangle
* Structure for a native rectangle.

View File

@ -52,87 +52,6 @@ extern "C" {
* 100% pure java.
*/
/*
* AWT Native Drawing Surface (JAWT_DrawingSurface).
*
* For each platform, there is a native drawing surface structure. This
* platform-specific structure can be found in jawt_md.h. It is recommended
* that additional platforms follow the same model. It is also recommended
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
*
*******************
* EXAMPLE OF USAGE:
*******************
*
* In Win32, a programmer wishes to access the HWND of a canvas to perform
* native rendering into it. The programmer has declared the paint() method
* for their canvas subclass to be native:
*
*
* MyCanvas.java:
*
* import java.awt.*;
*
* public class MyCanvas extends Canvas {
*
* static {
* System.loadLibrary("mylib");
* }
*
* public native void paint(Graphics g);
* }
*
*
* myfile.c:
*
* #include "jawt_md.h"
* #include <assert.h>
*
* JNIEXPORT void JNICALL
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
* {
* JAWT awt;
* JAWT_DrawingSurface* ds;
* JAWT_DrawingSurfaceInfo* dsi;
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
* jboolean result;
* jint lock;
*
* // Get the AWT
* awt.version = JAWT_VERSION_1_3;
* result = JAWT_GetAWT(env, &awt);
* assert(result != JNI_FALSE);
*
* // Get the drawing surface
* ds = awt.GetDrawingSurface(env, canvas);
* assert(ds != NULL);
*
* // Lock the drawing surface
* lock = ds->Lock(ds);
* assert((lock & JAWT_LOCK_ERROR) == 0);
*
* // Get the drawing surface info
* dsi = ds->GetDrawingSurfaceInfo(ds);
*
* // Get the platform-specific drawing info
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
*
* //////////////////////////////
* // !!! DO PAINTING HERE !!! //
* //////////////////////////////
*
* // Free the drawing surface info
* ds->FreeDrawingSurfaceInfo(dsi);
*
* // Unlock the drawing surface
* ds->Unlock(ds);
*
* // Free the drawing surface
* awt.FreeDrawingSurface(ds);
* }
*
*/
/*
* JAWT_Rectangle
* Structure for a native rectangle.

View File

@ -0,0 +1,271 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wrapper.h"
#ifdef WINDOWS
#define DRIVER_NATIVE_NAME "taosnative.dll"
#define DRIVER_WSBSOCKET_NAME "taosws.dll"
#elif defined(DARWIN)
#define DRIVER_NATIVE_NAME "libtaosnative.dylib"
#define DRIVER_WSBSOCKET_NAME "libtaosws.dylib"
#else
#define DRIVER_NATIVE_NAME "libtaosnative.so"
#define DRIVER_WSBSOCKET_NAME "libtaosws.so"
#endif
#define LOAD_FUNC(fptr, fname) \
funcName = fname; \
fptr = taosLoadDllFunc(tsDriver, funcName); \
if (fptr == NULL) goto _OVER;
#ifdef WEBSOCKET
EDriverType tsDriverType = DRIVER_NATIVE; // todo simon
#else
EDriverType tsDriverType = DRIVER_NATIVE;
#endif
void *tsDriver = NULL;
static int32_t tossGetDevelopPath(char *driverPath, const char *driverName) {
char appPath[PATH_MAX] = {0};
int32_t ret = taosAppPath(appPath, PATH_MAX);
if (ret == 0) {
snprintf(driverPath, PATH_MAX, "%s%s..%slib%s%s", appPath, TD_DIRSEP, TD_DIRSEP, TD_DIRSEP, driverName);
ret = taosRealPath(driverPath, NULL, PATH_MAX);
}
return ret;
}
static int32_t taosGetInstallPath(char *driverPath, const char *driverName) {
tstrncpy(driverPath, driverName, PATH_MAX);
return 0;
}
int32_t taosDriverInit(EDriverType driverType) {
int32_t code = -1;
char driverPath[PATH_MAX + 32] = {0};
const char *driverName = NULL;
const char *funcName = NULL;
if (driverType == DRIVER_NATIVE) {
driverName = DRIVER_NATIVE_NAME;
} else {
driverName = DRIVER_WSBSOCKET_NAME;
}
if (tsDriver == NULL && tossGetDevelopPath(driverPath, driverName) == 0) {
tsDriver = taosLoadDll(driverPath);
}
if (tsDriver == NULL && taosGetInstallPath(driverPath, driverName) == 0) {
tsDriver = taosLoadDll(driverPath);
}
if (tsDriver == NULL) {
printf("failed to load %s since %s [0x%X]\r\n", driverName, terrstr(), terrno);
return code;
}
// printf("load driver from %s\r\n", driverPath);
LOAD_FUNC(fp_taos_set_config, "taos_set_config");
LOAD_FUNC(fp_taos_init, "taos_init");
LOAD_FUNC(fp_taos_cleanup, "taos_cleanup");
LOAD_FUNC(fp_taos_options, "taos_options");
LOAD_FUNC(fp_taos_options_connection, "taos_options_connection");
LOAD_FUNC(fp_taos_connect, "taos_connect");
LOAD_FUNC(fp_taos_connect_auth, "taos_connect_auth");
LOAD_FUNC(fp_taos_close, "taos_close");
LOAD_FUNC(fp_taos_data_type, "taos_data_type");
LOAD_FUNC(fp_taos_stmt_init, "taos_stmt_init");
LOAD_FUNC(fp_taos_stmt_init_with_reqid, "taos_stmt_init_with_reqid");
LOAD_FUNC(fp_taos_stmt_init_with_options, "taos_stmt_init_with_options");
LOAD_FUNC(fp_taos_stmt_prepare, "taos_stmt_prepare");
LOAD_FUNC(fp_taos_stmt_set_tbname_tags, "taos_stmt_set_tbname_tags");
LOAD_FUNC(fp_taos_stmt_set_tbname, "taos_stmt_set_tbname");
LOAD_FUNC(fp_taos_stmt_set_tags, "taos_stmt_set_tags");
LOAD_FUNC(fp_taos_stmt_set_sub_tbname, "taos_stmt_set_sub_tbname");
LOAD_FUNC(fp_taos_stmt_get_tag_fields, "taos_stmt_get_tag_fields");
LOAD_FUNC(fp_taos_stmt_get_col_fields, "taos_stmt_get_col_fields");
LOAD_FUNC(fp_taos_stmt_reclaim_fields, "taos_stmt_reclaim_fields");
LOAD_FUNC(fp_taos_stmt_is_insert, "taos_stmt_is_insert");
LOAD_FUNC(fp_taos_stmt_num_params, "taos_stmt_num_params");
LOAD_FUNC(fp_taos_stmt_get_param, "taos_stmt_get_param");
LOAD_FUNC(fp_taos_stmt_bind_param, "taos_stmt_bind_param");
LOAD_FUNC(fp_taos_stmt_bind_param_batch, "taos_stmt_bind_param_batch");
LOAD_FUNC(fp_taos_stmt_bind_single_param_batch, "taos_stmt_bind_single_param_batch");
LOAD_FUNC(fp_taos_stmt_add_batch, "taos_stmt_add_batch");
LOAD_FUNC(fp_taos_stmt_execute, "taos_stmt_execute");
LOAD_FUNC(fp_taos_stmt_use_result, "taos_stmt_use_result");
LOAD_FUNC(fp_taos_stmt_close, "taos_stmt_close");
LOAD_FUNC(fp_taos_stmt_errstr, "taos_stmt_errstr");
LOAD_FUNC(fp_taos_stmt_affected_rows, "taos_stmt_affected_rows");
LOAD_FUNC(fp_taos_stmt_affected_rows_once, "taos_stmt_affected_rows_once");
LOAD_FUNC(fp_taos_stmt2_init, "taos_stmt2_init");
LOAD_FUNC(fp_taos_stmt2_prepare, "taos_stmt2_prepare");
LOAD_FUNC(fp_taos_stmt2_bind_param, "taos_stmt2_bind_param");
LOAD_FUNC(fp_taos_stmt2_bind_param_a, "taos_stmt2_bind_param_a");
LOAD_FUNC(fp_taos_stmt2_exec, "taos_stmt2_exec");
LOAD_FUNC(fp_taos_stmt2_close, "taos_stmt2_close");
LOAD_FUNC(fp_taos_stmt2_is_insert, "taos_stmt2_is_insert");
LOAD_FUNC(fp_taos_stmt2_get_fields, "taos_stmt2_get_fields");
LOAD_FUNC(fp_taos_stmt2_free_fields, "taos_stmt2_free_fields");
LOAD_FUNC(fp_taos_stmt2_result, "taos_stmt2_result");
LOAD_FUNC(fp_taos_stmt2_error, "taos_stmt2_error");
LOAD_FUNC(fp_taos_query, "taos_query");
LOAD_FUNC(fp_taos_query_with_reqid, "taos_query_with_reqid");
LOAD_FUNC(fp_taos_fetch_row, "taos_fetch_row");
LOAD_FUNC(fp_taos_result_precision, "taos_result_precision");
LOAD_FUNC(fp_taos_free_result, "taos_free_result");
LOAD_FUNC(fp_taos_kill_query, "taos_kill_query");
LOAD_FUNC(fp_taos_field_count, "taos_field_count");
LOAD_FUNC(fp_taos_num_fields, "taos_num_fields");
LOAD_FUNC(fp_taos_affected_rows, "taos_affected_rows");
LOAD_FUNC(fp_taos_affected_rows64, "taos_affected_rows64");
LOAD_FUNC(fp_taos_fetch_fields, "taos_fetch_fields");
LOAD_FUNC(fp_taos_fetch_fields_e, "taos_fetch_fields_e");
LOAD_FUNC(fp_taos_select_db, "taos_select_db");
LOAD_FUNC(fp_taos_print_row, "taos_print_row");
LOAD_FUNC(fp_taos_print_row_with_size, "taos_print_row_with_size");
LOAD_FUNC(fp_taos_stop_query, "taos_stop_query");
LOAD_FUNC(fp_taos_is_null, "taos_is_null");
LOAD_FUNC(fp_taos_is_null_by_column, "taos_is_null_by_column");
LOAD_FUNC(fp_taos_is_update_query, "taos_is_update_query");
LOAD_FUNC(fp_taos_fetch_block, "taos_fetch_block");
LOAD_FUNC(fp_taos_fetch_block_s, "taos_fetch_block_s");
LOAD_FUNC(fp_taos_fetch_raw_block, "taos_fetch_raw_block");
LOAD_FUNC(fp_taos_get_column_data_offset, "taos_get_column_data_offset");
LOAD_FUNC(fp_taos_validate_sql, "taos_validate_sql");
LOAD_FUNC(fp_taos_reset_current_db, "taos_reset_current_db");
LOAD_FUNC(fp_taos_fetch_lengths, "taos_fetch_lengths");
LOAD_FUNC(fp_taos_result_block, "taos_result_block");
LOAD_FUNC(fp_taos_get_server_info, "taos_get_server_info");
LOAD_FUNC(fp_taos_get_client_info, "taos_get_client_info");
LOAD_FUNC(fp_taos_get_current_db, "taos_get_current_db");
LOAD_FUNC(fp_taos_errstr, "taos_errstr");
LOAD_FUNC(fp_taos_errno, "taos_errno");
LOAD_FUNC(fp_taos_query_a, "taos_query_a");
LOAD_FUNC(fp_taos_query_a_with_reqid, "taos_query_a_with_reqid");
LOAD_FUNC(fp_taos_fetch_rows_a, "taos_fetch_rows_a");
LOAD_FUNC(fp_taos_fetch_raw_block_a, "taos_fetch_raw_block_a");
LOAD_FUNC(fp_taos_get_raw_block, "taos_get_raw_block");
LOAD_FUNC(fp_taos_get_db_route_info, "taos_get_db_route_info");
LOAD_FUNC(fp_taos_get_table_vgId, "taos_get_table_vgId");
LOAD_FUNC(fp_taos_get_tables_vgId, "taos_get_tables_vgId");
LOAD_FUNC(fp_taos_load_table_info, "taos_load_table_info");
LOAD_FUNC(fp_taos_set_hb_quit, "taos_set_hb_quit");
LOAD_FUNC(fp_taos_set_notify_cb, "taos_set_notify_cb");
LOAD_FUNC(fp_taos_fetch_whitelist_a, "taos_fetch_whitelist_a");
LOAD_FUNC(fp_taos_set_conn_mode, "taos_set_conn_mode");
LOAD_FUNC(fp_taos_schemaless_insert, "taos_schemaless_insert");
LOAD_FUNC(fp_taos_schemaless_insert_with_reqid, "taos_schemaless_insert_with_reqid");
LOAD_FUNC(fp_taos_schemaless_insert_raw, "taos_schemaless_insert_raw");
LOAD_FUNC(fp_taos_schemaless_insert_raw_with_reqid, "taos_schemaless_insert_raw_with_reqid");
LOAD_FUNC(fp_taos_schemaless_insert_ttl, "taos_schemaless_insert_ttl");
LOAD_FUNC(fp_taos_schemaless_insert_ttl_with_reqid, "taos_schemaless_insert_ttl_with_reqid");
LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl, "taos_schemaless_insert_raw_ttl");
LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl_with_reqid, "taos_schemaless_insert_raw_ttl_with_reqid");
LOAD_FUNC(fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key,
"taos_schemaless_insert_raw_ttl_with_reqid_tbname_key");
LOAD_FUNC(fp_taos_schemaless_insert_ttl_with_reqid_tbname_key, "taos_schemaless_insert_ttl_with_reqid_tbname_key");
LOAD_FUNC(fp_tmq_conf_new, "tmq_conf_new");
LOAD_FUNC(fp_tmq_conf_set, "tmq_conf_set");
LOAD_FUNC(fp_tmq_conf_destroy, "tmq_conf_destroy");
LOAD_FUNC(fp_tmq_conf_set_auto_commit_cb, "tmq_conf_set_auto_commit_cb");
LOAD_FUNC(fp_tmq_list_new, "tmq_list_new");
LOAD_FUNC(fp_tmq_list_append, "tmq_list_append");
LOAD_FUNC(fp_tmq_list_destroy, "tmq_list_destroy");
LOAD_FUNC(fp_tmq_list_get_size, "tmq_list_get_size");
LOAD_FUNC(fp_tmq_list_to_c_array, "tmq_list_to_c_array");
LOAD_FUNC(fp_tmq_consumer_new, "tmq_consumer_new");
LOAD_FUNC(fp_tmq_subscribe, "tmq_subscribe");
LOAD_FUNC(fp_tmq_unsubscribe, "tmq_unsubscribe");
LOAD_FUNC(fp_tmq_subscription, "tmq_subscription");
LOAD_FUNC(fp_tmq_consumer_poll, "tmq_consumer_poll");
LOAD_FUNC(fp_tmq_consumer_close, "tmq_consumer_close");
LOAD_FUNC(fp_tmq_commit_sync, "tmq_commit_sync");
LOAD_FUNC(fp_tmq_commit_async, "tmq_commit_async");
LOAD_FUNC(fp_tmq_commit_offset_sync, "tmq_commit_offset_sync");
LOAD_FUNC(fp_tmq_commit_offset_async, "tmq_commit_offset_async");
LOAD_FUNC(fp_tmq_get_topic_assignment, "tmq_get_topic_assignment");
LOAD_FUNC(fp_tmq_free_assignment, "tmq_free_assignment");
LOAD_FUNC(fp_tmq_offset_seek, "tmq_offset_seek");
LOAD_FUNC(fp_tmq_position, "tmq_position");
LOAD_FUNC(fp_tmq_committed, "tmq_committed");
LOAD_FUNC(fp_tmq_get_connect, "tmq_get_connect");
LOAD_FUNC(fp_tmq_get_table_name, "tmq_get_table_name");
LOAD_FUNC(fp_tmq_get_res_type, "tmq_get_res_type");
LOAD_FUNC(fp_tmq_get_topic_name, "tmq_get_topic_name");
LOAD_FUNC(fp_tmq_get_db_name, "tmq_get_db_name");
LOAD_FUNC(fp_tmq_get_vgroup_id, "tmq_get_vgroup_id");
LOAD_FUNC(fp_tmq_get_vgroup_offset, "tmq_get_vgroup_offset");
LOAD_FUNC(fp_tmq_err2str, "tmq_err2str");
LOAD_FUNC(fp_tmq_get_raw, "tmq_get_raw");
LOAD_FUNC(fp_tmq_write_raw, "tmq_write_raw");
LOAD_FUNC(fp_taos_write_raw_block, "taos_write_raw_block");
LOAD_FUNC(fp_taos_write_raw_block_with_reqid, "taos_write_raw_block_with_reqid");
LOAD_FUNC(fp_taos_write_raw_block_with_fields, "taos_write_raw_block_with_fields");
LOAD_FUNC(fp_taos_write_raw_block_with_fields_with_reqid, "taos_write_raw_block_with_fields_with_reqid");
LOAD_FUNC(fp_tmq_free_raw, "tmq_free_raw");
LOAD_FUNC(fp_tmq_get_json_meta, "tmq_get_json_meta");
LOAD_FUNC(fp_tmq_free_json_meta, "tmq_free_json_meta");
LOAD_FUNC(fp_taos_check_server_status, "taos_check_server_status");
LOAD_FUNC(fp_taos_write_crashinfo, "taos_write_crashinfo");
LOAD_FUNC(fp_getBuildInfo, "getBuildInfo");
code = 0;
_OVER:
if (code != 0) {
printf("failed to load function %s from %s since %s [0x%X]\r\n", funcName, driverPath, terrstr(), terrno);
taosDriverCleanup();
}
return code;
}
void taosDriverCleanup() {
if (tsDriver != NULL) {
taosCloseDll(tsDriver);
tsDriver = NULL;
}
}

View File

@ -0,0 +1,870 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "version.h"
#include "wrapper.h"
static TdThreadOnce tsDriverOnce = PTHREAD_ONCE_INIT;
volatile int32_t tsDriverOnceRet = 0;
#define ERR_VOID(code) \
terrno = code; \
return;
#define ERR_PTR(code) \
terrno = code; \
return NULL;
#define ERR_INT(code) \
terrno = code; \
return -1;
#define ERR_BOOL(code) \
terrno = code; \
return false;
#define ERR_CONFRET(code) \
terrno = code; \
setConfRet ret = {.retCode = -1}; \
return ret;
#define CHECK_VOID(fp) \
if (tsDriver == NULL) { \
ERR_VOID(TSDB_CODE_DLL_NOT_LOAD) \
} \
if (fp == NULL) { \
ERR_VOID(TSDB_CODE_DLL_NOT_LOAD) \
}
#define CHECK_PTR(fp) \
if (tsDriver == NULL) { \
ERR_PTR(TSDB_CODE_DLL_NOT_LOAD) \
} \
if (fp == NULL) { \
ERR_PTR(TSDB_CODE_DLL_NOT_LOAD) \
}
#define CHECK_INT(fp) \
if (tsDriver == NULL) { \
ERR_INT(TSDB_CODE_DLL_NOT_LOAD) \
} \
if (fp == NULL) { \
ERR_INT(TSDB_CODE_DLL_NOT_LOAD) \
}
#define CHECK_BOOL(fp) \
if (tsDriver == NULL) { \
ERR_BOOL(TSDB_CODE_DLL_NOT_LOAD) \
} \
if (fp == NULL) { \
ERR_BOOL(TSDB_CODE_DLL_NOT_LOAD) \
}
#define CHECK_CONFRET(fp) \
if (tsDriver == NULL) { \
ERR_CONFRET(TSDB_CODE_DLL_NOT_LOAD) \
} \
if (fp == NULL) { \
ERR_CONFRET(TSDB_CODE_DLL_NOT_LOAD) \
}
setConfRet taos_set_config(const char *config) {
if (taos_init() != 0) {
ERR_CONFRET(TSDB_CODE_DLL_NOT_LOAD)
}
CHECK_CONFRET(fp_taos_set_config);
return (*fp_taos_set_config)(config);
}
static void taos_init_wrapper(void) {
tsDriverOnceRet = taosDriverInit(tsDriverType);
if (tsDriverOnceRet != 0) return;
if (fp_taos_init == NULL) {
terrno = TSDB_CODE_DLL_FUNC_NOT_LOAD;
tsDriverOnceRet = -1;
} else {
tsDriverOnceRet = (*fp_taos_init)();
}
}
int taos_init(void) {
(void)taosThreadOnce(&tsDriverOnce, taos_init_wrapper);
return tsDriverOnceRet;
}
void taos_cleanup(void) {
CHECK_VOID(fp_taos_cleanup);
(*fp_taos_cleanup)();
}
int taos_options(TSDB_OPTION option, const void *arg, ...) {
if (option == TSDB_OPTION_DRIVER) {
if (tsDriver == NULL) {
if (strcasecmp((const char *)arg, "native") == 0) {
tsDriverType = DRIVER_NATIVE;
return 0;
}
if (strcasecmp((const char *)arg, "websocket") == 0) {
tsDriverType = DRIVER_WEBSOCKET;
return 0;
}
}
terrno = TSDB_CODE_REPEAT_INIT;
return -1;
}
if (taos_init() != 0) {
terrno = TSDB_CODE_DLL_NOT_LOAD;
return -1;
}
CHECK_INT(fp_taos_options);
return (*fp_taos_options)(option, arg);
}
int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...) {
CHECK_INT(fp_taos_options_connection);
return (*fp_taos_options_connection)(taos, option, (const char *)arg);
}
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
if (taos_init() != 0) {
terrno = TSDB_CODE_DLL_NOT_LOAD;
return NULL;
}
CHECK_PTR(fp_taos_connect);
return (*fp_taos_connect)(ip, user, pass, db, port);
}
TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port) {
if (taos_init() != 0) {
terrno = TSDB_CODE_DLL_NOT_LOAD;
return NULL;
}
CHECK_PTR(fp_taos_connect_auth);
return (*fp_taos_connect_auth)(ip, user, auth, db, port);
}
void taos_close(TAOS *taos) {
CHECK_VOID(fp_taos_close);
(*fp_taos_close)(taos);
}
const char *taos_data_type(int type) {
CHECK_PTR(fp_taos_data_type);
return (*fp_taos_data_type)(type);
}
TAOS_STMT *taos_stmt_init(TAOS *taos) {
CHECK_PTR(fp_taos_stmt_init);
return (*fp_taos_stmt_init)(taos);
}
TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid) {
CHECK_PTR(fp_taos_stmt_init_with_reqid);
return (*fp_taos_stmt_init_with_reqid)(taos, reqid);
}
TAOS_STMT *taos_stmt_init_with_options(TAOS *taos, TAOS_STMT_OPTIONS *options) {
CHECK_PTR(fp_taos_stmt_init_with_options);
return (*fp_taos_stmt_init_with_options)(taos, options);
}
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
CHECK_INT(fp_taos_stmt_prepare);
return (*fp_taos_stmt_prepare)(stmt, sql, length);
}
int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags) {
CHECK_INT(fp_taos_stmt_set_tbname_tags);
return (*fp_taos_stmt_set_tbname_tags)(stmt, name, tags);
}
int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
CHECK_INT(fp_taos_stmt_set_tbname);
return (*fp_taos_stmt_set_tbname)(stmt, name);
}
int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) {
CHECK_INT(fp_taos_stmt_set_tags);
return (*fp_taos_stmt_set_tags)(stmt, tags);
}
int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) {
CHECK_INT(fp_taos_stmt_set_sub_tbname);
return (*fp_taos_stmt_set_sub_tbname)(stmt, name);
}
int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
CHECK_INT(fp_taos_stmt_get_tag_fields);
return (*fp_taos_stmt_get_tag_fields)(stmt, fieldNum, fields);
}
int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
CHECK_INT(fp_taos_stmt_get_col_fields);
return (*fp_taos_stmt_get_col_fields)(stmt, fieldNum, fields);
}
void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields) {
CHECK_VOID(fp_taos_stmt_reclaim_fields);
(*fp_taos_stmt_reclaim_fields)(stmt, fields);
}
int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) {
CHECK_INT(fp_taos_stmt_is_insert);
return (*fp_taos_stmt_is_insert)(stmt, insert);
}
int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) {
CHECK_INT(fp_taos_stmt_num_params);
return (*fp_taos_stmt_num_params)(stmt, nums);
}
int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes) {
CHECK_INT(fp_taos_stmt_get_param);
return (*fp_taos_stmt_get_param)(stmt, idx, type, bytes);
}
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
CHECK_INT(fp_taos_stmt_bind_param);
return (*fp_taos_stmt_bind_param)(stmt, bind);
}
int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
CHECK_INT(fp_taos_stmt_bind_param_batch);
return (*fp_taos_stmt_bind_param_batch)(stmt, bind);
}
int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx) {
CHECK_INT(fp_taos_stmt_bind_single_param_batch);
return (*fp_taos_stmt_bind_single_param_batch)(stmt, bind, colIdx);
}
int taos_stmt_add_batch(TAOS_STMT *stmt) {
CHECK_INT(fp_taos_stmt_add_batch);
return (*fp_taos_stmt_add_batch)(stmt);
}
int taos_stmt_execute(TAOS_STMT *stmt) {
CHECK_INT(fp_taos_stmt_execute);
return (*fp_taos_stmt_execute)(stmt);
}
TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
CHECK_PTR(fp_taos_stmt_use_result);
return (*fp_taos_stmt_use_result)(stmt);
}
int taos_stmt_close(TAOS_STMT *stmt) {
CHECK_INT(fp_taos_stmt_close);
return (*fp_taos_stmt_close)(stmt);
}
char *taos_stmt_errstr(TAOS_STMT *stmt) {
CHECK_PTR(fp_taos_stmt_errstr);
return (*fp_taos_stmt_errstr)(stmt);
}
int taos_stmt_affected_rows(TAOS_STMT *stmt) {
CHECK_INT(fp_taos_stmt_affected_rows);
return (*fp_taos_stmt_affected_rows)(stmt);
}
int taos_stmt_affected_rows_once(TAOS_STMT *stmt) {
CHECK_INT(fp_taos_stmt_affected_rows_once);
return (*fp_taos_stmt_affected_rows_once)(stmt);
}
TAOS_STMT2 *taos_stmt2_init(TAOS *taos, TAOS_STMT2_OPTION *option) {
CHECK_PTR(fp_taos_stmt2_init);
return (*fp_taos_stmt2_init)(taos, option);
}
int taos_stmt2_prepare(TAOS_STMT2 *stmt, const char *sql, unsigned long length) {
CHECK_INT(fp_taos_stmt2_prepare);
return (*fp_taos_stmt2_prepare)(stmt, sql, length);
}
int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx) {
CHECK_INT(fp_taos_stmt2_bind_param);
return (*fp_taos_stmt2_bind_param)(stmt, bindv, col_idx);
}
int taos_stmt2_bind_param_a(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx, __taos_async_fn_t fp,
void *param) {
CHECK_INT(fp_taos_stmt2_bind_param_a);
return (*fp_taos_stmt2_bind_param_a)(stmt, bindv, col_idx, fp, param);
}
int taos_stmt2_exec(TAOS_STMT2 *stmt, int *affected_rows) {
CHECK_INT(fp_taos_stmt2_exec);
return (*fp_taos_stmt2_exec)(stmt, affected_rows);
}
int taos_stmt2_close(TAOS_STMT2 *stmt) {
CHECK_INT(fp_taos_stmt2_close);
return (*fp_taos_stmt2_close)(stmt);
}
int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert) {
CHECK_INT(fp_taos_stmt2_is_insert);
return (*fp_taos_stmt2_is_insert)(stmt, insert);
}
int taos_stmt2_get_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields) {
CHECK_INT(fp_taos_stmt2_get_fields);
return (*fp_taos_stmt2_get_fields)(stmt, count, fields);
}
void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields) {
CHECK_VOID(fp_taos_stmt2_free_fields);
(*fp_taos_stmt2_free_fields)(stmt, fields);
}
TAOS_RES *taos_stmt2_result(TAOS_STMT2 *stmt) {
CHECK_PTR(fp_taos_stmt2_result);
return (*fp_taos_stmt2_result)(stmt);
}
char *taos_stmt2_error(TAOS_STMT2 *stmt) {
CHECK_PTR(fp_taos_stmt2_error);
return (*fp_taos_stmt2_error)(stmt);
}
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
CHECK_PTR(fp_taos_query);
return (*fp_taos_query)(taos, sql);
}
TAOS_RES *taos_query_with_reqid(TAOS *taos, const char *sql, int64_t reqId) {
CHECK_PTR(fp_taos_query_with_reqid);
return (*fp_taos_query_with_reqid)(taos, sql, reqId);
}
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
CHECK_PTR(fp_taos_fetch_row);
return (*fp_taos_fetch_row)(res);
}
int taos_result_precision(TAOS_RES *res) {
CHECK_INT(fp_taos_result_precision);
return (*fp_taos_result_precision)(res);
}
void taos_free_result(TAOS_RES *res) {
CHECK_VOID(fp_taos_free_result);
return (*fp_taos_free_result)(res);
}
void taos_kill_query(TAOS *taos) {
CHECK_VOID(fp_taos_kill_query);
return (*fp_taos_kill_query)(taos);
}
int taos_field_count(TAOS_RES *res) {
CHECK_INT(fp_taos_field_count);
return (*fp_taos_field_count)(res);
}
int taos_num_fields(TAOS_RES *res) {
CHECK_INT(fp_taos_num_fields);
return (*fp_taos_num_fields)(res);
}
int taos_affected_rows(TAOS_RES *res) {
CHECK_INT(fp_taos_affected_rows);
return (*fp_taos_affected_rows)(res);
}
int64_t taos_affected_rows64(TAOS_RES *res) {
CHECK_INT(fp_taos_affected_rows64);
return (*fp_taos_affected_rows64)(res);
}
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
CHECK_PTR(fp_taos_fetch_fields);
return (*fp_taos_fetch_fields)(res);
}
TAOS_FIELD_E *taos_fetch_fields_e(TAOS_RES *res) {
CHECK_PTR(fp_taos_fetch_fields_e);
return (*fp_taos_fetch_fields_e)(res);
}
int taos_select_db(TAOS *taos, const char *db) {
CHECK_INT(fp_taos_select_db);
return (*fp_taos_select_db)(taos, db);
}
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
CHECK_INT(fp_taos_print_row);
return (*fp_taos_print_row)(str, row, fields, num_fields);
}
int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
CHECK_INT(fp_taos_print_row_with_size);
return (*fp_taos_print_row_with_size)(str, size, row, fields, num_fields);
}
void taos_stop_query(TAOS_RES *res) {
CHECK_VOID(fp_taos_stop_query);
(*fp_taos_stop_query)(res);
}
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
CHECK_BOOL(fp_taos_is_null);
return (*fp_taos_is_null)(res, row, col);
}
int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows) {
CHECK_INT(fp_taos_is_null_by_column);
return (*fp_taos_is_null_by_column)(res, columnIndex, result, rows);
}
bool taos_is_update_query(TAOS_RES *res) {
CHECK_BOOL(fp_taos_is_update_query);
return (*fp_taos_is_update_query)(res);
}
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
CHECK_INT(fp_taos_fetch_block);
return (*fp_taos_fetch_block)(res, rows);
}
int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
CHECK_INT(fp_taos_fetch_block_s);
return (*fp_taos_fetch_block_s)(res, numOfRows, rows);
}
int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
CHECK_INT(fp_taos_fetch_raw_block);
return (*fp_taos_fetch_raw_block)(res, numOfRows, pData);
}
int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
CHECK_PTR(fp_taos_get_column_data_offset);
return (*fp_taos_get_column_data_offset)(res, columnIndex);
}
int taos_validate_sql(TAOS *taos, const char *sql) {
CHECK_INT(fp_taos_validate_sql);
return (*fp_taos_validate_sql)(taos, sql);
}
void taos_reset_current_db(TAOS *taos) {
CHECK_VOID(fp_taos_reset_current_db);
(*fp_taos_reset_current_db)(taos);
}
int *taos_fetch_lengths(TAOS_RES *res) {
CHECK_PTR(fp_taos_fetch_lengths);
return (*fp_taos_fetch_lengths)(res);
}
TAOS_ROW *taos_result_block(TAOS_RES *res) {
CHECK_PTR(fp_taos_result_block);
return (*fp_taos_result_block)(res);
}
const char *taos_get_server_info(TAOS *taos) {
CHECK_PTR(fp_taos_get_server_info);
return (*fp_taos_get_server_info)(taos);
}
const char *taos_get_client_info() {
if (fp_taos_get_client_info == NULL) {
return td_version;
} else {
return (*fp_taos_get_client_info)();
}
}
int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
CHECK_INT(fp_taos_get_current_db);
return (*fp_taos_get_current_db)(taos, database, len, required);
}
const char *taos_errstr(TAOS_RES *res) {
if (fp_taos_errstr == NULL) {
return tstrerror(terrno);
}
return (*fp_taos_errstr)(res);
}
int taos_errno(TAOS_RES *res) {
if (fp_taos_errno == NULL) {
return terrno;
}
return (*fp_taos_errno)(res);
}
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
CHECK_VOID(fp_taos_query_a);
(*fp_taos_query_a)(taos, sql, fp, param);
}
void taos_query_a_with_reqid(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, int64_t reqid) {
CHECK_VOID(fp_taos_query_a_with_reqid);
(*fp_taos_query_a_with_reqid)(taos, sql, fp, param, reqid);
}
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
CHECK_VOID(fp_taos_fetch_rows_a);
(*fp_taos_fetch_rows_a)(res, fp, param);
}
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
CHECK_VOID(fp_taos_fetch_raw_block_a);
(*fp_taos_fetch_raw_block_a)(res, fp, param);
}
const void *taos_get_raw_block(TAOS_RES *res) {
CHECK_PTR(fp_taos_get_raw_block);
return (*fp_taos_get_raw_block)(res);
}
int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo) {
CHECK_INT(fp_taos_get_db_route_info);
return (*fp_taos_get_db_route_info)(taos, db, dbInfo);
}
int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId) {
CHECK_INT(fp_taos_get_table_vgId);
return (*fp_taos_get_table_vgId)(taos, db, table, vgId);
}
int taos_get_tables_vgId(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId) {
CHECK_INT(fp_taos_get_tables_vgId);
return (*fp_taos_get_tables_vgId)(taos, db, table, tableNum, vgId);
}
int taos_load_table_info(TAOS *taos, const char *tableNameList) {
CHECK_INT(fp_taos_load_table_info);
return (*fp_taos_load_table_info)(taos, tableNameList);
}
void taos_set_hb_quit(int8_t quitByKill) {
if (taos_init() != 0) {
return;
}
CHECK_VOID(fp_taos_set_hb_quit);
return (*fp_taos_set_hb_quit)(quitByKill);
}
int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type) {
CHECK_INT(fp_taos_set_notify_cb);
return (*fp_taos_set_notify_cb)(taos, fp, param, type);
}
void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param) {
CHECK_VOID(fp_taos_fetch_whitelist_a);
return (*fp_taos_fetch_whitelist_a)(taos, fp, param);
}
int taos_set_conn_mode(TAOS *taos, int mode, int value) {
CHECK_INT(fp_taos_set_conn_mode);
return (*fp_taos_set_conn_mode)(taos, mode, value);
}
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
CHECK_PTR(fp_taos_schemaless_insert);
return (*fp_taos_schemaless_insert)(taos, lines, numLines, protocol, precision);
}
TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int64_t reqid) {
CHECK_PTR(fp_taos_schemaless_insert_with_reqid);
return (*fp_taos_schemaless_insert_with_reqid)(taos, lines, numLines, protocol, precision, reqid);
}
TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision) {
CHECK_PTR(fp_taos_schemaless_insert_raw);
return (*fp_taos_schemaless_insert_raw)(taos, lines, len, totalRows, protocol, precision);
}
TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision, int64_t reqid) {
CHECK_PTR(fp_taos_schemaless_insert_raw_with_reqid);
return (*fp_taos_schemaless_insert_raw_with_reqid)(taos, lines, len, totalRows, protocol, precision, reqid);
}
TAOS_RES *taos_schemaless_insert_ttl(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int32_t ttl) {
CHECK_PTR(fp_taos_schemaless_insert_ttl);
return (*fp_taos_schemaless_insert_ttl)(taos, lines, numLines, protocol, precision, ttl);
}
TAOS_RES *taos_schemaless_insert_ttl_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int32_t ttl, int64_t reqid) {
CHECK_PTR(fp_taos_schemaless_insert_ttl_with_reqid);
return (*fp_taos_schemaless_insert_ttl_with_reqid)(taos, lines, numLines, protocol, precision, ttl, reqid);
}
TAOS_RES *taos_schemaless_insert_raw_ttl(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision, int32_t ttl) {
CHECK_PTR(fp_taos_schemaless_insert_raw_ttl);
return (*fp_taos_schemaless_insert_raw_ttl)(taos, lines, len, totalRows, protocol, precision, ttl);
}
TAOS_RES *taos_schemaless_insert_raw_ttl_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision, int32_t ttl, int64_t reqid) {
CHECK_PTR(fp_taos_schemaless_insert_raw_ttl_with_reqid);
return (*fp_taos_schemaless_insert_raw_ttl_with_reqid)(taos, lines, len, totalRows, protocol, precision, ttl, reqid);
}
TAOS_RES *taos_schemaless_insert_raw_ttl_with_reqid_tbname_key(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int32_t ttl, int64_t reqid,
char *tbnameKey) {
CHECK_PTR(fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key);
return (*fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key)(taos, lines, len, totalRows, protocol, precision,
ttl, reqid, tbnameKey);
}
TAOS_RES *taos_schemaless_insert_ttl_with_reqid_tbname_key(TAOS *taos, char *lines[], int numLines, int protocol,
int precision, int32_t ttl, int64_t reqid, char *tbnameKey) {
CHECK_PTR(fp_taos_schemaless_insert_ttl_with_reqid_tbname_key);
return (*fp_taos_schemaless_insert_ttl_with_reqid_tbname_key)(taos, lines, numLines, protocol, precision, ttl, reqid,
tbnameKey);
}
tmq_conf_t *tmq_conf_new() {
CHECK_PTR(fp_tmq_conf_new);
return (*fp_tmq_conf_new)();
}
tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value) {
CHECK_INT(fp_tmq_conf_set);
return (*fp_tmq_conf_set)(conf, key, value);
}
void tmq_conf_destroy(tmq_conf_t *conf) {
CHECK_VOID(fp_tmq_conf_destroy);
(*fp_tmq_conf_destroy)(conf);
}
void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param) {
CHECK_VOID(fp_tmq_conf_set_auto_commit_cb);
(*fp_tmq_conf_set_auto_commit_cb)(conf, cb, param);
}
tmq_list_t *tmq_list_new() {
CHECK_PTR(fp_tmq_list_new);
return (*fp_tmq_list_new)();
}
int32_t tmq_list_append(tmq_list_t *tlist, const char *val) {
CHECK_INT(fp_tmq_list_append);
return (*fp_tmq_list_append)(tlist, val);
}
void tmq_list_destroy(tmq_list_t *tlist) {
CHECK_VOID(fp_tmq_list_destroy);
(*fp_tmq_list_destroy)(tlist);
}
int32_t tmq_list_get_size(const tmq_list_t *tlist) {
CHECK_INT(fp_tmq_list_get_size);
return (*fp_tmq_list_get_size)(tlist);
}
char **tmq_list_to_c_array(const tmq_list_t *tlist) {
CHECK_PTR(fp_tmq_list_to_c_array);
return (*fp_tmq_list_to_c_array)(tlist);
}
tmq_t *tmq_consumer_new(tmq_conf_t *conf, char *errstr, int32_t errstrLen) {
CHECK_PTR(fp_tmq_consumer_new);
return (*fp_tmq_consumer_new)(conf, errstr, errstrLen);
}
int32_t tmq_subscribe(tmq_t *tmq, const tmq_list_t *topic_list) {
CHECK_INT(fp_tmq_subscribe);
return (*fp_tmq_subscribe)(tmq, topic_list);
}
int32_t tmq_unsubscribe(tmq_t *tmq) {
CHECK_INT(fp_tmq_unsubscribe);
return (*fp_tmq_unsubscribe)(tmq);
}
int32_t tmq_subscription(tmq_t *tmq, tmq_list_t **topics) {
CHECK_INT(fp_tmq_subscription);
return (*fp_tmq_subscription)(tmq, topics);
}
TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t timeout) {
CHECK_PTR(fp_tmq_consumer_poll);
return (*fp_tmq_consumer_poll)(tmq, timeout);
}
int32_t tmq_consumer_close(tmq_t *tmq) {
CHECK_INT(fp_tmq_consumer_close);
return (*fp_tmq_consumer_close)(tmq);
}
int32_t tmq_commit_sync(tmq_t *tmq, const TAOS_RES *msg) {
CHECK_INT(fp_tmq_commit_sync);
return (*fp_tmq_commit_sync)(tmq, msg);
}
void tmq_commit_async(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param) {
CHECK_VOID(fp_tmq_commit_async);
(*fp_tmq_commit_async)(tmq, msg, cb, param);
}
int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset) {
CHECK_INT(fp_tmq_commit_offset_sync);
return (*fp_tmq_commit_offset_sync)(tmq, pTopicName, vgId, offset);
}
void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb,
void *param) {
CHECK_VOID(fp_tmq_commit_offset_async);
(*fp_tmq_commit_offset_async)(tmq, pTopicName, vgId, offset, cb, param);
}
int32_t tmq_get_topic_assignment(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,
int32_t *numOfAssignment) {
CHECK_INT(fp_tmq_get_topic_assignment);
return (*fp_tmq_get_topic_assignment)(tmq, pTopicName, assignment, numOfAssignment);
}
void tmq_free_assignment(tmq_topic_assignment *pAssignment) {
CHECK_VOID(fp_tmq_free_assignment);
(*fp_tmq_free_assignment)(pAssignment);
}
int32_t tmq_offset_seek(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset) {
CHECK_INT(fp_tmq_offset_seek);
return (*fp_tmq_offset_seek)(tmq, pTopicName, vgId, offset);
}
int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId) {
CHECK_INT(fp_tmq_position);
return (*fp_tmq_position)(tmq, pTopicName, vgId);
}
int64_t tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId) {
CHECK_INT(fp_tmq_committed);
return (*fp_tmq_committed)(tmq, pTopicName, vgId);
}
TAOS *tmq_get_connect(tmq_t *tmq) {
CHECK_PTR(fp_tmq_get_connect);
return (*fp_tmq_get_connect)(tmq);
}
const char *tmq_get_table_name(TAOS_RES *res) {
CHECK_PTR(fp_tmq_get_table_name);
return (*fp_tmq_get_table_name)(res);
}
tmq_res_t tmq_get_res_type(TAOS_RES *res) {
CHECK_INT(fp_tmq_get_res_type);
return (*fp_tmq_get_res_type)(res);
}
const char *tmq_get_topic_name(TAOS_RES *res) {
CHECK_PTR(fp_tmq_get_topic_name);
return (*fp_tmq_get_topic_name)(res);
}
const char *tmq_get_db_name(TAOS_RES *res) {
CHECK_PTR(fp_tmq_get_db_name);
return (*fp_tmq_get_db_name)(res);
}
int32_t tmq_get_vgroup_id(TAOS_RES *res) {
CHECK_INT(fp_tmq_get_vgroup_id);
return (*fp_tmq_get_vgroup_id)(res);
}
int64_t tmq_get_vgroup_offset(TAOS_RES *res) {
CHECK_INT(fp_tmq_get_vgroup_offset);
return (*fp_tmq_get_vgroup_offset)(res);
}
const char *tmq_err2str(int32_t code) {
CHECK_PTR(fp_tmq_err2str);
return (*fp_tmq_err2str)(code);
}
int32_t tmq_get_raw(TAOS_RES *res, tmq_raw_data *raw) {
CHECK_INT(fp_tmq_get_raw);
return (*fp_tmq_get_raw)(res, raw);
}
int32_t tmq_write_raw(TAOS *taos, tmq_raw_data raw) {
CHECK_INT(fp_tmq_write_raw);
return (*fp_tmq_write_raw)(taos, raw);
}
int taos_write_raw_block(TAOS *taos, int numOfRows, char *pData, const char *tbname) {
CHECK_INT(fp_taos_write_raw_block);
return (*fp_taos_write_raw_block)(taos, numOfRows, pData, tbname);
}
int taos_write_raw_block_with_reqid(TAOS *taos, int numOfRows, char *pData, const char *tbname, int64_t reqid) {
CHECK_INT(fp_taos_write_raw_block_with_reqid);
return (*fp_taos_write_raw_block_with_reqid)(taos, numOfRows, pData, tbname, reqid);
}
int taos_write_raw_block_with_fields(TAOS *taos, int rows, char *pData, const char *tbname, TAOS_FIELD *fields,
int numFields) {
CHECK_INT(fp_taos_write_raw_block_with_fields);
return (*fp_taos_write_raw_block_with_fields)(taos, rows, pData, tbname, fields, numFields);
}
int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pData, const char *tbname,
TAOS_FIELD *fields, int numFields, int64_t reqid) {
CHECK_INT(fp_taos_write_raw_block_with_fields_with_reqid);
return (*fp_taos_write_raw_block_with_fields_with_reqid)(taos, rows, pData, tbname, fields, numFields, reqid);
}
void tmq_free_raw(tmq_raw_data raw) {
CHECK_VOID(fp_tmq_free_raw);
(*fp_tmq_free_raw)(raw);
}
char *tmq_get_json_meta(TAOS_RES *res) {
CHECK_PTR(fp_tmq_get_json_meta);
return (*fp_tmq_get_json_meta)(res);
}
void tmq_free_json_meta(char *jsonMeta) {
CHECK_VOID(fp_tmq_free_json_meta);
return (*fp_tmq_free_json_meta)(jsonMeta);
}
TSDB_SERVER_STATUS taos_check_server_status(const char *fqdn, int port, char *details, int maxlen) {
CHECK_INT(fp_taos_check_server_status);
return (*fp_taos_check_server_status)(fqdn, port, details, maxlen);
}
void taos_write_crashinfo(int signum, void *sigInfo, void *context) {
CHECK_VOID(fp_taos_write_crashinfo);
(*fp_taos_write_crashinfo)(signum, sigInfo, context);
}
char *getBuildInfo() {
CHECK_PTR(fp_getBuildInfo);
return (*fp_getBuildInfo)();
}

View File

@ -0,0 +1,205 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY = NULL; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wrapper.h"
setConfRet (*fp_taos_set_config)(const char *config) = NULL;
int (*fp_taos_init)(void) = NULL;
void (*fp_taos_cleanup)(void) = NULL;
int (*fp_taos_options)(TSDB_OPTION option, const void *arg, ...) = NULL;
int (*fp_taos_options_connection)(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...) = NULL;
TAOS *(*fp_taos_connect)(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) = NULL;
TAOS *(*fp_taos_connect_auth)(const char *ip, const char *user, const char *auth, const char *db, uint16_t port) = NULL;
void (*fp_taos_close)(TAOS *taos) = NULL;
const char *(*fp_taos_data_type)(int type) = NULL;
TAOS_STMT *(*fp_taos_stmt_init)(TAOS *taos) = NULL;
TAOS_STMT *(*fp_taos_stmt_init_with_reqid)(TAOS *taos, int64_t reqid) = NULL;
TAOS_STMT *(*fp_taos_stmt_init_with_options)(TAOS *taos, TAOS_STMT_OPTIONS *options) = NULL;
int (*fp_taos_stmt_prepare)(TAOS_STMT *stmt, const char *sql, unsigned long length) = NULL;
int (*fp_taos_stmt_set_tbname_tags)(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags) = NULL;
int (*fp_taos_stmt_set_tbname)(TAOS_STMT *stmt, const char *name) = NULL;
int (*fp_taos_stmt_set_tags)(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) = NULL;
int (*fp_taos_stmt_set_sub_tbname)(TAOS_STMT *stmt, const char *name) = NULL;
int (*fp_taos_stmt_get_tag_fields)(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) = NULL;
int (*fp_taos_stmt_get_col_fields)(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) = NULL;
void (*fp_taos_stmt_reclaim_fields)(TAOS_STMT *stmt, TAOS_FIELD_E *fields) = NULL;
int (*fp_taos_stmt_is_insert)(TAOS_STMT *stmt, int *insert) = NULL;
int (*fp_taos_stmt_num_params)(TAOS_STMT *stmt, int *nums) = NULL;
int (*fp_taos_stmt_get_param)(TAOS_STMT *stmt, int idx, int *type, int *bytes) = NULL;
int (*fp_taos_stmt_bind_param)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) = NULL;
int (*fp_taos_stmt_bind_param_batch)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) = NULL;
int (*fp_taos_stmt_bind_single_param_batch)(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx) = NULL;
int (*fp_taos_stmt_add_batch)(TAOS_STMT *stmt) = NULL;
int (*fp_taos_stmt_execute)(TAOS_STMT *stmt) = NULL;
TAOS_RES *(*fp_taos_stmt_use_result)(TAOS_STMT *stmt) = NULL;
int (*fp_taos_stmt_close)(TAOS_STMT *stmt) = NULL;
char *(*fp_taos_stmt_errstr)(TAOS_STMT *stmt) = NULL;
int (*fp_taos_stmt_affected_rows)(TAOS_STMT *stmt) = NULL;
int (*fp_taos_stmt_affected_rows_once)(TAOS_STMT *stmt) = NULL;
TAOS_STMT2 *(*fp_taos_stmt2_init)(TAOS *taos, TAOS_STMT2_OPTION *option) = NULL;
int (*fp_taos_stmt2_prepare)(TAOS_STMT2 *stmt, const char *sql, unsigned long length) = NULL;
int (*fp_taos_stmt2_bind_param)(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx) = NULL;
int (*fp_taos_stmt2_bind_param_a)(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx, __taos_async_fn_t fp,
void *param) = NULL;
int (*fp_taos_stmt2_exec)(TAOS_STMT2 *stmt, int *affected_rows) = NULL;
int (*fp_taos_stmt2_close)(TAOS_STMT2 *stmt) = NULL;
int (*fp_taos_stmt2_is_insert)(TAOS_STMT2 *stmt, int *insert) = NULL;
int (*fp_taos_stmt2_get_fields)(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields) = NULL;
void (*fp_taos_stmt2_free_fields)(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields) = NULL;
TAOS_RES *(*fp_taos_stmt2_result)(TAOS_STMT2 *stmt) = NULL;
char *(*fp_taos_stmt2_error)(TAOS_STMT2 *stmt) = NULL;
TAOS_RES *(*fp_taos_query)(TAOS *taos, const char *sql) = NULL;
TAOS_RES *(*fp_taos_query_with_reqid)(TAOS *taos, const char *sql, int64_t reqId) = NULL;
TAOS_ROW (*fp_taos_fetch_row)(TAOS_RES *res) = NULL;
int (*fp_taos_result_precision)(TAOS_RES *res) = NULL; // get the time precision of result
void (*fp_taos_free_result)(TAOS_RES *res) = NULL;
void (*fp_taos_kill_query)(TAOS *taos) = NULL;
int (*fp_taos_field_count)(TAOS_RES *res) = NULL;
int (*fp_taos_num_fields)(TAOS_RES *res) = NULL;
int (*fp_taos_affected_rows)(TAOS_RES *res) = NULL;
int64_t (*fp_taos_affected_rows64)(TAOS_RES *res) = NULL;
TAOS_FIELD *(*fp_taos_fetch_fields)(TAOS_RES *res) = NULL;
TAOS_FIELD_E *(*fp_taos_fetch_fields_e)(TAOS_RES *res) = NULL;
int (*fp_taos_select_db)(TAOS *taos, const char *db) = NULL;
int (*fp_taos_print_row)(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) = NULL;
int (*fp_taos_print_row_with_size)(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) = NULL;
void (*fp_taos_stop_query)(TAOS_RES *res) = NULL;
bool (*fp_taos_is_null)(TAOS_RES *res, int32_t row, int32_t col) = NULL;
int (*fp_taos_is_null_by_column)(TAOS_RES *res, int columnIndex, bool result[], int *rows) = NULL;
bool (*fp_taos_is_update_query)(TAOS_RES *res) = NULL;
int (*fp_taos_fetch_block)(TAOS_RES *res, TAOS_ROW *rows) = NULL;
int (*fp_taos_fetch_block_s)(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) = NULL;
int (*fp_taos_fetch_raw_block)(TAOS_RES *res, int *numOfRows, void **pData) = NULL;
int *(*fp_taos_get_column_data_offset)(TAOS_RES *res, int columnIndex) = NULL;
int (*fp_taos_validate_sql)(TAOS *taos, const char *sql) = NULL;
void (*fp_taos_reset_current_db)(TAOS *taos) = NULL;
int *(*fp_taos_fetch_lengths)(TAOS_RES *res) = NULL;
TAOS_ROW *(*fp_taos_result_block)(TAOS_RES *res) = NULL;
const char *(*fp_taos_get_server_info)(TAOS *taos) = NULL;
const char *(*fp_taos_get_client_info)() = NULL;
int (*fp_taos_get_current_db)(TAOS *taos, char *database, int len, int *required) = NULL;
const char *(*fp_taos_errstr)(TAOS_RES *res) = NULL;
int (*fp_taos_errno)(TAOS_RES *res) = NULL;
void (*fp_taos_query_a)(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) = NULL;
void (*fp_taos_query_a_with_reqid)(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param,
int64_t reqid) = NULL;
void (*fp_taos_fetch_rows_a)(TAOS_RES *res, __taos_async_fn_t fp, void *param) = NULL;
void (*fp_taos_fetch_raw_block_a)(TAOS_RES *res, __taos_async_fn_t fp, void *param) = NULL;
const void *(*fp_taos_get_raw_block)(TAOS_RES *res) = NULL;
int (*fp_taos_get_db_route_info)(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo) = NULL;
int (*fp_taos_get_table_vgId)(TAOS *taos, const char *db, const char *table, int *vgId) = NULL;
int (*fp_taos_get_tables_vgId)(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId) = NULL;
int (*fp_taos_load_table_info)(TAOS *taos, const char *tableNameList) = NULL;
void (*fp_taos_set_hb_quit)(int8_t quitByKill) = NULL;
int (*fp_taos_set_notify_cb)(TAOS *taos, __taos_notify_fn_t fp, void *param, int type) = NULL;
void (*fp_taos_fetch_whitelist_a)(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param) = NULL;
int (*fp_taos_set_conn_mode)(TAOS *taos, int mode, int value) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert)(TAOS *taos, char *lines[], int numLines, int protocol, int precision) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_with_reqid)(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int64_t reqid) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_raw)(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_raw_with_reqid)(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int64_t reqid) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_ttl)(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
int32_t ttl) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_ttl_with_reqid)(TAOS *taos, char *lines[], int numLines, int protocol,
int precision, int32_t ttl, int64_t reqid) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl)(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
int precision, int32_t ttl) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl_with_reqid)(TAOS *taos, char *lines, int len, int32_t *totalRows,
int protocol, int precision, int32_t ttl,
int64_t reqid) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_raw_ttl_with_reqid_tbname_key)(TAOS *taos, char *lines, int len,
int32_t *totalRows, int protocol, int precision,
int32_t ttl, int64_t reqid,
char *tbnameKey) = NULL;
TAOS_RES *(*fp_taos_schemaless_insert_ttl_with_reqid_tbname_key)(TAOS *taos, char *lines[], int numLines, int protocol,
int precision, int32_t ttl, int64_t reqid,
char *tbnameKey) = NULL;
tmq_conf_t *(*fp_tmq_conf_new)() = NULL;
tmq_conf_res_t (*fp_tmq_conf_set)(tmq_conf_t *conf, const char *key, const char *value) = NULL;
void (*fp_tmq_conf_destroy)(tmq_conf_t *conf) = NULL;
void (*fp_tmq_conf_set_auto_commit_cb)(tmq_conf_t *conf, tmq_commit_cb *cb, void *param) = NULL;
tmq_list_t *(*fp_tmq_list_new)() = NULL;
int32_t (*fp_tmq_list_append)(tmq_list_t *, const char *) = NULL;
void (*fp_tmq_list_destroy)(tmq_list_t *) = NULL;
int32_t (*fp_tmq_list_get_size)(const tmq_list_t *) = NULL;
char **(*fp_tmq_list_to_c_array)(const tmq_list_t *) = NULL;
tmq_t *(*fp_tmq_consumer_new)(tmq_conf_t *conf, char *errstr, int32_t errstrLen) = NULL;
int32_t (*fp_tmq_subscribe)(tmq_t *tmq, const tmq_list_t *topic_list) = NULL;
int32_t (*fp_tmq_unsubscribe)(tmq_t *tmq) = NULL;
int32_t (*fp_tmq_subscription)(tmq_t *tmq, tmq_list_t **topics) = NULL;
TAOS_RES *(*fp_tmq_consumer_poll)(tmq_t *tmq, int64_t timeout) = NULL;
int32_t (*fp_tmq_consumer_close)(tmq_t *tmq) = NULL;
int32_t (*fp_tmq_commit_sync)(tmq_t *tmq, const TAOS_RES *msg) = NULL;
void (*fp_tmq_commit_async)(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param) = NULL;
int32_t (*fp_tmq_commit_offset_sync)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset) = NULL;
void (*fp_tmq_commit_offset_async)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb,
void *param) = NULL;
int32_t (*fp_tmq_get_topic_assignment)(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,
int32_t *numOfAssignment) = NULL;
void (*fp_tmq_free_assignment)(tmq_topic_assignment *pAssignment) = NULL;
int32_t (*fp_tmq_offset_seek)(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset) = NULL;
int64_t (*fp_tmq_position)(tmq_t *tmq, const char *pTopicName, int32_t vgId) = NULL;
int64_t (*fp_tmq_committed)(tmq_t *tmq, const char *pTopicName, int32_t vgId) = NULL;
TAOS *(*fp_tmq_get_connect)(tmq_t *tmq) = NULL;
const char *(*fp_tmq_get_table_name)(TAOS_RES *res) = NULL;
tmq_res_t (*fp_tmq_get_res_type)(TAOS_RES *res) = NULL;
const char *(*fp_tmq_get_topic_name)(TAOS_RES *res) = NULL;
const char *(*fp_tmq_get_db_name)(TAOS_RES *res) = NULL;
int32_t (*fp_tmq_get_vgroup_id)(TAOS_RES *res) = NULL;
int64_t (*fp_tmq_get_vgroup_offset)(TAOS_RES *res) = NULL;
const char *(*fp_tmq_err2str)(int32_t code) = NULL;
int32_t (*fp_tmq_get_raw)(TAOS_RES *res, tmq_raw_data *raw) = NULL;
int32_t (*fp_tmq_write_raw)(TAOS *taos, tmq_raw_data raw) = NULL;
int (*fp_taos_write_raw_block)(TAOS *taos, int numOfRows, char *pData, const char *tbname) = NULL;
int (*fp_taos_write_raw_block_with_reqid)(TAOS *taos, int numOfRows, char *pData, const char *tbname,
int64_t reqid) = NULL;
int (*fp_taos_write_raw_block_with_fields)(TAOS *taos, int rows, char *pData, const char *tbname, TAOS_FIELD *fields,
int numFields) = NULL;
int (*fp_taos_write_raw_block_with_fields_with_reqid)(TAOS *taos, int rows, char *pData, const char *tbname,
TAOS_FIELD *fields, int numFields, int64_t reqid) = NULL;
void (*fp_tmq_free_raw)(tmq_raw_data raw) = NULL;
char *(*fp_tmq_get_json_meta)(TAOS_RES *res) = NULL;
void (*fp_tmq_free_json_meta)(char *jsonMeta) = NULL;
TSDB_SERVER_STATUS (*fp_taos_check_server_status)(const char *fqdn, int port, char *details, int maxlen) = NULL;
void (*fp_taos_write_crashinfo)(int signum, void *sigInfo, void *context) = NULL;
char *(*fp_getBuildInfo)() = NULL;

View File

@ -6,5 +6,5 @@ target_include_directories(
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
target_link_libraries(
node_util cjson mnode vnode qnode snode wal sync ${TAOS_LIB_STATIC} tfs monitor monitorfw
node_util cjson mnode vnode qnode snode wal sync ${TAOS_NATIVE_LIB_STATIC} tfs monitor monitorfw
)

View File

@ -9,7 +9,7 @@ IF(NOT TD_DARWIN)
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
TARGET_LINK_LIBRARIES(
catalogTest
PUBLIC os util common nodes catalog transport gtest qcom ${TAOS_LIB_STATIC}
PUBLIC os util common nodes catalog transport gtest qcom ${TAOS_NATIVE_LIB_STATIC}
)
TARGET_INCLUDE_DIRECTORIES(
@ -19,7 +19,7 @@ IF(NOT TD_DARWIN)
)
add_test(
NAME catalogTest
COMMAND catalogTest
NAME catalogTest
COMMAND catalogTest
)
ENDIF()

View File

@ -9,7 +9,7 @@ MESSAGE(STATUS "build parser unit test")
# ADD_EXECUTABLE(executorTest ${SOURCE_LIST})
# TARGET_LINK_LIBRARIES(
# executorTest
# PRIVATE os util common transport gtest ${TAOS_LIB_STATIC} qcom executor function planner scalar nodes vnode
# PRIVATE os util common transport gtest ${TAOS_NATIVE_LIB_STATIC} qcom executor function planner scalar nodes vnode
# )
#
# TARGET_INCLUDE_DIRECTORIES(

View File

@ -8,15 +8,15 @@ IF(NOT TD_DARWIN)
ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST})
IF (TD_GRANT)
IF(TD_GRANT)
TARGET_LINK_LIBRARIES(
schedulerTest
PUBLIC os util common catalog transport gtest qcom ${TAOS_LIB_STATIC} planner scheduler grant
PUBLIC os util common catalog transport gtest qcom ${TAOS_NATIVE_LIB_STATIC} planner scheduler grant
)
ELSE ()
ELSE()
TARGET_LINK_LIBRARIES(
schedulerTest
PUBLIC os util common catalog transport gtest qcom ${TAOS_LIB_STATIC} planner scheduler
PUBLIC os util common catalog transport gtest qcom ${TAOS_NATIVE_LIB_STATIC} planner scheduler
)
ENDIF()
@ -28,6 +28,5 @@ IF(NOT TD_DARWIN)
add_test(
NAME schedulerTest
COMMAND schedulerTest
)
)
ENDIF()

View File

@ -85,6 +85,7 @@ else()
)
endif()
if(JEMALLOC_ENABLED)
add_dependencies(os jemalloc)
endif()
@ -96,3 +97,4 @@ endif()
if(${BUILD_TEST})
add_subdirectory(test)
endif(${BUILD_TEST})

View File

@ -58,7 +58,7 @@ int32_t wordexp(char *words, wordexp_t *pwordexp, int32_t flags) {
void wordfree(wordexp_t *pwordexp) {}
#elif defined(DARWIN)
#include <dlfcn.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
@ -77,6 +77,7 @@ typedef struct TdDir {
#else
#include <dlfcn.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
@ -372,8 +373,9 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {
OS_PARAM_CHECK(dirname);
#ifndef TD_ASTRA
char tmp[PATH_MAX] = {0};
char tmp[PATH_MAX + 1] = {0};
#ifdef WINDOWS
if (_fullpath(tmp, dirname, maxlen) != NULL) {
#else
@ -602,6 +604,24 @@ void taosGetCwd(char *buf, int32_t len) {
#endif
}
int32_t taosAppPath(char *path, int32_t maxLen) {
int32_t ret = 0;
#ifdef WINDOWS
ret = GetModuleFileName(NULL, path, maxLen - 1);
#elif defined(DARWIN)
ret = _NSGetExecutablePath(path, &maxLen) ;
#else
ret = readlink("/proc/self/exe", path, maxLen - 1);
#endif
if (ret >= 0) {
ret = (taosDirName(path) == NULL) ? -1 : 0;
}
return ret;
}
int32_t taosGetDirSize(const char *path, int64_t *size) {
int32_t code = 0;
char fullPath[PATH_MAX + 100] = {0};
@ -638,3 +658,54 @@ _OVER:
TAOS_UNUSED(taosCloseDir(&pDir));
return code;
}
void* taosLoadDll(const char* fileName) {
#if defined(WINDOWS)
void* handle = LoadLibraryA(fileName);
#else
void* handle = dlopen(fileName, RTLD_LAZY);
#endif
if (handle == NULL) {
if (errno != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
} else {
terrno = TSDB_CODE_DLL_NOT_LOAD;
}
}
return handle;
}
void taosCloseDll(void* handle) {
if (handle == NULL) return;
#if defined(WINDOWS)
FreeLibrary((HMODULE)handle);
#else
if (dlclose(handle) != 0 && errno != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
}
#endif
}
void* taosLoadDllFunc(void* handle, const char* funcName) {
if (handle == NULL) return NULL;
#if defined(WINDOWS)
void *fptr = GetProcAddress((HMODULE)handle, funcName);
#else
void *fptr = dlsym(handle, funcName);
#endif
if (handle == NULL) {
if (errno != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
} else {
terrno = TSDB_CODE_DLL_FUNC_NOT_LOAD;
}
}
return fptr;
}

View File

@ -88,38 +88,6 @@ struct termios oldtio;
typedef struct FILE TdCmd;
#ifdef BUILD_NO_CALL
void* taosLoadDll(const char* filename) {
#if defined(WINDOWS)
return NULL;
#elif defined(_TD_DARWIN_64)
return NULL;
#else
void* handle = dlopen(filename, RTLD_LAZY);
if (!handle) {
// printf("load dll:%s failed, error:%s", filename, dlerror());
return NULL;
}
// printf("dll %s loaded", filename);
return handle;
#endif
}
void taosCloseDll(void* handle) {
#if defined(WINDOWS)
return;
#elif defined(_TD_DARWIN_64)
return;
#else
if (handle) {
dlclose(handle);
}
#endif
}
#endif
int32_t taosSetConsoleEcho(bool on) {
#if defined(WINDOWS)
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);

View File

@ -76,7 +76,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, "Ref ID is removed")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, "Invalid Ref ID")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, "Ref is already there")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, "Ref is not there")
TAOS_DEFINE_ERROR(TSDB_CODE_DLL_NOT_LOAD, "Driver was not loaded")
TAOS_DEFINE_ERROR(TSDB_CODE_DLL_FUNC_NOT_LOAD, "Function was not loaded from the driver")
TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, "Unexpected generic error")
TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, "Action in progress")
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RANGE, "Out of range")

View File

@ -1374,6 +1374,10 @@ static void checkWriteCrashLogToFileInNewThead() {
}
taosLogCrashInfo(gCrashBasicInfo.nodeType, pMsg, msgLen, gCrashBasicInfo.signum, gCrashBasicInfo.sigInfo);
setCrashWriterStatus(CRASH_LOG_WRITER_INIT);
int32_t code = tsem_post(&gCrashBasicInfo.sem);
if (code != 0 ) {
uError("failed to post sem for crashBasicInfo, code:%d", code);
}
TAOS_UNUSED(tsem_post(&gCrashBasicInfo.sem));
}
}

View File

@ -17,6 +17,8 @@ TSDB_CODE_REF_ID_REMOVED = 0x80000107
TSDB_CODE_REF_INVALID_ID = 0x80000108
TSDB_CODE_REF_ALREADY_EXIST = 0x80000109
TSDB_CODE_REF_NOT_EXIST = 0x8000010A
TSDB_CODE_DLL_NOT_LOAD = 0x8000010B
TSDB_CODE_DLL_FUNC_NOT_LOAD = 0x8000010C
TSDB_CODE_APP_ERROR = 0x80000110
TSDB_CODE_ACTION_IN_PROGRESS = 0x80000111
TSDB_CODE_OUT_OF_RANGE = 0x80000112

View File

@ -57,31 +57,29 @@ class TDTestCase(TBase):
def checkResultWithMode(self, db, stb, arg):
result = "Query OK, 10 row(s)"
mode = arg[0]
rowh = arg[1]
rowv = arg[2]
idx = arg[3]
idxv = arg[4]
# use db
if mode != "-R":
rlist = self.taos(f'{mode} -s "show databases;use {db};show databases;" ')
self.checkListString(rlist, "Database changed")
rlist = self.taos(f'{mode} -s "show databases;use {db};show databases;" ')
self.checkListString(rlist, "Database changed")
# hori
cmd = f'{mode} -s "select * from {db}.{stb} limit 10'
cmd = f'{mode} -s "select ts,ic from {db}.{stb} limit 10'
rlist = self.taos(cmd + '"')
# line count
self.checkSame(len(rlist), rowh)
# last line
self.checkSame(rlist[idx][:len(result)], result)
results = [
"2022-10-01 00:00:09.000 |",
result
]
self.checkManyString(rlist, results)
# vec
rlist = self.taos(cmd + '\G"')
# line count
self.checkSame(len(rlist), rowv)
self.checkSame(rlist[idxv], "*************************** 10.row ***************************")
# last line
self.checkSame(rlist[idx][:len(result)], result)
results = [
"****** 10.row *******",
"ts: 2022-10-01 00:00:09.000",
result
]
self.checkManyString(rlist, results)
# -B have some problem need todo
self.taos(f'{mode} -B -s "select * from {db}.{stb} where ts < 1"')
@ -125,12 +123,16 @@ class TDTestCase(TBase):
# insert
json = "cmdline/json/taosCli.json"
db, stb, childCount, insertRows = self.insertBenchJson(json)
# set
self.db = db
self.stb = stb
self.insert_rows = insertRows
self.childtable_count = childCount
# native restful websock test
args = [
["", 18, 346, -2, 310],
["-R", 22, 350, -3, 313],
["-T 40 -E http://localhost:6041", 21, 349, -3, 312]
["-Z native"],
["-T 40 -E http://localhost:6041"]
]
for arg in args:
self.checkResultWithMode(db, stb, arg)
@ -164,8 +166,7 @@ class TDTestCase(TBase):
def checkDumpInOut(self):
args = [
["", 18],
["-R ", 22],
["", 18],
["-E http://localhost:6041", 21]
]
@ -181,10 +182,18 @@ class TDTestCase(TBase):
rlist2 = self.taos("--version")
self.checkSame(rlist1, rlist2)
self.checkSame(len(rlist1), 5)
if len(rlist1) < 4:
tdLog.exit(f"version lines less than 4. {rlist1}")
if len(rlist1[2]) < 42:
tdLog.exit("git commit id length is invalid: " + rlist1[2])
keys = [
"version:",
"git:",
"build:"
]
self.checkManyString(rlist1, keys)
def checkHelp(self):
@ -205,20 +214,13 @@ class TDTestCase(TBase):
def checkCommand(self):
# check coredump
# o logpath
char = 'a'
lname =f'-o "/root/log/{char * 1000}/" -s "quit;"'
queryOK = "Query OK"
# invalid input check
# support Both
args = [
[lname, "failed to create log at"],
['-uroot -w 40 -ptaosdata -c /root/taos/ -s"show databases"', queryOK],
['-o "./current/log/files/" -s"show databases;"', queryOK],
['-a ""', "Invalid auth"],
['-o "./current/log/files/" -h localhost -uroot -ptaosdata -s"show databases;"', queryOK],
['-s "quit;"', "Welcome to the TDengine Command Line Interface"],
['-a "abc"', "[0x80000357]"],
['-h "" -s "show dnodes;"', "Invalid host"],
['-u "" -s "show dnodes;"', "Invalid user"],
['-P "" -s "show dnodes;"', "Invalid port"],
@ -226,7 +228,7 @@ class TDTestCase(TBase):
['-p"abc" -s "show dnodes;"', "[0x80000357]"],
['-d "abc" -s "show dnodes;"', "[0x80000388]"],
['-N 0 -s "show dnodes;"', "Invalid pktNum"],
['-N 10 -s "show dnodes;"', queryOK],
['-N 10 -h 127.0.0.1 -s "show dnodes;"', queryOK],
['-w 0 -s "show dnodes;"', "Invalid displayWidth"],
['-w 10 -s "show dnodes;"', queryOK],
['-W 10 -s "show dnodes;"', None],
@ -240,10 +242,133 @@ class TDTestCase(TBase):
['-uroot -p < cmdline/data/pwd.txt -s "show dnodes;"', queryOK],
]
modes = ["-Z 0","-Z 1"]
for mode in modes:
for arg in args:
rlist = self.taos(mode + " " + arg[0])
if arg[1] != None:
self.checkListString(rlist, arg[1])
#
# support native only
#
# o logpath
char = 'a'
lname =f'-o "/root/log/{char * 1000}/" -s "quit;"'
args = [
[lname, "failed to create log at"],
['-a ""', "Invalid auth"],
['-a "abc"', "[0x80000357]"],
]
for arg in args:
rlist = self.taos(arg[0])
rlist = self.taos("Z 0 " + arg[0])
if arg[1] != None:
self.checkListString(rlist, arg[1])
self.checkListString(rlist, arg[1])
# expect cmd > json > evn
def checkPriority(self):
#
# cmd & env
#
# env 6043 - invalid
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6043"
# cmd 6041 - valid
cmd = f"-X http://127.0.0.1:6041 -s 'select ts from test.meters'"
rlist = self.taos(cmd, checkRun = True)
results = [
"WebSocket Client Version",
"2022-10-01 00:01:39.000",
"Query OK, 200 row(s) in set"
]
self.checkManyString(rlist, results)
#
# env
#
# cloud
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6041"
cmd = f"-s 'select ts from test.meters'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
# local
os.environ['TDENGINE_CLOUD_DSN'] = ""
os.environ['TDENGINE_DSN'] = "http://127.0.0.1:6041"
cmd = f"-s 'select ts from test.meters'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
# local & cloud -> cloud first
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6041" # valid
os.environ['TDENGINE_DSN'] = "http://127.0.0.1:6042" # invalid
cmd = f"-s 'select ts from test.meters'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
#
# cmd
#
os.environ['TDENGINE_CLOUD_DSN'] = ""
os.environ['TDENGINE_DSN'] = ""
cmd = f"-X http://127.0.0.1:6041 -s 'select ts from test.meters'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
def checkExceptCmd(self):
# exe
taos = frame.etool.taosFile()
# option
options = [
"-Z native -X http://127.0.0.1:6041",
"-Z 100",
"-Z abcdefg",
"-X",
"-X ",
"-X 127.0.0.1:6041",
"-X https://gw.cloud.taosdata.com?token617ffdf...",
"-Z 1 -X https://gw.cloud.taosdata.com?token=617ffdf...",
"-X http://127.0.0.1:6042"
]
# do check
for option in options:
self.checkExcept(taos + " -s 'show dnodes;' " + option)
def checkModeVersion(self):
# results
results = [
"WebSocket Client Version",
"2022-10-01 00:01:39.000",
"Query OK, 100 row(s) in set"
]
# default
cmd = f"-s 'select ts from test.d0'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
# websocket
cmd = f"-Z 1 -s 'select ts from test.d0'"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
# native
cmd = f"-Z 0 -s 'select ts from test.d0'"
results[0] = "Native Client Version"
rlist = self.taos(cmd, checkRun = True)
self.checkManyString(rlist, results)
def checkConnMode(self):
# priority
self.checkPriority()
# except
self.checkExceptCmd()
# mode version
self.checkModeVersion()
# password
def checkPassword(self):
@ -288,6 +413,10 @@ class TDTestCase(TBase):
# check data in/out
self.checkDumpInOut()
# check conn mode
self.checkConnMode()
# max password
self.checkPassword()

View File

@ -38,6 +38,12 @@ class TBase:
# init
def init(self, conn, logSql, replicaVar=1, db="db", stb="stb", checkColName="ic"):
# init
self.childtable_count = 0
self.insert_rows = 0
self.timestamp_step = 0
# save param
self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor(), True)
@ -54,12 +60,12 @@ class TBase:
self.stb = stb
# sql
self.sqlSum = f"select sum({checkColName}) from {self.stb}"
self.sqlMax = f"select max({checkColName}) from {self.stb}"
self.sqlMin = f"select min({checkColName}) from {self.stb}"
self.sqlAvg = f"select avg({checkColName}) from {self.stb}"
self.sqlFirst = f"select first(ts) from {self.stb}"
self.sqlLast = f"select last(ts) from {self.stb}"
self.sqlSum = f"select sum({checkColName}) from {db}.{self.stb}"
self.sqlMax = f"select max({checkColName}) from {db}.{self.stb}"
self.sqlMin = f"select min({checkColName}) from {db}.{self.stb}"
self.sqlAvg = f"select avg({checkColName}) from {db}.{self.stb}"
self.sqlFirst = f"select first(ts) from {db}.{self.stb}"
self.sqlLast = f"select last(ts) from {db}.{self.stb}"
# stop
def stop(self):
@ -140,15 +146,15 @@ class TBase:
# basic
def checkInsertCorrect(self, difCnt = 0):
# check count
sql = f"select count(*) from {self.stb}"
sql = f"select count(*) from {self.db}.{self.stb}"
tdSql.checkAgg(sql, self.childtable_count * self.insert_rows)
# check child table count
sql = f" select count(*) from (select count(*) as cnt , tbname from {self.stb} group by tbname) where cnt = {self.insert_rows} "
sql = f" select count(*) from (select count(*) as cnt , tbname from {self.db}.{self.stb} group by tbname) where cnt = {self.insert_rows} "
tdSql.checkAgg(sql, self.childtable_count)
# check step
sql = f"select count(*) from (select diff(ts) as dif from {self.stb} partition by tbname order by ts desc) where dif != {self.timestamp_step}"
sql = f"select count(*) from (select diff(ts) as dif from {self.db}.{self.stb} partition by tbname order by ts desc) where dif != {self.timestamp_step}"
tdSql.checkAgg(sql, difCnt)
# save agg result
@ -172,27 +178,27 @@ class TBase:
# self check
def checkConsistency(self, col):
# top with max
sql = f"select max({col}) from {self.stb}"
sql = f"select max({col}) from {self.db}.{self.stb}"
expect = tdSql.getFirstValue(sql)
sql = f"select top({col}, 5) from {self.stb}"
sql = f"select top({col}, 5) from {self.db}.{self.stb}"
tdSql.checkFirstValue(sql, expect)
#bottom with min
sql = f"select min({col}) from {self.stb}"
sql = f"select min({col}) from {self.db}.{self.stb}"
expect = tdSql.getFirstValue(sql)
sql = f"select bottom({col}, 5) from {self.stb}"
sql = f"select bottom({col}, 5) from {self.db}.{self.stb}"
tdSql.checkFirstValue(sql, expect)
# order by asc limit 1 with first
sql = f"select last({col}) from {self.stb}"
sql = f"select last({col}) from {self.db}.{self.stb}"
expect = tdSql.getFirstValue(sql)
sql = f"select {col} from {self.stb} order by _c0 desc limit 1"
sql = f"select {col} from {self.db}.{self.stb} order by _c0 desc limit 1"
tdSql.checkFirstValue(sql, expect)
# order by desc limit 1 with last
sql = f"select first({col}) from {self.stb}"
sql = f"select first({col}) from {self.db}.{self.db}."
expect = tdSql.getFirstValue(sql)
sql = f"select {col} from {self.stb} order by _c0 asc limit 1"
sql = f"select {col} from {self.db}.{self.db}. order by _c0 asc limit 1"
tdSql.checkFirstValue(sql, expect)
@ -243,6 +249,17 @@ class TBase:
else:
tdLog.exit(f"check same failed. real={real} expect={expect}.")
# check except
def checkExcept(self, command):
try:
code = frame.eos.exe(command, show = True)
if code == 0:
tdLog.exit(f"Failed, not report error cmd:{command}")
else:
tdLog.info(f"Passed, report error code={code} is expect, cmd:{command}")
except:
tdLog.info(f"Passed, catch expect report error for command {command}")
#
# get db information
#
@ -292,7 +309,8 @@ class TBase:
def taosdump(self, command, show = True, checkRun = True, retFail = True):
return frame.etool.runBinFile("taosdump", command, show, checkRun, retFail)
def benchmark(self, command, show = True, checkRun = True, retFail = True):
return frame.etool.runBinFile("taosBenchmark", command, show, checkRun, retFail)
#
# util
#
@ -335,15 +353,22 @@ class TBase:
# check list have str
def checkListString(self, vlist, s):
for i in range(len(vlist)):
if vlist[i].find(s) != -1:
def checkListString(self, rlist, s):
if s is None:
return
for i in range(len(rlist)):
if rlist[i].find(s) != -1:
# found
tdLog.info(f'found "{s}" on index {i} , line={vlist[i]}')
tdLog.info(f'found "{s}" on index {i} , line={rlist[i]}')
return
# not found
tdLog.exit(f'faild, not found "{s}" on list:{vlist}')
tdLog.exit(f'faild, not found "{s}" on list:{rlist}')
# check many string
def checkManyString(self, rlist, manys):
for s in manys:
self.checkListString(rlist, s)
#
# str util
@ -480,6 +505,23 @@ class TBase:
return rlist
# cmd
def benchmarkCmd(self, options, childCnt, insertRows, timeStep, results):
# set
self.childtable_count = childCnt
self.insert_rows = insertRows
self.timestamp_step = timeStep
# run
cmd = f"{options} -t {childCnt} -n {insertRows} -S {timeStep} -y"
rlist = self.benchmark(cmd)
for result in results:
self.checkListString(rlist, result)
# check correct
self.checkInsertCorrect()
# generate new json file
def genNewJson(self, jsonFile, modifyFunc=None):
try:

View File

@ -23,6 +23,14 @@ import frame.epath
import frame.eos
from frame.log import *
# taos
def taosFile():
bmFile = frame.epath.binFile("taos")
if frame.eos.isWin():
bmFile += ".exe"
return bmFile
# taosdump
def taosDumpFile():
bmFile = frame.epath.binFile("taosdump")

View File

@ -89,6 +89,10 @@ else
export LD_PRELOAD="$(realpath "$(gcc -print-file-name=libasan.so)") $(realpath "$(gcc -print-file-name=libstdc++.so)")"
echo "Preload AsanSo:" $?
export ASAN_OPTIONS=detect_odr_violation=0
echo "forbid check ODR violation."
$* -a 2>$AsanFile
unset LD_PRELOAD

View File

@ -37,6 +37,9 @@ import taos
import taosrest
import taosws
from taos.cinterface import *
taos.taos_options(6, "native")
def checkRunTimeError():
import win32gui
timeCount = 0
@ -258,8 +261,9 @@ if __name__ == "__main__":
#
# do exeCmd command
#
taosAdapter = True # default is websocket , so must start taosAdapter
if not execCmd == "":
if taosAdapter or taosAdapter or restful or websocket:
if taosAdapter or restful or websocket:
tAdapter.init(deployPath)
else:
tdDnodes.init(deployPath)

View File

@ -1,75 +0,0 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import os
import frame
import frame.etool
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame import *
class TDTestCase(TBase):
def caseDescription(self):
"""
[TD-22334] taosBenchmark sml rest test cases
"""
def run(self):
binPath = etool.benchMarkFile()
cmd = "%s -I sml-rest -t 1 -n 1 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 1)
cmd = "%s -I sml-rest-line -t 1 -n 1 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 1)
cmd = "%s -I sml-rest-telnet -t 1 -n 1 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 1)
cmd = "%s -I sml-rest-json -t 1 -n 1 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 1)
cmd = "%s -I sml-rest-taosjson -t 1 -n 1 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 1)
cmd = "%s -N -I sml-rest -y" % binPath
tdLog.info("%s" % cmd)
assert os.system("%s" % cmd) != 0
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -67,6 +67,16 @@ class TDTestCase(TBase):
tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 10*10000)
# add normal table
cmd = "%s -N -I sml -t 2 -n 10000 -y" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.query("select count(*) from test.d0")
tdSql.checkData(0, 0, 1*10000)
tdSql.query("select count(*) from test.d1")
tdSql.checkData(0, 0, 1*10000)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)

View File

@ -184,7 +184,7 @@ class TDTestCase(TBase):
tdSql.query("select last(ts) from test.meters")
tdSql.checkData(0, 0, "2017-07-14 10:40:00.034")
cmd = "%s -N -I taosc -t 11 -n 11 -y -x -E" % binPath
cmd = "%s -N -I taosc -t 11 -n 11 -y -x -E -c abcde" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.execute("use test")
@ -195,7 +195,7 @@ class TDTestCase(TBase):
tdSql.query("select count(*) from `d10`")
tdSql.checkData(0, 0, 11)
cmd = "%s -N -I rest -t 11 -n 11 -y -x" % binPath
cmd = "%s -N -I rest -t 11 -n 11 -y -x -c /etc/taos" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.execute("use test")
@ -315,21 +315,6 @@ class TDTestCase(TBase):
tdSql.query("describe test.meters")
tdSql.checkData(1, 1, "NCHAR")
# 2.x is binary and 3.x is varchar
# cmd = "%s -n 1 -t 1 -y -b binary" %binPath
# tdLog.info("%s" % cmd)
# os.system("%s" % cmd)
# tdSql.execute("reset query cache")
# tdSql.query("describe test.meters")
# tdSql.checkData(1, 1, "BINARY")
# cmd = "%s -n 1 -t 1 -y -b binary\(7\)" %binPath
# tdLog.info("%s" % cmd)
# os.system("%s" % cmd)
# tdSql.execute("reset query cache")
# tdSql.query("describe test.meters")
# tdSql.checkData(1, 1, "BINARY")
cmd = "%s -n 1 -t 1 -y -A json" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)

View File

@ -0,0 +1,158 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
# import os, signal
import os
from time import sleep
import frame
import frame.etool
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame import *
class TDTestCase(TBase):
def caseDescription(self):
"""
taosBenchmark public->connMode test cases
"""
# expect cmd > evn > json
def checkPriority(self):
#
# cmd & json
#
# cmd first 6041 - valid
options = "-X http://127.0.0.1:6041"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, options, True)
#
# env > json
#
# env 6041 - valid
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6041"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, "", True)
#
# cmd & json & evn
#
# cmd 6041 - valid
options = "-X http://127.0.0.1:6041"
# env 6043 - invalid
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6043"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, options, True)
# clear env
os.environ['TDENGINE_CLOUD_DSN'] = ""
def checkCommandLine(self):
# modes
modes = ["", "-Z 1 -B 1", "-Z websocket", "-Z 0", "-Z native -B 2"]
# result
Rows = "insert rows: 9990"
results1 = [
["Connect mode is : WebSocket", Rows],
["Connect mode is : WebSocket", Rows],
["Connect mode is : WebSocket", Rows],
["Connect mode is : Native", Rows],
["Connect mode is : Native", Rows],
]
# iface todo add sml
iface = ["taosc", "stmt", "stmt2"]
# do check
for face in iface:
for i in range(len(modes)):
self.benchmarkCmd(f"{modes[i]} -I {face}", 10, 999, 1000, results1[i])
def checkExceptCmd(self):
# exe
bench = frame.etool.benchMarkFile()
# option
options = [
"-Z native -X http://127.0.0.1:6041",
"-Z 100",
"-Z abcdefg",
"-X",
"-X 127.0.0.1:6041",
"-X https://gw.cloud.taosdata.com?token617ffdf...",
"-Z 1 -X https://gw.cloud.taosdata.com?token=617ffdf...",
"-X http://127.0.0.1:6042"
]
# do check
for option in options:
self.checkExcept(bench + " -y " + option)
def checkHostPort(self):
#
# ommand
#
self.benchmarkCmd("-h 127.0.0.1", 5, 100, 10, ["insert rows: 500"])
self.benchmarkCmd("-h 127.0.0.1 -P 6041 -uroot -ptaosdata", 5, 100, 10, ["insert rows: 500"])
self.benchmarkCmd("-Z 0 -h 127.0.0.1 -P 6030 -uroot -ptaosdata", 5, 100, 10, ["insert rows: 500"])
#
# command & json
#
# 6041 is default
options = "-h 127.0.0.1 -P 6041 -uroot -ptaosdata"
json = "tools/benchmark/basic/json/connModePriorityErrHost.json"
self.insertBenchJson(json, options, True)
# cmd port first json port
options = "-Z native -P 6030"
json = "tools/benchmark/basic/json/connModePriority.json"
self.insertBenchJson(json, options, True)
options = "-Z websocket -P 6041"
json = "tools/benchmark/basic/json/connModePriority.json"
self.insertBenchJson(json, options, True)
def run(self):
# init
self.db = "test"
self.stb = "meters"
# command line test
self.checkCommandLine()
# except
self.checkExceptCmd()
# cmd > json > env
self.checkPriority()
# host and port
self.checkHostPort()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -22,7 +22,7 @@
"wal_retention_period": 0,
"buffer": 256,
"stt_trigger": 1,
"vgroups ": 1
"vgroups": 1
},
"super_tables": [
{

View File

@ -24,7 +24,7 @@
"cachemodel": "'both'",
"cachesize": 100,
"stt_trigger": 1,
"vgroups ": 3
"vgroups": 3
},
"super_tables": [
{

View File

@ -0,0 +1,65 @@
{
"filetype": "insert",
"dsn": "http://127.0.0.1:6041",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"num_of_records_per_req": 3000,
"thread_count": 2,
"confirm_parameter_prompt": "no",
"databases": [
{
"dbinfo": {
"name": "test",
"drop": "yes",
"precision": "ms",
"vgroups": 1
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 2,
"insert_rows": 1000,
"childtable_prefix": "d",
"insert_mode": "taosc",
"interlace_rows": 0,
"timestamp_step": 1000,
"start_timestamp":1700000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
{ "type": "double", "name": "dc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "ti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "si", "max": 100, "min": -50 },
{ "type": "int", "name": "ic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "bi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
{ "type": "uint", "name": "ui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "ubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "bin", "len": 4},
{ "type": "nchar", "name": "nch", "len": 8}
],
"tags": [
{ "type": "bool", "name": "tbc"},
{ "type": "float", "name": "tfc", "max": 1, "min": 0 },
{ "type": "double", "name": "tdc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "tti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "tsi", "max": 100, "min": -50 },
{ "type": "int", "name": "tic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "tbi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "tuti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "tusi", "max": 100, "min": 0 },
{ "type": "uint", "name": "tui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "tubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "tbin", "len": 4},
{ "type": "nchar", "name": "tnch", "len": 8}
]
}
]
}
]
}

View File

@ -0,0 +1,60 @@
{
"filetype": "insert",
"dsn": "http://127.0.0.1:6042",
"num_of_records_per_req": 3000,
"thread_count": 2,
"confirm_parameter_prompt": "no",
"databases": [
{
"dbinfo": {
"name": "test",
"drop": "yes",
"precision": "ms",
"vgroups": 1
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 2,
"insert_rows": 1000,
"childtable_prefix": "d",
"insert_mode": "taosc",
"interlace_rows": 0,
"timestamp_step": 1000,
"start_timestamp":1700000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
{ "type": "double", "name": "dc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "ti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "si", "max": 100, "min": -50 },
{ "type": "int", "name": "ic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "bi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
{ "type": "uint", "name": "ui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "ubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "bin", "len": 4},
{ "type": "nchar", "name": "nch", "len": 8}
],
"tags": [
{ "type": "bool", "name": "tbc"},
{ "type": "float", "name": "tfc", "max": 1, "min": 0 },
{ "type": "double", "name": "tdc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "tti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "tsi", "max": 100, "min": -50 },
{ "type": "int", "name": "tic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "tbi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "tuti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "tusi", "max": 100, "min": 0 },
{ "type": "uint", "name": "tui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "tubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "tbin", "len": 4},
{ "type": "nchar", "name": "tnch", "len": 8}
]
}
]
}
]
}

View File

@ -0,0 +1,64 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.2",
"port": 6032,
"user": "root-error",
"password": "taosdata-error",
"num_of_records_per_req": 3000,
"thread_count": 2,
"confirm_parameter_prompt": "no",
"databases": [
{
"dbinfo": {
"name": "test",
"drop": "yes",
"precision": "ms",
"vgroups": 1
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 2,
"insert_rows": 1000,
"childtable_prefix": "d",
"insert_mode": "taosc",
"interlace_rows": 0,
"timestamp_step": 1000,
"start_timestamp":1700000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
{ "type": "double", "name": "dc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "ti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "si", "max": 100, "min": -50 },
{ "type": "int", "name": "ic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "bi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
{ "type": "uint", "name": "ui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "ubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "bin", "len": 4},
{ "type": "nchar", "name": "nch", "len": 8}
],
"tags": [
{ "type": "bool", "name": "tbc"},
{ "type": "float", "name": "tfc", "max": 1, "min": 0 },
{ "type": "double", "name": "tdc", "max": 10, "min": 0 },
{ "type": "tinyint", "name": "tti", "max": 100, "min": -100 },
{ "type": "smallint", "name": "tsi", "max": 100, "min": -50 },
{ "type": "int", "name": "tic", "max": 1000, "min": -1000 },
{ "type": "bigint", "name": "tbi", "max": 100, "min": -1000 },
{ "type": "utinyint", "name": "tuti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "tusi", "max": 100, "min": 0 },
{ "type": "uint", "name": "tui", "max": 1000, "min": 0 },
{ "type": "ubigint", "name": "tubi", "max": 10000, "min": 0 },
{ "type": "binary", "name": "tbin", "len": 4},
{ "type": "nchar", "name": "tnch", "len": 8}
]
}
]
}
]
}

View File

@ -1,73 +0,0 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 4,
"thread_count_create_tbl": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 0,
"num_of_records_per_req": 3000,
"max_sql_len": 1024000,
"databases": [{
"dbinfo": {
"name": "db",
"drop": "yes",
"precision": "ms"
},
"super_tables": [{
"name": "stb0",
"child_table_exists":"no",
"childtable_count": 2,
"childtable_prefix": "stb00_",
"auto_create_table": "no",
"batch_create_tbl_num": 10,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0,
"insert_interval": 0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-11-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}],
"tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}]
},
{
"name": "stb1",
"child_table_exists":"no",
"childtable_count": 2,
"childtable_prefix": "stb01_",
"auto_create_table": "no",
"batch_create_tbl_num": 10,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 5,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0 ,
"insert_interval": 0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-11-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 1, "count":3}, {"type": "BINARY", "len": 2, "count":6}],
"tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}]
}]
}]
}

View File

@ -1,27 +0,0 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "db",
"query_times": 2,
"query_mode": "rest",
"specified_table_query": {
"query_interval": 1,
"threads": 3,
"sqls": [
{
"sql": "select last_row(*) from db.stb0 ",
"result": "./query_res0.txt"
},
{
"sql": "select count(*) from db.stb00_1",
"result": "./query_res1.txt"
}
]
}
}

View File

@ -1,24 +0,0 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "db",
"query_times": 2,
"query_mode": "rest",
"super_table_query": {
"stblname": "stb1",
"query_interval": 1,
"threads": 3,
"sqls": [
{
"sql": "select last_row(ts) from xxxx",
"result": "./query_res2.txt"
}
]
}
}

View File

@ -13,7 +13,7 @@
{
"query_interval": 1,
"concurrent":1,
"sql_file": "./taosbenchmark/json/query-sqls.txt",
"sql_file": "tools/benchmark/basic/json/query-sqls.txt",
"result": "taosc_query_specified-sqlfile"
}
}

View File

@ -124,7 +124,7 @@ class TDTestCase(TBase):
except:
continueIfFail = "no"
concurrent = data[label]["concurrent"]
threads = data[label]["threads"]
sqls = data[label]["sqls"]
@ -140,7 +140,7 @@ class TDTestCase(TBase):
except:
mixedQuery = "no"
tdLog.info(f"queryTimes={queryTimes} concurrent={concurrent} mixedQuery={mixedQuery} "
tdLog.info(f"queryTimes={queryTimes} threads={threads} mixedQuery={mixedQuery} "
f"batchQuery={batchQuery} len(sqls)={len(sqls)} label={label}\n")
totalQueries = 0
@ -154,9 +154,9 @@ class TDTestCase(TBase):
if specMode and mixedQuery.lower() != "yes":
# spec
threadQueries = queryTimes * concurrent
totalQueries = queryTimes * concurrent * len(sqls)
threadKey = f"complete query with {concurrent} threads and "
threadQueries = queryTimes * threads
totalQueries = queryTimes * threads * len(sqls)
threadKey = f"complete query with {threads} threads and "
qpsKey = "QPS: "
avgKey = "query delay avg: "
minKey = "min:"
@ -178,10 +178,10 @@ class TDTestCase(TBase):
threadQueries = totalQueries
nSql = len(sqls)
if specMode and nSql < concurrent :
tdLog.info(f"set concurrent = {nSql} because len(sqls) < concurrent")
concurrent = nSql
threadKey = f"using {concurrent} threads complete query "
if specMode and nSql < threads :
tdLog.info(f"set threads = {nSql} because len(sqls) < threads")
threads = nSql
threadKey = f"using {threads} threads complete query "
qpsKey = ""
avgKey = "avg delay:"
minKey = "min delay:"
@ -219,10 +219,6 @@ class TDTestCase(TBase):
for arg in args:
self.checkAfterRun(benchmark, arg[0] + ".json", arg[1], tbCnt)
# rest
for arg in args:
self.checkAfterRun(benchmark, arg[0] + "Rest.json", arg[1], tbCnt)
def expectFailed(self, command):
ret = os.system(command)
if ret == 0:

View File

@ -40,13 +40,9 @@ class TDTestCase(TBase):
tdSql.execute("insert into stb_1 using stb tags (1) values (now, 1)")
tdSql.execute("insert into stb_2 using stb tags (2) values (now, 2)")
cmd = "%s -f ./tools/benchmark/basic/json/taosc_query-sqlfile.json" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
# with open("%s" % "taosc_query_specified-sqlfile-0", "r+") as f1:
# for line in f1.readlines():
# queryTaosc = line.strip().split()[0]
# assert queryTaosc == "3", "result is %s != expect: 3" % queryTaosc
rlist = self.benchmark(f"-f {cmd}")
# check result
self.checkListString(rlist, "completed total queries: 2")
def stop(self):
tdSql.close()

View File

@ -32,7 +32,7 @@ class TDTestCase(TBase):
def run(self):
binPath = etool.benchMarkFile()
os.system(
"rm -f rest_query_specified-0 rest_query_super-0 taosc_query_specified-0 taosc_query_super-0"
"rm -f taosc_query_specified-0 taosc_query_super-0"
)
tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db")
@ -58,46 +58,6 @@ class TDTestCase(TBase):
queryTaosc = line.strip().split()[0]
assert queryTaosc == "1", "result is %s != expect: 1" % queryTaosc
# split two
cmd = "%s -f ./tools/benchmark/basic/json/rest_query.json" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
cmd = "%s -f ./tools/benchmark/basic/json/rest_query1.json" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
times = 0
with open("rest_query_super-0", "r+") as f1:
for line in f1.readlines():
contents = line.strip()
if contents.find("data") != -1:
pattern = re.compile("{.*}")
contents = pattern.search(contents).group()
contentsDict = ast.literal_eval(contents)
queryResultRest = contentsDict["data"][0][0]
assert queryResultRest == 1, (
"result is %s != expect: 1" % queryResultRest
)
times += 1
assert times == 3, "result is %s != expect: 3" % times
times = 0
with open("rest_query_specified-0", "r+") as f1:
for line in f1.readlines():
contents = line.strip()
if contents.find("data") != -1:
pattern = re.compile("{.*}")
contents = pattern.search(contents).group()
contentsDict = ast.literal_eval(contents)
queryResultRest = contentsDict["data"][0][0]
assert queryResultRest == 3, (
"result is %s != expect: 3" % queryResultRest
)
times += 1
assert times == 1, "result is %s != expect: 1" % times
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)

View File

@ -37,22 +37,6 @@ class TDTestCase(TBase):
queryResultTaosc = line.strip().split()[0]
self.assertCheck(filename, queryResultTaosc, expectResult)
# 获取restful接口查询的结果文件中的关键内容,目前的关键内容找到第一个key就跳出循所以就只有一个数据。后续再修改多个结果文件。
def getfileDataRestful(self, filename):
self.filename = filename
with open("%s" % filename, "r+") as f1:
for line in f1.readlines():
contents = line.strip()
if contents.find("data") != -1:
pattern = re.compile("{.*}")
contents = pattern.search(contents).group()
contentsDict = ast.literal_eval(contents) # 字符串转换为字典
queryResultRest = contentsDict["data"][0][0]
break
else:
queryResultRest = ""
return queryResultRest
# 获取taosc接口查询次数
def queryTimesTaosc(self, filename):
self.filename = filename
@ -60,13 +44,6 @@ class TDTestCase(TBase):
times = int(subprocess.getstatusoutput(command)[1])
return times
# 获取restful接口查询次数
def queryTimesRestful(self, filename):
self.filename = filename
command = 'cat %s |grep "200 OK" |wc -l' % filename
times = int(subprocess.getstatusoutput(command)[1])
return times
# 定义断言结果是否正确。不正确返回错误结果,正确即通过。
def assertCheck(self, filename, queryResult, expectResult):
self.filename = filename
@ -106,26 +83,6 @@ class TDTestCase(TBase):
os.system("rm -rf ./query_res*")
os.system("rm -rf ./all_query*")
# use restful api to query
os.system("%s -f ./tools/benchmark/basic/json/queryInsertrestdata.json" % binPath)
os.system("%s -f ./tools/benchmark/basic/json/queryRestful.json" % binPath)
os.system("%s -f ./tools/benchmark/basic/json/queryRestful1.json" % binPath)
os.system("cat query_res2.txt* > all_query_res2_rest.txt")
# correct Times testcases
queryTimes2Restful = self.queryTimesRestful("all_query_res2_rest.txt")
self.assertCheck("all_query_res2_rest.txt", queryTimes2Restful, 4)
# correct data testcase
data2 = self.getfileDataRestful("all_query_res2_rest.txt")
print(data2)
if data2 != "2020-11-01 00:00:00.004" and data2 != "2020-10-31T16:00:00.004Z":
tdLog.exit(
"data2 is not 2020-11-01 00:00:00.004 and 2020-10-31T16:00:00.004Z"
)
# query times less than or equal to 100
assert (
os.system("%s -f ./tools/benchmark/basic/json/queryInsertdata.json" % binPath) == 0

Some files were not shown because too many files have changed in this diff Show More