From e63f352f8b124b66bad1166918ebdec635e09812 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 10 Mar 2022 12:02:55 +0800 Subject: [PATCH] Feature/sangshuduo/td 13558 taos shell refactor (#10661) * [TD-13558]: taos shell refactor add taosTools as submodule * add tools/taos-tools * add more client interface for taosTools compile * update taos-tools * update taos-tools --- .gitmodules | 3 ++ CMakeLists.txt | 26 ++++++++++++ include/client/taos.h | 4 ++ include/common/taosdef.h | 2 + source/client/src/clientMain.c | 74 ++++++++++++++++++++++++++++++++++ tools/CMakeLists.txt | 11 ++++- tools/taos-tools | 1 + 7 files changed, 120 insertions(+), 1 deletion(-) create mode 160000 tools/taos-tools diff --git a/.gitmodules b/.gitmodules index 07e4bb2b9c..bc38453f19 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "examples/rust"] path = examples/rust url = https://github.com/songtianyi/tdengine-rust-bindings.git +[submodule "tools/taos-tools"] + path = tools/taos-tools + url = https://github.com/taosdata/taos-tools diff --git a/CMakeLists.txt b/CMakeLists.txt index df3aab5cb3..9d64966861 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,32 @@ project( DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)" ) +IF ("${BUILD_TOOLS}" STREQUAL "") + IF (TD_LINUX) + IF (TD_ARM_32) + SET(BUILD_TOOLS "false") + ELSEIF (TD_ARM_64) + SET(BUILD_TOOLS "false") + ELSE () + SET(BUILD_TOOLS "false") + ENDIF () + ELSEIF (TD_DARWIN) + SET(BUILD_TOOLS "false") + ELSE () + SET(BUILD_TOOLS "false") + ENDIF () +ENDIF () + +IF ("${BUILD_TOOLS}" MATCHES "false") + MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}") + SET(TD_TAOS_TOOLS FALSE) +ELSE () + MESSAGE("") + MESSAGE("${Green} Will build taos_tools! ${ColourReset}") + MESSAGE("") + SET(TD_TAOS_TOOLS TRUE) +ENDIF () + set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib") include(${CMAKE_SUPPORT_DIR}/cmake.options) diff --git a/include/client/taos.h b/include/client/taos.h index 8b1517c6ff..5da5908779 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -256,6 +256,10 @@ DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_co void tmqShowMsg(tmq_message_t *tmq_message); int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message); +typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code); + +DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT* stmt); + #ifdef __cplusplus } #endif diff --git a/include/common/taosdef.h b/include/common/taosdef.h index 99360b8d3f..9e5e5ebdcf 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -63,6 +63,8 @@ typedef enum { extern char *qtypeStr[]; +#define TSDB_PORT_HTTP 11 + #ifdef __cplusplus } #endif diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 5bcc287116..09a0233e04 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -343,3 +343,77 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { // TODO } + +TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char *sql, TAOS_SUBSCRIBE_CALLBACK fp, void *param, int interval) { + // TODO + return NULL; +} + +TAOS_RES *taos_consume(TAOS_SUB *tsub) { + // TODO + return NULL; +} + +void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { + // TODO +} + +TAOS_STMT* taos_stmt_init(TAOS* taos) { + // TODO + return NULL; +} + +int taos_stmt_close(TAOS_STMT* stmt) { + // TODO + return -1; +} + +int taos_stmt_execute(TAOS_STMT* stmt) { + // TODO + return -1; +} + +char *taos_stmt_errstr(TAOS_STMT *stmt) { + // TODO + return NULL; +} + +int taos_stmt_affected_rows(TAOS_STMT* stmt) { + // TODO + return -1; +} + +TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) { + // TODO + return NULL; +} + +int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) { + // TODO + return -1; +} + +int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { + // TODO + return -1; +} + +int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags) { + // TODO + return -1; +} + +int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) { + // TODO + return -1; +} + +int taos_stmt_add_batch(TAOS_STMT* stmt) { + // TODO + return -1; +} + +int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) { + // TODO + return -1; +} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 629677c9a5..dae0a1c840 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1 +1,10 @@ -add_subdirectory(shell) \ No newline at end of file +IF (TD_TAOS_TOOLS) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/tools/taos_tools/deps/avro/lang/c/src) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/client) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/common) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/util) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/os) + ADD_SUBDIRECTORY(taos-tools) +ENDIF () + +add_subdirectory(shell) diff --git a/tools/taos-tools b/tools/taos-tools new file mode 160000 index 0000000000..f36b07f710 --- /dev/null +++ b/tools/taos-tools @@ -0,0 +1 @@ +Subproject commit f36b07f710d661dca88fdd70e73b5e3e16a960e0 -- GitLab